Overview

Packages

  • bootstrap
    • behaviors
    • components
    • form
    • gii
    • helpers
    • widgets

Classes

  • TbActiveForm
  • TbAffix
  • TbAlert
  • TbBreadcrumb
  • TbButtonColumn
  • TbCollapse
  • TbDataColumn
  • TbDetailView
  • TbGridView
  • TbHeroUnit
  • TbListView
  • TbModal
  • TbNav
  • TbNavbar
  • TbPager
  • TbScrollspy
  • TbTabs
  • TbThumbnails
  • TbTypeAhead
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * TbThumbnails class file.
 4:  * @author Christoffer Niska <christoffer.niska@gmail.com>
 5:  * @copyright Copyright &copy; Christoffer Niska 2013-
 6:  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 7:  * @package bootstrap.widgets
 8:  */
 9: 
10: Yii::import('bootstrap.helpers.TbHtml');
11: Yii::import('bootstrap.widgets.TbListView');
12: 
13: /**
14:  * Bootstrap thumbnails widget.
15:  * http://twitter.github.com/bootstrap/components.html#thumbnails
16:  */
17: class TbThumbnails extends TbListView
18: {
19:     /**
20:      * @var mixed a PHP expression that is evaluated for every item and whose result is used
21:      * as the URL for the thumbnail.
22:      */
23:     public $url;
24:     /**
25:      * @var integer the number of grid columns that the thumbnails spans over.
26:      */
27:     public $span;
28: 
29:     /**
30:      * Initializes the widget
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:      * Renders the data items for the view.
43:      * Each item is corresponding to a single data model instance.
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: 
Yiistrap API documentation generated by ApiGen 2.8.0