Gino Multimedia  0.1
Modulo di gestione di contenuti multimediali per Gino CMS
 Tutto Strutture dati File Funzioni Variabili Gruppi Pagine
class.multimediaSlider.php
Vai alla documentazione di questo file.
1 <?php
37 class multimediaSlider extends propertyObject {
38 
39  private $_controller;
41  private $_image_orders;
42 
43  public static $tbl_slider = "multimedia_slider";
44 
51  function __construct($id, $instance) {
52 
53  $this->_controller = $instance;
54  $this->_tbl_data = self::$tbl_slider;
55 
56  $this->_fields_label = array(
57  'tpl'=>array(_("Template"), _('Inserire lo slider con la stringa {{ slider }}')),
58  'image_order'=>_('Ordinamento immagini'),
59  'gallery'=>_('Galleria'),
60  'animation_effect_duration'=>_('Durata effetto di animazione (ms)'),
61  'auto_play'=>_('Auto play'),
62  'show_ctrls'=>_('Mostra controlli navigazione'),
63  'mouseout_hide_ctrls'=>_('Nascondi controlli navigazione al mouseout'),
64  'transition_effect'=>_('Effetto di transizione'),
65  'animation_interval'=>_('Intervallo immagini successive (ms)'),
66  'pause_interval_mouseover'=>_('Pausa dell\'intervallo al mouseover'),
67  'slices'=>_('Numero di slices')
68  );
69 
70  $this->_image_orders = array(
71  1 => _('random'),
72  2 => _('data decrescente'),
73  3 => _('data crescente')
74  );
75 
76  $this->_transition_effects = array(
77  1=>"fade",
78  2=>"fold",
79  3=>"random",
80  4=>"horiz sliceLeftDown",
81  5=>"horiz sliceLeftUp",
82  6=>"horiz sliceLeftRightDown",
83  7=>"horiz sliceLeftRightUp",
84  8=>"horiz sliceRightDown",
85  9=>"horiz sliceRightUp",
86  10=>"horiz wipeDown",
87  11=>"horiz wipeUp",
88  12=>"vert sliceDownLeft",
89  13=>"vert sliceDownRight",
90  14=>"vert sliceUpDownLeft",
91  15=>"vert sliceUpDownRight",
92  16=>"vert sliceUpLeft",
93  17=>"vert sliceUpRight",
94  18=>"vert wipeLeft",
95  19=>"vert wipeRight"
96  );
97 
98  parent::__construct($id);
99 
100  $this->_model_label = $this->id ? $this->id : '';
101 
102  }
103 
111  public function structure($id) {
112 
113  $structure = parent::structure($id);
114 
115  $structure['auto_play'] = new booleanField(array(
116  'name'=>'auto_play',
117  'required'=>true,
118  'label'=>$this->_fields_label['auto_play'],
119  'enum'=>array(1 => _('si'), 0 => _('no')),
120  'default'=>0,
121  'value'=>$this->auto_play
122  ));
123 
124  $structure['show_ctrls'] = new booleanField(array(
125  'name'=>'show_ctrls',
126  'required'=>true,
127  'label'=>$this->_fields_label['show_ctrls'],
128  'enum'=>array(1 => _('si'), 0 => _('no')),
129  'default'=>0,
130  'value'=>$this->show_ctrls
131  ));
132 
133  $structure['mouseout_hide_ctrls'] = new booleanField(array(
134  'name'=>'mouseout_hide_ctrls',
135  'required'=>true,
136  'label'=>$this->_fields_label['mouseout_hide_ctrls'],
137  'enum'=>array(1 => _('si'), 0 => _('no')),
138  'default'=>0,
139  'value'=>$this->mouseout_hide_ctrls
140  ));
141 
142  $structure['pause_interval_mouseover'] = new booleanField(array(
143  'name'=>'pause_interval_mouseover',
144  'required'=>true,
145  'label'=>$this->_fields_label['pause_interval_mouseover'],
146  'enum'=>array(1 => _('si'), 0 => _('no')),
147  'default'=>0,
148  'value'=>$this->pause_interval_mouseover
149  ));
150 
151  $structure['gallery'] = new foreignKeyField(array(
152  'name'=>'gallery',
153  'value'=>$this->gallery,
154  'label'=>$this->_fields_label['gallery'],
155  'lenght'=>11,
156  'fkey_table'=>multimediaGallery::$tbl_gallery,
157  'fkey_id'=>'id',
158  'fkey_field'=>'name',
159  'fkey_where'=>'instance=\''.$this->_controller->getInstance().'\'',
160  'fkey_order'=>'name'
161 
162  ));
163 
164  $structure['image_order'] = new enumField(array(
165  'name'=>'image_order',
166  'required'=>true,
167  'label'=>$this->_fields_label['image_order'],
168  'enum'=>$this->_image_orders,
169  'default'=>1,
170  'value'=>$this->image_order
171  ));
172 
173  $structure['transition_effect'] = new enumField(array(
174  'name'=>'transition_effect',
175  'required'=>true,
176  'label'=>$this->_fields_label['transition_effect'],
177  'enum'=>$this->_transition_effects,
178  'default'=>1,
179  'value'=>$this->transition_effect
180  ));
181 
182  return $structure;
183  }
184 
191  public function getEffectOrientation() {
192 
193  if(preg_match("#(horiz|vert) (.*)#", $this->_transition_effects[$this->transition_effect], $matches)) {
194  $effect = $matches[2];
195  $orientation = $matches[1] == 'horiz' ? "horizontal" : "vertical";
196  }
197  else {
198  $effect = $this->_transition_effects[$this->transition_effect];
199  $orientation = 'horizontal';
200  }
201 
202  return array($effect, $orientation);
203  }
204 
211  public static function getFromInstance($controller) {
212 
213  $db = db::instance();
214  $rows = $db->select('id', self::$tbl_slider, "instance='".$controller->getInstance()."'", null, null);
215  if($rows && count($rows)) {
216  return new multimediaSlider($rows[0]['id'], $controller);
217  }
218 
219  return new multimediaSlider(null, $controller);
220 
221  }
222 
230  public function getItems($controller, $private) {
231 
232  $res = array();
233 
234  if(!$this->id) {
235  return $res;
236  }
237 
238  $gallery = new multimediaGallery($this->gallery, $controller);
239 
240  if($this->image_order == 3) {
241  $order = 'insertion_date ASC';
242  }
243  else {
244  $order = 'insertion_date DESC';
245  }
246 
247  $items = $gallery->getItems($controller, array(
248  'order' => $order,
249  'private' => $private,
250  'published' => true,
251  'where_c' => "type='".IMAGE_CHOICE."'"
252  ));
253 
254  if($this->_image_orders == 1) {
255  shuffle($items);
256  }
257 
258  return $items;
259 
260  }
261 
262 }
263 
264 ?>