-
Notifications
You must be signed in to change notification settings - Fork 33
/
EBootstrapGridView.php
84 lines (71 loc) · 1.82 KB
/
EBootstrapGridView.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
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
<?php
Yii::import('zii.widgets.grid.CGridView');
/**
* Wrapper class for CGridView
* Render the GridView as a bootstrap table
*
* @author Tim Helfensdörfer <[email protected]>
* @version 0.3.0
* @package bootstrap.yiiwidgets
*/
class EBootstrapGridView extends CGridView {
/**
* Do not include the default style
*
* If it's set unequal false the css file specified will be included
* If it's set null the default css file will be included
*/
public $cssFile = false;
/**
* Bordered table
*/
public $bordered = false;
/**
* Every second row has a darker background
*/
public $striped = false;
/**
* Smaller table fields to display more content
*/
public $condensed = false;
/**
* Default css class for the pager
*/
public $pagerCssClass = 'pagination';
/**
* Align of the pager
*
* Possible values: centered|right
* Default: left
*/
public $pagerAlign = 'centered';
/**
* Init the widget
*/
public function init() {
parent::init();
$classes = array('table');
if ($this->bordered)
$classes[] = 'table-bordered';
if ($this->striped)
$classes[] = 'table-striped';
if ($this->condensed)
$classes[] = 'table-condensed';
EBootstrap::mergeClassString($this->itemsCssClass, $classes);
EBootstrap::mergeClass($this->htmlOptions, array('bootstrap-grid-view'));
switch ($this->pagerAlign) {
case 'centered':
EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-centered'));
break;
case 'right':
EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-right'));
break;
}
if ($this->cssFile === false) {
$cssFile = dirname(__FILE__).'/css/bootstrap.css';
$this->cssFile = Yii::app()->getAssetManager()->publish($cssFile);
Yii::app()->clientScript->registerCssFile($this->cssFile);
}
}
}
?>