27 public $prevLabel =
'<span class="glyphicon glyphicon-chevron-left"></span>';
32 public $nextLabel =
'<span class="glyphicon glyphicon-chevron-right"></span>';
71 if (!isset($this->htmlOptions[
'id'])) {
72 $this->htmlOptions[
'id'] = $this->getId();
75 $classes = array(
'carousel');
77 if ($this->slide ===
true) {
81 if (!empty($classes)) {
82 $classes = implode(
' ', $classes);
83 if (isset($this->htmlOptions[
'class'])) {
84 $this->htmlOptions[
'class'] .=
' ' . $classes;
86 $this->htmlOptions[
'class'] = $classes;
96 public function run() {
98 $id = $this->htmlOptions[
'id'];
100 echo CHtml::openTag(
'div', $this->htmlOptions);
102 echo
'<div class="carousel-inner">';
106 if ($this->displayPrevAndNext) {
107 echo
'<a class="carousel-control left" href="#' . $id .
'" data-slide="prev">' . $this->prevLabel .
'</a>';
108 echo
'<a class="carousel-control right" href="#' . $id .
'" data-slide="next">' . $this->nextLabel .
'</a>';
114 $cs = Yii::app()->getClientScript();
115 $options = !empty($this->options) ? CJavaScript::encode($this->options) :
'';
116 $cs->registerScript(__CLASS__ .
'#' . $id,
"jQuery('#{$id}').carousel({$options});");
118 foreach ($this->events as $name => $handler) {
119 $handler = CJavaScript::encode($handler);
120 $cs->registerScript(__CLASS__ .
'#' . $id .
'_' . $name,
"jQuery('#{$id}').on('{$name}', {$handler});");
129 echo
'<ol class="carousel-indicators">';
130 $count = count($this->items);
132 echo
'<li data-target="#'.$this->id.
'" data-slide-to="'.
$i.
'" class="'.(
$i===0?
'active':
'').
'"></li>';
147 if (!is_array($item)) {
151 if (isset($item[
'visible']) && $item[
'visible'] ===
false) {
155 if (!isset($item[
'itemOptions'])) {
156 $item[
'itemOptions'] = array();
159 $classes = array(
'item');
162 $classes[] =
'active';
165 if (!empty($classes)) {
166 $classes = implode(
' ', $classes);
167 if (isset($item[
'itemOptions'][
'class'])) {
168 $item[
'itemOptions'][
'class'] .=
' ' . $classes;
170 $item[
'itemOptions'][
'class'] = $classes;
174 echo CHtml::openTag(
'div', $item[
'itemOptions']);
176 if (isset($item[
'image'])) {
177 if (!isset($item[
'alt'])) {
181 if (!isset($item[
'imageOptions'])) {
182 $item[
'imageOptions'] = array();
189 if (isset($item[
'link'])) {
191 if (!isset($item[
'linkOptions']) || !is_array($item[
'linkOptions'])) {
192 $item[
'linkOptions'] = array();
196 if(is_array($item[
'link'])) {
197 $route = isset($item[
'link'][0]) ? $item[
'link'][0] :
'';
198 $item[
'linkOptions'][
'href'] = Yii::app()->createUrl($route, array_splice($item[
'link'], 1));
200 $item[
'linkOptions'][
'href'] = $item[
'link'];
204 echo CHtml::openTag(
'a', $item[
'linkOptions']);
207 echo CHtml::image($item[
'image'], $item[
'alt'], $item[
'imageOptions']);
209 if (isset($item[
'link'])) {
214 if (!empty($item[
'caption']) && (isset($item[
'label']) || isset($item[
'caption']))) {
215 if (!isset($item[
'captionOptions'])) {
216 $item[
'captionOptions'] = array();
219 if (isset($item[
'captionOptions'][
'class'])) {
220 $item[
'captionOptions'][
'class'] .=
' carousel-caption';
222 $item[
'captionOptions'][
'class'] =
'carousel-caption';
225 echo CHtml::openTag(
'div', $item[
'captionOptions']);
227 if (isset($item[
'label'])) {
228 echo
'<h3>' . $item[
'label'] .
'</h3>';
231 if (isset($item[
'caption'])) {
232 echo
'<p>' . $item[
'caption'] .
'</p>';