67 $this->_controller = $instance;
68 $this->_tbl_data = self::$_tbl_collection;
69 parent::__construct($id);
71 $this->_extension_media = array(
'jpg',
'jpeg',
'png');
72 $this->_prefix_img =
'img_';
73 $this->_prefix_thumb =
'thumb_';
74 $this->_data_www = CONTENT_WWW.
'/gmaps/'.$this->_controller->instanceName().
'/point/collections';
75 $this->_data_dir = CONTENT_DIR.OS.
'gmaps'.OS.$this->_controller->instanceName().OS.
'point'.OS.
'collections';
77 $this->_images = array();
78 $query =
"SELECT id FROM ".self::$_tbl_collection_image.
" WHERE collection_id='".$this->
id.
"'";
79 $a = $this->_db->selectquery($query);
96 if($this->_p[
'point_id']!=$value && !in_array(
'point_id', $this->_chgP)) $this->_chgP[] =
'point_id';
97 $this->_p[
'point_id'] = $value;
121 public function form($redirect) {
123 if(isset($_POST[
'submit'])) {
124 $gform =
new Form(
'form_collection',
'post',
false, array(
'verifyToken'=>
true));
125 $gform->save(
'dataform');
126 $req_error = $gform->arequired();
128 $this->name = cleanVar($_POST,
'name',
'string',
'');
129 $this->description = cleanVar($_POST,
'description',
'string',
'');
131 $this->updateDbData();
133 $old_image = cleanVar($_POST,
'old_image',
'string',
'');
135 $res = $gform->manageFile(
'image', $old_image,
true, $this->_extension_media, $this->_data_dir.OS, preg_replace(
"#action=insert#",
'action=modify&id='.$this->
id, $_SERVER[
'QUERY_STRING']), $this->_tbl_data,
'image',
'id', $this->
id, array(
'prefix_file'=>$this->_prefix_img,
'prefix_thumb'=>$this->_prefix_thumb,
'width'=>$this->_img_width,
'thumb_width'=>$this->_thumb_width));
137 header(
"Location: ".$redirect);
141 error::errorMessage(array(
'error'=>1), $_SERVER[
'QUERY_STRING']);
147 $title = _(
"Modifica collezione");
148 $submit = _(
"modifica");
151 $title = _(
"Nuova collezione");
152 $submit= _(
"inserisci");
154 $htmlsection =
new htmlSection(array(
'class'=>
'admin',
'headerTag'=>
'header',
'headerLabel'=>$title));
156 $gform =
new Form(
'form_collection',
'post',
true, array(
'trnsl_table'=>$this->_tbl_data,
'trnsl_id'=>$this->
id));
157 $gform->load(
'dataform');
158 $buffer = $gform->form(
'',
true,
'name', array(
'generateToken'=>
true));
159 $buffer .= $gform->hidden(
'id', $this->
id);
161 $buffer .= $gform->cinput(
'name',
'text', $gform->retvar(
'name', htmlInput($this->name)), _(
"Nome"), array(
'required'=>
true,
'maxlength'=>200,
'size'=>40,
'trnsl'=>
true,
'field'=>
'name'));
162 $buffer .= $gform->ctextarea(
'description', $gform->retvar(
'description', htmlInput($this->description)), _(
"Descrizione"), array(
'cols'=>40,
'rows'=>4,
'trnsl'=>
true,
'field'=>
'description'));
164 $buffer .= $gform->cfile(
'image', $this->image, _(
"Immagine"), array(
"required"=>
false,
"extensions"=>$this->_extension_media,
"del_check"=>
true,
"preview"=>
true,
"previewSrc"=>$this->_data_www.
'/'.$this->_prefix_img.$this->image));
165 $buffer .= $gform->cinput(
'submit',
'submit', $submit,
'', array(
'classField'=>
'submit'));
167 $buffer .= $gform->cform();
169 $htmlsection->content = $buffer;
171 return $htmlsection->render();
182 return "<img class=\"".$css_class.
"\" src=\"".$this->_data_www.
"/".$this->_prefix_thumb.$this->image.
"\" alt=\"".preg_replace(
"#\"#",
"'", htmlChars($this->ml(
'name'))).
"\" />";
192 public function img($css_class =
'', $title = null, $description=null) {
194 return "<img class=\"".$css_class.
"\" src=\"".$this->_data_www.
"/".$this->_prefix_img.$this->image.
"\" alt=\"".preg_replace(
"#\"#",
"'", htmlChars($this->ml(
'name'))).
"\" />";
206 return $this->_data_www.
"/".$this->_prefix_thumb.$this->image;
218 return $this->_data_www.
"/".$this->_prefix_img.$this->image;
229 public function delete() {
232 foreach($this->_images as $image) {
236 @unlink($this->_data_dir.OS.$this->_prefix_img.$this->image);
237 @unlink($this->_data_dir.OS.$this->_prefix_thumb.$this->image);
239 return $this->deleteDbData();