49 $this->_controller = $instance;
50 $this->_tbl_data = self::$_tbl_event;
51 parent::__construct($id);
53 $this->_extension_attachment = array(
'doc',
'docx',
'pdf',
'ppt',
'pptx',
'xlsx',
'xls',
'odt',
'ods',
'odp',
'zip');
54 $this->_data_www = CONTENT_WWW.
'/gmaps/'.$this->_controller->instanceName().
'/point/attachments';
55 $this->_data_dir = CONTENT_DIR.OS.
'gmaps'.OS.$this->_controller->instanceName().OS.
'point'.OS.
'attachments';
67 if($this->_p[
'point_id']!=$value && !in_array(
'point_id', $this->_chgP)) $this->_chgP[] =
'point_id';
68 $this->_p[
'point_id'] = $value;
82 if($this->_p[
'size']!=$value && !in_array(
'size', $this->_chgP)) $this->_chgP[] =
'size';
83 $this->_p[
'size'] = $value;
95 public function form($redirect) {
97 if(isset($_POST[
'submit'])) {
98 $gform =
new Form(
'form_attachment',
'post',
false, array(
'verifyToken'=>
true));
99 $gform->save(
'dataform');
100 $req_error = $gform->arequired();
103 $this->insert_date = date(
"Y-m-d H:i:s");
105 $this->name = cleanVar($_POST,
'name',
'string',
'');
106 $this->description = cleanVar($_POST,
'description',
'string',
'');
108 $this->updateDbData();
110 $old_filename = cleanVar($_POST,
'old_filename',
'string',
'');
112 $res = $gform->manageFile(
'filename', $old_filename,
false, $this->_extension_attachment, $this->_data_dir.OS, preg_replace(
"#action=insert#",
'action=modify&id='.$this->
id, $_SERVER[
'QUERY_STRING']), $this->_tbl_data,
'filename',
'id', $this->
id, array(
'check_type'=>
false));
114 $this->size = $_FILES[
'filename'][
'size'];
115 $this->updateDbData();
117 header(
"Location: ".$redirect);
121 error::errorMessage(array(
'error'=>1), $_SERVER[
'QUERY_STRING']);
127 $title = _(
"Modifica allegato");
128 $submit = _(
"modifica");
131 $title = _(
"Nuovo allegato");
132 $submit= _(
"inserisci");
134 $htmlsection =
new htmlSection(array(
'class'=>
'admin',
'headerTag'=>
'header',
'headerLabel'=>$title));
136 $gform =
new Form(
'form_attachment',
'post',
true, array(
'trnsl_table'=>$this->_tbl_data,
'trnsl_id'=>$this->
id));
137 $gform->load(
'dataform');
138 $buffer = $gform->form(
'',
true,
'name', array(
'generateToken'=>
true));
139 $buffer .= $gform->hidden(
'id', $this->
id);
141 $buffer .= $gform->cinput(
'name',
'text', $gform->retvar(
'name', htmlInput($this->name)), _(
"Nome"), array(
'required'=>
true,
'maxlength'=>200,
'size'=>40,
'trnsl'=>
true,
'field'=>
'name'));
142 $buffer .= $gform->ctextarea(
'description', $gform->retvar(
'description', htmlInput($this->description)), _(
"Descrizione"), array(
'cols'=>40,
'rows'=>4,
'trnsl'=>
true,
'field'=>
'description'));
143 $buffer .= $gform->cfile(
'filename', $this->filename, _(
"File"), array(
"required"=>
true,
"extensions"=>$this->_extension_attachment,
"del_check"=>
true,
"preview"=>
false));
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->filename);
165 return $this->deleteDbData();
177 return $this->_data_www.
"/".$this->filename;