HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbImageColumn.php
Go to the documentation of this file.
1 <?php
10 Yii::import('zii.widgets.grid.CGridColumn');
11 
17 class TbImageColumn extends CGridColumn
18 {
22  public $imageOptions = array();
23 
32 
36  public $emptyText = '';
37 
43  public $usePlaceHoldIt = false;
44 
49  public $usePlaceKitten = true;
50 
55  public $placeHoldItSize = '48x48';
56 
61  public $placeKittenSize = '48/48';
62 
69  protected function renderDataCellContent($row, $data)
70  {
71  $content = $this->emptyText;
72  if ($this->imagePathExpression && $imagePath = $this->evaluateExpression(
73  $this->imagePathExpression,
74  array('row' => $row, 'data' => $data)
75  )
76  ) {
77  $this->imageOptions['src'] = $imagePath;
78  $content = CHtml::tag('img', $this->imageOptions);
79  } elseif ($this->usePlaceHoldIt && !empty($this->placeHoldItSize)) {
80  $content = CHtml::tag(
81  'img',
82  array('src' => 'http://placehold.it/' . $this->placeHoldItSize)
83  );
84  } elseif ($this->usePlaceKitten && !empty($this->placeKittenSize)) {
85  $content = CHtml::tag('img', array('src' => 'http://placekitten.com/' . $this->placeKittenSize));
86  }
87  echo $content;
88  }
89 }