47 $this->_controller = $instance;
48 $this->_tbl_data = self::$_tbl_marker;
49 parent::__construct($id);
51 $this->_extension_media = array(
'png');
52 $this->_data_www = CONTENT_WWW.
'/gmaps/'.$this->_controller->instanceName().
'/marker';
53 $this->_data_dir = CONTENT_DIR.OS.
'gmaps'.OS.$this->_controller->instanceName().OS.
'marker';
65 if($this->_p[
'instance']!=$value && !in_array(
'instance', $this->_chgP)) $this->_chgP[] =
'instance';
66 $this->_p[
'instance'] = $value;
82 $query =
"DELETE FROM ".self::$_tbl_marker.
" WHERE instance='$instance'";
83 $res = $db->actionquery($query);
101 public static function get($instance, $opts=null) {
103 $where =
"instance='".$instance.
"'".(isset($opts[
'where']) ?
" AND ".$opts[
'where'] :
'');
104 $order = isset($opts[
'order']) ? $opts[
'order'] :
'label';
105 $limit = isset($opts[
'limit']) ?
"LIMIT ".$opts[
'limit'] :
'';
109 $db = db::instance();
110 $query =
"SELECT id FROM ".self::$_tbl_marker.
" WHERE $where ORDER BY $order $limit";
111 $a = $db->selectquery($query);
133 $where =
"instance='".$instance.
"'".(isset($opts[
'where']) ?
" AND ".$opts[
'where'] :
'');
134 $order = isset($opts[
'order']) ? $opts[
'order'] :
'label';
138 $db = db::instance();
139 $query =
"SELECT id, label FROM ".self::$_tbl_marker.
" WHERE $where ORDER BY $order";
140 $a = $db->selectquery($query);
142 $res[$b[
'id']] = htmlChars($b[
'label']);
156 public function form($redirect) {
158 if(isset($_POST[
'submit'])) {
159 $gform =
new Form(
'form_marker',
'post',
false, array(
'verifyToken'=>
true));
160 $gform->save(
'dataform');
161 $req_error = $gform->arequired();
163 $this->label = cleanVar($_POST,
'label',
'string',
'');
164 $this->description = cleanVar($_POST,
'description',
'string',
'');
165 $this->updateDbData();
167 $old_icon = cleanVar($_POST,
'old_icon',
'string',
'');
168 $old_shadow = cleanVar($_POST,
'old_shadow',
'string',
'');
170 $res = $gform->manageFile(
'icon', $old_icon,
false, $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());
171 $res = $gform->manageFile(
'shadow', $old_shadow,
false, $this->_extension_media, $this->_data_dir.OS, preg_replace(
"#action=insert#",
'action=modify&id='.$this->
id, $_SERVER[
'QUERY_STRING']), $this->_tbl_data,
'shadow',
'id', $this->
id, array());
173 header(
"Location: ".$redirect);
177 error::errorMessage(array(
'error'=>1), $_SERVER[
'QUERY_STRING']);
183 $title = _(
"Modifica marker");
184 $submit = _(
"modifica");
187 $title = _(
"Nuovo marker");
188 $submit= _(
"inserisci");
190 $htmlsection =
new htmlSection(array(
'class'=>
'admin',
'headerTag'=>
'header',
'headerLabel'=>$title));
192 $gform =
new Form(
'form_marker',
'post',
true, array(
'trnsl_table'=>$this->_tbl_data,
'trnsl_id'=>$this->
id));
193 $gform->load(
'dataform');
194 $buffer = $gform->form(
'',
true,
'label', array(
'generateToken'=>
true));
195 $buffer .= $gform->hidden(
'id', $this->
id);
197 $buffer .= $gform->cinput(
'label',
'text', $gform->retvar(
'label', htmlInput($this->label)), _(
"Etichetta"), array(
'required'=>
true,
'maxlength'=>200,
'size'=>40,
'trnsl'=>
true,
'field'=>
'label'));
199 $buffer .= $gform->cfile(
'icon', $this->icon, _(
"Icona"), array(
"extensions"=>$this->_extension_media,
"del_check"=>
true,
"preview"=>
true,
"previewSrc"=>$this->_data_www.
'/'.$this->icon));
200 $buffer .= $gform->cfile(
'shadow', $this->shadow, _(
"Ombra"), array(
"extensions"=>$this->_extension_media,
"del_check"=>
true,
"preview"=>
true,
"previewSrc"=>$this->_data_www.
'/'.$this->shadow));
201 $buffer .= $gform->cinput(
'submit',
'submit', $submit,
'', array(
'classField'=>
'submit'));
203 $buffer .= $gform->cform();
205 $htmlsection->content = $buffer;
207 return $htmlsection->render();
218 return $this->icon ? $this->_data_www.
'/'.$this->icon : null;
230 return $this->shadow ? $this->_data_www.
'/'.$this->shadow : null;
241 public function delete() {
250 @unlink($this->_data_dir.OS.$this->icon);
253 @unlink($this->_data_dir.OS.$this->shadow);
256 return $this->deleteDbData();