60 $this->_controller = $instance;
61 $this->_tbl_data = self::$_tbl_event;
62 parent::__construct($id);
64 $this->_extension_media = array(
'jpg',
'jpeg',
'png');
65 $this->_prefix_img =
'img_';
66 $this->_prefix_thumb =
'thumb_';
67 $this->_data_www = CONTENT_WWW.
'/gmaps/'.$this->_controller->instanceName().
'/point/events';
68 $this->_data_dir = CONTENT_DIR.OS.
'gmaps'.OS.$this->_controller->instanceName().OS.
'point'.OS.
'events';
80 if($this->_p[
'point_id']!=$value && !in_array(
'point_id', $this->_chgP)) $this->_chgP[] =
'point_id';
81 $this->_p[
'point_id'] = $value;
93 public function form($redirect) {
95 if(isset($_POST[
'submit'])) {
96 $gform =
new Form(
'form_event',
'post',
false, array(
'verifyToken'=>
true));
97 $gform->save(
'dataform');
98 $req_error = $gform->arequired();
101 $this->insert_date = date(
"Y-m-d H:i:s");
103 $this->name = cleanVar($_POST,
'name',
'string',
'');
104 $this->description = cleanVar($_POST,
'description',
'string',
'');
105 $this->duration = cleanVar($_POST,
'duration',
'string',
'');
106 $this->date = dateToDbDate(cleanVar($_POST,
'date',
'string',
''),
'/');
108 $this->updateDbData();
110 $old_image = cleanVar($_POST,
'old_image',
'string',
'');
112 $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));
114 header(
"Location: ".$redirect);
118 error::errorMessage(array(
'error'=>1), $_SERVER[
'QUERY_STRING']);
124 $title = _(
"Modifica evento");
125 $submit = _(
"modifica");
128 $title = _(
"Nuovo evento");
129 $submit= _(
"inserisci");
131 $htmlsection =
new htmlSection(array(
'class'=>
'admin',
'headerTag'=>
'header',
'headerLabel'=>$title));
133 $gform =
new Form(
'form_event',
'post',
true, array(
'trnsl_table'=>$this->_tbl_data,
'trnsl_id'=>$this->
id));
134 $gform->load(
'dataform');
135 $buffer = $gform->form(
'',
true,
'name,date,duration', array(
'generateToken'=>
true));
136 $buffer .= $gform->hidden(
'id', $this->
id);
138 $buffer .= $gform->cinput(
'name',
'text', $gform->retvar(
'name', htmlInput($this->name)), _(
"Nome"), array(
'required'=>
true,
'maxlength'=>200,
'size'=>40,
'trnsl'=>
true,
'field'=>
'name'));
139 $buffer .= $gform->cinput_date(
'date', $gform->retvar(
'date', dbDateToDate($this->date,
'/')), _(
"Data"), array(
'required'=>
true));
140 $buffer .= $gform->ctextarea(
'description', $gform->retvar(
'description', htmlInput($this->description)), _(
"Descrizione"), array(
'cols'=>40,
'rows'=>4,
'trnsl'=>
true,
'field'=>
'description'));
141 $duration = $gform->retvar(
'duration', htmlInput($this->duration));
142 $buffer .= $gform->cinput(
'duration',
'text', $duration, array(_(
"Durata"), _(
"giorni")), array(
'required'=>
true,
'maxlength'=>200,
'size'=>40));
143 $buffer .= $gform->cfile(
'image', $this->image, _(
"Immagine"), array(
"required"=>
true,
"extensions"=>$this->_extension_media,
"del_check"=>
true,
"preview"=>
true,
"previewSrc"=>$this->_data_www.
'/'.$this->_prefix_img.$this->image));
145 $buffer .= $gform->cinput(
'submit',
'submit', $submit,
'', array(
'classField'=>
'submit'));
147 $buffer .= $gform->cform();
149 $htmlsection->content = $buffer;
151 return $htmlsection->render();
161 public function delete() {
163 @unlink($this->_data_dir.OS.$this->_prefix_img.$this->image);
164 @unlink($this->_data_dir.OS.$this->_prefix_thumb.$this->image);
166 return $this->deleteDbData();
178 return $this->_data_www.
"/".$this->_prefix_img.$this->image;
190 return $this->_data_www.
"/".$this->_prefix_thumb.$this->image;