58                 $this->_controller = $instance;
 
   59                 $this->_tbl_data = self::$_tbl_image;
 
   60                 parent::__construct($id);
 
   62                 $this->_extension_media = array(
'jpg', 
'jpeg', 
'png');
 
   63                 $this->_prefix_img = 
'img_';
 
   64                 $this->_prefix_thumb = 
'thumb_';
 
   65                 $this->_data_www = CONTENT_WWW.
'/gmaps/'.$this->_controller->instanceName().
'/point/collections/images';
 
   66                 $this->_data_dir = CONTENT_DIR.OS.
'gmaps'.OS.$this->_controller->instanceName().OS.
'point'.OS.
'collections'.OS.
'images';
 
   78                 if($this->_p[
'collection_id']!=$value && !in_array(
'collection_id', $this->_chgP)) $this->_chgP[] = 
'collection_id';
 
   79                 $this->_p[
'collection_id'] = $value;
 
   91         public function form($redirect) {
 
   93                 if(isset($_POST[
'submit'])) {
 
   94                         $gform = 
new Form(
'form_image', 
'post', 
false, array(
'verifyToken'=>
true));
 
   95                         $gform->save(
'dataform');
 
   96                         $req_error = $gform->arequired();       
 
   98                                 $this->title = cleanVar($_POST, 
'title', 
'string', 
'');
 
   99                                 $this->description = cleanVar($_POST, 
'description', 
'string', 
'');
 
  100                                 $this->credits = cleanVar($_POST, 
'credits', 
'string', 
'');
 
  102                                 $this->updateDbData();
 
  104                                 $old_filename = cleanVar($_POST, 
'old_filename', 
'string', 
'');
 
  106                                 $res = $gform->manageFile(
'filename', $old_filename, 
true, $this->_extension_media, $this->_data_dir.OS, preg_replace(
"#action=insert#", 
'action=modify&id='.$this->
id, $_SERVER[
'QUERY_STRING']), $this->_tbl_data, 
'filename', 
'id', $this->
id, array(
'prefix_file'=>$this->_prefix_img, 
'prefix_thumb'=>$this->_prefix_thumb, 
'width'=>$this->_img_width, 
'thumb_width'=>$this->_thumb_width));
 
  108                                 header(
"Location: ".$redirect);
 
  112                                 error::errorMessage(array(
'error'=>1), $_SERVER[
'QUERY_STRING']);
 
  118                         $title = _(
"Modifica immagine");
 
  119                         $submit = _(
"modifica");
 
  122                         $title = _(
"Nuova immagine");
 
  123                         $submit= _(
"inserisci");
 
  125                 $htmlsection = 
new htmlSection(array(
'class'=>
'admin', 
'headerTag'=>
'header', 
'headerLabel'=>$title));
 
  127                 $gform = 
new Form(
'form_image', 
'post', 
true, array(
'trnsl_table'=>$this->_tbl_data, 
'trnsl_id'=>$this->
id));
 
  128                 $gform->load(
'dataform');
 
  129                 $buffer = $gform->form(
'', 
true, 
'title', array(
'generateToken'=>
true));
 
  130                 $buffer .= $gform->hidden(
'image_id', $this->
id);
 
  132                 $buffer .= $gform->cinput(
'title', 
'text', $gform->retvar(
'title', htmlInput($this->title)), _(
"Titolo"), array(
'required'=>
true, 
'maxlength'=>200, 
'size'=>40, 
'trnsl'=>
true, 
'field'=>
'title'));
 
  133                 $buffer .= $gform->ctextarea(
'description', $gform->retvar(
'description', htmlInput($this->description)), _(
"Descrizione"), array(
'cols'=>40, 
'rows'=>4, 
'trnsl'=>
true, 
'field'=>
'description'));
 
  134                 $buffer .= $gform->ctextarea(
'credits', $gform->retvar(
'credits', htmlInput($this->credits)), _(
"Credits"), array(
'cols'=>40, 
'rows'=>2, 
'trnsl'=>
true, 
'field'=>
'credits'));
 
  136                 $buffer .= $gform->cfile(
'filename', $this->filename, _(
"File"), array(
"required"=>
true, 
"extensions"=>$this->_extension_media, 
"del_check"=>
true, 
"preview"=>
true, 
"previewSrc"=>$this->_data_www.
'/'.$this->_prefix_img.$this->filename));
 
  137                 $buffer .= $gform->cinput(
'submit', 
'submit', $submit, 
'', array(
'classField'=>
'submit'));
 
  139                 $buffer .= $gform->cform();
 
  141                 $htmlsection->content = $buffer;
 
  143                 return $htmlsection->render();
 
  154                 return "<img class=\"".$css_class.
"\" src=\"".$this->_data_www.
"/".$this->_prefix_thumb.$this->filename.
"\" alt=\"".preg_replace(
"#\"#", 
"'", htmlChars($this->ml(
'title'))).
"\" />";
 
  164         public function img($css_class = 
'', $title = null, $description=null) {
 
  166                 return "<img class=\"".$css_class.
"\" src=\"".$this->_data_www.
"/".$this->_prefix_img.$this->filename.
"\" alt=\"".preg_replace(
"#\"#", 
"'", htmlChars($this->ml(
'title'))).
"\" />";
 
  178                 return $this->_data_www.
"/".$this->_prefix_thumb.$this->filename;
 
  190                 return $this->_data_www.
"/".$this->_prefix_img.$this->filename;
 
  201         public function delete() {
 
  203                 @unlink($this->_data_dir.OS.$this->_prefix_img.$this->filename);
 
  204                 @unlink($this->_data_dir.OS.$this->_prefix_thumb.$this->filename);
 
  206                 return $this->deleteDbData();