Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/handlers/views_handler_sort.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* @todo.
|
|
5 |
* Definition of views_handler_sort.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
21 | 21 |
/** |
22 | 22 |
* Determine if a sort can be exposed. |
23 | 23 |
*/ |
24 |
function can_expose() { return TRUE; } |
|
24 |
public function can_expose() { |
|
25 |
return TRUE; |
|
26 |
} |
|
25 | 27 |
|
26 | 28 |
/** |
27 | 29 |
* Called to add the sort to a query. |
28 | 30 |
*/ |
29 |
function query() { |
|
31 |
public function query() {
|
|
30 | 32 |
$this->ensure_my_table(); |
31 | 33 |
// Add the field. |
32 | 34 |
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']); |
33 | 35 |
} |
34 | 36 |
|
35 |
function option_definition() { |
|
37 |
/** |
|
38 |
* {@inheritdoc} |
|
39 |
*/ |
|
40 |
public function option_definition() { |
|
36 | 41 |
$options = parent::option_definition(); |
37 | 42 |
|
38 | 43 |
$options['order'] = array('default' => 'ASC'); |
... | ... | |
48 | 53 |
/** |
49 | 54 |
* Display whether or not the sort order is ascending or descending |
50 | 55 |
*/ |
51 |
function admin_summary() { |
|
56 |
public function admin_summary() {
|
|
52 | 57 |
if (!empty($this->options['exposed'])) { |
53 | 58 |
return t('Exposed'); |
54 | 59 |
} |
... | ... | |
57 | 62 |
case 'asc': |
58 | 63 |
default: |
59 | 64 |
return t('asc'); |
60 |
break; |
|
65 |
|
|
61 | 66 |
case 'DESC'; |
62 | 67 |
case 'desc'; |
63 | 68 |
return t('desc'); |
64 |
break; |
|
65 | 69 |
} |
66 | 70 |
} |
67 | 71 |
|
68 | 72 |
/** |
69 | 73 |
* Basic options for all sort criteria |
70 | 74 |
*/ |
71 |
function options_form(&$form, &$form_state) { |
|
75 |
public function options_form(&$form, &$form_state) {
|
|
72 | 76 |
parent::options_form($form, $form_state); |
73 | 77 |
if ($this->can_expose()) { |
74 | 78 |
$this->show_expose_button($form, $form_state); |
... | ... | |
84 | 88 |
/** |
85 | 89 |
* Shortcut to display the expose/hide button. |
86 | 90 |
*/ |
87 |
function show_expose_button(&$form, &$form_state) { |
|
91 |
public function show_expose_button(&$form, &$form_state) {
|
|
88 | 92 |
$form['expose_button'] = array( |
89 | 93 |
'#prefix' => '<div class="views-expose clearfix">', |
90 | 94 |
'#suffix' => '</div>', |
91 |
// Should always come first |
|
95 |
// Should always come first.
|
|
92 | 96 |
'#weight' => -1000, |
93 | 97 |
); |
94 | 98 |
|
... | ... | |
131 | 135 |
} |
132 | 136 |
|
133 | 137 |
/** |
134 |
* Simple validate handler |
|
138 |
* Simple validate handler.
|
|
135 | 139 |
*/ |
136 |
function options_validate(&$form, &$form_state) { |
|
140 |
public function options_validate(&$form, &$form_state) {
|
|
137 | 141 |
$this->sort_validate($form, $form_state); |
138 | 142 |
if (!empty($this->options['exposed'])) { |
139 | 143 |
$this->expose_validate($form, $form_state); |
... | ... | |
142 | 146 |
} |
143 | 147 |
|
144 | 148 |
/** |
145 |
* Simple submit handler |
|
149 |
* Simple submit handler.
|
|
146 | 150 |
*/ |
147 |
function options_submit(&$form, &$form_state) { |
|
148 |
unset($form_state['values']['expose_button']); // don't store this. |
|
151 |
public function options_submit(&$form, &$form_state) { |
|
152 |
// Don't store this. |
|
153 |
unset($form_state['values']['expose_button']); |
|
154 |
|
|
149 | 155 |
$this->sort_submit($form, $form_state); |
150 | 156 |
if (!empty($this->options['exposed'])) { |
151 | 157 |
$this->expose_submit($form, $form_state); |
... | ... | |
155 | 161 |
/** |
156 | 162 |
* Shortcut to display the value form. |
157 | 163 |
*/ |
158 |
function show_sort_form(&$form, &$form_state) { |
|
164 |
public function show_sort_form(&$form, &$form_state) {
|
|
159 | 165 |
$options = $this->sort_options(); |
160 | 166 |
if (!empty($options)) { |
161 | 167 |
$form['order'] = array( |
... | ... | |
166 | 172 |
} |
167 | 173 |
} |
168 | 174 |
|
169 |
function sort_validate(&$form, &$form_state) { } |
|
175 |
/** |
|
176 |
* {@inheritdoc} |
|
177 |
*/ |
|
178 |
public function sort_validate(&$form, &$form_state) { |
|
179 |
} |
|
170 | 180 |
|
171 |
function sort_submit(&$form, &$form_state) { } |
|
181 |
/** |
|
182 |
* {@inheritdoc} |
|
183 |
*/ |
|
184 |
public function sort_submit(&$form, &$form_state) { |
|
185 |
} |
|
172 | 186 |
|
173 | 187 |
/** |
174 | 188 |
* Provide a list of options for the default sort form. |
175 |
* Should be overridden by classes that don't override sort_form |
|
189 |
* |
|
190 |
* Should be overridden by classes that don't override sort_form. |
|
176 | 191 |
*/ |
177 |
function sort_options() { |
|
192 |
public function sort_options() {
|
|
178 | 193 |
return array( |
179 | 194 |
'ASC' => t('Sort ascending'), |
180 | 195 |
'DESC' => t('Sort descending'), |
181 | 196 |
); |
182 | 197 |
} |
183 | 198 |
|
184 |
function expose_form(&$form, &$form_state) { |
|
199 |
/** |
|
200 |
* {@inheritdoc} |
|
201 |
*/ |
|
202 |
public function expose_form(&$form, &$form_state) { |
|
185 | 203 |
// #flatten will move everything from $form['expose'][$key] to $form[$key] |
186 | 204 |
// prior to rendering. That's why the pre_render for it needs to run first, |
187 | 205 |
// so that when the next pre_render (the one for fieldsets) runs, it gets |
... | ... | |
196 | 214 |
'#required' => TRUE, |
197 | 215 |
'#size' => 40, |
198 | 216 |
'#weight' => -1, |
199 |
); |
|
217 |
);
|
|
200 | 218 |
} |
201 | 219 |
|
202 | 220 |
/** |
203 | 221 |
* Provide default options for exposed sorts. |
204 | 222 |
*/ |
205 |
function expose_options() { |
|
223 |
public function expose_options() {
|
|
206 | 224 |
$this->options['expose'] = array( |
207 | 225 |
'order' => $this->options['order'], |
208 | 226 |
'label' => $this->definition['title'], |
209 | 227 |
); |
210 | 228 |
} |
229 |
|
|
211 | 230 |
} |
212 | 231 |
|
213 | 232 |
/** |
... | ... | |
216 | 235 |
* @ingroup views_sort_handlers |
217 | 236 |
*/ |
218 | 237 |
class views_handler_sort_broken extends views_handler_sort { |
219 |
function ui_name($short = FALSE) { |
|
238 |
|
|
239 |
/** |
|
240 |
* {@inheritdoc} |
|
241 |
*/ |
|
242 |
public function ui_name($short = FALSE) { |
|
220 | 243 |
return t('Broken/missing handler'); |
221 | 244 |
} |
222 | 245 |
|
223 |
function ensure_my_table() { /* No table to ensure! */ } |
|
224 |
function query($group_by = FALSE) { /* No query to run */ } |
|
225 |
function options_form(&$form, &$form_state) { |
|
246 |
/** |
|
247 |
* {@inheritdoc} |
|
248 |
*/ |
|
249 |
public function ensure_my_table() { |
|
250 |
// No table to ensure! |
|
251 |
} |
|
252 |
|
|
253 |
/** |
|
254 |
* {@inheritdoc} |
|
255 |
*/ |
|
256 |
public function query($group_by = FALSE) { |
|
257 |
// No query to run. |
|
258 |
} |
|
259 |
|
|
260 |
/** |
|
261 |
* {@inheritdoc} |
|
262 |
*/ |
|
263 |
public function options_form(&$form, &$form_state) { |
|
226 | 264 |
$form['markup'] = array( |
227 | 265 |
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>', |
228 | 266 |
); |
229 | 267 |
} |
230 | 268 |
|
231 | 269 |
/** |
232 |
* Determine if the handler is considered 'broken' |
|
270 |
* Determine if the handler is considered 'broken'.
|
|
233 | 271 |
*/ |
234 |
function broken() { return TRUE; } |
|
272 |
public function broken() { |
|
273 |
return TRUE; |
|
274 |
} |
|
275 |
|
|
235 | 276 |
} |
236 | 277 |
|
237 | 278 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules