1 | <?php |
||
17 | class TbPager extends CLinkPager { |
||
18 | |||
19 | // Pager alignments. |
||
20 | const ALIGNMENT_CENTER = 'centered'; |
||
21 | const ALIGNMENT_RIGHT = 'right'; |
||
22 | |||
23 | /** |
||
24 | * @var string attributes for the pager container tag. |
||
25 | */ |
||
26 | public $containerTag = 'div'; |
||
27 | |||
28 | /** |
||
29 | * @var array HTML attributes for the pager container tag. |
||
30 | */ |
||
31 | public $containerHtmlOptions = array(); |
||
32 | |||
33 | /** |
||
34 | * @var string the pager alignment. |
||
35 | * Valid values are 'centered' and 'right'. |
||
36 | */ |
||
37 | public $alignment = self::ALIGNMENT_RIGHT; |
||
38 | |||
39 | /** |
||
40 | * @var string the text shown before page buttons. |
||
41 | * Defaults to an empty string, meaning that no header will be displayed. |
||
42 | */ |
||
43 | public $header = ''; |
||
44 | |||
45 | /** |
||
46 | * @var string the URL of the CSS file used by this pager. |
||
47 | * Defaults to false, meaning that no CSS will be included. |
||
48 | */ |
||
49 | public $cssFile = false; |
||
50 | |||
51 | /** |
||
52 | * @var boolean whether to display the first and last items. |
||
53 | */ |
||
54 | public $displayFirstAndLast = false; |
||
55 | |||
56 | /** |
||
57 | *### .init() |
||
58 | * |
||
59 | * Initializes the pager by setting some default property values. |
||
60 | */ |
||
61 | public function init() { |
||
114 | |||
115 | /** |
||
116 | * Executes the widget. |
||
117 | * This overrides the parent implementation by displaying the generated page buttons. |
||
118 | */ |
||
119 | public function run() { |
||
120 | |||
121 | $this->registerClientScript(); |
||
122 | $buttons=$this->createPageButtons(); |
||
123 | if(empty($buttons)) |
||
124 | return; |
||
125 | echo CHtml::openTag($this->containerTag, $this->containerHtmlOptions); |
||
126 | echo $this->header; |
||
127 | echo CHtml::tag('ul',$this->htmlOptions,implode("\n",$buttons)); |
||
128 | echo '<div style="clear: both;"></div>'; |
||
129 | echo $this->footer; |
||
130 | echo CHtml::closeTag($this->containerTag); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | *### .createPageButtons() |
||
135 | * |
||
136 | * Creates the page buttons. |
||
137 | * @return array a list of page buttons (in HTML code). |
||
138 | */ |
||
139 | protected function createPageButtons() { |
||
194 | |||
195 | /** |
||
196 | *### .createPageButton() |
||
197 | * |
||
198 | * Creates a page button. |
||
199 | * You may override this method to customize the page buttons. |
||
200 | * |
||
201 | * @param string $label the text label for the button |
||
202 | * @param integer $page the page number |
||
203 | * @param string $class the CSS class for the page button. This could be 'page', 'first', 'last', 'next' or 'previous'. |
||
204 | * @param boolean $hidden whether this page button is visible |
||
205 | * @param boolean $selected whether this page button is selected |
||
206 | * |
||
207 | * @return string the generated button |
||
208 | */ |
||
209 | protected function createPageButton($label, $page, $class, $hidden, $selected) |
||
217 | } |
||
218 |