57 $this->_controller = $instance;
58 $this->_tbl_data = self::$tbl_item;
60 $this->_fields_label = array(
61 'type'=>_(
'Tipologia'),
63 'galleries'=>_(
"Gallerie"),
64 'description'=>_(
'Descrizione'),
65 'tags'=>array(_(
"Tag"), _(
"inserire tag separati da virgole, utilizzare la funzione di autocompletamento quando possibile.")),
66 'credits'=>_(
'Credits'),
67 'license'=>_(
'Licenza'),
68 'lat'=>_(
'Latitudine'),
69 'lng'=>_(
'Longitudine'),
70 'thumb'=>array(_(
'Thumbnail'), _(
'viene inserito un thumbnail di default oppure il thumb dell\'immagine inserita se lasciato vuoto')),
71 'insertion_date'=>_(
'Data di inserimento'),
72 'last_edit_date'=>_(
'Data di ultima modifica'),
73 'published'=>_(
'Pubblicato'),
74 'private'=>array(_(
'Privato'), _(
'i media privati saranno visibili solamente agli utenti iscritti al gruppo di visualizzazione di contenuti provati')),
75 'img_filename'=>_(
'File'),
76 'video_code'=>_(
'Codice video'),
77 'video_platform'=>_(
'Piattaforma video'),
78 'video_width'=>_(
'Larghezza video'),
79 'video_height'=>_(
'Altezza video'),
80 'mpeg_filename'=>_(
'File mpeg'),
81 'ogg_filename'=>_(
'File ogg')
84 parent::__construct($id);
86 $this->_model_label = $this->
id ? $this->name :
'';
87 $this->_tbl_item_tag =
'multimedia_item_tag';
98 $new_string_tags = array();
100 foreach(explode(
',', $tags) as $tag) {
102 $new_string_tags[] = $tag;
105 $this->_p[
'tags'] = implode(
',', $new_string_tags);
106 $this->_chgP[] =
'tags';
118 $structure = parent::structure($id);
120 $structure[
'galleries'] =
new manyToManyField(array(
122 'value'=>explode(
',', $this->galleries),
123 'label'=>$this->_fields_label[
'galleries'],
127 'fkey_field'=>
'name',
128 'fkey_where'=>
'instance=\''.$this->_controller->getInstance().
'\'',
129 'fkey_order'=>
'name',
130 'table'=>$this->_tbl_data
133 $structure[
'license'] =
new foreignKeyField(array(
135 'value'=>$this->license,
136 'label'=>$this->_fields_label[
'license'],
140 'fkey_field'=>
'name',
141 'fkey_where'=>
'instance=\''.$this->_controller->getInstance().
'\'',
145 $structure[
'published'] =
new booleanField(array(
148 'label'=>$this->_fields_label[
'published'],
149 'enum'=>array(1 => _(
'si'), 0 => _(
'no')),
151 'value'=>$this->published,
152 'table'=>$this->_tbl_data
155 $structure[
'private'] =
new booleanField(array(
158 'label'=>$this->_fields_label[
'private'],
159 'enum'=>array(1 => _(
'si'), 0 => _(
'no')),
161 'value'=>$this->
private,
162 'table'=>$this->_tbl_data
165 $structure[
'insertion_date'] =
new datetimeField(array(
166 'name'=>
'insertion_date',
168 'label'=>$this->_fields_label[
'insertion_date'],
170 'value'=>$this->insertion_date
173 $base_path = $this->_controller->getBaseAbsPath(
'thumb');
177 'value'=>$this->thumb,
178 'label'=>$this->_fields_label[
'thumb'],
180 'extensions'=>self::$_extension_thumb,
183 'side_dimension'=>$this->_controller->getThumbDimension()
220 public static function get($instance_obj, $options = null) {
224 $private = gOpt(
'private', $options,
false);
225 $published = gOpt(
'published', $options,
true);
226 $geolocalization = gOpt(
'geolocalization', $options,
false);
227 $gallery = gOpt(
'gallery', $options, null);
228 $order = gOpt(
'order', $options,
'name');
229 $limit = gOpt(
'limit', $options, null);
231 $db = db::instance();
232 $selection = array(
'id',
'type');
233 $table = self::$tbl_item;
234 $where_arr = array(
"instance='".$instance_obj->getInstance().
"'");
236 $where_arr[] =
"private='0'";
239 $where_arr[] =
"published='1'";
242 $where_arr[] =
"galleries REGEXP '[[:<:]]".$gallery.
"[[:>:]]'";
244 if($geolocalization) {
245 $where_arr[] =
"lat != '' AND lng != ''";
248 $where = implode(
' AND ', $where_arr);
250 $rows = $db->select($selection, $table, $where, $order, $limit);
252 foreach($rows as $row) {
277 $db = db::instance();
283 $query =
"DELETE FROM ".$this->_tbl_item_tag.
" WHERE item='".$this->
id.
"'";
284 $res = $db->actionquery($query);
287 foreach($tags as $tag) {
288 $inserts[] =
"('".$this->id.
"', '".$tag.
"')";
291 $query =
"INSERT INTO ".$this->_tbl_item_tag.
" (item, tag) VALUES ".implode(
',', $inserts);
292 return $db->actionquery($query);
301 public function delete() {
304 $db = db::instance();
305 $query =
"DELETE FROM ".$this->_tbl_item_tag.
" WHERE item='".$this->
id.
"'";
307 $db->actionquery($query);
309 return parent::delete();