1: <?php
2: 3: 4: 5: 6: 7: 8:
9:
10: Yii::import('bootstrap.helpers.TbHtml');
11: Yii::import('bootstrap.widgets.TbListView');
12:
13: 14: 15: 16:
17: class TbThumbnails extends TbListView
18: {
19: 20: 21: 22:
23: public $url;
24: 25: 26:
27: public $span;
28:
29: 30: 31:
32: public function init()
33: {
34: parent::init();
35:
36: if (isset($this->itemsCssClass)) {
37: TbHtml::addCssClass($this->itemsCssClass, $this->htmlOptions);
38: }
39: }
40:
41: 42: 43: 44:
45: public function renderItems()
46: {
47: $thumbnails = array();
48: $data = $this->dataProvider->getData();
49:
50: if (!empty($data)) {
51: $owner = $this->getOwner();
52: $render = $owner instanceof CController ? 'renderPartial' : 'render';
53: foreach ($data as $i => $row) {
54: $thumbnail = array();
55: $d = $this->viewData;
56: $d['index'] = $i;
57: $d['data'] = $row;
58: $d['widget'] = $this;
59: $thumbnail['caption'] = $owner->$render($this->itemView, $d, true);
60: if (isset($this->url)) {
61: $thumbnail['url'] = $this->evaluateExpression($this->url, array('data' => $row));
62: }
63: if (isset($this->span)) {
64: $thumbnail['span'] = $this->span;
65: }
66: $thumbnails[] = $thumbnail;
67: }
68: echo TbHtml::thumbnails($thumbnails, $this->htmlOptions);
69: } else {
70: $this->renderEmptyText();
71: }
72: }
73: }
74: