-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPipedButtonColumn.php
executable file
·37 lines (33 loc) · 1.1 KB
/
PipedButtonColumn.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* An extension to {@link CButtonColumn} that displays text-links instead of images and
* adds a pipe between each link.
*/
class PipedButtonColumn extends CButtonColumn {
/**
* Renders the data cell content, adding a pipe "|" between each button.
* This method renders the view, update and delete buttons in the data cell, text-mode.
* @param integer $row the row number (zero-based)
* @param mixed $data the data associated with the row
*/
protected function renderDataCellContent($row, $data) {
$tr = array();
ob_start();
$total_buttons = 0;
foreach ($this->buttons as $button) {
if (!isset($button['visible']) || $this->evaluateExpression($button['visible'],array('row'=>$row,'data'=>$data)))
++$total_buttons;
}
$b = 0;
foreach ($this->buttons as $id => $button) {
$button['imageUrl'] = false;
$this->renderButton($id, $button, $row, $data);
$content = ob_get_contents();
$tr['{'.$id.'}'] = $content;
if (strlen($content) > 0 && ++$b != $total_buttons) $tr['{'.$id.'}'] .= ' |' ;
ob_clean();
}
ob_end_clean();
echo strtr($this->template, $tr);
}
}