| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* TDataGridPagerStyle class file.
|
|
|
4 |
*
|
|
|
5 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: TDataGridPagerStyle.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
10 |
* @package System.Web.UI.WebControls
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
Prado::using('System.Web.UI.WebControls.TDataGrid');
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
* TDataGridPagerStyle class.
|
|
|
17 |
*
|
|
|
18 |
* TDataGridPagerStyle specifies the styles available for a datagrid pager.
|
|
|
19 |
*
|
|
|
20 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
21 |
* @version $Id: TDataGridPagerStyle.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
22 |
* @package System.Web.UI.WebControls
|
|
|
23 |
* @since 3.0
|
|
|
24 |
*/
|
|
|
25 |
class TDataGridPagerStyle extends TPanelStyle
|
|
|
26 |
{
|
|
|
27 |
private $_mode=null;
|
|
|
28 |
private $_nextText=null;
|
|
|
29 |
private $_prevText=null;
|
|
|
30 |
private $_buttonCount=null;
|
|
|
31 |
private $_position=null;
|
|
|
32 |
private $_visible=null;
|
|
|
33 |
private $_buttonType=null;
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* @return TDataGridPagerMode pager mode. Defaults to TDataGridPagerMode::NextPrev.
|
|
|
37 |
*/
|
|
|
38 |
public function getMode()
|
|
|
39 |
{
|
|
|
40 |
return $this->_mode===null?TDataGridPagerMode::NextPrev : $this->_mode;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
* @param TDataGridPagerMode pager mode.
|
|
|
45 |
*/
|
|
|
46 |
public function setMode($value)
|
|
|
47 |
{
|
|
|
48 |
$this->_mode=TPropertyValue::ensureEnum($value,'TDataGridPagerMode');
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* @return TDataGridPagerButtonType the type of command button. Defaults to TDataGridPagerButtonType::LinkButton.
|
|
|
53 |
*/
|
|
|
54 |
public function getButtonType()
|
|
|
55 |
{
|
|
|
56 |
return $this->_buttonType===null?TDataGridPagerButtonType::LinkButton:$this->_buttonType;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* @param TDataGridPagerButtonType the type of command button
|
|
|
61 |
*/
|
|
|
62 |
public function setButtonType($value)
|
|
|
63 |
{
|
|
|
64 |
$this->_buttonType=TPropertyValue::ensureEnum($value,'TDataGridPagerButtonType');
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* @return string text for the next page button. Defaults to '>'.
|
|
|
69 |
*/
|
|
|
70 |
public function getNextPageText()
|
|
|
71 |
{
|
|
|
72 |
return $this->_nextText===null?'>':$this->_nextText;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* @param string text for the next page button.
|
|
|
77 |
*/
|
|
|
78 |
public function setNextPageText($value)
|
|
|
79 |
{
|
|
|
80 |
$this->_nextText=$value;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
/**
|
|
|
84 |
* @return string text for the previous page button. Defaults to '<'.
|
|
|
85 |
*/
|
|
|
86 |
public function getPrevPageText()
|
|
|
87 |
{
|
|
|
88 |
return $this->_prevText===null?'<':$this->_prevText;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
/**
|
|
|
92 |
* @param string text for the next page button.
|
|
|
93 |
*/
|
|
|
94 |
public function setPrevPageText($value)
|
|
|
95 |
{
|
|
|
96 |
$this->_prevText=$value;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
/**
|
|
|
100 |
* @return integer maximum number of pager buttons to be displayed. Defaults to 10.
|
|
|
101 |
*/
|
|
|
102 |
public function getPageButtonCount()
|
|
|
103 |
{
|
|
|
104 |
return $this->_buttonCount===null?10:$this->_buttonCount;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* @param integer maximum number of pager buttons to be displayed
|
|
|
109 |
* @throws TInvalidDataValueException if the value is less than 1.
|
|
|
110 |
*/
|
|
|
111 |
public function setPageButtonCount($value)
|
|
|
112 |
{
|
|
|
113 |
if(($value=TPropertyValue::ensureInteger($value))<1)
|
|
|
114 |
throw new TInvalidDataValueException('datagridpagerstyle_pagebuttoncount_invalid');
|
|
|
115 |
$this->_buttonCount=$value;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
/**
|
|
|
119 |
* @return TDataGridPagerPosition where the pager is to be displayed. Defaults to TDataGridPagerPosition::Bottom.
|
|
|
120 |
*/
|
|
|
121 |
public function getPosition()
|
|
|
122 |
{
|
|
|
123 |
return $this->_position===null?TDataGridPagerPosition::Bottom:$this->_position;
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
/**
|
|
|
127 |
* @param TDataGridPagerPosition where the pager is to be displayed.
|
|
|
128 |
*/
|
|
|
129 |
public function setPosition($value)
|
|
|
130 |
{
|
|
|
131 |
$this->_position=TPropertyValue::ensureEnum($value,'TDataGridPagerPosition');
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
/**
|
|
|
135 |
* @return boolean whether the pager is visible. Defaults to true.
|
|
|
136 |
*/
|
|
|
137 |
public function getVisible()
|
|
|
138 |
{
|
|
|
139 |
return $this->_visible===null?true:$this->_visible;
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
/**
|
|
|
143 |
* @param boolean whether the pager is visible.
|
|
|
144 |
*/
|
|
|
145 |
public function setVisible($value)
|
|
|
146 |
{
|
|
|
147 |
$this->_visible=TPropertyValue::ensureBoolean($value);
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
/**
|
|
|
151 |
* Resets the style to the original empty state.
|
|
|
152 |
*/
|
|
|
153 |
public function reset()
|
|
|
154 |
{
|
|
|
155 |
parent::reset();
|
|
|
156 |
$this->_visible=null;
|
|
|
157 |
$this->_position=null;
|
|
|
158 |
$this->_buttonCount=null;
|
|
|
159 |
$this->_prevText=null;
|
|
|
160 |
$this->_nextText=null;
|
|
|
161 |
$this->_mode=null;
|
|
|
162 |
$this->_buttonType=null;
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
/**
|
|
|
166 |
* Copies the fields in a new style to this style.
|
|
|
167 |
* If a style field is set in the new style, the corresponding field
|
|
|
168 |
* in this style will be overwritten.
|
|
|
169 |
* @param TStyle the new style
|
|
|
170 |
*/
|
|
|
171 |
public function copyFrom($style)
|
|
|
172 |
{
|
|
|
173 |
parent::copyFrom($style);
|
|
|
174 |
if($style instanceof TDataGridPagerStyle)
|
|
|
175 |
{
|
|
|
176 |
if($style->_visible!==null)
|
|
|
177 |
$this->_visible=$style->_visible;
|
|
|
178 |
if($style->_position!==null)
|
|
|
179 |
$this->_position=$style->_position;
|
|
|
180 |
if($style->_buttonCount!==null)
|
|
|
181 |
$this->_buttonCount=$style->_buttonCount;
|
|
|
182 |
if($style->_prevText!==null)
|
|
|
183 |
$this->_prevText=$style->_prevText;
|
|
|
184 |
if($style->_nextText!==null)
|
|
|
185 |
$this->_nextText=$style->_nextText;
|
|
|
186 |
if($style->_mode!==null)
|
|
|
187 |
$this->_mode=$style->_mode;
|
|
|
188 |
if($style->_buttonType!==null)
|
|
|
189 |
$this->_buttonType=$style->_buttonType;
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
/**
|
|
|
194 |
* Merges the style with a new one.
|
|
|
195 |
* If a style field is not set in this style, it will be overwritten by
|
|
|
196 |
* the new one.
|
|
|
197 |
* @param TStyle the new style
|
|
|
198 |
*/
|
|
|
199 |
public function mergeWith($style)
|
|
|
200 |
{
|
|
|
201 |
parent::mergeWith($style);
|
|
|
202 |
if($style instanceof TDataGridPagerStyle)
|
|
|
203 |
{
|
|
|
204 |
if($this->_visible===null)
|
|
|
205 |
$this->_visible=$style->_visible;
|
|
|
206 |
if($this->_position===null)
|
|
|
207 |
$this->_position=$style->_position;
|
|
|
208 |
if($this->_buttonCount===null)
|
|
|
209 |
$this->_buttonCount=$style->_buttonCount;
|
|
|
210 |
if($this->_prevText===null)
|
|
|
211 |
$this->_prevText=$style->_prevText;
|
|
|
212 |
if($this->_nextText===null)
|
|
|
213 |
$this->_nextText=$style->_nextText;
|
|
|
214 |
if($this->_mode===null)
|
|
|
215 |
$this->_mode=$style->_mode;
|
|
|
216 |
if($this->_buttonType===null)
|
|
|
217 |
$this->_buttonType=$style->_buttonType;
|
|
|
218 |
}
|
|
|
219 |
}
|
|
|
220 |
}
|
|
|
221 |
|