30 abstract class gmapsCtg extends propertyObject {
69 $this->_tbl_data = $tbl;
70 parent::__construct($id);
83 if($this->_p[
'instance']!=$value && !in_array(
'instance', $this->_chgP)) $this->_chgP[] =
'instance';
84 $this->_p[
'instance'] = $value;
100 $query =
"DELETE FROM ".static::$_tbl.
" WHERE instance='$instance'";
101 $res = $db->actionquery($query);
119 public static function get($instance, $opts=null) {
121 $where =
"instance='".$instance.
"'".(isset($opts[
'where']) ?
" AND ".$opts[
'where'] :
'');
122 $order = isset($opts[
'order']) ? $opts[
'order'] :
'name';
123 $limit = isset($opts[
'limit']) ?
"LIMIT ".$opts[
'limit'] :
'';
127 $db = db::instance();
128 $query =
"SELECT id FROM ".static::$_tbl.
" WHERE $where ORDER BY $order $limit";
129 $a = $db->selectquery($query);
151 $where =
"instance='".$instance.
"'".(isset($opts[
'where']) ?
" AND ".$opts[
'where'] :
'');
152 $order = isset($opts[
'order']) ? $opts[
'order'] :
'name';
156 $db = db::instance();
157 $query =
"SELECT id, name FROM ".static::$_tbl.
" WHERE $where ORDER BY $order";
158 $a = $db->selectquery($query);
160 $res[$b[
'id']] = htmlChars($b[
'name']);
174 public function form($redirect) {
176 if(isset($_POST[
'submit'])) {
177 $gform =
new Form(
'form_ctg',
'post',
false, array(
'verifyToken'=>
true));
178 $gform->save(
'dataform');
179 $req_error = $gform->arequired();
181 $this->name = cleanVar($_POST,
'name',
'string',
'');
182 $this->description = cleanVar($_POST,
'description',
'string',
'');
183 $this->updateDbData();
185 $old_icon = cleanVar($_POST,
'old_icon',
'string',
'');
187 $res = $gform->manageFile(
'icon', $old_icon,
true, $this->_extension_media, $this->_data_dir.OS, preg_replace(
"#action=insert#",
'action=modify&id='.$this->
id, $_SERVER[
'QUERY_STRING']), $this->_tbl_data,
'icon',
'id', $this->
id, array(
'prefix_file'=>$this->_prefix_img,
'prefix_thumb'=>$this->_prefix_thumb,
'width'=>$this->_img_width,
'thumb_width'=>$this->_thumb_width));
189 header(
"Location: ".$redirect);
193 error::errorMessage(array(
'error'=>1), $_SERVER[
'QUERY_STRING']);
199 $title = _(
"Modifica categoria");
200 $submit = _(
"modifica");
203 $title = _(
"Nuova categoria");
204 $submit= _(
"inserisci");
206 $htmlsection =
new htmlSection(array(
'class'=>
'admin',
'headerTag'=>
'header',
'headerLabel'=>$title));
208 $gform =
new Form(
'form_ctg',
'post',
true, array(
'trnsl_table'=>$this->_tbl_data,
'trnsl_id'=>$this->
id));
209 $gform->load(
'dataform');
210 $buffer = $gform->form(
'',
true,
'name', array(
'generateToken'=>
true));
211 $buffer .= $gform->hidden(
'id', $this->
id);
213 $buffer .= $gform->cinput(
'name',
'text', $gform->retvar(
'name', htmlInput($this->name)), _(
"Nome"), array(
'required'=>
true,
'maxlength'=>200,
'size'=>40,
'trnsl'=>
true,
'field'=>
'name'));
214 $buffer .= $gform->ctextarea(
'description', $gform->retvar(
'description', htmlInput($this->description)), _(
"Descrizione"), array(
'cols'=>40,
'rows'=>4,
'trnsl'=>
true,
'field'=>
'description'));
215 $buffer .= $gform->cfile(
'icon', $this->icon, _(
"Icona"), array(
"extensions"=>$this->_extension_media,
"del_check"=>
true,
"preview"=>
true,
"previewSrc"=>$this->_data_www.
'/'.$this->_prefix_img.$this->icon));
216 $buffer .= $gform->cinput(
'submit',
'submit', $submit,
'', array(
'classField'=>
'submit'));
218 $buffer .= $gform->cform();
220 $htmlsection->content = $buffer;
222 return $htmlsection->render();