HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbButtonColumn.php
Go to the documentation of this file.
1 <?php
11 Yii::import('zii.widgets.grid.CButtonColumn');
12 
20 class TbButtonColumn extends CButtonColumn {
21 
25  public $viewButtonIcon = 'eye-open';
26 
30  public $updateButtonIcon = 'pencil';
31 
35  public $deleteButtonIcon = 'trash';
36 
42  protected function initDefaultButtons() {
43 
45 
46  if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
47  $this->buttons['view']['icon'] = $this->viewButtonIcon;
48  }
49  if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
50  $this->buttons['update']['icon'] = $this->updateButtonIcon;
51  }
52  if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
53  $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
54  }
55  }
56 
67  protected function renderButton($id, $button, $row, $data) {
68 
69  if (isset($button['visible']) && !$this->evaluateExpression(
70  $button['visible'],
71  array('row' => $row, 'data' => $data)
72  )
73  ) {
74  return;
75  }
76 
77  $label = isset($button['label']) ? $button['label'] : $id;
78  $url = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row))
79  : '#';
80  $options = isset($button['options']) ? $button['options'] : array();
81 
82  if (!isset($options['title'])) {
83  $options['title'] = $label;
84  }
85 
86  if (!isset($options['data-toggle'])) {
87  $options['data-toggle'] = 'tooltip';
88  }
89 
90  if (isset($button['icon']) && $button['icon']) {
91  if (strpos($button['icon'], 'icon') === false && strpos($button['icon'], 'fa') === false) {
92  $button['icon'] = 'glyphicon glyphicon-' . implode('glyphicon-', explode(' ', $button['icon']));
93  }
94 
95  echo CHtml::link('<i class="' . $button['icon'] . '"></i>', $url, $options);
96  } else if (isset($button['imageUrl']) && is_string($button['imageUrl'])) {
97  echo CHtml::link(CHtml::image($button['imageUrl'], $label), $url, $options);
98  } else {
99  echo CHtml::link($label, $url, $options);
100  }
101  }
102 }