Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/plugins/views_plugin_display_page.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Contains the page display plugin.
|
|
5 |
* Definition of views_plugin_display_page.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
11 | 11 |
* @ingroup views_display_plugins |
12 | 12 |
*/ |
13 | 13 |
class views_plugin_display_page extends views_plugin_display { |
14 |
|
|
14 | 15 |
/** |
15 | 16 |
* The page display has a path. |
16 | 17 |
*/ |
17 |
function has_path() { return TRUE; } |
|
18 |
function uses_breadcrumb() { return TRUE; } |
|
18 |
public function has_path() { |
|
19 |
return TRUE; |
|
20 |
} |
|
21 |
|
|
22 |
/** |
|
23 |
* {@inheritdoc} |
|
24 |
*/ |
|
25 |
public function uses_breadcrumb() { |
|
26 |
return TRUE; |
|
27 |
} |
|
19 | 28 |
|
20 |
function option_definition() { |
|
29 |
/** |
|
30 |
* {@inheritdoc} |
|
31 |
*/ |
|
32 |
public function option_definition() { |
|
21 | 33 |
$options = parent::option_definition(); |
22 | 34 |
|
23 | 35 |
$options['path'] = array('default' => ''); |
... | ... | |
50 | 62 |
/** |
51 | 63 |
* Add this display's path information to Drupal's menu system. |
52 | 64 |
*/ |
53 |
function execute_hook_menu($callbacks) { |
|
65 |
public function execute_hook_menu($callbacks) {
|
|
54 | 66 |
$items = array(); |
55 | 67 |
// Replace % with the link to our standard views argument loader |
56 | 68 |
// views_arg_load -- which lives in views.module |
... | ... | |
79 | 91 |
$access_plugin = views_get_plugin('access', 'none'); |
80 | 92 |
} |
81 | 93 |
|
82 |
// Get access callback might return an array of the callback + the dynamic arguments. |
|
94 |
// Get access callback might return an array of the callback + the dynamic |
|
95 |
// arguments. |
|
83 | 96 |
$access_plugin_callback = $access_plugin->get_access_callback(); |
84 | 97 |
|
85 | 98 |
if (is_array($access_plugin_callback)) { |
... | ... | |
140 | 153 |
default: |
141 | 154 |
$items[$path]['type'] = MENU_CALLBACK; |
142 | 155 |
break; |
156 |
|
|
143 | 157 |
case 'normal': |
144 | 158 |
$items[$path]['type'] = MENU_NORMAL_ITEM; |
145 | 159 |
// Insert item into the proper menu |
146 | 160 |
$items[$path]['menu_name'] = $menu['name']; |
147 | 161 |
break; |
162 |
|
|
148 | 163 |
case 'tab': |
149 | 164 |
$items[$path]['type'] = MENU_LOCAL_TASK; |
150 | 165 |
break; |
166 |
|
|
151 | 167 |
case 'default tab': |
152 | 168 |
$items[$path]['type'] = MENU_DEFAULT_LOCAL_TASK; |
153 | 169 |
break; |
... | ... | |
169 | 185 |
$bit = array_pop($bits); |
170 | 186 |
|
171 | 187 |
// we can't do this if they tried to make the last path bit variable. |
172 |
// @todo: We can validate this.
|
|
188 |
// @todo We can validate this. |
|
173 | 189 |
if ($bit != '%views_arg' && !empty($bits)) { |
174 | 190 |
$default_path = implode('/', $bits); |
175 | 191 |
$items[$default_path] = array( |
... | ... | |
192 | 208 |
case 'normal': |
193 | 209 |
$items[$default_path]['type'] = MENU_NORMAL_ITEM; |
194 | 210 |
break; |
211 |
|
|
195 | 212 |
case 'tab': |
196 | 213 |
$items[$default_path]['type'] = MENU_LOCAL_TASK; |
197 | 214 |
break; |
... | ... | |
212 | 229 |
* a drupal_set_title for the page, and does a views_set_page_view |
213 | 230 |
* on the view. |
214 | 231 |
*/ |
215 |
function execute() { |
|
232 |
public function execute() {
|
|
216 | 233 |
// Let the world know that this is the page view we're using. |
217 | 234 |
views_set_page_view($this->view); |
218 | 235 |
|
... | ... | |
250 | 267 |
* |
251 | 268 |
* This output is returned as an array. |
252 | 269 |
*/ |
253 |
function options_summary(&$categories, &$options) { |
|
254 |
// It is very important to call the parent function here:
|
|
270 |
public function options_summary(&$categories, &$options) {
|
|
271 |
// It is very important to call the parent function here.
|
|
255 | 272 |
parent::options_summary($categories, $options); |
256 | 273 |
|
257 | 274 |
$categories['page'] = array( |
... | ... | |
280 | 297 |
if (!is_array($menu)) { |
281 | 298 |
$menu = array('type' => 'none'); |
282 | 299 |
} |
283 |
switch($menu['type']) { |
|
300 |
switch ($menu['type']) {
|
|
284 | 301 |
case 'none': |
285 | 302 |
default: |
286 | 303 |
$menu_str = t('No menu'); |
287 | 304 |
break; |
305 |
|
|
288 | 306 |
case 'normal': |
289 | 307 |
$menu_str = t('Normal: @title', array('@title' => $menu['title'])); |
290 | 308 |
break; |
309 |
|
|
291 | 310 |
case 'tab': |
292 | 311 |
case 'default tab': |
293 | 312 |
$menu_str = t('Tab: @title', array('@title' => $menu['title'])); |
... | ... | |
300 | 319 |
'value' => views_ui_truncate($menu_str, 24), |
301 | 320 |
); |
302 | 321 |
|
303 |
// This adds a 'Settings' link to the style_options setting if the style has options. |
|
322 |
// This adds a 'Settings' link to the style_options setting if the style |
|
323 |
// has options. |
|
304 | 324 |
if ($menu['type'] == 'default tab') { |
305 | 325 |
$options['menu']['setting'] = t('Parent menu item'); |
306 | 326 |
$options['menu']['links']['tab_options'] = t('Change settings for the parent menu'); |
... | ... | |
310 | 330 |
/** |
311 | 331 |
* Provide the default form for setting options. |
312 | 332 |
*/ |
313 |
function options_form(&$form, &$form_state) { |
|
314 |
// It is very important to call the parent function here:
|
|
333 |
public function options_form(&$form, &$form_state) {
|
|
334 |
// It is very important to call the parent function here.
|
|
315 | 335 |
parent::options_form($form, $form_state); |
316 | 336 |
|
317 | 337 |
switch ($form_state['section']) { |
... | ... | |
322 | 342 |
'#type' => 'textfield', |
323 | 343 |
'#description' => t('This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for contextual filters: For example, "node/%/feed".'), |
324 | 344 |
'#default_value' => $this->get_option('path'), |
325 |
'#field_prefix' => '<span dir="ltr">' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
|
|
326 |
'#field_suffix' => '</span>‎',
|
|
327 |
'#attributes' => array('dir'=>'ltr'),
|
|
345 |
'#field_prefix' => '<span dir="ltr">' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
|
|
346 |
'#field_suffix' => '</span>‎',
|
|
347 |
'#attributes' => array('dir'=>'ltr'),
|
|
328 | 348 |
); |
329 | 349 |
break; |
350 |
|
|
330 | 351 |
case 'menu': |
331 | 352 |
$form['#title'] .= t('Menu item entry'); |
332 | 353 |
$form['#help_topic'] = 'menu'; |
... | ... | |
415 | 436 |
'#dependency_count' => 2, |
416 | 437 |
); |
417 | 438 |
break; |
439 |
|
|
418 | 440 |
case 'tab_options': |
419 | 441 |
$form['#title'] .= t('Default tab options'); |
420 | 442 |
$tab_options = $this->get_option('tab_options'); |
... | ... | |
487 | 509 |
} |
488 | 510 |
} |
489 | 511 |
|
490 |
function options_validate(&$form, &$form_state) { |
|
491 |
// It is very important to call the parent function here: |
|
512 |
/** |
|
513 |
* {@inheritdoc} |
|
514 |
*/ |
|
515 |
public function options_validate(&$form, &$form_state) { |
|
516 |
// It is very important to call the parent function here. |
|
492 | 517 |
parent::options_validate($form, $form_state); |
493 | 518 |
switch ($form_state['section']) { |
494 | 519 |
case 'path': |
... | ... | |
500 | 525 |
form_error($form['path'], t('"%" may not be used for the first segment of a path.')); |
501 | 526 |
} |
502 | 527 |
|
503 |
// automatically remove '/' and trailing whitespace from path.
|
|
528 |
// Automatically remove '/' and trailing whitespace from path.
|
|
504 | 529 |
$form_state['values']['path'] = trim($form_state['values']['path'], '/ '); |
505 | 530 |
break; |
531 |
|
|
506 | 532 |
case 'menu': |
507 | 533 |
$path = $this->get_option('path'); |
508 | 534 |
if ($form_state['values']['menu']['type'] == 'normal' && strpos($path, '%') !== FALSE) { |
... | ... | |
524 | 550 |
} |
525 | 551 |
} |
526 | 552 |
|
527 |
function options_submit(&$form, &$form_state) { |
|
528 |
// It is very important to call the parent function here: |
|
553 |
/** |
|
554 |
* {@inheritdoc} |
|
555 |
*/ |
|
556 |
public function options_submit(&$form, &$form_state) { |
|
557 |
// It is very important to call the parent function here. |
|
529 | 558 |
parent::options_submit($form, $form_state); |
530 | 559 |
switch ($form_state['section']) { |
531 | 560 |
case 'path': |
532 | 561 |
$this->set_option('path', $form_state['values']['path']); |
533 | 562 |
break; |
563 |
|
|
534 | 564 |
case 'menu': |
535 | 565 |
$this->set_option('menu', $form_state['values']['menu']); |
536 |
// send ajax form to options page if we use it.
|
|
566 |
// Send ajax form to options page if we use it.
|
|
537 | 567 |
if ($form_state['values']['menu']['type'] == 'default tab') { |
538 | 568 |
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('tab_options')); |
539 | 569 |
} |
540 | 570 |
break; |
571 |
|
|
541 | 572 |
case 'tab_options': |
542 | 573 |
$this->set_option('tab_options', $form_state['values']['tab_options']); |
543 | 574 |
break; |
544 | 575 |
} |
545 | 576 |
} |
546 | 577 |
|
547 |
function validate() { |
|
578 |
/** |
|
579 |
* {@inheritdoc} |
|
580 |
*/ |
|
581 |
public function validate() { |
|
548 | 582 |
$errors = parent::validate(); |
549 | 583 |
|
550 | 584 |
$menu = $this->get_option('menu'); |
... | ... | |
562 | 596 |
return $errors; |
563 | 597 |
} |
564 | 598 |
|
565 |
function get_argument_text() { |
|
599 |
/** |
|
600 |
* {@inheritdoc} |
|
601 |
*/ |
|
602 |
public function get_argument_text() { |
|
566 | 603 |
return array( |
567 | 604 |
'filter value not present' => t('When the filter value is <em>NOT</em> in the URL'), |
568 | 605 |
'filter value present' => t('When the filter value <em>IS</em> in the URL or a default is provided'), |
... | ... | |
570 | 607 |
); |
571 | 608 |
} |
572 | 609 |
|
573 |
function get_pager_text() { |
|
610 |
/** |
|
611 |
* {@inheritdoc} |
|
612 |
*/ |
|
613 |
public function get_pager_text() { |
|
574 | 614 |
return array( |
575 | 615 |
'items per page title' => t('Items per page'), |
576 |
'items per page description' => t('The number of items to display per page. Enter 0 for no limit.') |
|
616 |
'items per page description' => t('The number of items to display per page. Enter 0 for no limit.'),
|
|
577 | 617 |
); |
578 | 618 |
} |
619 |
|
|
579 | 620 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules