|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
*## TbDetailView class file. |
|
4
|
|
|
* |
|
5
|
|
|
* |
|
6
|
|
|
* @author Christoffer Niska <[email protected]> |
|
7
|
|
|
* @copyright Copyright © Christoffer Niska 2011- |
|
8
|
|
|
* @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
Yii::import('zii.widgets.CDetailView'); |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
*## Bootstrap Zii detail view. |
|
15
|
|
|
* |
|
16
|
|
|
* @package booster.widgets.grouping |
|
17
|
|
|
*/ |
|
18
|
|
|
class TbDetailView extends CDetailView |
|
19
|
|
|
{ |
|
20
|
|
|
// Table types. |
|
21
|
|
|
const TYPE_STRIPED = 'striped'; |
|
22
|
|
|
const TYPE_BORDERED = 'bordered'; |
|
23
|
|
|
const TYPE_CONDENSED = 'condensed'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var string|array the table type. |
|
27
|
|
|
* Valid values are 'striped', 'bordered' and/or 'condensed'. |
|
28
|
|
|
*/ |
|
29
|
|
|
public $type = array(self::TYPE_STRIPED, self::TYPE_CONDENSED); |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string the URL of the CSS file used by this detail view. |
|
33
|
|
|
* Defaults to false, meaning that no CSS will be included. |
|
34
|
|
|
*/ |
|
35
|
|
|
public $cssFile = false; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
*### .init() |
|
39
|
|
|
* |
|
40
|
|
|
* Initializes the widget. |
|
41
|
|
|
*/ |
|
42
|
|
|
public function init() |
|
43
|
|
|
{ |
|
44
|
|
|
parent::init(); |
|
45
|
|
|
|
|
46
|
|
|
$classes = array('table'); |
|
47
|
|
|
|
|
48
|
|
|
if (isset($this->type)) { |
|
49
|
|
|
if (is_string($this->type)) { |
|
50
|
|
|
$this->type = explode(' ', $this->type); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED); |
|
54
|
|
|
|
|
55
|
|
|
if (!empty($this->type)) { |
|
56
|
|
|
foreach ($this->type as $type) { |
|
57
|
|
|
if (in_array($type, $validTypes)) { |
|
58
|
|
|
$classes[] = 'table-' . $type; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
if (!empty($classes)) { |
|
65
|
|
|
$classes = implode(' ', $classes); |
|
66
|
|
|
if (isset($this->htmlOptions['class'])) { |
|
67
|
|
|
$this->htmlOptions['class'] .= ' ' . $classes; |
|
68
|
|
|
} else { |
|
69
|
|
|
$this->htmlOptions['class'] = $classes; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|