1 <?php
2 3 4 5 6 7 8 9 10 11 12 13 14
15 Yii::import('yiiwheels.widgets.gallery.WhCarousel');
16
17 class WhVideoCarousel extends WhCarousel
18 {
19 20 21
22 public function init()
23 {
24 parent::init();
25 $this->pluginOptions['carousel'] = true;
26 $this->pluginOptions['container'] = '#' . $this->htmlOptions['id'] . '-videocarousel';
27 }
28
29 30 31 32
33 public function run()
34 {
35 if (empty($this->items)) {
36 return null;
37 }
38 $this->renderTemplate();
39 $this->registerClientScript();
40 }
41
42 43 44
45 public function renderTemplate()
46 {
47 $options = array(
48 'id' => $this->htmlOptions['id'] . '-videocarousel',
49 'class' => 'blueimp-gallery blueimp-gallery-carousel'
50 );
51 if($this->displayControls) {
52 TbHtml::addCssClass('blueimp-gallery-controls', $options);
53 }
54 echo CHtml::openTag('div', $options);
55 echo '<div class="slides"></div>
56 <h3 class="title"></h3>
57 <a class="prev">‹</a>
58 <a class="next">›</a>
59 <a class="play-pause"></a>
60 <ol class="indicator"></ol>';
61 echo CHtml::closeTag('div');
62 }
63
64 65 66
67 public function registerClientScript() {
68 $this->registerGalleryScriptFiles();
69
70 $items = CJavaScript::encode($this->items);
71 $options = CJavaScript::encode($this->pluginOptions);
72 $js = ";blueimp.Gallery({$items}, {$options});";
73
74 Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->getId(), $js);
75 }
76 }