48 $this->_controller = $instance;
49 $this->_tbl_data = self::$tbl_gallery;
51 $this->_fields_label = array(
53 'slug'=>array(_(
"Slug"), _(
'utilizzato per creare un permalink alla risorsa')),
54 'description'=>_(
'Descrizione'),
55 'thumb'=>array(_(
'Thumbnail'), _(
'viene inserito il thumbnail del primo media contenuto se lasciato vuoto')),
56 'published'=>_(
'Pubblicata'),
57 'private'=>array(_(
'Privata'), _(
'le gallerie private saranno visibili solamente agli utenti iscritti al gruppo di visualizzazione di contenuti provati')),
58 'insertion_date'=>_(
'Data di inserimento'),
59 'last_edit_date'=>_(
'Data di ultima modifica'),
60 'promoted'=>array(_(
'Promossa'), _(
'La più recente galleria promossa viene inserita in testa alla vista "ultime gallerie"'))
63 parent::__construct($id);
65 $this->_model_label = $this->
id ? $this->name :
'';
77 $structure = parent::structure($id);
79 $structure[
'published'] =
new booleanField(array(
82 'label'=>$this->_fields_label[
'published'],
83 'enum'=>array(1 => _(
'si'), 0 => _(
'no')),
85 'value'=>$this->published
88 $structure[
'private'] =
new booleanField(array(
91 'label'=>$this->_fields_label[
'private'],
92 'enum'=>array(1 => _(
'si'), 0 => _(
'no')),
94 'value'=>$this->
private
97 $structure[
'promoted'] =
new booleanField(array(
100 'label'=>$this->_fields_label[
'promoted'],
101 'enum'=>array(1 => _(
'si'), 0 => _(
'no')),
103 'value'=>$this->promoted
106 $structure[
'insertion_date'] =
new datetimeField(array(
107 'name'=>
'insertion_date',
109 'label'=>$this->_fields_label[
'insertion_date'],
111 'value'=>$this->insertion_date
114 $base_path = $this->_controller->getBaseAbsPath(
'thumb');
118 'value'=>$this->thumb,
119 'label'=>$this->_fields_label[
'thumb'],
121 'extensions'=>self::$_extension_thumb,
124 'side_dimension'=>$this->_controller->getThumbDimension()
143 $db = db::instance();
144 $rows = $db->select(
'id', self::$tbl_gallery,
"slug='$slug'", null, array(0, 1));
164 $private = gOpt(
'private', $options,
false);
165 $published = gOpt(
'published', $options,
true);
167 $db = db::instance();
169 $table = self::$tbl_gallery;
170 $where_arr = array(
"instance='".$instance_obj->getInstance().
"'",
"promoted='1'");
172 $where_arr[] =
"private='0'";
175 $where_arr[] =
"published='1'";
177 $where = implode(
' AND ', $where_arr);
179 $rows = $db->select($selection, $table, $where,
'last_edit_date DESC', array(0, 1));
180 if($rows && count($rows)) {
196 public static function get($instance_obj, $options = null) {
200 $private = gOpt(
'private', $options,
false);
201 $published = gOpt(
'published', $options,
true);
202 $where_q = gOpt(
'where', $options,
'');
203 $order = gOpt(
'order', $options,
'name');
204 $limit = gOpt(
'limit', $options, null);
206 $db = db::instance();
208 $table = self::$tbl_gallery;
209 $where_arr = array(
"instance='".$instance_obj->getInstance().
"'");
211 $where_arr[] =
"private='0'";
214 $where_arr[] =
"published='1'";
217 $where_arr[] = $where_q;
219 $where = implode(
' AND ', $where_arr);
221 $rows = $db->select($selection, $table, $where, $order, $limit);
223 foreach($rows as $row) {
239 public static function getCount($instance_obj, $options = null) {
243 $private = gOpt(
'private', $options,
false);
244 $published = gOpt(
'published', $options,
true);
246 $db = db::instance();
247 $selection =
'COUNT(id) AS tot';
248 $table = self::$tbl_gallery;
249 $where_arr = array(
"instance='".$instance_obj->getInstance().
"'");
251 $where_arr[] =
"private='0'";
254 $where_arr[] =
"published='1'";
256 $where = implode(
' AND ', $where_arr);
258 $rows = $db->select($selection, $table, $where, null, null);
260 $tot = $rows[0][
'tot'];
274 public function getItems($instance_obj, $options = null) {
278 $private = gOpt(
'private', $options,
false);
279 $published = gOpt(
'published', $options,
true);
280 $order = gOpt(
'order', $options,
'insertion_date DESC');
281 $limit = gOpt(
'limit', $options, null);
282 $where_c = gOpt(
'where', $options,
false);
284 $db = db::instance();
285 $selection = array(
'id',
'type');
288 "instance='".$instance_obj->getInstance().
"'",
289 "galleries REGEXP '[[:<:]]".$this->id.
"[[:>:]]'",
292 $where_arr[] =
"private='0'";
295 $where_arr[] =
"published='1'";
298 $where_arr[] = $where_c;
300 $where = implode(
' AND ', $where_arr);
302 $rows = $db->select($selection, $table, $where, $order, $limit);
304 foreach($rows as $row) {
332 $private = gOpt(
'private', $options,
false);
333 $published = gOpt(
'published', $options,
true);
335 $db = db::instance();
336 $selection =
'COUNT(id) AS tot';
339 "instance='".$instance_obj->getInstance().
"'",
340 "galleries REGEXP '[[:<:]]".$this->id.
"[[:>:]]'"
343 $where_arr[] =
"private='0'";
346 $where_arr[] =
"published='1'";
348 $where = implode(
' AND ', $where_arr);
350 $rows = $db->select($selection, $table, $where, null, null);
352 $tot = $rows[0][
'tot'];
369 return $controller->getBasePath(
'thumb').
'/'.$this->thumb;
372 $media =
multimediaItem::get($controller, array(
'published'=>
true,
'gallery'=>$this->
id,
'order'=>
'insertion_date ASC',
'limit'=>array(0, 1)));
373 if(count($media) && $media) {
374 return $media[0]->thumbPath($controller);
376 else return $controller->defaultGalleryThumbPath();