1 <?php
2 /**
3 * TbThumbnails class file.
4 * @author Christoffer Niska <ChristofferNiska@gmail.com>
5 * @copyright Copyright © Christoffer Niska 2011-
6 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
7 * @package bootstrap.widgets
8 */
9
10 Yii::import('bootstrap.widgets.TbListView');
11
12 /**
13 * Bootstrap thumbnails widget.
14 * @see http://twitter.github.com/bootstrap/components.html#thumbnails
15 */
16 class TbThumbnails extends TbListView
17 {
18 /**
19 * Renders the data items for the view.
20 * Each item is corresponding to a single data model instance.
21 * Child classes should override this method to provide the actual item rendering logic.
22 */
23 public function renderItems()
24 {
25 echo CHtml::openTag($this->itemsTagName,array('class'=>$this->itemsCssClass))."\n";
26
27 $data = $this->dataProvider->getData();
28
29 if (!empty($data))
30 {
31 echo CHtml::openTag('ul', array('class'=>'thumbnails'));
32 $owner = $this->getOwner();
33 $render = $owner instanceof CController ? 'renderPartial' : 'render';
34 foreach($data as $i=>$item)
35 {
36 $data = $this->viewData;
37 $data['index'] = $i;
38 $data['data'] = $item;
39 $data['widget'] = $this;
40 $owner->$render($this->itemView,$data);
41 }
42
43 echo '</ul>';
44 }
45 else
46 $this->renderEmptyText();
47
48 echo CHtml::closeTag($this->itemsTagName);
49 }
50 }
51