Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/plugins/views_plugin_display.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Contains the base display plugin.
|
|
5 |
* Definition of views_plugin_display.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
23 | 23 |
* basic mechanisms for different output methods. |
24 | 24 |
*/ |
25 | 25 |
class views_plugin_display extends views_plugin { |
26 |
|
|
26 | 27 |
/** |
27 | 28 |
* The top object of a view. |
28 | 29 |
* |
29 | 30 |
* @var view |
30 | 31 |
*/ |
31 |
var $view = NULL;
|
|
32 |
public $view = NULL;
|
|
32 | 33 |
|
33 |
var $handlers = array(); |
|
34 |
/** |
|
35 |
* |
|
36 |
*/ |
|
37 |
public $handlers = array(); |
|
34 | 38 |
|
35 | 39 |
/** |
36 | 40 |
* Stores all available display extenders. |
37 | 41 |
*/ |
38 |
var $extender = array();
|
|
42 |
public $extender = array();
|
|
39 | 43 |
|
40 |
function init(&$view, &$display, $options = NULL) { |
|
44 |
/** |
|
45 |
* {@inheritdoc} |
|
46 |
*/ |
|
47 |
public function init(&$view, &$display, $options = NULL) { |
|
41 | 48 |
$this->view = &$view; |
42 | 49 |
$this->display = &$display; |
43 | 50 |
|
... | ... | |
61 | 68 |
// Track changes that the user should know about. |
62 | 69 |
$changed = FALSE; |
63 | 70 |
|
64 |
// Make some modifications:
|
|
71 |
// Make some modifications.
|
|
65 | 72 |
if (!isset($options) && isset($display->display_options)) { |
66 | 73 |
$options = $display->display_options; |
67 | 74 |
} |
... | ... | |
93 | 100 |
$this->unpack_options($this->options, $options); |
94 | 101 |
} |
95 | 102 |
|
96 |
// Translate changed settings:
|
|
103 |
// Translate changed settings.
|
|
97 | 104 |
$items_per_page = $this->get_option('items_per_page'); |
98 | 105 |
$offset = $this->get_option('offset'); |
99 | 106 |
$use_pager = $this->get_option('use_pager'); |
... | ... | |
106 | 113 |
// for exported Views as it's not stored in the database. |
107 | 114 |
// If you would like to change this code, really take care that you thought |
108 | 115 |
// of every possibility. |
109 |
// @TODO: Provide a way to convert the database views as well.
|
|
116 |
// @todo Provide a way to convert the database views as well.
|
|
110 | 117 |
if (((!empty($items_per_page) && $items_per_page != 10) || !empty($offset) || !empty($use_pager)) |
111 | 118 |
|| (!empty($view->api_version) && $view->api_version == 2)) { |
112 | 119 |
// Find out the right pager type. |
... | ... | |
209 | 216 |
|
210 | 217 |
// Convert filter groups. |
211 | 218 |
$filter_groups = $this->get_option('filter_groups'); |
212 |
// Only convert if it wasn't converted yet, which is the case if there is a 0 group. |
|
219 |
// Only convert if it wasn't converted yet, which is the case if there is a |
|
220 |
// 0 group. |
|
213 | 221 |
if (isset($filter_groups['groups'][0])) { |
214 | 222 |
// Update filter groups. |
215 | 223 |
$filter_groups ['groups'] = views_array_key_plus($filter_groups['groups']); |
... | ... | |
253 | 261 |
} |
254 | 262 |
} |
255 | 263 |
|
256 |
function destroy() { |
|
264 |
/** |
|
265 |
* {@inheritdoc} |
|
266 |
*/ |
|
267 |
public function destroy() { |
|
257 | 268 |
parent::destroy(); |
258 | 269 |
|
259 | 270 |
foreach ($this->handlers as $type => $handlers) { |
... | ... | |
277 | 288 |
* Determine if this display is the 'default' display which contains |
278 | 289 |
* fallback settings |
279 | 290 |
*/ |
280 |
function is_default_display() { return FALSE; } |
|
291 |
public function is_default_display() { |
|
292 |
return FALSE; |
|
293 |
} |
|
281 | 294 |
|
282 | 295 |
/** |
283 | 296 |
* Determine if this display uses exposed filters, so the view |
284 | 297 |
* will know whether or not to build them. |
285 | 298 |
*/ |
286 |
function uses_exposed() { |
|
299 |
public function uses_exposed() {
|
|
287 | 300 |
if (!isset($this->has_exposed)) { |
288 | 301 |
foreach ($this->handlers as $type => $value) { |
289 | 302 |
foreach ($this->view->$type as $id => $handler) { |
... | ... | |
314 | 327 |
* returns, exposed filters will not be used nor |
315 | 328 |
* displayed unless uses_exposed() returns TRUE. |
316 | 329 |
*/ |
317 |
function displays_exposed() { |
|
330 |
public function displays_exposed() {
|
|
318 | 331 |
return TRUE; |
319 | 332 |
} |
320 | 333 |
|
321 | 334 |
/** |
322 | 335 |
* Does the display use AJAX? |
323 | 336 |
*/ |
324 |
function use_ajax() { |
|
337 |
public function use_ajax() {
|
|
325 | 338 |
if (!empty($this->definition['use ajax'])) { |
326 | 339 |
return $this->get_option('use_ajax'); |
327 | 340 |
} |
... | ... | |
331 | 344 |
/** |
332 | 345 |
* Does the display have a pager enabled? |
333 | 346 |
*/ |
334 |
function use_pager() { |
|
347 |
public function use_pager() {
|
|
335 | 348 |
$pager = $this->get_plugin('pager'); |
336 | 349 |
if ($pager) { |
337 | 350 |
return $pager->use_pager(); |
... | ... | |
341 | 354 |
/** |
342 | 355 |
* Does the display have a more link enabled? |
343 | 356 |
*/ |
344 |
function use_more() { |
|
357 |
public function use_more() {
|
|
345 | 358 |
if (!empty($this->definition['use more'])) { |
346 | 359 |
return $this->get_option('use_more'); |
347 | 360 |
} |
... | ... | |
351 | 364 |
/** |
352 | 365 |
* Does the display have groupby enabled? |
353 | 366 |
*/ |
354 |
function use_group_by() { |
|
367 |
public function use_group_by() {
|
|
355 | 368 |
return $this->get_option('group_by'); |
356 | 369 |
} |
357 | 370 |
|
358 | 371 |
/** |
359 | 372 |
* Should the enabled display more link be shown when no more items? |
360 | 373 |
*/ |
361 |
function use_more_always() { |
|
374 |
public function use_more_always() {
|
|
362 | 375 |
if (!empty($this->definition['use more'])) { |
363 | 376 |
return $this->get_option('use_more_always'); |
364 | 377 |
} |
... | ... | |
367 | 380 |
|
368 | 381 |
/** |
369 | 382 |
* Should the enabled display more link being opened in an new window? |
370 |
* |
|
371 |
* @codingStandardsIgnoreStart |
|
372 | 383 |
*/ |
373 |
function use_more_open_new_window() { |
|
374 |
// @codingStandardsIgnoreEnd |
|
384 |
public function use_more_open_new_window() { |
|
375 | 385 |
if (!empty($this->definition['use more'])) { |
376 | 386 |
return $this->get_option('open_new_window'); |
377 | 387 |
} |
... | ... | |
381 | 391 |
/** |
382 | 392 |
* Does the display have custom link text? |
383 | 393 |
*/ |
384 |
function use_more_text() { |
|
394 |
public function use_more_text() {
|
|
385 | 395 |
if (!empty($this->definition['use more'])) { |
386 | 396 |
return $this->get_option('use_more_text'); |
387 | 397 |
} |
... | ... | |
391 | 401 |
/** |
392 | 402 |
* Can this display accept attachments? |
393 | 403 |
*/ |
394 |
function accept_attachments() { |
|
404 |
public function accept_attachments() {
|
|
395 | 405 |
if (empty($this->definition['accept attachments'])) { |
396 | 406 |
return FALSE; |
397 | 407 |
} |
... | ... | |
408 | 418 |
/** |
409 | 419 |
* Allow displays to attach to other views. |
410 | 420 |
*/ |
411 |
function attach_to($display_id) { } |
|
421 |
public function attach_to($display_id) { |
|
422 |
} |
|
412 | 423 |
|
413 | 424 |
/** |
414 | 425 |
* Static member function to list which sections are defaultable |
415 | 426 |
* and what items each section contains. |
416 | 427 |
*/ |
417 |
function defaultable_sections($section = NULL) { |
|
428 |
public function defaultable_sections($section = NULL) {
|
|
418 | 429 |
$sections = array( |
419 | 430 |
'access' => array('access', 'access_options'), |
420 | 431 |
'access_options' => array('access', 'access_options'), |
... | ... | |
496 | 507 |
} |
497 | 508 |
} |
498 | 509 |
|
499 |
function option_definition() { |
|
510 |
/** |
|
511 |
* {@inheritdoc} |
|
512 |
*/ |
|
513 |
public function option_definition() { |
|
500 | 514 |
$options = array( |
501 | 515 |
'defaults' => array( |
502 | 516 |
'default' => array( |
... | ... | |
574 | 588 |
'default' => FALSE, |
575 | 589 |
'bool' => TRUE, |
576 | 590 |
), |
577 |
// This is legacy code:
|
|
578 |
// Items_per/offset/use_pager is moved to the pager plugin |
|
579 |
// but the automatic update path needs this items defined, so don't remove it.
|
|
591 |
// This is legacy code.
|
|
592 |
// Items_per/offset/use_pager is moved to the pager plugin but the
|
|
593 |
// automatic update path needs this items defined, so don't remove it. |
|
580 | 594 |
// @see views_plugin_display::init() |
581 | 595 |
'items_per_page' => array( |
582 | 596 |
'default' => 10, |
... | ... | |
618 | 632 |
'default' => 1, |
619 | 633 |
), |
620 | 634 |
|
621 |
// These types are all plugins that can have individual settings |
|
622 |
// and therefore need special handling.
|
|
635 |
// These types are all plugins that can have individual settings and
|
|
636 |
// therefore need special handling. |
|
623 | 637 |
'access' => array( |
624 | 638 |
'contains' => array( |
625 | 639 |
'type' => array('default' => 'none', 'export' => 'export_plugin', 'unpack_translatable' => 'unpack_plugin'), |
... | ... | |
761 | 775 |
* |
762 | 776 |
* By default, displays do not have a path. |
763 | 777 |
*/ |
764 |
function has_path() { return FALSE; } |
|
778 |
public function has_path() { |
|
779 |
return FALSE; |
|
780 |
} |
|
765 | 781 |
|
766 | 782 |
/** |
767 | 783 |
* Check to see if the display has some need to link to another display. |
768 | 784 |
* |
769 |
* For the most part, displays without a path will use a link display. However,
|
|
770 |
* sometimes displays that have a path might also need to link to another display.
|
|
771 |
* This is true for feeds. |
|
785 |
* For the most part, displays without a path will use a link display. |
|
786 |
* However, sometimes displays that have a path might also need to link to
|
|
787 |
* another display. This is true for feeds.
|
|
772 | 788 |
*/ |
773 |
function uses_link_display() { return !$this->has_path(); } |
|
789 |
public function uses_link_display() { |
|
790 |
return !$this->has_path(); |
|
791 |
} |
|
774 | 792 |
|
775 | 793 |
/** |
776 | 794 |
* Check to see if the display can put the exposed form in a block. |
777 | 795 |
* |
778 |
* By default, displays that do not have a path cannot disconnect |
|
779 |
* the exposed form and put it in a block, because the form has no |
|
780 |
* place to go and Views really wants the forms to go to a specific |
|
781 |
* page. |
|
796 |
* By default, displays that do not have a path cannot disconnect the exposed |
|
797 |
* form and put it in a block, because the form has no place to go and Views |
|
798 |
* really wants the forms to go to a specific page. |
|
782 | 799 |
*/ |
783 |
function uses_exposed_form_in_block() { return $this->has_path(); } |
|
800 |
public function uses_exposed_form_in_block() { |
|
801 |
return $this->has_path(); |
|
802 |
} |
|
784 | 803 |
|
785 | 804 |
/** |
786 |
* Check to see which display to use when creating links within |
|
787 |
* a view using this display. |
|
805 |
* Check to see which display to use when creating links. |
|
788 | 806 |
*/ |
789 |
function get_link_display() { |
|
807 |
public function get_link_display() {
|
|
790 | 808 |
$display_id = $this->get_option('link_display'); |
791 | 809 |
// If unknown, pick the first one. |
792 | 810 |
if (empty($display_id) || empty($this->view->display[$display_id])) { |
... | ... | |
805 | 823 |
/** |
806 | 824 |
* Return the base path to use for this display. |
807 | 825 |
* |
808 |
* This can be overridden for displays that do strange things |
|
809 |
* with the path. |
|
826 |
* This can be overridden for displays that do strange things with the path. |
|
810 | 827 |
*/ |
811 |
function get_path() { |
|
828 |
public function get_path() {
|
|
812 | 829 |
if ($this->has_path()) { |
813 | 830 |
return $this->get_option('path'); |
814 | 831 |
} |
... | ... | |
823 | 840 |
} |
824 | 841 |
} |
825 | 842 |
|
826 |
function get_url() { |
|
843 |
/** |
|
844 |
* |
|
845 |
*/ |
|
846 |
public function get_url() { |
|
827 | 847 |
return $this->view->get_url(); |
828 | 848 |
} |
829 | 849 |
|
830 | 850 |
/** |
831 |
* Check to see if the display needs a breadcrumb |
|
851 |
* Check to see if the display needs a breadcrumb.
|
|
832 | 852 |
* |
833 |
* By default, displays do not need breadcrumbs |
|
853 |
* By default, displays do not need breadcrumbs.
|
|
834 | 854 |
*/ |
835 |
function uses_breadcrumb() { return FALSE; } |
|
855 |
public function uses_breadcrumb() { |
|
856 |
return FALSE; |
|
857 |
} |
|
836 | 858 |
|
837 | 859 |
/** |
838 |
* Determine if a given option is set to use the default display or the |
|
839 |
* current display |
|
860 |
* Determine if a given option is set to use the default or current display. |
|
840 | 861 |
* |
841 | 862 |
* @return |
842 |
* TRUE for the default display |
|
863 |
* TRUE for the default display.
|
|
843 | 864 |
*/ |
844 |
function is_defaulted($option) { |
|
865 |
public function is_defaulted($option) {
|
|
845 | 866 |
return !$this->is_default_display() && !empty($this->default_display) && !empty($this->options['defaults'][$option]); |
846 | 867 |
} |
847 | 868 |
|
848 | 869 |
/** |
849 |
* Intelligently get an option either from this display or from the |
|
850 |
* default display, if directed to do so. |
|
870 |
* Intelligently get an option either from this or default display. |
|
851 | 871 |
*/ |
852 |
function get_option($option) { |
|
872 |
public function get_option($option) {
|
|
853 | 873 |
if ($this->is_defaulted($option)) { |
854 | 874 |
return $this->default_display->get_option($option); |
855 | 875 |
} |
856 | 876 |
|
857 |
if (array_key_exists($option, $this->options)) { |
|
877 |
if (isset($this->options[$option]) || array_key_exists($option, $this->options)) {
|
|
858 | 878 |
return $this->options[$option]; |
859 | 879 |
} |
860 | 880 |
} |
... | ... | |
862 | 882 |
/** |
863 | 883 |
* Determine if the display's style uses fields. |
864 | 884 |
*/ |
865 |
function uses_fields() { |
|
885 |
public function uses_fields() {
|
|
866 | 886 |
$plugin = $this->get_plugin(); |
867 | 887 |
if ($plugin) { |
868 | 888 |
return $plugin->uses_fields(); |
... | ... | |
879 | 899 |
* |
880 | 900 |
* @return views_plugin|FALSE |
881 | 901 |
*/ |
882 |
function get_plugin($type = 'style', $name = NULL) { |
|
902 |
public function get_plugin($type = 'style', $name = NULL) {
|
|
883 | 903 |
static $cache = array(); |
884 | 904 |
if (!isset($cache[$type][$name])) { |
885 | 905 |
switch ($type) { |
... | ... | |
890 | 910 |
if (!$name) { |
891 | 911 |
$name = $this->get_option($option_name); |
892 | 912 |
} |
893 |
|
|
894 | 913 |
break; |
914 |
|
|
895 | 915 |
case 'query': |
896 | 916 |
$views_data = views_fetch_data($this->view->base_table); |
897 | 917 |
$name = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query'; |
... | ... | |
902 | 922 |
$name = $options['type']; |
903 | 923 |
} |
904 | 924 |
|
905 |
// access & cache store their options as siblings with the
|
|
906 |
// type; all others use an 'options' array.
|
|
925 |
// Access & cache store their options as siblings with the type; all
|
|
926 |
// others use an 'options' array. |
|
907 | 927 |
if ($type != 'access' && $type != 'cache') { |
908 | 928 |
$options = $options['options']; |
909 | 929 |
} |
... | ... | |
935 | 955 |
/** |
936 | 956 |
* Get the handler object for a single handler. |
937 | 957 |
*/ |
938 |
function &get_handler($type, $id) { |
|
958 |
public function &get_handler($type, $id) {
|
|
939 | 959 |
if (!isset($this->handlers[$type])) { |
940 | 960 |
$this->get_handlers($type); |
941 | 961 |
} |
... | ... | |
952 | 972 |
/** |
953 | 973 |
* Get a full array of handlers for $type. This caches them. |
954 | 974 |
*/ |
955 |
function &get_handlers($type) { |
|
975 |
public function &get_handlers($type) {
|
|
956 | 976 |
if (!isset($this->handlers[$type])) { |
957 | 977 |
$this->handlers[$type] = array(); |
958 | 978 |
$types = views_object_types(); |
... | ... | |
1011 | 1031 |
} |
1012 | 1032 |
|
1013 | 1033 |
/** |
1014 |
* Retrieve a list of fields for the current display with the |
|
1015 |
* relationship associated if it exists. |
|
1034 |
* List of fields for the current display with the associated relationship. |
|
1016 | 1035 |
* |
1017 |
* @param $groupable_only |
|
1036 |
* @param $groupable_only
|
|
1018 | 1037 |
* Return only an array of field labels from handler that return TRUE |
1019 | 1038 |
* from use_string_group_by method. |
1020 | 1039 |
*/ |
1021 |
function get_field_labels() { |
|
1022 |
// Use func_get_arg so the function signature isn't amended |
|
1023 |
// but we can still pass TRUE into the function to filter |
|
1024 |
// by groupable handlers. |
|
1040 |
public function get_field_labels() { |
|
1041 |
// Use func_get_arg so the function signature isn't amended but we can |
|
1042 |
// still pass TRUE into the function to filter by groupable handlers. |
|
1025 | 1043 |
$args = func_get_args(); |
1026 | 1044 |
$groupable_only = isset($args[0]) ? $args[0] : FALSE; |
1027 | 1045 |
|
... | ... | |
1057 | 1075 |
* Intelligently set an option either from this display or from the |
1058 | 1076 |
* default display, if directed to do so. |
1059 | 1077 |
*/ |
1060 |
function set_option($option, $value) { |
|
1078 |
public function set_option($option, $value) {
|
|
1061 | 1079 |
if ($this->is_defaulted($option)) { |
1062 | 1080 |
return $this->default_display->set_option($option, $value); |
1063 | 1081 |
} |
... | ... | |
1072 | 1090 |
/** |
1073 | 1091 |
* Set an option and force it to be an override. |
1074 | 1092 |
*/ |
1075 |
function override_option($option, $value) { |
|
1093 |
public function override_option($option, $value) {
|
|
1076 | 1094 |
$this->set_override($option, FALSE); |
1077 | 1095 |
$this->set_option($option, $value); |
1078 | 1096 |
} |
... | ... | |
1081 | 1099 |
* Because forms may be split up into sections, this provides |
1082 | 1100 |
* an easy URL to exactly the right section. Don't override this. |
1083 | 1101 |
*/ |
1084 |
function option_link($text, $section, $class = '', $title = '') { |
|
1102 |
public function option_link($text, $section, $class = '', $title = '') {
|
|
1085 | 1103 |
views_add_js('ajax'); |
1086 | 1104 |
if (!empty($class)) { |
1087 | 1105 |
$text = '<span>' . $text . '</span>'; |
... | ... | |
1109 | 1127 |
* This function is similar to views_handler_field::get_render_tokens() |
1110 | 1128 |
* but without fields tokens. |
1111 | 1129 |
*/ |
1112 |
function get_arguments_tokens() { |
|
1130 |
public function get_arguments_tokens() {
|
|
1113 | 1131 |
$tokens = array(); |
1114 | 1132 |
if (!empty($this->view->build_info['substitutions'])) { |
1115 | 1133 |
$tokens = $this->view->build_info['substitutions']; |
... | ... | |
1135 | 1153 |
* |
1136 | 1154 |
* This output is returned as an array. |
1137 | 1155 |
*/ |
1138 |
function options_summary(&$categories, &$options) { |
|
1156 |
public function options_summary(&$categories, &$options) {
|
|
1139 | 1157 |
$categories = array( |
1140 | 1158 |
'title' => array( |
1141 | 1159 |
'title' => t('Title'), |
... | ... | |
1224 | 1242 |
'desc' => t('Change the way content is formatted.'), |
1225 | 1243 |
); |
1226 | 1244 |
|
1227 |
// This adds a 'Settings' link to the style_options setting if the style has options. |
|
1245 |
// This adds a 'Settings' link to the style_options setting if the style |
|
1246 |
// has options. |
|
1228 | 1247 |
if (!empty($style_plugin['uses options'])) { |
1229 | 1248 |
$options['style_plugin']['links']['style_options'] = t('Change settings for this format'); |
1230 | 1249 |
} |
... | ... | |
1242 | 1261 |
'setting' => $row_summary, |
1243 | 1262 |
'desc' => t('Change the way each row in the view is styled.'), |
1244 | 1263 |
); |
1245 |
// This adds a 'Settings' link to the row_options setting if the row style has options. |
|
1264 |
// This adds a 'Settings' link to the row_options setting if the row |
|
1265 |
// style has options. |
|
1246 | 1266 |
if (!empty($row_plugin['uses options'])) { |
1247 | 1267 |
$options['row_plugin']['links']['row_options'] = t('Change settings for this style'); |
1248 | 1268 |
} |
... | ... | |
1274 | 1294 |
|
1275 | 1295 |
$pager_plugin = $this->get_plugin('pager'); |
1276 | 1296 |
if (!$pager_plugin) { |
1277 |
// default to the no pager plugin.
|
|
1297 |
// Default to the no pager plugin.
|
|
1278 | 1298 |
$pager_plugin = views_get_plugin('pager', 'none'); |
1279 | 1299 |
} |
1280 | 1300 |
|
... | ... | |
1288 | 1308 |
'desc' => t("Change this display's pager setting."), |
1289 | 1309 |
); |
1290 | 1310 |
|
1291 |
// If pagers aren't allowed, change the text of the item:
|
|
1311 |
// If pagers aren't allowed, change the text of the item.
|
|
1292 | 1312 |
if (empty($this->definition['use pager'])) { |
1293 | 1313 |
$options['pager']['title'] = t('Items to display'); |
1294 | 1314 |
} |
... | ... | |
1406 | 1426 |
|
1407 | 1427 |
$exposed_form_plugin = $this->get_plugin('exposed_form'); |
1408 | 1428 |
if (!$exposed_form_plugin) { |
1409 |
// default to the no cache control plugin.
|
|
1429 |
// Default to the no cache control plugin.
|
|
1410 | 1430 |
$exposed_form_plugin = views_get_plugin('exposed_form', 'basic'); |
1411 | 1431 |
} |
1412 | 1432 |
|
... | ... | |
1451 | 1471 |
/** |
1452 | 1472 |
* Provide the default form for setting options. |
1453 | 1473 |
*/ |
1454 |
function options_form(&$form, &$form_state) { |
|
1474 |
public function options_form(&$form, &$form_state) {
|
|
1455 | 1475 |
parent::options_form($form, $form_state); |
1456 | 1476 |
if ($this->defaultable_sections($form_state['section'])) { |
1457 | 1477 |
views_ui_standard_display_dropdown($form, $form_state, $form_state['section']); |
... | ... | |
1480 | 1500 |
'#size' => 64, |
1481 | 1501 |
); |
1482 | 1502 |
break; |
1503 |
|
|
1483 | 1504 |
case 'display_title': |
1484 | 1505 |
$form['#title'] .= t('The name and the description of this display'); |
1485 | 1506 |
$form['display_title'] = array( |
... | ... | |
1495 | 1516 |
'#default_value' => $this->get_option('display_description'), |
1496 | 1517 |
); |
1497 | 1518 |
break; |
1519 |
|
|
1498 | 1520 |
case 'display_comment': |
1499 | 1521 |
$form['#title'] .= t("This display's comments"); |
1500 | 1522 |
$form['display_comment'] = array( |
... | ... | |
1503 | 1525 |
'#default_value' => $this->get_option('display_comment'), |
1504 | 1526 |
); |
1505 | 1527 |
break; |
1528 |
|
|
1506 | 1529 |
case 'title': |
1507 | 1530 |
$form['#title'] .= t('The title of this view'); |
1508 | 1531 |
$form['title'] = array( |
... | ... | |
1511 | 1534 |
'#default_value' => $this->get_option('title'), |
1512 | 1535 |
); |
1513 | 1536 |
break; |
1537 |
|
|
1514 | 1538 |
case 'css_class': |
1515 | 1539 |
$form['#title'] .= t('CSS class'); |
1516 | 1540 |
$form['css_class'] = array( |
... | ... | |
1519 | 1543 |
'#default_value' => $this->get_option('css_class'), |
1520 | 1544 |
); |
1521 | 1545 |
break; |
1546 |
|
|
1522 | 1547 |
case 'use_ajax': |
1523 | 1548 |
$form['#title'] .= t('Use AJAX when available to load this view'); |
1524 | 1549 |
$form['description'] = array( |
... | ... | |
1530 | 1555 |
'#default_value' => $this->get_option('use_ajax') ? 1 : 0, |
1531 | 1556 |
); |
1532 | 1557 |
break; |
1558 |
|
|
1533 | 1559 |
case 'hide_attachment_summary': |
1534 | 1560 |
$form['#title'] .= t('Hide attachments when displaying a contextual filter summary'); |
1535 | 1561 |
$form['hide_attachment_summary'] = array( |
... | ... | |
1538 | 1564 |
'#default_value' => $this->get_option('hide_attachment_summary') ? 1 : 0, |
1539 | 1565 |
); |
1540 | 1566 |
break; |
1567 |
|
|
1541 | 1568 |
case 'hide_admin_links': |
1542 | 1569 |
$form['#title'] .= t('Hide contextual links on this view.'); |
1543 | 1570 |
$form['hide_admin_links'] = array( |
... | ... | |
1545 | 1572 |
'#options' => array(1 => t('Yes'), 0 => t('No')), |
1546 | 1573 |
'#default_value' => $this->get_option('hide_admin_links') ? 1 : 0, |
1547 | 1574 |
); |
1548 |
break; |
|
1575 |
break; |
|
1576 |
|
|
1549 | 1577 |
case 'use_more': |
1550 | 1578 |
$form['#title'] .= t('Add a more link to the bottom of the display.'); |
1551 | 1579 |
$form['use_more'] = array( |
... | ... | |
1563 | 1591 |
'edit-use-more' => array(TRUE), |
1564 | 1592 |
), |
1565 | 1593 |
); |
1566 |
|
|
1567 | 1594 |
$form['open_new_window'] = array( |
1568 | 1595 |
'#type' => 'checkbox', |
1569 | 1596 |
'#title' => t("Open 'more' link in new window (target='blank')"), |
... | ... | |
1573 | 1600 |
'edit-use-more' => array(TRUE), |
1574 | 1601 |
), |
1575 | 1602 |
); |
1576 |
|
|
1577 | 1603 |
$form['use_more_text'] = array( |
1578 | 1604 |
'#type' => 'textfield', |
1579 | 1605 |
'#title' => t('More link text'), |
... | ... | |
1584 | 1610 |
), |
1585 | 1611 |
); |
1586 | 1612 |
break; |
1613 |
|
|
1587 | 1614 |
case 'group_by': |
1588 | 1615 |
$form['#title'] .= t('Allow grouping and aggregation (calculation) of fields.'); |
1589 | 1616 |
$form['group_by'] = array( |
... | ... | |
1593 | 1620 |
'#default_value' => $this->get_option('group_by'), |
1594 | 1621 |
); |
1595 | 1622 |
break; |
1623 |
|
|
1596 | 1624 |
case 'access': |
1597 | 1625 |
$form['#title'] .= t('Access restrictions'); |
1598 | 1626 |
$form['access'] = array( |
... | ... | |
1600 | 1628 |
'#suffix' => '</div>', |
1601 | 1629 |
'#tree' => TRUE, |
1602 | 1630 |
); |
1603 |
|
|
1604 | 1631 |
$access = $this->get_option('access'); |
1605 | 1632 |
$form['access']['type'] = array( |
1606 | 1633 |
'#type' => 'radios', |
1607 | 1634 |
'#options' => views_fetch_plugin_names('access', NULL, array($this->view->base_table)), |
1608 | 1635 |
'#default_value' => $access['type'], |
1609 | 1636 |
); |
1610 |
|
|
1611 | 1637 |
$access_plugin = views_fetch_plugin_data('access', $access['type']); |
1612 | 1638 |
if (!empty($access_plugin['uses options'])) { |
1613 | 1639 |
$form['markup'] = array( |
... | ... | |
1616 | 1642 |
'#suffix' => '</div>', |
1617 | 1643 |
); |
1618 | 1644 |
} |
1619 |
|
|
1620 | 1645 |
break; |
1646 |
|
|
1621 | 1647 |
case 'access_options': |
1622 | 1648 |
$access = $this->get_option('access'); |
1623 | 1649 |
$plugin = $this->get_plugin('access'); |
... | ... | |
1629 | 1655 |
if (!empty($plugin->definition['module'])) { |
1630 | 1656 |
$form['#help_module'] = $plugin->definition['module']; |
1631 | 1657 |
} |
1632 |
|
|
1633 | 1658 |
$form['access_options'] = array( |
1634 | 1659 |
'#tree' => TRUE, |
1635 | 1660 |
); |
... | ... | |
1640 | 1665 |
$plugin->options_form($form['access_options'], $form_state); |
1641 | 1666 |
} |
1642 | 1667 |
break; |
1668 |
|
|
1643 | 1669 |
case 'cache': |
1644 | 1670 |
$form['#title'] .= t('Caching'); |
1645 | 1671 |
$form['cache'] = array( |
... | ... | |
1647 | 1673 |
'#suffix' => '</div>', |
1648 | 1674 |
'#tree' => TRUE, |
1649 | 1675 |
); |
1650 |
|
|
1651 | 1676 |
$cache = $this->get_option('cache'); |
1652 | 1677 |
$form['cache']['type'] = array( |
1653 | 1678 |
'#type' => 'radios', |
1654 | 1679 |
'#options' => views_fetch_plugin_names('cache', NULL, array($this->view->base_table)), |
1655 | 1680 |
'#default_value' => $cache['type'], |
1656 | 1681 |
); |
1657 |
|
|
1658 | 1682 |
$cache_plugin = views_fetch_plugin_data('cache', $cache['type']); |
1659 | 1683 |
if (!empty($cache_plugin['uses options'])) { |
1660 | 1684 |
$form['markup'] = array( |
... | ... | |
1664 | 1688 |
); |
1665 | 1689 |
} |
1666 | 1690 |
break; |
1691 |
|
|
1667 | 1692 |
case 'cache_options': |
1668 | 1693 |
$cache = $this->get_option('cache'); |
1669 | 1694 |
$plugin = $this->get_plugin('cache'); |
... | ... | |
1675 | 1700 |
if (!empty($plugin->definition['module'])) { |
1676 | 1701 |
$form['#help_module'] = $plugin->definition['module']; |
1677 | 1702 |
} |
1678 |
|
|
1679 | 1703 |
$form['cache_options'] = array( |
1680 | 1704 |
'#tree' => TRUE, |
1681 | 1705 |
); |
... | ... | |
1686 | 1710 |
$plugin->options_form($form['cache_options'], $form_state); |
1687 | 1711 |
} |
1688 | 1712 |
break; |
1713 |
|
|
1689 | 1714 |
case 'query': |
1690 | 1715 |
$query_options = $this->get_option('query'); |
1691 | 1716 |
$plugin_name = $query_options['type']; |
... | ... | |
1699 | 1724 |
if (!empty($this->view->query->definition['module'])) { |
1700 | 1725 |
$form['#help_module'] = $this->view->query->definition['module']; |
1701 | 1726 |
} |
1702 |
|
|
1703 | 1727 |
$form['query'] = array( |
1704 | 1728 |
'#tree' => TRUE, |
1705 | 1729 |
'type' => array( |
... | ... | |
1710 | 1734 |
'#tree' => TRUE, |
1711 | 1735 |
), |
1712 | 1736 |
); |
1713 |
|
|
1714 | 1737 |
$this->view->query->options_form($form['query']['options'], $form_state); |
1715 | 1738 |
} |
1716 | 1739 |
break; |
1740 |
|
|
1717 | 1741 |
case 'field_language': |
1718 | 1742 |
$form['#title'] .= t('Field Language'); |
1719 | 1743 |
|
... | ... | |
1756 | 1780 |
$form['field_language']['#markup'] = t("You don't have translatable entity types."); |
1757 | 1781 |
} |
1758 | 1782 |
break; |
1783 |
|
|
1759 | 1784 |
case 'style_plugin': |
1760 | 1785 |
$form['#title'] .= t('How should this view be styled'); |
1761 | 1786 |
$form['#help_topic'] = 'style'; |
... | ... | |
1772 | 1797 |
'#markup' => '<div class="form-item description">' . t('You may also adjust the !settings for the currently selected style.', array('!settings' => $this->option_link(t('settings'), 'style_options'))) . '</div>', |
1773 | 1798 |
); |
1774 | 1799 |
} |
1775 |
|
|
1776 | 1800 |
break; |
1801 |
|
|
1777 | 1802 |
case 'style_options': |
1778 | 1803 |
$form['#title'] .= t('Style options'); |
1779 | 1804 |
$style = TRUE; |
... | ... | |
1784 | 1809 |
if (!isset($name)) { |
1785 | 1810 |
$name = $this->get_option('row_plugin'); |
1786 | 1811 |
} |
1787 |
// if row, $style will be empty.
|
|
1812 |
// If row, $style will be empty.
|
|
1788 | 1813 |
if (empty($style)) { |
1789 | 1814 |
$form['#title'] .= t('Row style options'); |
1790 | 1815 |
$type = 'row_plugin'; |
... | ... | |
1803 | 1828 |
$plugin->options_form($form[$form_state['section']], $form_state); |
1804 | 1829 |
} |
1805 | 1830 |
break; |
1831 |
|
|
1806 | 1832 |
case 'row_plugin': |
1807 | 1833 |
$form['#title'] .= t('How should each row in this view be styled'); |
1808 | 1834 |
$form['#help_topic'] = 'style-row'; |
... | ... | |
1818 | 1844 |
'#markup' => '<div class="form-item description">' . t('You may also adjust the !settings for the currently selected row style.', array('!settings' => $this->option_link(t('settings'), 'row_options'))) . '</div>', |
1819 | 1845 |
); |
1820 | 1846 |
} |
1821 |
|
|
1822 | 1847 |
break; |
1848 |
|
|
1823 | 1849 |
case 'link_display': |
1824 | 1850 |
$form['#title'] .= t('Which display to use for path'); |
1825 | 1851 |
foreach ($this->view->display as $display_id => $display) { |
... | ... | |
1838 | 1864 |
} |
1839 | 1865 |
|
1840 | 1866 |
$options = array(); |
1841 |
$count = 0; // This lets us prepare the key as we want it printed. |
|
1867 |
// This lets us prepare the key as we want it printed. |
|
1868 |
$count = 0; |
|
1842 | 1869 |
foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { |
1843 | 1870 |
$options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); |
1844 | 1871 |
$options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name())); |
1845 | 1872 |
} |
1846 | 1873 |
|
1847 |
// Default text. |
|
1848 |
// We have some options, so make a list. |
|
1874 |
// Default text. We have some options, so make a list. |
|
1849 | 1875 |
$output = ''; |
1850 | 1876 |
if (!empty($options)) { |
1851 | 1877 |
$output = t('<p>The following tokens are available for this link.</p>'); |
... | ... | |
1872 | 1898 |
'#dependency' => array('radio:link_display' => array('custom_url')), |
1873 | 1899 |
); |
1874 | 1900 |
break; |
1901 |
|
|
1875 | 1902 |
case 'analyze-theme': |
1876 | 1903 |
$form['#title'] .= t('Theming information'); |
1877 | 1904 |
$form['#help_topic'] = 'analyze-theme'; |
... | ... | |
1902 | 1929 |
// The base themes should be initialized in the right order. |
1903 | 1930 |
$base_theme = array_reverse($base_theme); |
1904 | 1931 |
|
1905 |
// This code is copied directly from _drupal_theme_initialize() |
|
1932 |
// This code is copied directly from _drupal_theme_initialize().
|
|
1906 | 1933 |
$theme_engine = NULL; |
1907 | 1934 |
|
1908 | 1935 |
// Initialize the theme. |
... | ... | |
1934 | 1961 |
$this->theme_registry = _theme_load_registry($theme, $base_theme, $theme_engine); |
1935 | 1962 |
} |
1936 | 1963 |
|
1937 |
// If there's a theme engine involved, we also need to know its extension
|
|
1938 |
// so we can give the proper filename. |
|
1964 |
// If there's a theme engine involved, we also need to know its |
|
1965 |
// extension so we can give the proper filename.
|
|
1939 | 1966 |
$this->theme_extension = '.tpl.php'; |
1940 | 1967 |
if (isset($theme_engine)) { |
1941 | 1968 |
$extension_function = $theme_engine . '_extension'; |
... | ... | |
2042 | 2069 |
|
2043 | 2070 |
$form_state['ok_button'] = TRUE; |
2044 | 2071 |
break; |
2072 |
|
|
2045 | 2073 |
case 'analyze-theme-display': |
2046 | 2074 |
$form['#title'] .= t('Theming information (display)'); |
2047 | 2075 |
$output = '<p>' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '</p>'; |
... | ... | |
2067 | 2095 |
|
2068 | 2096 |
$form_state['ok_button'] = TRUE; |
2069 | 2097 |
break; |
2098 |
|
|
2070 | 2099 |
case 'analyze-theme-style': |
2071 | 2100 |
$form['#title'] .= t('Theming information (style)'); |
2072 | 2101 |
$output = '<p>' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '</p>'; |
... | ... | |
2094 | 2123 |
|
2095 | 2124 |
$form_state['ok_button'] = TRUE; |
2096 | 2125 |
break; |
2126 |
|
|
2097 | 2127 |
case 'analyze-theme-row': |
2098 | 2128 |
$form['#title'] .= t('Theming information (row style)'); |
2099 | 2129 |
$output = '<p>' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '</p>'; |
... | ... | |
2121 | 2151 |
|
2122 | 2152 |
$form_state['ok_button'] = TRUE; |
2123 | 2153 |
break; |
2154 |
|
|
2124 | 2155 |
case 'analyze-theme-field': |
2125 | 2156 |
$form['#title'] .= t('Theming information (row style)'); |
2126 | 2157 |
$output = '<p>' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '</p>'; |
... | ... | |
2148 | 2179 |
'#default_value' => $this->get_option('exposed_block') ? 1 : 0, |
2149 | 2180 |
); |
2150 | 2181 |
break; |
2182 |
|
|
2151 | 2183 |
case 'exposed_form': |
2152 | 2184 |
$form['#title'] .= t('Exposed Form'); |
2153 | 2185 |
$form['exposed_form'] = array( |
... | ... | |
2172 | 2204 |
); |
2173 | 2205 |
} |
2174 | 2206 |
break; |
2207 |
|
|
2175 | 2208 |
case 'exposed_form_options': |
2176 | 2209 |
$plugin = $this->get_plugin('exposed_form'); |
2177 | 2210 |
$form['#title'] .= t('Exposed form options'); |
... | ... | |
2189 | 2222 |
$plugin->options_form($form['exposed_form_options'], $form_state); |
2190 | 2223 |
} |
2191 | 2224 |
break; |
2225 |
|
|
2192 | 2226 |
case 'pager': |
2193 | 2227 |
$form['#title'] .= t('Select which pager, if any, to use for this view'); |
2194 | 2228 |
$form['pager'] = array( |
... | ... | |
2212 | 2246 |
'#markup' => t('You may also adjust the !settings for the currently selected pager.', array('!settings' => $this->option_link(t('settings'), 'pager_options'))), |
2213 | 2247 |
); |
2214 | 2248 |
} |
2215 |
|
|
2216 | 2249 |
break; |
2250 |
|
|
2217 | 2251 |
case 'pager_options': |
2218 | 2252 |
$plugin = $this->get_plugin('pager'); |
2219 | 2253 |
$form['#title'] .= t('Pager options'); |
... | ... | |
2241 | 2275 |
/** |
2242 | 2276 |
* Format a list of theme templates for output by the theme info helper. |
2243 | 2277 |
*/ |
2244 |
function format_themes($themes) { |
|
2278 |
public function format_themes($themes) {
|
|
2245 | 2279 |
$registry = $this->theme_registry; |
2246 | 2280 |
$extension = $this->theme_extension; |
2247 | 2281 |
|
... | ... | |
2269 | 2303 |
/** |
2270 | 2304 |
* Validate the options form. |
2271 | 2305 |
*/ |
2272 |
function options_validate(&$form, &$form_state) { |
|
2306 |
public function options_validate(&$form, &$form_state) {
|
|
2273 | 2307 |
switch ($form_state['section']) { |
2274 | 2308 |
case 'display_title': |
2275 | 2309 |
if (empty($form_state['values']['display_title'])) { |
2276 | 2310 |
form_error($form['display_title'], t('Display title may not be empty.')); |
2277 | 2311 |
} |
2278 | 2312 |
break; |
2313 |
|
|
2279 | 2314 |
case 'css_class': |
2280 | 2315 |
$css_class = $form_state['values']['css_class']; |
2281 | 2316 |
if (preg_match('/[^a-zA-Z0-9-_ ]/', $css_class)) { |
2282 | 2317 |
form_error($form['css_class'], t('CSS classes must be alphanumeric or dashes only.')); |
2283 | 2318 |
} |
2284 |
break; |
|
2319 |
break; |
|
2320 |
|
|
2285 | 2321 |
case 'display_id': |
2286 | 2322 |
if ($form_state['values']['display_id']) { |
2287 | 2323 |
if (preg_match('/[^a-z0-9_]/', $form_state['values']['display_id'])) { |
... | ... | |
2295 | 2331 |
} |
2296 | 2332 |
} |
2297 | 2333 |
break; |
2334 |
|
|
2298 | 2335 |
case 'style_options': |
2299 | 2336 |
$style = TRUE; |
2300 | 2337 |
case 'row_options': |
... | ... | |
2304 | 2341 |
$plugin->options_validate($form[$form_state['section']], $form_state); |
2305 | 2342 |
} |
2306 | 2343 |
break; |
2344 |
|
|
2307 | 2345 |
case 'access_options': |
2308 | 2346 |
$plugin = $this->get_plugin('access'); |
2309 | 2347 |
if ($plugin) { |
2310 | 2348 |
$plugin->options_validate($form['access_options'], $form_state); |
2311 | 2349 |
} |
2312 | 2350 |
break; |
2351 |
|
|
2313 | 2352 |
case 'query': |
2314 | 2353 |
if ($this->view->query) { |
2315 | 2354 |
$this->view->query->options_validate($form['query'], $form_state); |
2316 | 2355 |
} |
2317 | 2356 |
break; |
2357 |
|
|
2318 | 2358 |
case 'cache_options': |
2319 | 2359 |
$plugin = $this->get_plugin('cache'); |
2320 | 2360 |
if ($plugin) { |
2321 | 2361 |
$plugin->options_validate($form['cache_options'], $form_state); |
2322 | 2362 |
} |
2323 | 2363 |
break; |
2364 |
|
|
2324 | 2365 |
case 'exposed_form_options': |
2325 | 2366 |
$plugin = $this->get_plugin('exposed_form'); |
2326 | 2367 |
if ($plugin) { |
2327 | 2368 |
$plugin->options_validate($form['exposed_form_options'], $form_state); |
2328 | 2369 |
} |
2329 | 2370 |
break; |
2371 |
|
|
2330 | 2372 |
case 'pager_options': |
2331 | 2373 |
$plugin = $this->get_plugin('pager'); |
2332 | 2374 |
if ($plugin) { |
... | ... | |
2344 | 2386 |
* Perform any necessary changes to the form values prior to storage. |
2345 | 2387 |
* There is no need for this function to actually store the data. |
2346 | 2388 |
*/ |
2347 |
function options_submit(&$form, &$form_state) { |
|
2389 |
public function options_submit(&$form, &$form_state) {
|
|
2348 | 2390 |
// Not sure I like this being here, but it seems (?) like a logical place. |
2349 | 2391 |
$cache_plugin = $this->get_plugin('cache'); |
2350 | 2392 |
if ($cache_plugin) { |
... | ... | |
2358 | 2400 |
$this->display->new_id = $form_state['values']['display_id']; |
2359 | 2401 |
} |
2360 | 2402 |
break; |
2403 |
|
|
2361 | 2404 |
case 'display_title': |
2362 | 2405 |
$this->display->display_title = $form_state['values']['display_title']; |
2363 | 2406 |
$this->set_option('display_description', $form_state['values']['display_description']); |
2364 | 2407 |
break; |
2408 |
|
|
2365 | 2409 |
case 'access': |
2366 | 2410 |
$access = $this->get_option('access'); |
2367 | 2411 |
if ($access['type'] != $form_state['values']['access']['type']) { |
... | ... | |
2374 | 2418 |
} |
2375 | 2419 |
} |
2376 | 2420 |
} |
2377 |
|
|
2378 | 2421 |
break; |
2422 |
|
|
2379 | 2423 |
case 'access_options': |
2380 | 2424 |
$plugin = views_get_plugin('access', $form_state['values'][$section]['type']); |
2381 | 2425 |
if ($plugin) { |
... | ... | |
2383 | 2427 |
$this->set_option('access', $form_state['values'][$section]); |
2384 | 2428 |
} |
2385 | 2429 |
break; |
2430 |
|
|
2386 | 2431 |
case 'cache': |
2387 | 2432 |
$cache = $this->get_option('cache'); |
2388 | 2433 |
if ($cache['type'] != $form_state['values']['cache']['type']) { |
... | ... | |
2395 | 2440 |
} |
2396 | 2441 |
} |
2397 | 2442 |
} |
2398 |
|
|
2399 | 2443 |
break; |
2444 |
|
|
2400 | 2445 |
case 'cache_options': |
2401 | 2446 |
$plugin = views_get_plugin('cache', $form_state['values'][$section]['type']); |
2402 | 2447 |
if ($plugin) { |
... | ... | |
2404 | 2449 |
$this->set_option('cache', $form_state['values'][$section]); |
2405 | 2450 |
} |
2406 | 2451 |
break; |
2452 |
|
|
2407 | 2453 |
case 'query': |
2408 | 2454 |
$plugin = $this->get_plugin('query'); |
2409 | 2455 |
if ($plugin) { |
... | ... | |
2419 | 2465 |
case 'display_comment': |
2420 | 2466 |
$this->set_option($section, $form_state['values'][$section]); |
2421 | 2467 |
break; |
2468 |
|
|
2422 | 2469 |
case 'field_language': |
2423 | 2470 |
$this->set_option('field_language', $form_state['values']['field_language']); |
2424 | 2471 |
$this->set_option('field_language_add_to_query', $form_state['values']['field_language_add_to_query']); |
2425 | 2472 |
break; |
2473 |
|
|
2426 | 2474 |
case 'use_ajax': |
2427 | 2475 |
case 'hide_attachment_summary': |
2428 | 2476 |
case 'hide_admin_links': |
2429 | 2477 |
$this->set_option($section, (bool)$form_state['values'][$section]); |
2430 | 2478 |
break; |
2479 |
|
|
2431 | 2480 |
case 'use_more': |
2432 | 2481 |
$this->set_option($section, intval($form_state['values'][$section])); |
2433 | 2482 |
$this->set_option('use_more_always', !intval($form_state['values']['use_more_always'])); |
... | ... | |
2436 | 2485 |
case 'distinct': |
2437 | 2486 |
$this->set_option($section, $form_state['values'][$section]); |
2438 | 2487 |
break; |
2488 |
|
|
2439 | 2489 |
case 'group_by': |
2440 | 2490 |
$this->set_option($section, $form_state['values'][$section]); |
2441 | 2491 |
break; |
2492 |
|
|
2442 | 2493 |
case 'row_plugin': |
2443 | 2494 |
// This if prevents resetting options to default if they don't change |
2444 | 2495 |
// the plugin. |
... | ... | |
2455 | 2506 |
} |
2456 | 2507 |
} |
2457 | 2508 |
break; |
2509 |
|
|
2458 | 2510 |
case 'style_plugin': |
2459 | 2511 |
// This if prevents resetting options to default if they don't change |
2460 | 2512 |
// the plugin. |
... | ... | |
2470 | 2522 |
} |
2471 | 2523 |
} |
2472 | 2524 |
break; |
2525 |
|
|
2473 | 2526 |
case 'style_options': |
2474 | 2527 |
$style = TRUE; |
2475 | 2528 |
case 'row_options': |
... | ... | |
2480 | 2533 |
} |
2481 | 2534 |
$this->set_option($section, $form_state['values'][$section]); |
2482 | 2535 |
break; |
2536 |
|
|
2483 | 2537 |
case 'exposed_block': |
2484 | 2538 |
$this->set_option($section, (bool) $form_state['values'][$section]); |
2485 | 2539 |
break; |
2540 |
|
|
2486 | 2541 |
case 'exposed_form': |
2487 | 2542 |
$exposed_form = $this->get_option('exposed_form'); |
2488 | 2543 |
if ($exposed_form['type'] != $form_state['values']['exposed_form']['type']) { |
... | ... | |
2495 | 2550 |
} |
2496 | 2551 |
} |
2497 | 2552 |
} |
2498 |
|
|
2499 | 2553 |
break; |
2554 |
|
|
2500 | 2555 |
case 'exposed_form_options': |
2501 | 2556 |
$plugin = $this->get_plugin('exposed_form'); |
2502 | 2557 |
if ($plugin) { |
... | ... | |
2506 | 2561 |
$this->set_option('exposed_form', $exposed_form); |
2507 | 2562 |
} |
2508 | 2563 |
break; |
2564 |
|
|
2509 | 2565 |
case 'pager': |
2510 | 2566 |
$pager = $this->get_option('pager'); |
2511 | 2567 |
if ($pager['type'] != $form_state['values']['pager']['type']) { |
... | ... | |
2522 | 2578 |
} |
2523 | 2579 |
} |
2524 | 2580 |
} |
2525 |
|
|
2526 | 2581 |
break; |
2582 |
|
|
2527 | 2583 |
case 'pager_options': |
2528 | 2584 |
$plugin = $this->get_plugin('pager'); |
2529 | 2585 |
if ($plugin) { |
... | ... | |
2543 | 2599 |
/** |
2544 | 2600 |
* If override/revert was clicked, perform the proper toggle. |
2545 | 2601 |
*/ |
2546 |
function options_override($form, &$form_state) { |
|
2602 |
public function options_override($form, &$form_state) {
|
|
2547 | 2603 |
$this->set_override($form_state['section']); |
2548 | 2604 |
} |
2549 | 2605 |
|
... | ... | |
2557 | 2613 |
* - TRUE: Revert to default. |
2558 | 2614 |
* - FALSE: Mark it as overridden. |
2559 | 2615 |
*/ |
2560 |
function set_override($section, $new_state = NULL) { |
|
2616 |
public function set_override($section, $new_state = NULL) {
|
|
2561 | 2617 |
$options = $this->defaultable_sections($section); |
2562 | 2618 |
if (!$options) { |
2563 | 2619 |
return; |
... | ... | |
2587 | 2643 |
/** |
2588 | 2644 |
* Inject anything into the query that the display handler needs. |
2589 | 2645 |
*/ |
2590 |
function query() { |
|
2646 |
public function query() {
|
|
2591 | 2647 |
foreach ($this->extender as $extender) { |
2592 | 2648 |
$extender->query(); |
2593 | 2649 |
} |
2594 | 2650 |
} |
2595 | 2651 |
|
2596 | 2652 |
/** |
2597 |
* Not all display plugins will support filtering |
|
2653 |
* Not all display plugins will support filtering.
|
|
2598 | 2654 |
*/ |
2599 |
function render_filters() { } |
|
2655 |
public function render_filters() { |
|
2656 |
} |
|
2600 | 2657 |
|
2601 | 2658 |
/** |
2602 | 2659 |
* Not all display plugins will suppert pager rendering. |
2603 | 2660 |
*/ |
2604 |
function render_pager() { |
|
2661 |
public function render_pager() {
|
|
2605 | 2662 |
return TRUE; |
2606 | 2663 |
} |
2607 | 2664 |
|
2608 | 2665 |
/** |
2609 |
* Render the 'more' link |
|
2666 |
* Render the 'more' link.
|
|
2610 | 2667 |
*/ |
2611 |
function render_more_link() { |
|
2668 |
public function render_more_link() {
|
|
2612 | 2669 |
if ($this->use_more() && ($this->use_more_always() || (!empty($this->view->query->pager) && $this->view->query->pager->has_more_records()))) { |
2613 | 2670 |
$path = $this->get_path(); |
2614 | 2671 |
|
... | ... | |
2650 | 2707 |
} |
2651 | 2708 |
} |
2652 | 2709 |
|
2653 |
|
|
2654 | 2710 |
/** |
2655 | 2711 |
* Legacy functions. |
2656 | 2712 |
*/ |
... | ... | |
2658 | 2714 |
/** |
2659 | 2715 |
* Render the header of the view. |
2660 | 2716 |
*/ |
2661 |
function render_header() { |
|
2717 |
public function render_header() {
|
|
2662 | 2718 |
$empty = !empty($this->view->result); |
2663 | 2719 |
return $this->render_area('header', $empty); |
2664 | 2720 |
} |
... | ... | |
2666 | 2722 |
/** |
2667 | 2723 |
* Render the footer of the view. |
2668 | 2724 |
*/ |
2669 |
function render_footer() { |
|
2725 |
public function render_footer() {
|
|
2670 | 2726 |
$empty = !empty($this->view->result); |
2671 | 2727 |
return $this->render_area('footer', $empty); |
2672 | 2728 |
} |
2673 | 2729 |
|
2674 |
function render_empty() { |
|
2730 |
/** |
|
2731 |
* |
|
2732 |
*/ |
|
2733 |
public function render_empty() { |
|
2675 | 2734 |
return $this->render_area('empty'); |
2676 | 2735 |
} |
2677 | 2736 |
|
2678 | 2737 |
/** |
2679 | 2738 |
* If this display creates a block, implement one of these. |
2680 | 2739 |
*/ |
2681 |
function hook_block_list($delta = 0, $edit = array()) { return array(); } |
|
2740 |
public function hook_block_list($delta = 0, $edit = array()) { |
|
2741 |
return array(); |
|
2742 |
} |
|
2682 | 2743 |
|
2683 | 2744 |
/** |
2684 | 2745 |
* If this display creates a page with a menu item, implement it here. |
2685 | 2746 |
*/ |
2686 |
function hook_menu() { return array(); } |
|
2747 |
public function hook_menu() { |
|
2748 |
return array(); |
|
2749 |
} |
|
2687 | 2750 |
|
2688 | 2751 |
/** |
2689 | 2752 |
* Render this display. |
2690 | 2753 |
*/ |
2691 |
function render() { |
|
2754 |
public function render() {
|
|
2692 | 2755 |
return theme($this->theme_functions(), array('view' => $this->view)); |
2693 | 2756 |
} |
2694 | 2757 |
|
2695 |
function render_area($area, $empty = FALSE) { |
|
2758 |
/** |
|
2759 |
* |
|
2760 |
*/ |
|
2761 |
public function render_area($area, $empty = FALSE) { |
|
2696 | 2762 |
$return = ''; |
2697 | 2763 |
foreach ($this->get_handlers($area) as $area) { |
2698 | 2764 |
$return .= $area->render($empty); |
... | ... | |
2700 | 2766 |
return $return; |
2701 | 2767 |
} |
2702 | 2768 |
|
2703 |
|
|
2704 | 2769 |
/** |
2705 | 2770 |
* Determine if the user has access to this display of the view. |
2706 | 2771 |
*/ |
2707 |
function access($account = NULL) { |
|
2772 |
public function access($account = NULL) {
|
|
2708 | 2773 |
if (!isset($account)) { |
2709 | 2774 |
global $user; |
2710 | 2775 |
$account = $user; |
... | ... | |
2720 | 2785 |
return $plugin->access($account); |
2721 | 2786 |
} |
2722 | 2787 |
|
2723 |
// fallback to all access if no plugin.
|
|
2788 |
// Fallback to all access if no plugin.
|
|
2724 | 2789 |
return TRUE; |
2725 | 2790 |
} |
2726 | 2791 |
|
... | ... | |
2729 | 2794 |
* from execute because they are extremely common and unlikely to be |
2730 | 2795 |
* overridden on an individual display. |
2731 | 2796 |
*/ |
2732 |
function pre_execute() { |
|
2797 |
public function pre_execute() {
|
|
2733 | 2798 |
$this->view->set_use_ajax($this->use_ajax()); |
2734 | 2799 |
if ($this->use_more() && !$this->use_more_always()) { |
2735 | 2800 |
$this->view->get_total_rows = TRUE; |
... | ... | |
2755 | 2820 |
* |
2756 | 2821 |
* The base class cannot be executed. |
2757 | 2822 |
*/ |
2758 |
function execute() { } |
|
2823 |
public function execute() { |
|
2824 |
} |
|
2759 | 2825 |
|
2760 | 2826 |
/** |
2761 |
* Fully render the display for the purposes of a live preview or |
|
2762 |
* some other AJAXy reason. |
|
2827 |
* Fully render the display. |
|
2828 |
* |
|
2829 |
* Used for the purposes of a live preview or some other AJAXy reason. |
|
2763 | 2830 |
*/ |
2764 |
function preview() { return $this->view->render(); } |
|
2831 |
public function preview() { |
|
2832 |
return $this->view->render(); |
|
2833 |
} |
|
2765 | 2834 |
|
2766 | 2835 |
/** |
2767 |
* Displays can require a certain type of style plugin. By default, they will |
|
2768 |
* be 'normal'. |
|
2836 |
* Displays can require a certain type of style plugin. |
|
2837 |
* |
|
2838 |
* By default, they will be 'normal'. |
|
2769 | 2839 |
*/ |
2770 |
function get_style_type() { return 'normal'; } |
|
2840 |
public function get_style_type() { |
|
2841 |
return 'normal'; |
|
2842 |
} |
|
2771 | 2843 |
|
2772 | 2844 |
/** |
2773 | 2845 |
* Make sure the display and all associated handlers are valid. |
2774 | 2846 |
* |
2775 | 2847 |
* @return |
2776 |
* Empty array if the display is valid; an array of error strings if it is not. |
|
2848 |
* Empty array if the display is valid; an array of error strings if it is |
|
2849 |
* not. |
|
2777 | 2850 |
*/ |
2778 |
function validate() { |
|
2851 |
public function validate() {
|
|
2779 | 2852 |
$errors = array(); |
2780 | 2853 |
// Make sure displays that use fields HAVE fields. |
2781 | 2854 |
if ($this->uses_fields()) { |
... | ... | |
2795 | 2868 |
$errors[] = t('Display "@display" uses a path but the path is undefined.', array('@display' => $this->display->display_title)); |
2796 | 2869 |
} |
2797 | 2870 |
|
2798 |
// Validate style plugin |
|
2871 |
// Validate style plugin.
|
|
2799 | 2872 |
$style = $this->get_plugin(); |
2800 | 2873 |
if (empty($style)) { |
2801 | 2874 |
$errors[] = t('Display "@display" has an invalid style plugin.', array('@display' => $this->display->display_title)); |
... | ... | |
2814 | 2887 |
$errors = array_merge($errors, $result); |
2815 | 2888 |
} |
2816 | 2889 |
|
2817 |
// Validate handlers |
|
2890 |
// Validate handlers.
|
|
2818 | 2891 |
foreach (views_object_types() as $type => $info) { |
2819 | 2892 |
foreach ($this->get_handlers($type) as $handler) { |
2820 | 2893 |
$result = $handler->validate(); |
... | ... | |
2837 | 2910 |
* |
2838 | 2911 |
* @return bool |
2839 | 2912 |
* Returns whether the identifier is unique on all handlers. |
2840 |
* |
|
2841 | 2913 |
*/ |
2842 |
function is_identifier_unique($id, $identifier) { |
|
2914 |
public function is_identifier_unique($id, $identifier) {
|
|
2843 | 2915 |
foreach (views_object_types() as $type => $info) { |
2844 | 2916 |
foreach ($this->get_handlers($type) as $key => $handler) { |
2845 | 2917 |
if ($handler->can_expose() && $handler->is_exposed()) { |
... | ... | |
2862 | 2934 |
/** |
2863 | 2935 |
* Provide the block system with any exposed widget blocks for this display. |
2864 | 2936 |
*/ |
2865 |
function get_special_blocks() { |
|
2937 |
public function get_special_blocks() {
|
|
2866 | 2938 |
$blocks = array(); |
2867 | 2939 |
|
2868 | 2940 |
if ($this->uses_exposed_form_in_block()) { |
... | ... | |
2881 | 2953 |
/** |
2882 | 2954 |
* Render any special blocks provided for this display. |
2883 | 2955 |
*/ |
2884 |
function view_special_blocks($type) { |
|
2956 |
public function view_special_blocks($type) {
|
|
2885 | 2957 |
if ($type == '-exp') { |
2886 | 2958 |
// avoid interfering with the admin forms. |
2887 | 2959 |
if (arg(0) == 'admin' && arg(1) == 'structure' && arg(2) == 'views') { |
... | ... | |
2901 | 2973 |
/** |
2902 | 2974 |
* Override of export_option() |
2903 | 2975 |
* |
2904 |
* Because displays do not want to export options that are NOT overridden from the |
|
2905 |
* default display, we need some special handling during the export process. |
|
2976 |
* Because displays do not want to export options that are NOT overridden from |
|
2977 |
* the default display, we need some special handling during the export |
|
2978 |
* process. |
|
2906 | 2979 |
*/ |
2907 |
function export_option($indent, $prefix, $storage, $option, $definition, $parents) { |
|
2908 |
// The $prefix is wrong because we store our actual options a little differently: |
|
2980 |
public function export_option($indent, $prefix, $storage, $option, $definition, $parents) { |
|
2981 |
// The $prefix is wrong because we store our actual options a little |
|
2982 |
// differently. |
|
2909 | 2983 |
$prefix = '$handler->display->display_options'; |
2910 | 2984 |
$output = ''; |
2911 | 2985 |
if (!$parents && !$this->is_default_display()) { |
... | ... | |
2914 | 2988 |
return; |
2915 | 2989 |
} |
2916 | 2990 |
|
2917 |
// If this is not defaulted and is overrideable, flip the switch to say this
|
|
2918 |
// is overridden. |
|
2991 |
// If this is not defaulted and is overrideable, flip the switch to say |
|
2992 |
// this is overridden.
|
|
2919 | 2993 |
if ($this->defaultable_sections($option)) { |
2920 | 2994 |
$output .= $indent . $prefix . "['defaults']['$option'] = FALSE;\n"; |
2921 | 2995 |
} |
... | ... | |
2928 | 3002 |
/** |
2929 | 3003 |
* Special method to export items that have handlers. |
2930 | 3004 |
* |
2931 |
* This method was specified in the option_definition() as the method to utilize to
|
|
2932 |
* export fields, filters, sort criteria, relationships and arguments. This passes
|
|
2933 |
* the export off to the individual handlers so that they can export themselves
|
|
2934 |
* properly. |
|
3005 |
* This method was specified in the option_definition() as the method to |
|
3006 |
* utilize to export fields, filters, sort criteria, relationships and
|
|
3007 |
* arguments. This passes the export off to the individual handlers so that
|
|
3008 |
* they can export themselves properly.
|
|
2935 | 3009 |
*/ |
2936 |
function export_handler($indent, $prefix, $storage, $option, $definition, $parents) { |
|
3010 |
public function export_handler($indent, $prefix, $storage, $option, $definition, $parents) {
|
|
2937 | 3011 |
$output = ''; |
2938 | 3012 |
|
2939 |
// cut the 's' off because the data is stored as the plural form but we need
|
|
3013 |
// Cut the 's' off because the data is stored as the plural form but we need
|
|
2940 | 3014 |
// the singular form. Who designed that anyway? Oh yeah, I did. :( |
2941 | 3015 |
if ($option != 'header' && $option != 'footer' && $option != 'empty') { |
2942 | 3016 |
$type = substr($option, 0, -1); |
... | ... | |
2986 | 3060 |
* row_options accordingly. The options are told not to export, and the |
2987 | 3061 |
* export for the plugin should export both. |
2988 | 3062 |
*/ |
2989 |
function export_style($indent, $prefix, $storage, $option, $definition, $parents) { |
|
3063 |
public function export_style($indent, $prefix, $storage, $option, $definition, $parents) {
|
|
2990 | 3064 |
$output = ''; |
2991 | 3065 |
$style_plugin = $this->get_plugin(); |
2992 | 3066 |
if ($option == 'style_plugin') { |
... | ... | |
3025 | 3099 |
* array, but for legacy plugins (access and cache) options are stored as |
3026 | 3100 |
* siblings to the type. |
3027 | 3101 |
*/ |
3028 |
function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { |
|
3102 |
public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) {
|
|
3029 | 3103 |
$output = ''; |
3030 | 3104 |
$plugin_type = end($parents); |
3031 | 3105 |
$plugin = $this->get_plugin($plugin_type); |
... | ... | |
3047 | 3121 |
return $output; |
3048 | 3122 |
} |
3049 | 3123 |
|
3050 |
function unpack_style($indent, $prefix, $storage, $option, $definition, $parents) { |
|
3124 |
/** |
|
3125 |
* |
|
3126 |
*/ |
|
3127 |
public function unpack_style($indent, $prefix, $storage, $option, $definition, $parents) { |
|
3051 | 3128 |
$output = ''; |
3052 | 3129 |
$style_plugin = $this->get_plugin(); |
3053 | 3130 |
if ($option == 'style_plugin') { |
... | ... | |
3074 | 3151 |
/** |
3075 | 3152 |
* Special handling for plugin unpacking. |
3076 | 3153 |
*/ |
3077 |
function unpack_plugin(&$translatable, $storage, $option, $definition, $parents) { |
|
3154 |
public function unpack_plugin(&$translatable, $storage, $option, $definition, $parents) {
|
|
3078 | 3155 |
$plugin_type = end($parents); |
3079 | 3156 |
$plugin = $this->get_plugin($plugin_type); |
3080 | 3157 |
if ($plugin) { |
... | ... | |
3083 | 3160 |
} |
3084 | 3161 |
} |
3085 | 3162 |
|
3086 |
/**
|
|
3163 |
/** |
|
3087 | 3164 |
* Special method to unpack items that have handlers. |
3088 | 3165 |
* |
3089 |
* This method was specified in the option_definition() as the method to utilize to
|
|
3090 |
* export fields, filters, sort criteria, relationships and arguments. This passes
|
|
3091 |
* the export off to the individual handlers so that they can export themselves
|
|
3092 |
* properly. |
|
3166 |
* This method was specified in the option_definition() as the method to |
|
3167 |
* utilize to export fields, filters, sort criteria, relationships and
|
|
3168 |
* arguments. This passes the export off to the individual handlers so that
|
|
3169 |
* they can export themselves properly.
|
|
3093 | 3170 |
*/ |
3094 |
function unpack_handler(&$translatable, $storage, $option, $definition, $parents) { |
|
3171 |
public function unpack_handler(&$translatable, $storage, $option, $definition, $parents) {
|
|
3095 | 3172 |
$output = ''; |
3096 | 3173 |
|
3097 |
// cut the 's' off because the data is stored as the plural form but we need
|
|
3174 |
// Cut the 's' off because the data is stored as the plural form but we need
|
|
3098 | 3175 |
// the singular form. Who designed that anyway? Oh yeah, I did. :( |
3099 | 3176 |
if ($option != 'header' && $option != 'footer' && $option != 'empty') { |
3100 | 3177 |
$type = substr($option, 0, -1); |
... | ... | |
3125 | 3202 |
|
3126 | 3203 |
/** |
3127 | 3204 |
* Provide some helpful text for the arguments. |
3205 |
* |
|
3128 | 3206 |
* The result should contain of an array with |
3129 | 3207 |
* - filter value present: The title of the fieldset in the argument |
3130 | 3208 |
* where you can configure what should be done with a given argument. |
... | ... | |
3134 | 3212 |
* - description: A description about how arguments comes to the display. |
3135 | 3213 |
* For example blocks don't get it from url. |
3136 | 3214 |
*/ |
Formats disponibles : Unified diff
Weekly update of contrib modules