Gino Gmaps  1.0.1
Modulo di gestione di mappe interattive per Gino CMS
 Tutto Strutture dati File Funzioni Variabili Gruppi Pagine
class.gmapsEvent.php
Vai alla documentazione di questo file.
1 <?php
34 class gmapsEvent extends propertyObject {
35 
36  private static $_tbl_event = 'gmaps_point_event';
37 
39 
43  private $_img_width = 600;
44 
48  private $_thumb_width = 100;
49 
58  function __construct($id, $instance) {
59 
60  $this->_controller = $instance;
61  $this->_tbl_data = self::$_tbl_event;
62  parent::__construct($id);
63 
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';
69  }
70 
78  public function setPoint_id($value) {
79 
80  if($this->_p['point_id']!=$value && !in_array('point_id', $this->_chgP)) $this->_chgP[] = 'point_id';
81  $this->_p['point_id'] = $value;
82  return true;
83 
84  }
85 
93  public function form($redirect) {
94 
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();
99  if(!$req_error) {
100  if(!$this->id) {
101  $this->insert_date = date("Y-m-d H:i:s");
102  }
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', ''), '/');
107 
108  $this->updateDbData();
109 
110  $old_image = cleanVar($_POST, 'old_image', 'string', '');
111 
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));
113 
114  header("Location: ".$redirect);
115  exit();
116  }
117  else {
118  error::errorMessage(array('error'=>1), $_SERVER['QUERY_STRING']);
119  exit();
120  }
121  }
122 
123  if($this->id) {
124  $title = _("Modifica evento");
125  $submit = _("modifica");
126  }
127  else {
128  $title = _("Nuovo evento");
129  $submit= _("inserisci");
130  }
131  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
132 
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);
137 
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));
144 
145  $buffer .= $gform->cinput('submit', 'submit', $submit, '', array('classField'=>'submit'));
146 
147  $buffer .= $gform->cform();
148 
149  $htmlsection->content = $buffer;
150 
151  return $htmlsection->render();
152  }
153 
161  public function delete() {
162 
163  @unlink($this->_data_dir.OS.$this->_prefix_img.$this->image);
164  @unlink($this->_data_dir.OS.$this->_prefix_thumb.$this->image);
165 
166  return $this->deleteDbData();
167 
168  }
169 
176  public function imagePath() {
177 
178  return $this->_data_www."/".$this->_prefix_img.$this->image;
179 
180  }
181 
188  public function thumbPath() {
189 
190  return $this->_data_www."/".$this->_prefix_thumb.$this->image;
191 
192  }
193 
194 
195 
196 }
197 
198 ?>