-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBootProgressColumn.php
More file actions
91 lines (72 loc) · 2.22 KB
/
BootProgressColumn.php
File metadata and controls
91 lines (72 loc) · 2.22 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Implements the BootProgress inside CDataColumn
*
* @author Luiz
*/
class BootProgressColumn extends CDataColumn {
// Progress bar types.
const TYPE_DEFAULT = '';
const TYPE_INFO = 'info';
const TYPE_SUCCESS = 'success';
const TYPE_DANGER = 'danger';
/**
* @var string the bar type.
* Valid values are '', 'info', 'success', and 'danger'.
*/
public $type = self::TYPE_DEFAULT;
/**
* @var boolean whether the bar is striped.
*/
public $striped = false;
/**
* @var boolean whether the bar is animated.
*/
public $animated = false;
/**
* @var integer the progress.
*/
public $percent = 0;
public $htmlOpt = array('class'=>'progress');
/**
* Initializes the widget.
*/
public function init() {
$classes = array('progress');
$validTypes = array(self::TYPE_DEFAULT, self::TYPE_INFO, self::TYPE_SUCCESS, self::TYPE_DANGER);
if ($this->type !== self::TYPE_DEFAULT && in_array($this->type, $validTypes))
$classes[] = 'progress-' . $this->type;
if ($this->striped)
$classes[] = 'progress-striped';
if ($this->animated)
$classes[] = 'active';
$classes = implode(' ', $classes);
$this->htmlOpt['class'] = $classes;
if ($this->percent < 0)
$this->percent = 0;
else if ($this->percent > 100)
$this->percent = 100;
}
protected function renderDataCellContent($row, $data) {
if ($this->value !== null)
{
$value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
}
else if ($this->name !== null)
$value = CHtml::value($data, $this->name);
if($this->percent!==0)
$this->percent = $value;
echo CHtml::openTag('div', $this->htmlOpt);
echo '<div class="bar" style="width: ' . $this->percent . '%;"></div>';
echo '</div>';
}
/**
* Renders the filter cell.
*/
public function renderFilterCell()
{
echo '<td><div class="filter-container">';
$this->renderFilterCellContent();
echo '</div></td>';
}
}