HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbGroupButtonColumn.php
Go to the documentation of this file.
1 <?php
10 Yii::import('zii.widgets.grid.CButtonColumn');
11 
19 class TbGroupButtonColumn extends CButtonColumn
20 {
29  protected function renderButton($id, $button, $row, $data)
30  {
31  if (isset($button['visible']) && !$this->evaluateExpression(
32  $button['visible'],
33  array('row' => $row, 'data' => $data)
34  )
35  ) {
36  return;
37  }
38 
39  $label = isset($button['label']) ? $button['label'] : $id;
40  $url = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row))
41  : '#';
42  $options = isset($button['options']) ? $button['options'] : array();
43 
44  if (!isset($options['title'])) {
45  $options['title'] = $label;
46  }
47 
48  //Forsing btn class
49  if (!isset($options['class'])) {
50  $options['class'] = 'btn';
51  } else if (!preg_match('/[^A-z\-]btn[^A-z\-]/', $options['class'])) {
52  $options['class'] = 'btn ' . $options['class'];
53  }
54 
55  if (isset($button['icon'])) {
56  if (strpos($button['icon'], 'icon') === false && strpos($button['icon'], 'fa') === false) {
57  $button['icon'] = 'icon-' . implode(' icon-', explode(' ', $button['icon']));
58  }
59 
60  echo CHtml::link('<i class="' . $button['icon'] . '"></i>', $url, $options);
61  } else {
62  echo CHtml::link($label, $url, $options);
63  }
64  }
65 
73  protected function renderDataCellContent($row, $data)
74  {
75  $tr = array();
76  ob_start();
77  foreach ($this->buttons as $id => $button) {
78  $this->renderButton($id, $button, $row, $data);
79  $tr['{' . $id . '}'] = ob_get_contents();
80  ob_clean();
81  }
82 
83  ob_end_clean();
84  echo '<div class="btn-group">';
85  echo strtr($this->template, $tr);
86  echo '</div>';
87  }
88 }