Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/includes/admin.inc | ||
---|---|---|
8 | 8 |
/** |
9 | 9 |
* Create an array of Views admin CSS for adding or attaching. |
10 | 10 |
* |
11 |
* This returns an array of arrays. Each array represents a single |
|
12 |
* file. The array format is: |
|
13 |
* - file: The fully qualified name of the file to send to drupal_add_css |
|
14 |
* - options: An array of options to pass to drupal_add_css. |
|
11 |
* @return array |
|
12 |
* An array of arrays. Each array represents a single file. The array format |
|
13 |
* is: |
|
14 |
* - file: The fully qualified name of the file to send to drupal_add_css |
|
15 |
* - options: An array of options to pass to drupal_add_css. |
|
15 | 16 |
*/ |
16 | 17 |
function views_ui_get_admin_css() { |
17 | 18 |
$module_path = drupal_get_path('module', 'views_ui'); |
... | ... | |
21 | 22 |
$list[$module_path . '/css/ie/views-admin.ie7.css'] = array( |
22 | 23 |
'browsers' => array( |
23 | 24 |
'IE' => 'lte IE 7', |
24 |
'!IE' => FALSE |
|
25 |
'!IE' => FALSE,
|
|
25 | 26 |
), |
26 | 27 |
'preprocess' => FALSE, |
27 | 28 |
); |
28 | 29 |
|
29 | 30 |
$list[$module_path . '/css/views-admin.theme.css'] = array(); |
30 | 31 |
|
31 |
// Add in any theme specific CSS files we have |
|
32 |
// Add in any theme specific CSS files we have.
|
|
32 | 33 |
$themes = list_themes(); |
33 | 34 |
$theme_key = $GLOBALS['theme']; |
34 | 35 |
while ($theme_key) { |
35 | 36 |
// Try to find the admin css file for non-core themes. |
36 | 37 |
if (!in_array($theme_key, array('garland', 'seven', 'bartik'))) { |
37 | 38 |
$theme_path = drupal_get_path('theme', $theme_key); |
38 |
// First search in the css directory, then in the root folder of the theme. |
|
39 |
// First search in the css directory, then in the root folder of the |
|
40 |
// theme. |
|
39 | 41 |
if (file_exists($theme_path . "/css/views-admin.$theme_key.css")) { |
40 | 42 |
$list[$theme_path . "/css/views-admin.$theme_key.css"] = array( |
41 | 43 |
'group' => CSS_THEME, |
42 | 44 |
); |
43 | 45 |
} |
44 |
else if (file_exists($theme_path . "/views-admin.$theme_key.css")) {
|
|
46 |
elseif (file_exists($theme_path . "/views-admin.$theme_key.css")) { |
|
45 | 47 |
$list[$theme_path . "/views-admin.$theme_key.css"] = array( |
46 | 48 |
'group' => CSS_THEME, |
47 | 49 |
); |
... | ... | |
54 | 56 |
} |
55 | 57 |
$theme_key = isset($themes[$theme_key]->base_theme) ? $themes[$theme_key]->base_theme : ''; |
56 | 58 |
} |
57 |
// Views contains style overrides for the following modules |
|
59 |
// Views contains style overrides for the following modules.
|
|
58 | 60 |
$module_list = array('contextual', 'advanced_help', 'ctools'); |
59 | 61 |
foreach ($module_list as $module) { |
60 | 62 |
if (module_exists($module)) { |
... | ... | |
62 | 64 |
} |
63 | 65 |
} |
64 | 66 |
|
65 |
|
|
66 | 67 |
return $list; |
67 | 68 |
} |
68 | 69 |
|
... | ... | |
76 | 77 |
} |
77 | 78 |
|
78 | 79 |
/** |
79 |
* Check to see if the advanced help module is installed, and if not put up |
|
80 |
* a message. |
|
80 |
* Check to see if the advanced help module is installed. |
|
81 |
* |
|
82 |
* If not display a message. |
|
81 | 83 |
* |
82 |
* Only call this function if the user is already in a position for this to |
|
83 |
* be useful.
|
|
84 |
* Only call this function if the user is already in a position for this to be
|
|
85 |
* useful. |
|
84 | 86 |
*/ |
85 | 87 |
function views_ui_check_advanced_help() { |
86 | 88 |
if (!variable_get('views_ui_show_advanced_help_warning', TRUE)) { |
... | ... | |
91 | 93 |
$filename = db_query_range("SELECT filename FROM {system} WHERE type = 'module' AND name = 'advanced_help'", 0, 1) |
92 | 94 |
->fetchField(); |
93 | 95 |
if ($filename && file_exists($filename)) { |
94 |
drupal_set_message(t('If you <a href="@modules">enable the advanced help module</a>, Views will provide more and better help. <a href="@hide">You can disable this message at the Views settings page.</a>', array('@modules' => url('admin/modules'),'@hide' => url('admin/structure/views/settings')))); |
|
96 |
drupal_set_message(t('If you <a href="@modules">enable the advanced help module</a>, Views will provide more and better help. <a href="@hide">You can disable this message at the Views settings page.</a>', |
|
97 |
array( |
|
98 |
'@modules' => url('admin/modules'), |
|
99 |
'@hide' => url('admin/structure/views/settings'), |
|
100 |
))); |
|
95 | 101 |
} |
96 | 102 |
else { |
97 |
drupal_set_message(t('If you install the advanced help module from !href, Views will provide more and better help. <a href="@hide">You can disable this message at the Views settings page.</a>', array('!href' => l('http://drupal.org/project/advanced_help', 'http://drupal.org/project/advanced_help'), '@hide' => url('admin/structure/views/settings')))); |
|
103 |
drupal_set_message(t('If you install the advanced help module from !href, Views will provide more and better help. <a href="@hide">You can disable this message at the Views settings page.</a>', |
|
104 |
array( |
|
105 |
'!href' => l('http://drupal.org/project/advanced_help', 'http://drupal.org/project/advanced_help'), |
|
106 |
'@hide' => url('admin/structure/views/settings'), |
|
107 |
))); |
|
98 | 108 |
} |
99 | 109 |
} |
100 | 110 |
} |
... | ... | |
133 | 143 |
$view->live_preview = TRUE; |
134 | 144 |
$view->views_ui_context = TRUE; |
135 | 145 |
|
136 |
// AJAX happens via $_POST but everything expects exposed data to |
|
137 |
// be in GET. Copy stuff but remove ajax-framework specific keys.
|
|
138 |
// If we're clicking on links in a preview, though, we could actually
|
|
139 |
// still have some in $_GET, so we use $_REQUEST to ensure we get it all.
|
|
146 |
// AJAX happens via $_POST but everything expects exposed data to be in
|
|
147 |
// GET. Copy stuff but remove ajax-framework specific keys. If we're
|
|
148 |
// clicking on links in a preview, though, we could actually still have
|
|
149 |
// some in $_GET, so we use $_REQUEST to ensure we get it all. |
|
140 | 150 |
$exposed_input = $_REQUEST; |
141 | 151 |
foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', 'ajax_html_ids', 'ajax_page_state', 'form_id', 'form_build_id', 'form_token') as $key) { |
142 | 152 |
if (isset($exposed_input[$key])) { |
... | ... | |
146 | 156 |
|
147 | 157 |
$view->set_exposed_input($exposed_input); |
148 | 158 |
|
149 |
|
|
150 | 159 |
if (!$view->set_display($display_id)) { |
151 | 160 |
return t('Invalid display id @display', array('@display' => $display_id)); |
152 | 161 |
} |
153 | 162 |
|
154 | 163 |
$view->set_arguments($args); |
155 | 164 |
|
156 |
// Store the current view URL for later use:
|
|
165 |
// Store the current view URL for later use.
|
|
157 | 166 |
if ($view->display_handler->get_option('path')) { |
158 | 167 |
$path = $view->get_url(); |
159 | 168 |
} |
... | ... | |
187 | 196 |
if (!empty($view->build_info['query'])) { |
188 | 197 |
if ($show_query) { |
189 | 198 |
$query = $view->build_info['query']; |
190 |
// Only the sql default class has a method getArguments.
|
|
199 |
// Only the SQL default class has a method getArguments.
|
|
191 | 200 |
$quoted = array(); |
192 | 201 |
|
193 | 202 |
if (get_class($view->query) == 'views_plugin_query_default') { |
... | ... | |
401 | 410 |
* Helper form element validator: integer. |
402 | 411 |
* |
403 | 412 |
* The problem with this is that the function is private so it's not guaranteed |
404 |
* that it might not be renamed/changed. In the future field.module or something else
|
|
405 |
* should provide a public validate function. |
|
413 |
* that it might not be renamed/changed. In the future field.module or something |
|
414 |
* else should provide a public validate function.
|
|
406 | 415 |
* |
407 | 416 |
* @see _element_validate_integer_positive() |
408 | 417 |
*/ |
... | ... | |
414 | 423 |
} |
415 | 424 |
|
416 | 425 |
/** |
417 |
* Gets the current value of a #select element, from within a form constructor function.
|
|
426 |
* Gets the current value of a #select element, from within a form constructor. |
|
418 | 427 |
* |
419 | 428 |
* This function is intended for use in highly dynamic forms (in particular the |
420 | 429 |
* add view wizard) which are rebuilt in different ways depending on which |
... | ... | |
434 | 443 |
* the results of this function for any other purpose besides deciding how to |
435 | 444 |
* build the next version of the form. |
436 | 445 |
* |
437 |
* @param $form_state |
|
438 |
* The standard associative array containing the current state of the form.
|
|
439 |
* @param $parents |
|
446 |
* @param array $form_state
|
|
447 |
* The standard associative array containing the current state of the form. |
|
448 |
* @param array $parents
|
|
440 | 449 |
* An array of parent keys that point to the part of the submitted form |
441 | 450 |
* values that are expected to contain the element's value (in the case where |
442 | 451 |
* this form element was actually submitted). In a simple case (assuming |
... | ... | |
444 | 453 |
* $form['wrapper']['select'], so that the submitted form values would |
445 | 454 |
* normally be found in $form_state['values']['wrapper']['select'], you would |
446 | 455 |
* pass array('wrapper', 'select') for this parameter. |
447 |
* @param $default_value |
|
456 |
* @param mixed $default_value
|
|
448 | 457 |
* The default value to return if the #select element does not currently have |
449 | 458 |
* a proper value set based on the submitted input. |
450 |
* @param $element |
|
459 |
* @param array $element
|
|
451 | 460 |
* An array representing the current version of the #select element within |
452 | 461 |
* the form. |
453 | 462 |
* |
454 |
* @return |
|
463 |
* @return array
|
|
455 | 464 |
* The current value of the #select element. A common use for this is to feed |
456 | 465 |
* it back into $element['#default_value'] so that the form will be rendered |
457 | 466 |
* with the correct value selected. |
... | ... | |
508 | 517 |
* mean that the non-JavaScript fallback button does not appear in the correct |
509 | 518 |
* place in the form. |
510 | 519 |
* |
511 |
* @param $wrapping_element |
|
520 |
* @param array $wrapping_element
|
|
512 | 521 |
* The element whose child will server as the AJAX trigger. For example, if |
513 | 522 |
* $form['some_wrapper']['triggering_element'] represents the element which |
514 | 523 |
* will trigger the AJAX behavior, you would pass $form['some_wrapper'] for |
515 | 524 |
* this parameter. |
516 |
* @param $trigger_key |
|
525 |
* @param string $trigger_key
|
|
517 | 526 |
* The key within the wrapping element that identifies which of its children |
518 | 527 |
* serves as the AJAX trigger. In the above example, you would pass |
519 | 528 |
* 'triggering_element' for this parameter. |
520 |
* @param $refresh_parents |
|
529 |
* @param array $refresh_parents
|
|
521 | 530 |
* An array of parent keys that point to the part of the form that will be |
522 | 531 |
* refreshed by AJAX. For example, if triggering the AJAX behavior should |
523 | 532 |
* cause $form['dynamic_content']['section'] to be refreshed, you would pass |
... | ... | |
581 | 590 |
$wrapping_element[$button_key]['#value'] = t('Update "@title" choice (@number)', array( |
582 | 591 |
'@title' => $button_title, |
583 | 592 |
'@number' => ++$seen_buttons[$button_title], |
584 |
)); |
|
593 |
));
|
|
585 | 594 |
} |
586 | 595 |
|
587 | 596 |
// Attach custom data to the triggering element and submit button, so we can |
... | ... | |
600 | 609 |
} |
601 | 610 |
|
602 | 611 |
/** |
603 |
* Processes a non-JavaScript fallback submit button to limit its validation errors.
|
|
612 |
* Processes a non-JS fallback submit button to limit its validation errors.
|
|
604 | 613 |
*/ |
605 | 614 |
function views_ui_add_limited_validation($element, &$form_state) { |
606 | 615 |
// Retrieve the AJAX triggering element so we can determine its parents. (We |
... | ... | |
634 | 643 |
} |
635 | 644 |
|
636 | 645 |
/** |
637 |
* After-build function that adds a wrapper to a form region (for AJAX refreshes).
|
|
646 |
* After-build function that adds a wrapper to a form region (AJAX refreshes). |
|
638 | 647 |
* |
639 | 648 |
* This function inserts a wrapper around the region of the form that needs to |
640 |
* be refreshed by AJAX, based on information stored in the corresponding |
|
641 |
* submit button form element.
|
|
649 |
* be refreshed by AJAX, based on information stored in the corresponding submit
|
|
650 |
* button form element. |
|
642 | 651 |
*/ |
643 | 652 |
function views_ui_add_ajax_wrapper($element, &$form_state) { |
644 | 653 |
// Don't add the wrapper <div> if the same one was already inserted on this |
... | ... | |
721 | 730 |
if ($display->handler->has_path()) { |
722 | 731 |
$one_path = $display->handler->get_option('path'); |
723 | 732 |
if (strpos($one_path, '%') === FALSE) { |
724 |
$form_state['redirect'] = $one_path; // PATH TO THE VIEW IF IT HAS ONE |
|
733 |
$form_state['redirect'] = $one_path; |
|
734 |
// PATH TO THE VIEW IF IT HAS ONE. |
|
725 | 735 |
return; |
726 | 736 |
} |
727 | 737 |
} |
... | ... | |
811 | 821 |
/** |
812 | 822 |
* Theme function; returns basic administrative information about a view. |
813 | 823 |
* |
814 |
* TODO: template + preprocess |
|
824 |
* TODO: template + preprocess.
|
|
815 | 825 |
*/ |
816 | 826 |
function theme_views_ui_view_info($variables) { |
817 | 827 |
$view = $variables['view']; |
... | ... | |
832 | 842 |
|
833 | 843 |
case t('Overridden'): |
834 | 844 |
$type = t('Database overriding code'); |
845 |
break; |
|
835 | 846 |
} |
836 | 847 |
|
837 | 848 |
$output = ''; |
838 | 849 |
$output .= '<div class="views-ui-view-title">' . check_plain($title) . "</div>\n"; |
839 | 850 |
$output .= '<div class="views-ui-view-displays">' . $displays . "</div>\n"; |
840 | 851 |
$output .= '<div class="views-ui-view-storage">' . $type . "</div>\n"; |
841 |
$output .= '<div class="views-ui-view-base">' . t('Type') . ': ' . check_plain($variables['base']). "</div>\n"; |
|
852 |
$output .= '<div class="views-ui-view-base">' . t('Type') . ': ' . check_plain($variables['base']) . "</div>\n";
|
|
842 | 853 |
return $output; |
843 | 854 |
} |
844 | 855 |
|
... | ... | |
876 | 887 |
} |
877 | 888 |
|
878 | 889 |
/** |
879 |
* Helper function to return the used display_id for the edit page |
|
890 |
* Helper function to return the used display_id for the edit page.
|
|
880 | 891 |
* |
881 | 892 |
* This function handles access to the display. |
882 | 893 |
*/ |
... | ... | |
927 | 938 |
return $build; |
928 | 939 |
} |
929 | 940 |
|
941 |
/** |
|
942 |
* |
|
943 |
*/ |
|
930 | 944 |
function views_ui_build_preview($view, $display_id, $render = TRUE) { |
931 | 945 |
if (isset($_POST['ajax_html_ids'])) { |
932 | 946 |
unset($_POST['ajax_html_ids']); |
... | ... | |
1000 | 1014 |
$form['#attached']['library'][] = array('system', 'ui.dialog'); |
1001 | 1015 |
$form['#attached']['library'][] = array('system', 'drupal.ajax'); |
1002 | 1016 |
$form['#attached']['library'][] = array('system', 'jquery.form'); |
1003 |
// TODO: This should be getting added to the page when an ajax popup calls
|
|
1017 |
// @todo This should be getting added to the page when an ajax popup calls
|
|
1004 | 1018 |
// for it, instead of having to add it manually here. |
1005 | 1019 |
$form['#attached']['js'][] = 'misc/tabledrag.js'; |
1006 | 1020 |
|
... | ... | |
1009 | 1023 |
|
1010 | 1024 |
$form['#attached']['js'][] = $module_path . '/js/views-admin.js'; |
1011 | 1025 |
$form['#attached']['js'][] = array( |
1012 |
'data' => array('views' => array('ajax' => array( |
|
1013 |
'id' => '#views-ajax-body', |
|
1014 |
'title' => '#views-ajax-title', |
|
1015 |
'popup' => '#views-ajax-popup', |
|
1016 |
'defaultForm' => views_ui_get_default_ajax_message(), |
|
1017 |
))), |
|
1026 |
'data' => array( |
|
1027 |
'views' => array( |
|
1028 |
'ajax' => array( |
|
1029 |
'id' => '#views-ajax-body', |
|
1030 |
'title' => '#views-ajax-title', |
|
1031 |
'popup' => '#views-ajax-popup', |
|
1032 |
'defaultForm' => views_ui_get_default_ajax_message(), |
|
1033 |
), |
|
1034 |
), |
|
1035 |
), |
|
1018 | 1036 |
'type' => 'setting', |
1019 | 1037 |
); |
1020 | 1038 |
|
... | ... | |
1030 | 1048 |
if (isset($view->locked) && is_object($view->locked)) { |
1031 | 1049 |
$form['locked'] = array( |
1032 | 1050 |
'#theme_wrappers' => array('container'), |
1033 |
'#attributes' => array('class' => array('view-locked', 'messages', 'warning')), |
|
1051 |
'#attributes' => array( |
|
1052 |
'class' => array('view-locked', 'messages', 'warning'), |
|
1053 |
), |
|
1034 | 1054 |
'#markup' => t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to <a href="!break">break this lock</a>.', array('!user' => theme('username', array('account' => user_load($view->locked->uid))), '!age' => format_interval(REQUEST_TIME - $view->locked->updated), '!break' => url('admin/structure/views/view/' . $view->name . '/break-lock'))), |
1035 | 1055 |
); |
1036 | 1056 |
} |
... | ... | |
1043 | 1063 |
|
1044 | 1064 |
$form['changed'] = array( |
1045 | 1065 |
'#theme_wrappers' => array('container'), |
1046 |
'#attributes' => array('class' => array('view-changed', 'messages', 'warning')), |
|
1066 |
'#attributes' => array( |
|
1067 |
'class' => array('view-changed', 'messages', 'warning'), |
|
1068 |
), |
|
1047 | 1069 |
'#markup' => $message, |
1048 | 1070 |
); |
1049 | 1071 |
if (empty($view->changed)) { |
... | ... | |
1072 | 1094 |
$form['actions']['save'] = array( |
1073 | 1095 |
'#type' => 'submit', |
1074 | 1096 |
'#value' => t('Save'), |
1075 |
// Taken from the "old" UI. @TODO: Review and rename.
|
|
1097 |
// Taken from the "old" UI. @todo: Review and rename.
|
|
1076 | 1098 |
'#validate' => array('views_ui_edit_view_form_validate'), |
1077 | 1099 |
'#submit' => array('views_ui_edit_view_form_submit'), |
1078 | 1100 |
); |
... | ... | |
1083 | 1105 |
); |
1084 | 1106 |
|
1085 | 1107 |
$form['displays'] = array( |
1086 |
'#prefix' => '<h1 class="unit-title clearfix">' . t('Displays') . '</h1>' . "\n" . '<div class="views-displays">', |
|
1108 |
'#prefix' => '<h1 class="unit-title clearfix">' . t('Displays') . "</h1>\n" |
|
1109 |
. '<div class="views-displays">', |
|
1087 | 1110 |
'#suffix' => '</div>', |
1088 | 1111 |
); |
1089 | 1112 |
|
... | ... | |
1093 | 1116 |
if ($display_id) { |
1094 | 1117 |
$form_state['display_id'] = $display_id; |
1095 | 1118 |
|
1096 |
// The part of the page where editing will take place. |
|
1097 |
// This element is the ctools collapsible-div container for the display edit elements.
|
|
1119 |
// The part of the page where editing will take place. This element is the
|
|
1120 |
// CTools collapsible-div container for the display edit elements.
|
|
1098 | 1121 |
$form['displays']['settings'] = array( |
1099 | 1122 |
'#theme_wrappers' => array('container'), |
1100 | 1123 |
'#attributes' => array( |
... | ... | |
1107 | 1130 |
'#id' => 'edit-display-settings', |
1108 | 1131 |
); |
1109 | 1132 |
$display_title = views_ui_get_display_label($view, $display_id, FALSE); |
1110 |
// Add a handle for the ctools collapsible-div. The handle is the title of the display |
|
1133 |
// Add a handle for the ctools collapsible-div. The handle is the title of |
|
1134 |
// the display. |
|
1111 | 1135 |
$form['displays']['settings']['tab_title']['#markup'] = '<h2 id="edit-display-settings-title" class="ctools-collapsible-handle">' . t('@display_title details', array('@display_title' => ucwords($display_title))) . '</h2>'; |
1112 | 1136 |
// Add a text that the display is disabled. |
1113 | 1137 |
if (!empty($view->display[$display_id]->handler)) { |
... | ... | |
1116 | 1140 |
$form['displays']['settings']['disabled']['#markup'] = t('This display is disabled.'); |
1117 | 1141 |
} |
1118 | 1142 |
} |
1119 |
// The ctools collapsible-div content |
|
1120 |
$form['displays']['settings']['settings_content']= array( |
|
1143 |
// The ctools collapsible-div content.
|
|
1144 |
$form['displays']['settings']['settings_content'] = array(
|
|
1121 | 1145 |
'#theme_wrappers' => array('container'), |
1122 | 1146 |
'#id' => 'edit-display-settings-content', |
1123 | 1147 |
'#attributes' => array( |
... | ... | |
1126 | 1150 |
), |
1127 | 1151 |
), |
1128 | 1152 |
); |
1129 |
// Add the edit display content |
|
1153 |
// Add the edit display content.
|
|
1130 | 1154 |
$form['displays']['settings']['settings_content']['tab_content'] = views_ui_get_display_tab($view, $display_id); |
1131 | 1155 |
$form['displays']['settings']['settings_content']['tab_content']['#theme_wrappers'] = array('container'); |
1132 | 1156 |
$form['displays']['settings']['settings_content']['tab_content']['#attributes'] = array('class' => array('views-display-tab')); |
... | ... | |
1172 | 1196 |
$form_state['no_cache'] = TRUE; |
1173 | 1197 |
$form_state['view'] = $view; |
1174 | 1198 |
|
1175 |
$form['#attributes'] = array('class' => array('clearfix',));
|
|
1199 |
$form['#attributes'] = array('class' => array('clearfix')); |
|
1176 | 1200 |
|
1177 | 1201 |
// Add a checkbox controlling whether or not this display auto-previews. |
1178 | 1202 |
$form['live_preview'] = array( |
... | ... | |
1182 | 1206 |
'#default_value' => variable_get('views_ui_always_live_preview', TRUE), |
1183 | 1207 |
); |
1184 | 1208 |
|
1185 |
// Add the arguments textfield |
|
1209 |
// Add the arguments textfield.
|
|
1186 | 1210 |
$form['view_args'] = array( |
1187 | 1211 |
'#type' => 'textfield', |
1188 | 1212 |
'#title' => t('Preview with contextual filters:'), |
1189 | 1213 |
'#description' => t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')), |
1190 | 1214 |
'#id' => 'preview-args', |
1191 |
// '#attributes' => array('class' => array('ctools-auto-submit')),
|
|
1215 |
// '#attributes' => array('class' => array('ctools-auto-submit')),
|
|
1192 | 1216 |
); |
1193 | 1217 |
|
1194 |
// Add the preview button |
|
1218 |
// Add the preview button.
|
|
1195 | 1219 |
$form['button'] = array( |
1196 | 1220 |
'#type' => 'submit', |
1197 | 1221 |
'#value' => t('Update preview'), |
... | ... | |
1211 | 1235 |
// Make ENTER in arguments textfield (and other controls) submit the form |
1212 | 1236 |
// as this button, not the Save button. |
1213 | 1237 |
// @todo This only works for JS users. To make this work for nojs users, |
1214 |
// we may need to split Preview into a separate form.
|
|
1238 |
// we may need to split Preview into a separate form. |
|
1215 | 1239 |
'#process' => array_merge(array('views_ui_default_button'), element_info_property('submit', '#process', array())), |
1216 | 1240 |
); |
1217 |
$form['#action'] = url('admin/structure/views/view/' . $view->name .'/preview/' . $display_id); |
|
1241 |
$form['#action'] = url('admin/structure/views/view/' . $view->name . '/preview/' . $display_id);
|
|
1218 | 1242 |
|
1219 | 1243 |
return $form; |
1220 | 1244 |
} |
... | ... | |
1227 | 1251 |
$element['#attributes']['class'] = array('views-display-top', 'clearfix'); |
1228 | 1252 |
$element['#attributes']['id'] = array('views-display-top'); |
1229 | 1253 |
|
1230 |
// Extra actions for the display |
|
1254 |
// Extra actions for the display.
|
|
1231 | 1255 |
$element['extra_actions'] = array( |
1232 | 1256 |
'#theme' => 'links__ctools_dropbutton', |
1233 | 1257 |
'#attributes' => array( |
1234 |
'id' => 'views-display-extra-actions', |
|
1235 |
'class' => array( |
|
1236 |
'horizontal', 'right', 'links', 'actions', |
|
1237 |
), |
|
1258 |
'id' => 'views-display-extra-actions', |
|
1259 |
'class' => array( |
|
1260 |
'horizontal', 'right', 'links', 'actions', |
|
1238 | 1261 |
), |
1262 |
), |
|
1239 | 1263 |
'#links' => array( |
1240 | 1264 |
'edit-details' => array( |
1241 | 1265 |
'title' => t('edit view name/description'), |
... | ... | |
1310 | 1334 |
return $element; |
1311 | 1335 |
} |
1312 | 1336 |
|
1337 |
/** |
|
1338 |
* |
|
1339 |
*/ |
|
1313 | 1340 |
function views_ui_get_default_ajax_message() { |
1314 | 1341 |
return '<div class="message">' . t("Click on an item to edit that item's details.") . '</div>'; |
1315 | 1342 |
} |
... | ... | |
1372 | 1399 |
* Submit handler to add a restore a removed display to a view. |
1373 | 1400 |
*/ |
1374 | 1401 |
function views_ui_edit_form_submit_undo_delete_display($form, &$form_state) { |
1375 |
// Create the new display |
|
1402 |
// Create the new display.
|
|
1376 | 1403 |
$id = $form_state['display_id']; |
1377 | 1404 |
$form_state['view']->display[$id]->deleted = FALSE; |
1378 | 1405 |
|
1379 |
// Store in cache |
|
1406 |
// Store in cache.
|
|
1380 | 1407 |
views_ui_cache_set($form_state['view']); |
1381 | 1408 |
|
1382 | 1409 |
// Redirect to the top-level edit page. |
... | ... | |
1388 | 1415 |
*/ |
1389 | 1416 |
function views_ui_edit_form_submit_enable_display($form, &$form_state) { |
1390 | 1417 |
$id = $form_state['display_id']; |
1391 |
// set_option doesn't work because this would might affect upper displays |
|
1418 |
// set_option doesn't work because this would might affect upper displays.
|
|
1392 | 1419 |
$form_state['view']->display[$id]->handler->set_option('enabled', TRUE); |
1393 | 1420 |
|
1394 |
// Store in cache |
|
1421 |
// Store in cache.
|
|
1395 | 1422 |
views_ui_cache_set($form_state['view']); |
1396 | 1423 |
|
1397 | 1424 |
// Redirect to the top-level edit page. |
... | ... | |
1405 | 1432 |
$id = $form_state['display_id']; |
1406 | 1433 |
$form_state['view']->display[$id]->handler->set_option('enabled', FALSE); |
1407 | 1434 |
|
1408 |
// Store in cache |
|
1435 |
// Store in cache.
|
|
1409 | 1436 |
views_ui_cache_set($form_state['view']); |
1410 | 1437 |
|
1411 | 1438 |
// Redirect to the top-level edit page. |
... | ... | |
1459 | 1486 |
* |
1460 | 1487 |
* @param view $view |
1461 | 1488 |
* The view which will be edited. |
1462 |
* @param $display_id |
|
1489 |
* @param string $display_id
|
|
1463 | 1490 |
* The display_id which is edited on the current request. |
1464 | 1491 |
*/ |
1465 |
function views_ui_edit_page_display_tabs($view, $display_id = NULL) { |
|
1492 |
function views_ui_edit_page_display_tabs(view $view, $display_id = NULL) {
|
|
1466 | 1493 |
$tabs = array(); |
1467 | 1494 |
|
1468 | 1495 |
// Create a tab for each display. |
... | ... | |
1483 | 1510 |
} |
1484 | 1511 |
} |
1485 | 1512 |
|
1486 |
// If the default display isn't supposed to be shown, don't display its tab, unless it's the only display. |
|
1513 |
// If the default display isn't supposed to be shown, don't display its tab, |
|
1514 |
// unless it's the only display. |
|
1487 | 1515 |
if ((!views_ui_show_default_display($view) && $display_id != 'default') && count($tabs) > 1) { |
1488 | 1516 |
$tabs['default']['#access'] = FALSE; |
1489 | 1517 |
} |
... | ... | |
1526 | 1554 |
// page. |
1527 | 1555 |
if (empty($display->handler)) { |
1528 | 1556 |
$title = isset($display->display_title) ? $display->display_title : t('Invalid'); |
1529 |
// @TODO: Improved UX for the case where a plugin is missing.
|
|
1557 |
// @todo: Improved UX for the case where a plugin is missing.
|
|
1530 | 1558 |
$build['#markup'] = t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array('@display' => $display->id, '@plugin' => $display->display_plugin)); |
1531 | 1559 |
} |
1532 | 1560 |
// Build the content of the edit page. |
... | ... | |
1542 | 1570 |
/** |
1543 | 1571 |
* Helper function to get the display details section of the edit UI. |
1544 | 1572 |
* |
1545 |
* @param $view |
|
1546 |
* @param $display |
|
1573 |
* @param view $view |
|
1574 |
* The full view object. |
|
1575 |
* @param object $display |
|
1576 |
* The display object to work with. |
|
1547 | 1577 |
* |
1548 | 1578 |
* @return array |
1549 | 1579 |
* A renderable page build array. |
... | ... | |
1552 | 1582 |
$display_title = views_ui_get_display_label($view, $display->id, FALSE); |
1553 | 1583 |
$build = array( |
1554 | 1584 |
'#theme_wrappers' => array('container'), |
1555 |
'#attributes' => array('id' => 'edit-display-settings-details',),
|
|
1585 |
'#attributes' => array('id' => 'edit-display-settings-details'), |
|
1556 | 1586 |
); |
1557 | 1587 |
|
1558 | 1588 |
$plugin = views_fetch_plugin_data('display', $view->display[$display->id]->display_plugin); |
1559 |
// The following is for display purposes only. We need to determine if there is more than one button and wrap |
|
1560 |
// the buttons in a .ctools-dropbutton class if more than one is present. Otherwise, we'll just wrap the |
|
1561 |
// actions in the .ctools-button class. |
|
1562 |
$isDisplayDeleted = !empty($display->deleted); |
|
1563 |
$isDeletable = empty($plugin['no remove']); |
|
1589 |
// The following is for display purposes only. We need to determine if there |
|
1590 |
// is more than one button and wrap the buttons in a .ctools-dropbutton class |
|
1591 |
// if more than one is present. Otherwise, we'll just wrap the actions in the |
|
1592 |
// .ctools-button class. |
|
1593 |
$is_display_deleted = !empty($display->deleted); |
|
1594 |
$is_deletable = empty($plugin['no remove']); |
|
1564 | 1595 |
// The master display cannot be cloned. |
1565 |
$isDefault = $display->id == 'default';
|
|
1596 |
$is_default = $display->id == 'default';
|
|
1566 | 1597 |
// @todo: Figure out why get_option doesn't work here. |
1567 |
$isEnabled = $display->handler->get_option('enabled');
|
|
1598 |
$is_enabled = $display->handler->get_option('enabled');
|
|
1568 | 1599 |
|
1569 |
if (!$isDisplayDeleted && $isDeletable && !$isDefault) {
|
|
1600 |
if (!$is_display_deleted && $is_deletable && !$is_default) {
|
|
1570 | 1601 |
$prefix = '<div class="ctools-no-js ctools-button ctools-dropbutton"><div class="ctools-link"><a href="#" class="ctools-twisty ctools-text">open</a></div><div class="ctools-content"><ul class="horizontal right actions">'; |
1571 | 1602 |
$suffix = '</ul></div></div>'; |
1572 |
$itemElement = 'li';
|
|
1603 |
$item_element = 'li';
|
|
1573 | 1604 |
} |
1574 | 1605 |
else { |
1575 | 1606 |
$prefix = '<div class="ctools-button"><div class="ctools-content"><ul class="horizontal right actions">'; |
1576 | 1607 |
$suffix = '</ul></div></div>'; |
1577 |
$itemElement = 'li';
|
|
1608 |
$item_element = 'li';
|
|
1578 | 1609 |
} |
1579 | 1610 |
|
1580 | 1611 |
if ($display->id != 'default') { |
1581 | 1612 |
$build['top']['#theme_wrappers'] = array('container'); |
1582 | 1613 |
$build['top']['#attributes']['id'] = 'edit-display-settings-top'; |
1583 |
$build['top']['#attributes']['class'] = array('views-ui-display-tab-actions', 'views-ui-display-tab-bucket', 'clearfix'); |
|
1614 |
$build['top']['#attributes']['class'] = array( |
|
1615 |
'views-ui-display-tab-actions', |
|
1616 |
'views-ui-display-tab-bucket', |
|
1617 |
'clearfix', |
|
1618 |
); |
|
1584 | 1619 |
|
1585 | 1620 |
// The Delete, Duplicate and Undo Delete buttons. |
1586 | 1621 |
$build['top']['actions'] = array( |
... | ... | |
1588 | 1623 |
'#suffix' => $suffix, |
1589 | 1624 |
); |
1590 | 1625 |
|
1591 |
if (!$isDisplayDeleted) {
|
|
1592 |
if (!$isEnabled) {
|
|
1626 |
if (!$is_display_deleted) {
|
|
1627 |
if (!$is_enabled) {
|
|
1593 | 1628 |
$build['top']['actions']['enable'] = array( |
1594 | 1629 |
'#type' => 'submit', |
1595 | 1630 |
'#value' => t('enable @display_title', array('@display_title' => $display_title)), |
1596 | 1631 |
'#limit_validation_errors' => array(), |
1597 |
'#submit' => array('views_ui_edit_form_submit_enable_display', 'views_ui_edit_form_submit_delay_destination'), |
|
1598 |
'#prefix' => '<' . $itemElement . ' class="enable">', |
|
1599 |
"#suffix" => '</' . $itemElement . '>', |
|
1632 |
'#submit' => array( |
|
1633 |
'views_ui_edit_form_submit_enable_display', |
|
1634 |
'views_ui_edit_form_submit_delay_destination', |
|
1635 |
), |
|
1636 |
'#prefix' => '<' . $item_element . ' class="enable">', |
|
1637 |
"#suffix" => '</' . $item_element . '>', |
|
1600 | 1638 |
); |
1601 | 1639 |
} |
1602 | 1640 |
// Add a link to view the page. |
... | ... | |
1606 | 1644 |
$build['top']['actions']['path'] = array( |
1607 | 1645 |
'#type' => 'link', |
1608 | 1646 |
'#title' => t('view @display', array('@display' => $display->display_title)), |
1609 |
'#options' => array('alt' => array(t("Go to the real page for this display"))), |
|
1647 |
'#options' => array( |
|
1648 |
'alt' => array(t('Go to the real page for this display')), |
|
1649 |
), |
|
1610 | 1650 |
'#href' => $path, |
1611 |
'#prefix' => '<' . $itemElement . ' class="view">',
|
|
1612 |
"#suffix" => '</' . $itemElement . '>',
|
|
1651 |
'#prefix' => '<' . $item_element . ' class="view">',
|
|
1652 |
"#suffix" => '</' . $item_element . '>',
|
|
1613 | 1653 |
); |
1614 | 1654 |
} |
1615 | 1655 |
} |
1616 |
if (!$isDefault) {
|
|
1656 |
if (!$is_default) {
|
|
1617 | 1657 |
$build['top']['actions']['duplicate'] = array( |
1618 | 1658 |
'#type' => 'submit', |
1619 | 1659 |
'#value' => t('clone @display_title', array('@display_title' => $display_title)), |
1620 | 1660 |
'#limit_validation_errors' => array(), |
1621 |
'#submit' => array('views_ui_edit_form_submit_duplicate_display', 'views_ui_edit_form_submit_delay_destination'), |
|
1622 |
'#prefix' => '<' . $itemElement . ' class="duplicate">', |
|
1623 |
"#suffix" => '</' . $itemElement . '>', |
|
1661 |
'#submit' => array( |
|
1662 |
'views_ui_edit_form_submit_duplicate_display', |
|
1663 |
'views_ui_edit_form_submit_delay_destination', |
|
1664 |
), |
|
1665 |
'#prefix' => '<' . $item_element . ' class="duplicate">', |
|
1666 |
"#suffix" => '</' . $item_element . '>', |
|
1624 | 1667 |
); |
1625 | 1668 |
} |
1626 |
if ($isDeletable) {
|
|
1669 |
if ($is_deletable) {
|
|
1627 | 1670 |
$build['top']['actions']['delete'] = array( |
1628 | 1671 |
'#type' => 'submit', |
1629 | 1672 |
'#value' => t('delete @display_title', array('@display_title' => $display_title)), |
1630 | 1673 |
'#limit_validation_errors' => array(), |
1631 |
'#submit' => array('views_ui_edit_form_submit_delete_display', 'views_ui_edit_form_submit_delay_destination'), |
|
1632 |
'#prefix' => '<' . $itemElement . ' class="delete">', |
|
1633 |
"#suffix" => '</' . $itemElement . '>', |
|
1674 |
'#submit' => array( |
|
1675 |
'views_ui_edit_form_submit_delete_display', |
|
1676 |
'views_ui_edit_form_submit_delay_destination', |
|
1677 |
), |
|
1678 |
'#prefix' => '<' . $item_element . ' class="delete">', |
|
1679 |
"#suffix" => '</' . $item_element . '>', |
|
1634 | 1680 |
); |
1635 | 1681 |
} |
1636 |
if ($isEnabled) {
|
|
1682 |
if ($is_enabled) {
|
|
1637 | 1683 |
$build['top']['actions']['disable'] = array( |
1638 | 1684 |
'#type' => 'submit', |
1639 | 1685 |
'#value' => t('disable @display_title', array('@display_title' => $display_title)), |
1640 | 1686 |
'#limit_validation_errors' => array(), |
1641 |
'#submit' => array('views_ui_edit_form_submit_disable_display', 'views_ui_edit_form_submit_delay_destination'), |
|
1642 |
'#prefix' => '<' . $itemElement . ' class="disable">', |
|
1643 |
"#suffix" => '</' . $itemElement . '>', |
|
1687 |
'#submit' => array( |
|
1688 |
'views_ui_edit_form_submit_disable_display', |
|
1689 |
'views_ui_edit_form_submit_delay_destination', |
|
1690 |
), |
|
1691 |
'#prefix' => '<' . $item_element . ' class="disable">', |
|
1692 |
"#suffix" => '</' . $item_element . '>', |
|
1644 | 1693 |
); |
1645 | 1694 |
} |
1646 | 1695 |
} |
... | ... | |
1649 | 1698 |
'#type' => 'submit', |
1650 | 1699 |
'#value' => t('undo delete of @display_title', array('@display_title' => $display_title)), |
1651 | 1700 |
'#limit_validation_errors' => array(), |
1652 |
'#submit' => array('views_ui_edit_form_submit_undo_delete_display', 'views_ui_edit_form_submit_delay_destination'), |
|
1653 |
'#prefix' => '<' . $itemElement . ' class="undo-delete">', |
|
1654 |
"#suffix" => '</' . $itemElement . '>', |
|
1701 |
'#submit' => array( |
|
1702 |
'views_ui_edit_form_submit_undo_delete_display', |
|
1703 |
'views_ui_edit_form_submit_delay_destination', |
|
1704 |
), |
|
1705 |
'#prefix' => '<' . $item_element . ' class="undo-delete">', |
|
1706 |
"#suffix" => '</' . $item_element . '>', |
|
1655 | 1707 |
); |
1656 | 1708 |
} |
1657 | 1709 |
|
... | ... | |
1665 | 1717 |
|
1666 | 1718 |
$build['columns'] = array(); |
1667 | 1719 |
$build['columns']['#theme_wrappers'] = array('container'); |
1668 |
$build['columns']['#attributes'] = array('id' => 'edit-display-settings-main', 'class' => array('clearfix', 'views-display-columns'),); |
|
1720 |
$build['columns']['#attributes'] = array( |
|
1721 |
'id' => 'edit-display-settings-main', |
|
1722 |
'class' => array('clearfix', 'views-display-columns'), |
|
1723 |
); |
|
1669 | 1724 |
|
1670 | 1725 |
$build['columns']['first']['#theme_wrappers'] = array('container'); |
1671 |
$build['columns']['first']['#attributes'] = array('class' => array('views-display-column', 'first')); |
|
1726 |
$build['columns']['first']['#attributes'] = array( |
|
1727 |
'class' => array('views-display-column', 'first'), |
|
1728 |
); |
|
1672 | 1729 |
|
1673 | 1730 |
$build['columns']['second']['#theme_wrappers'] = array('container'); |
1674 |
$build['columns']['second']['#attributes'] = array('class' => array('views-display-column', 'second')); |
|
1731 |
$build['columns']['second']['#attributes'] = array( |
|
1732 |
'class' => array('views-display-column', 'second'), |
|
1733 |
); |
|
1675 | 1734 |
|
1676 | 1735 |
$build['columns']['second']['settings'] = array(); |
1677 | 1736 |
$build['columns']['second']['header'] = array(); |
1678 | 1737 |
$build['columns']['second']['footer'] = array(); |
1679 | 1738 |
$build['columns']['second']['pager'] = array(); |
1680 | 1739 |
|
1681 |
// The third column buckets are wrapped in a CTools collapsible div |
|
1740 |
// The third column buckets are wrapped in a CTools collapsible div.
|
|
1682 | 1741 |
$build['columns']['third']['#theme_wrappers'] = array('container'); |
1683 |
$build['columns']['third']['#attributes'] = array('class' => array('views-display-column', 'third', 'ctools-collapsible-container', 'ctools-collapsible-remember')); |
|
1742 |
$build['columns']['third']['#attributes'] = array( |
|
1743 |
'class' => array( |
|
1744 |
'views-display-column', |
|
1745 |
'third', |
|
1746 |
'ctools-collapsible-container', |
|
1747 |
'ctools-collapsible-remember', |
|
1748 |
), |
|
1749 |
); |
|
1750 |
|
|
1684 | 1751 |
// Specify an id that won't change after AJAX requests, so ctools can keep |
1685 | 1752 |
// track of the user's preferred collapsible state. Use the same id across |
1686 | 1753 |
// different displays of the same view, so changing displays doesn't |
... | ... | |
1690 | 1757 |
if (!variable_get('views_ui_show_advanced_column', FALSE)) { |
1691 | 1758 |
$build['columns']['third']['#attributes']['class'][] = 'ctools-collapsed'; |
1692 | 1759 |
} |
1693 |
$build['columns']['third']['advanced'] = array('#markup' => '<h3 class="ctools-collapsible-handle"><a href="">' . t('Advanced') . '</a></h3>',);
|
|
1760 |
$build['columns']['third']['advanced'] = array('#markup' => '<h3 class="ctools-collapsible-handle"><a href="">' . t('Advanced') . '</a></h3>'); |
|
1694 | 1761 |
$build['columns']['third']['collapse']['#theme_wrappers'] = array('container'); |
1695 |
$build['columns']['third']['collapse']['#attributes'] = array('class' => array('ctools-collapsible-content',),); |
|
1762 |
$build['columns']['third']['collapse']['#attributes'] = array( |
|
1763 |
'class' => array('ctools-collapsible-content'), |
|
1764 |
); |
|
1696 | 1765 |
|
1697 | 1766 |
// Each option (e.g. title, access, display as grid/table/list) fits into one |
1698 | 1767 |
// of several "buckets," or boxes (Format, Fields, Sort, and so on). |
... | ... | |
1721 | 1790 |
} |
1722 | 1791 |
if (isset($bucket['build']) && is_array($bucket['build'])) { |
1723 | 1792 |
// The third column is a CTools collapsible div, so |
1724 |
// the structure of the form is a little different for this column |
|
1793 |
// the structure of the form is a little different for this column.
|
|
1725 | 1794 |
if ($column === 'third') { |
1726 | 1795 |
$build['columns'][$column]['collapse'][$id] = $bucket['build']; |
1727 | 1796 |
$build['columns'][$column]['collapse'][$id]['#theme_wrappers'][] = 'views_ui_display_tab_bucket'; |
... | ... | |
1789 | 1858 |
return $option_build; |
1790 | 1859 |
} |
1791 | 1860 |
|
1861 |
/** |
|
1862 |
* |
|
1863 |
*/ |
|
1792 | 1864 |
function template_preprocess_views_ui_display_tab_setting(&$variables) { |
1793 | 1865 |
static $zebra = 0; |
1794 | 1866 |
$variables['zebra'] = ($zebra % 2 === 0 ? 'odd' : 'even'); |
1795 | 1867 |
$zebra++; |
1796 | 1868 |
|
1797 |
// Put the main link to the left side |
|
1869 |
// Put the main link to the left side.
|
|
1798 | 1870 |
array_unshift($variables['settings_links'], $variables['link']); |
1799 | 1871 |
$variables['settings_links'] = implode('<span class="label"> | </span>', $variables['settings_links']); |
1800 | 1872 |
|
... | ... | |
1815 | 1887 |
} |
1816 | 1888 |
} |
1817 | 1889 |
|
1890 |
/** |
|
1891 |
* |
|
1892 |
*/ |
|
1818 | 1893 |
function template_preprocess_views_ui_display_tab_bucket(&$variables) { |
1819 | 1894 |
$element = $variables['element']; |
1820 | 1895 |
|
... | ... | |
1835 | 1910 |
$variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : ''; |
1836 | 1911 |
} |
1837 | 1912 |
|
1913 |
/** |
|
1914 |
* |
|
1915 |
*/ |
|
1838 | 1916 |
function template_preprocess_views_ui_display_tab_column(&$variables) { |
1839 | 1917 |
$element = $variables['element']; |
1840 | 1918 |
|
... | ... | |
2016 | 2094 |
elseif (version_compare($view->api_version, views_api_version(), '>')) { |
2017 | 2095 |
form_error($form['view'], t('That view is created for the version @import_version of views, but you only have @api_version', array( |
2018 | 2096 |
'@import_version' => $view->api_version, |
2019 |
'@api_version' => views_api_version()))); |
|
2097 |
'@api_version' => views_api_version(), |
|
2098 |
))); |
|
2020 | 2099 |
} |
2021 | 2100 |
|
2022 | 2101 |
// View name must be alphanumeric or underscores, no other punctuation. |
... | ... | |
2049 | 2128 |
|
2050 | 2129 |
// Bypass the validation of view pluigns/handlers if option is checked. |
2051 | 2130 |
if (!$form_state['values']['bypass_validation']) { |
2052 |
// Make sure that all plugins and handlers needed by this view actually exist. |
|
2131 |
// Make sure that all plugins and handlers needed by this view actually |
|
2132 |
// exist. |
|
2053 | 2133 |
foreach ($view->display as $id => $display) { |
2054 | 2134 |
if (empty($display->handler) || !empty($display->handler->broken)) { |
2055 |
drupal_set_message(t('Display plugin @plugin is not available.', array('@plugin' => $display->display_plugin)), 'error'); |
|
2135 |
drupal_set_message(t('Display plugin @plugin is not available.', array( |
|
2136 |
'@plugin' => $display->display_plugin, |
|
2137 |
)), 'error'); |
|
2056 | 2138 |
$broken = TRUE; |
2057 | 2139 |
continue; |
2058 | 2140 |
} |
2059 | 2141 |
|
2060 | 2142 |
$plugin = views_get_plugin('style', $display->handler->get_option('style_plugin')); |
2061 | 2143 |
if (!$plugin) { |
2062 |
drupal_set_message(t('Style plugin @plugin is not available.', array('@plugin' => $display->handler->get_option('style_plugin'))), 'error'); |
|
2144 |
drupal_set_message(t('Style plugin @plugin is not available.', array( |
|
2145 |
'@plugin' => $display->handler->get_option('style_plugin'), |
|
2146 |
)), 'error'); |
|
2063 | 2147 |
$broken = TRUE; |
2064 | 2148 |
} |
2065 | 2149 |
elseif ($plugin->uses_row_plugin()) { |
2066 | 2150 |
$plugin = views_get_plugin('row', $display->handler->get_option('row_plugin')); |
2067 | 2151 |
if (!$plugin) { |
2068 |
drupal_set_message(t('Row plugin @plugin is not available.', array('@plugin' => $display->handler->get_option('row_plugin'))), 'error'); |
|
2152 |
drupal_set_message(t('Row plugin @plugin is not available.', array( |
|
2153 |
'@plugin' => $display->handler->get_option('row_plugin'), |
|
2154 |
)), 'error'); |
|
2069 | 2155 |
$broken = TRUE; |
2070 | 2156 |
} |
2071 | 2157 |
} |
... | ... | |
2076 | 2162 |
foreach ($handlers as $id => $handler) { |
2077 | 2163 |
if ($handler->broken()) { |
2078 | 2164 |
drupal_set_message(t('@type handler @table.@field is not available.', array( |
2079 |
'@type' => $info['stitle'], |
|
2080 |
'@table' => $handler->table, |
|
2081 |
'@field' => $handler->field, |
|
2082 |
)), 'error'); |
|
2165 |
'@type' => $info['stitle'],
|
|
2166 |
'@table' => $handler->table,
|
|
2167 |
'@field' => $handler->field,
|
|
2168 |
)), 'error');
|
|
2083 | 2169 |
$broken = TRUE; |
2084 | 2170 |
} |
2085 | 2171 |
} |
... | ... | |
2135 | 2221 |
foreach ($form_state['view']->display as $id => $display) { |
2136 | 2222 |
if (!empty($display->new_id)) { |
2137 | 2223 |
$form_state['view']->display[$id]->id = $display->new_id; |
2138 |
// Redirect the user to the renamed display to be sure that the page itself exists and doesn't throw errors. |
|
2224 |
// Redirect the user to the renamed display to be sure that the page |
|
2225 |
// itself exists and doesn't throw errors. |
|
2139 | 2226 |
$form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->name . '/edit/' . $display->new_id; |
2140 | 2227 |
} |
2141 | 2228 |
} |
... | ... | |
2143 | 2230 |
// Direct the user to the right url, if the path of the display has changed. |
2144 | 2231 |
if (!empty($_GET['destination'])) { |
2145 | 2232 |
$destination = $_GET['destination']; |
2146 |
// Find out the first display which has a changed path and redirect to this url. |
|
2233 |
// Find out the first display which has a changed path and redirect to this |
|
2234 |
// URL. |
|
2147 | 2235 |
$old_view = views_get_view($form_state['view']->name); |
2148 | 2236 |
foreach ($old_view->display as $id => $display) { |
2149 | 2237 |
// Only check for displays with a path. |
... | ... | |
2179 | 2267 |
} |
2180 | 2268 |
} |
2181 | 2269 |
|
2270 |
/** |
|
2271 |
* |
|
2272 |
*/ |
|
2182 | 2273 |
function views_ui_edit_view_form_delete($form, &$form_state) { |
2183 | 2274 |
unset($_REQUEST['destination']); |
2184 |
// Redirect to the delete confirm page |
|
2275 |
// Redirect to the delete confirm page.
|
|
2185 | 2276 |
$form_state['redirect'] = array('admin/structure/views/view/' . $form_state['view']->name . '/delete', array('query' => drupal_get_destination() + array('cancel' => 'admin/structure/views/view/' . $form_state['view']->name . '/edit'))); |
2186 | 2277 |
} |
2187 | 2278 |
|
... | ... | |
2212 | 2303 |
case 'filter': |
2213 | 2304 |
$rearrange_url = "admin/structure/views/nojs/rearrange-$type/$view->name/$display->id/$type"; |
2214 | 2305 |
$rearrange_text = t('And/Or, Rearrange'); |
2215 |
// TODO: Add another class to have another symbol for filter rearrange.
|
|
2306 |
// @todo Add another class to have another symbol for filter rearrange.
|
|
2216 | 2307 |
$class = 'icon compact rearrange'; |
2217 | 2308 |
break; |
2309 |
|
|
2218 | 2310 |
case 'field': |
2219 | 2311 |
// Fetch the style plugin info so we know whether to list fields or not. |
2220 | 2312 |
$style_plugin = $display->handler->get_plugin(); |
... | ... | |
2240 | 2332 |
$actions['add'] = array( |
2241 | 2333 |
'title' => t('Add'), |
2242 | 2334 |
'href' => "admin/structure/views/nojs/add-item/$view->name/$display->id/$type", |
2243 |
'attributes'=> array('class' => array('icon compact add', 'views-ajax-link'), 'title' => t('Add'), 'id' => 'views-add-' . $type), |
|
2335 |
'attributes' => array('class' => array('icon compact add', 'views-ajax-link'), 'title' => t('Add'), 'id' => 'views-add-' . $type),
|
|
2244 | 2336 |
'html' => TRUE, |
2245 | 2337 |
); |
2246 | 2338 |
if ($count_handlers > 0) { |
... | ... | |
2252 | 2344 |
); |
2253 | 2345 |
} |
2254 | 2346 |
|
2255 |
// Render the array of links |
|
2347 |
// Render the array of links.
|
|
2256 | 2348 |
$build['#actions'] = theme('links__ctools_dropbutton', |
2257 | 2349 |
array( |
2258 | 2350 |
'links' => $actions, |
2259 | 2351 |
'attributes' => array( |
2260 |
'class' => array('inline', 'links', 'actions', 'horizontal', 'right') |
|
2352 |
'class' => array('inline', 'links', 'actions', 'horizontal', 'right'),
|
|
2261 | 2353 |
), |
2262 | 2354 |
'class' => array('views-ui-settings-bucket-operations'), |
2263 | 2355 |
) |
... | ... | |
2279 | 2371 |
|
2280 | 2372 |
static $relationships = NULL; |
2281 | 2373 |
if (!isset($relationships)) { |
2282 |
// Get relationship labels |
|
2374 |
// Get relationship labels.
|
|
2283 | 2375 |
$relationships = array(); |
2284 | 2376 |
// @todo: get_handlers() |
2285 | 2377 |
$handlers = $display->handler->get_option('relationships'); |
... | ... | |
2291 | 2383 |
} |
2292 | 2384 |
} |
2293 | 2385 |
|
2294 |
// Filters can now be grouped so we do a little bit extra:
|
|
2386 |
// Filters can now be grouped so we do a little bit extra.
|
|
2295 | 2387 |
$groups = array(); |
2296 | 2388 |
$grouping = FALSE; |
2297 | 2389 |
if ($type == 'filter') { |
... | ... | |
2334 | 2426 |
$build['fields'][$id]['#link'] = l($link_text, "admin/structure/views/nojs/config-item/$view->name/$display->id/$type/$id", array('attributes' => $link_attributes, 'html' => TRUE)); |
2335 | 2427 |
$build['fields'][$id]['#class'][] = drupal_clean_css_identifier($display->id . '-' . $type . '-' . $id); |
2336 | 2428 |
if (!empty($view->changed_sections[$display->id . '-' . $type . '-' . $id])) { |
2337 |
// @TODO: #changed is no longer being used?
|
|
2429 |
// @todo: #changed is no longer being used?
|
|
2338 | 2430 |
$build['fields'][$id]['#changed'] = TRUE; |
2339 | 2431 |
} |
2340 | 2432 |
|
2341 | 2433 |
if ($display->handler->use_group_by() && $handler->use_group_by()) { |
2342 |
$build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Aggregation settings') . '</span>', "admin/structure/views/nojs/config-item-group/$view->name/$display->id/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => true));
|
|
2434 |
$build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Aggregation settings') . '</span>', "admin/structure/views/nojs/config-item-group/$view->name/$display->id/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => TRUE));
|
|
2343 | 2435 |
} |
2344 | 2436 |
|
2345 | 2437 |
if ($handler->has_extra_options()) { |
2346 |
$build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Settings') . '</span>', "admin/structure/views/nojs/config-item-extra/$view->name/$display->id/$type/$id", array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => t('Settings')), 'html' => true));
|
|
2438 |
$build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Settings') . '</span>', "admin/structure/views/nojs/config-item-extra/$view->name/$display->id/$type/$id", array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => t('Settings')), 'html' => TRUE));
|
|
2347 | 2439 |
} |
2348 | 2440 |
|
2349 | 2441 |
if ($grouping) { |
... | ... | |
2357 | 2449 |
} |
2358 | 2450 |
} |
2359 | 2451 |
|
2360 |
// If using grouping, re-order fields so that they show up properly in the list. |
|
2452 |
// If using grouping, re-order fields so that they show up properly in the |
|
2453 |
// list. |
|
2361 | 2454 |
if ($type == 'filter' && $grouping) { |
2362 | 2455 |
$store = $build['fields']; |
2363 | 2456 |
$build['fields'] = array(); |
... | ... | |
2405 | 2498 |
} |
2406 | 2499 |
|
2407 | 2500 |
/** |
2408 |
* Recursively adds microweights to a render array, similar to what form_builder() does for forms. |
|
2501 |
* Recursively adds microweights to a render array. |
|
2502 |
* |
|
2503 |
* Similar to what form_builder() does for forms. |
|
2409 | 2504 |
* |
2410 | 2505 |
* @todo Submit a core patch to fix drupal_render() to do this, so that all |
2411 | 2506 |
* render arrays automatically preserve array insertion order, as forms do. |
... | ... | |
2414 | 2509 |
$count = 0; |
2415 | 2510 |
foreach (element_children($build) as $key) { |
2416 | 2511 |
if (!isset($build[$key]['#weight'])) { |
2417 |
$build[$key]['#weight'] = $count/1000;
|
|
2512 |
$build[$key]['#weight'] = $count / 1000;
|
|
2418 | 2513 |
} |
2419 | 2514 |
views_ui_add_microweights($build[$key]); |
2420 | 2515 |
$count++; |
... | ... | |
2499 | 2594 |
); |
2500 | 2595 |
} |
2501 | 2596 |
|
2502 |
// Compatibility, to be removed later: // TODO: When is "later"?
|
|
2503 |
// We used to set these items on the form, but now we want them on the $form_state:
|
|
2597 |
// Compatibility, to be removed later: // @todo When is "later"? We used to
|
|
2598 |
// set these items on the form, but now we want them on the $form_state.
|
|
2504 | 2599 |
if (isset($form['#title'])) { |
2505 | 2600 |
$form_state['title'] = $form['#title']; |
2506 | 2601 |
} |
... | ... | |
2535 | 2630 |
function views_ui_standard_submit($form, &$form_state) { |
2536 | 2631 |
// Determine whether the values the user entered are intended to apply to |
2537 | 2632 |
// the current display or the default display. |
2538 |
|
|
2539 | 2633 |
list($was_defaulted, $is_defaulted, $revert) = views_ui_standard_override_values($form, $form_state); |
2540 | 2634 |
|
2541 | 2635 |
// Mark the changed section of the view as changed. |
2542 |
// TODO: Document why we are doing this, and see if we still need it.
|
|
2636 |
// @todo Document why we are doing this, and see if we still need it.
|
|
2543 | 2637 |
if (!empty($form['#section'])) { |
2544 | 2638 |
$form_state['view']->changed_sections[$form['#section']] = TRUE; |
2545 | 2639 |
} |
... | ... | |
2551 | 2645 |
$display = &$form_state['view']->display[$form_state['display_id']]; |
2552 | 2646 |
$display->handler->options_override($form, $form_state); |
2553 | 2647 |
|
2554 |
// Don't execute the normal submit handling but still store the changed view into cache. |
|
2648 |
// Don't execute the normal submit handling but still store the changed |
|
2649 |
// view into cache. |
|
2555 | 2650 |
views_ui_cache_set($form_state['view']); |
2556 | 2651 |
return; |
2557 | 2652 |
} |
... | ... | |
2590 | 2685 |
function views_ui_standard_override_values($form, $form_state) { |
2591 | 2686 |
// Make sure the dropdown exists in the first place. |
2592 | 2687 |
if (isset($form_state['values']['override']['dropdown'])) { |
2593 |
// #default_value is used to determine whether it was the default value or not. |
|
2594 |
// So the available options are: $display, 'default' and 'default_revert', not 'defaults'. |
|
2688 |
// #default_value is used to determine whether it was the default value or |
|
2689 |
// not. So the available options are: $display, 'default' and |
|
2690 |
// 'default_revert', not 'defaults'. |
|
2595 | 2691 |
$was_defaulted = ($form['override']['dropdown']['#default_value'] === 'defaults'); |
2596 | 2692 |
$is_defaulted = ($form_state['values']['override']['dropdown'] === 'default'); |
2597 | 2693 |
$revert = ($form_state['values']['override']['dropdown'] === 'default_revert'); |
... | ... | |
2613 | 2709 |
} |
2614 | 2710 |
|
2615 | 2711 |
/** |
2616 |
* Submit handler for cancel button |
|
2712 |
* Submit handler for cancel button.
|
|
2617 | 2713 |
*/ |
2618 | 2714 |
function views_ui_standard_cancel($form, &$form_state) { |
2619 | 2715 |
if (!empty($form_state['view']->changed) && isset($form_state['view']->form_cache)) { |
... | ... | |
2625 | 2721 |
} |
2626 | 2722 |
|
2627 | 2723 |
/** |
2628 |
* Add a <select> dropdown for a given section, allowing the user to |
|
2629 |
* change whether this info is stored on the default display or on |
|
2630 |
* the current display. |
|
2724 |
* Add a <select> dropdown for a given section. |
|
2725 |
* |
|
2726 |
* Allows the user to change whether this info is stored on the default display |
|
2727 |
* or on the current display. |
|
2631 | 2728 |
*/ |
2632 | 2729 |
function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { |
2633 | 2730 |
$view = &$form_state['view']; |
... | ... | |
2636 | 2733 |
$current_display = $view->display[$display_id]; |
2637 | 2734 |
|
2638 | 2735 |
// Add the "2 of 3" progress indicator. |
2639 |
// @TODO: Move this to a separate function if it's needed on any forms that
|
|
2736 |
// @todo: Move this to a separate function if it's needed on any forms that
|
|
2640 | 2737 |
// don't have the display dropdown. |
2641 | 2738 |
if ($form_progress = views_ui_get_form_progress($view)) { |
2642 | 2739 |
$form['progress']['#markup'] = '<div id="views-progress-indicator">' . t('@current of @total', array('@current' => $form_progress['current'], '@total' => $form_progress['total'])) . '</div>'; |
... | ... | |
2674 | 2771 |
); |
2675 | 2772 |
$form['override']['dropdown'] = array( |
2676 | 2773 |
'#type' => 'select', |
2677 |
'#title' => t('For'), // @TODO: Translators may need more context than this. |
|
2774 |
'#title' => t('For'), |
|
2775 |
// @todo: Translators may need more context than this. |
|
2678 | 2776 |
'#options' => $display_dropdown, |
2679 | 2777 |
); |
2680 | 2778 |
if ($current_display->handler->is_defaulted($section)) { |
... | ... | |
2689 | 2787 |
/** |
2690 | 2788 |
* Get the user's current progress through the form stack. |
2691 | 2789 |
* |
2692 |
* @param $view |
|
2790 |
* @param view $view
|
|
2693 | 2791 |
* The current view. |
2694 | 2792 |
* |
2695 | 2793 |
* @return |
... | ... | |
2721 | 2819 |
|
2722 | 2820 |
// -------------------------------------------------------------------------- |
2723 | 2821 |
// Various subforms for editing the pieces of a view. |
2724 |
|
|
2725 | 2822 |
function views_ui_ajax_forms($key = NULL) { |
2726 | 2823 |
$forms = array( |
2727 | 2824 |
'display' => array( |
... | ... | |
2809 | 2906 |
*/ |
2810 | 2907 |
function views_ui_build_form_state($js, $key, &$view, $display_id, $args) { |
2811 | 2908 |
$form = views_ui_ajax_forms($key); |
2812 |
// Build up form state |
|
2909 |
// Build up form state.
|
|
2813 | 2910 |
$form_state = array( |
2814 | 2911 |
'form_key' => $key, |
2815 | 2912 |
'form_id' => $form['form_id'], |
... | ... | |
2903 | 3000 |
|
2904 | 3001 |
views_include('ajax'); |
2905 | 3002 |
$args = func_get_args(); |
2906 |
// Remove the known args |
|
3003 |
// Remove the known args.
|
|
2907 | 3004 |
array_splice($args, 0, 4); |
2908 | 3005 |
|
2909 | 3006 |
$form_state = views_ui_build_form_state($js, $key, $view, $display_id, $args); |
... | ... | |
2915 | 3012 |
// Retrieve the first form from the stack without changing the integer keys, |
2916 | 3013 |
// as they're being used for the "2 of 3" progress indicator. |
2917 | 3014 |
reset($view->stack); |
2918 |
list($key, $top) = each($view->stack); |
|
3015 |
$key = key($view->stack); |
|
3016 |
$top = current($view->stack); |
|
2919 | 3017 |
unset($view->stack[$key]); |
2920 |
|
|
2921 | 3018 |
if (array_shift($top) != $identifier) { |
2922 | 3019 |
$view->stack = array(); |
2923 | 3020 |
} |
... | ... | |
2933 | 3030 |
// With the below logic, we may end up rendering a form twice (or two forms |
2934 | 3031 |
// each sharing the same element ids), potentially resulting in |
2935 | 3032 |
// drupal_add_js() being called twice to add the same setting. drupal_get_js() |
2936 |
// is ok with that, but until ajax_render() is (http://drupal.org/node/208611), |
|
2937 |
// reset the drupal_add_js() static before rendering the second time. |
|
3033 |
// is ok with that, but until ajax_render() is, reset the drupal_add_js() |
|
3034 |
// static before rendering the second time. |
|
3035 |
// @see http://drupal.org/node/208611 |
|
2938 | 3036 |
$drupal_add_js_original = drupal_add_js(); |
2939 | 3037 |
$drupal_add_js = &drupal_static('drupal_add_js'); |
2940 | 3038 |
$output = views_ajax_form_wrapper($form_state['form_id'], $form_state); |
... | ... | |
2955 | 3053 |
$output = views_ajax_form_wrapper($form_state['form_id'], $form_state); |
2956 | 3054 |
} |
2957 | 3055 |
elseif (!$js) { |
2958 |
// if nothing on the stack, non-js forms just go back to the main view editor. |
|
3056 |
// If nothing on the stack, non-js forms just go back to the main view |
|
3057 |
// editor. |
|
2959 | 3058 |
return drupal_goto("admin/structure/views/view/$view->name/edit"); |
2960 | 3059 |
} |
2961 | 3060 |
else { |
... | ... | |
2981 | 3080 |
* Submit handler to add a restore a removed display to a view. |
2982 | 3081 |
*/ |
2983 | 3082 |
function views_ui_remove_display_form_restore($form, &$form_state) { |
2984 |
// Create the new display |
|
3083 |
// Create the new display.
|
|
2985 | 3084 |
$id = $form_state['display_id']; |
2986 | 3085 |
$form_state['view']->display[$id]->deleted = FALSE; |
2987 | 3086 |
|
2988 |
// Store in cache |
|
3087 |
// Store in cache.
|
|
2989 | 3088 |
views_ui_cache_set($form_state['view']); |
2990 | 3089 |
} |
2991 | 3090 |
|
2992 | 3091 |
/** |
2993 |
* Form constructor callback to display analysis information on a view |
|
3092 |
* Form constructor callback to display analysis information on a view.
|
|
2994 | 3093 |
*/ |
2995 | 3094 |
function views_ui_analyze_view_form($form, &$form_state) { |
2996 | 3095 |
$view = &$form_state['view']; |
... | ... | |
3014 | 3113 |
} |
3015 | 3114 |
|
3016 | 3115 |
/** |
3017 |
* Submit handler for views_ui_analyze_view_form |
|
3116 |
* Submit handler for views_ui_analyze_view_form.
|
|
3018 | 3117 |
*/ |
3019 | 3118 |
function views_ui_analyze_view_form_submit($form, &$form_state) { |
3020 | 3119 |
$form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->name . '/edit'; |
3021 | 3120 |
} |
3022 | 3121 |
|
3023 | 3122 |
/** |
3024 |
* Form constructor callback to reorder displays on a view |
|
3123 |
* Form constructor callback to reorder displays on a view.
|
|
3025 | 3124 |
*/ |
3026 | 3125 |
function views_ui_reorder_displays_form($form, &$form_state) { |
3027 | 3126 |
$view = &$form_state['view']; |
... | ... | |
3066 | 3165 |
$form['#title'] = t('Displays Reorder'); |
3067 | 3166 |
$form['#section'] = 'reorder'; |
3068 | 3167 |
|
3069 |
// Add javascript settings that will be added via $.extend for tabledragging |
|
3168 |
// Add javascript settings that will be added via $.extend for tabledragging.
|
|
3070 | 3169 |
$form['#js']['tableDrag']['reorder-displays']['weight'][0] = array( |
3071 | 3170 |
'target' => 'weight', |
3072 | 3171 |
'source' => NULL, |
... | ... | |
3084 | 3183 |
} |
3085 | 3184 |
|
3086 | 3185 |
/** |
3087 |
* Display position sorting function |
|
3186 |
* Display position sorting function.
|
|
3088 | 3187 |
*/ |
3089 | 3188 |
function _views_position_sort($display1, $display2) { |
3090 | 3189 |
if ($display1->position != $display2->position) { |
... | ... | |
3095 | 3194 |
} |
3096 | 3195 |
|
3097 | 3196 |
/** |
3098 |
* Submit handler for rearranging display form |
|
3197 |
* Submit handler for rearranging display form.
|
|
3099 | 3198 |
*/ |
3100 | 3199 |
function views_ui_reorder_displays_form_submit($form, &$form_state) { |
3101 |
foreach($form_state['input'] as $display => $info) { |
|
3200 |
foreach ($form_state['input'] as $display => $info) {
|
|
3102 | 3201 |
// add each value that is a field with a weight to our list, but only if |
3103 | 3202 |
// it has had its 'removed' checkbox checked. |
3104 | 3203 |
if (is_array($info) && isset($info['weight']) && empty($info['removed'])) { |
... | ... | |
3106 | 3205 |
} |
3107 | 3206 |
} |
3108 | 3207 |
|
3109 |
// Sort the order array |
|
3208 |
// Sort the order array.
|
|
3110 | 3209 |
asort($order); |
3111 | 3210 |
|
3112 |
// Fixing up positions |
|
3211 |
// Fixing up positions.
|
|
3113 | 3212 |
$position = 2; |
3114 | 3213 |
|
3115 |
foreach(array_keys($order) as $display) { |
|
3214 |
foreach (array_keys($order) as $display) {
|
|
3116 | 3215 |
$order[$display] = $position++; |
3117 | 3216 |
} |
3118 | 3217 |
|
3119 |
// Setting up position and removing deleted displays |
|
3218 |
// Setting up position and removing deleted displays.
|
|
3120 | 3219 |
$displays = $form_state['view']->display; |
3121 |
foreach($displays as $display_id => $display) { |
|
3220 |
foreach ($displays as $display_id => $display) {
|
|
3122 | 3221 |
// Don't touch the default !!! |
3123 | 3222 |
if ($display_id === 'default') { |
3124 | 3223 |
continue; |
... | ... | |
3131 | 3230 |
} |
3132 | 3231 |
} |
3133 | 3232 |
|
3134 |
// Sorting back the display array as the position is not enough |
|
3233 |
// Sorting back the display array as the position is not enough.
|
|
3135 | 3234 |
uasort($form_state['view']->display, '_views_position_sort'); |
3136 | 3235 |
|
3137 |
// Store in cache |
|
3236 |
// Store in cache.
|
|
3138 | 3237 |
views_ui_cache_set($form_state['view']); |
3139 | 3238 |
$form_state['redirect'] = array('admin/structure/views/view/' . $form_state['view']->name . '/edit', array('fragment' => 'views-tab-default')); |
3140 | 3239 |
} |
3141 | 3240 |
|
3142 | 3241 |
/** |
3143 |
* Turn the reorder form into a proper table |
|
3242 |
* Turn the reorder form into a proper table.
|
|
3144 | 3243 |
*/ |
3145 | 3244 |
function theme_views_ui_reorder_displays_form($vars) { |
3146 | 3245 |
$form = $vars['form']; |
... | ... | |
3187 | 3286 |
$output = drupal_render($form['override']); |
3188 | 3287 |
$output .= '<div class="scroll">'; |
3189 | 3288 |
$output .= theme('table', |
3190 |
array('header' => $header, |
|
3191 |
'rows' => $rows, |
|
3192 |
'attributes' => array('id' => 'reorder-displays'), |
|
3193 |
)); |
|
3289 |
array( |
|
3290 |
'header' => $header, |
|
3291 |
'rows' => $rows, |
|
3292 |
'attributes' => array('id' => 'reorder-displays'), |
|
3293 |
)); |
|
3194 | 3294 |
$output .= '</div>'; |
3195 | 3295 |
$output .= drupal_render_children($form); |
3196 | 3296 |
|
... | ... | |
3251 | 3351 |
} |
3252 | 3352 |
|
3253 | 3353 |
/** |
3254 |
* Form constructor callback to edit display of a view |
|
3354 |
* Form constructor callback to edit display of a view.
|
|
3255 | 3355 |
*/ |
3256 | 3356 |
function views_ui_edit_display_form($form, &$form_state) { |
3257 | 3357 |
$view = &$form_state['view']; |
... | ... | |
3291 | 3391 |
} |
3292 | 3392 |
|
3293 | 3393 |
/** |
3294 |
* Validate handler for views_ui_edit_display_form |
|
3394 |
* Validate handler for views_ui_edit_display_form.
|
|
3295 | 3395 |
*/ |
3296 | 3396 |
function views_ui_edit_display_form_validate($form, &$form_state) { |
3297 | 3397 |
$display = &$form_state['view']->display[$form_state['display_id']]; |
... | ... | |
3303 | 3403 |
} |
3304 | 3404 |
|
3305 | 3405 |
/** |
3306 |
* Submit handler for views_ui_edit_display_form |
|
3406 |
* Submit handler for views_ui_edit_display_form.
|
|
3307 | 3407 |
*/ |
3308 | 3408 |
function views_ui_edit_display_form_submit($form, &$form_state) { |
3309 | 3409 |
$display = &$form_state['view']->display[$form_state['display_id']]; |
... | ... | |
3313 | 3413 |
} |
3314 | 3414 |
|
3315 | 3415 |
/** |
3316 |
* Override handler for views_ui_edit_display_form |
|
3416 |
* Override handler for views_ui_edit_display_form.
|
|
3317 | 3417 |
* |
3318 |
* @TODO: Not currently used. Remove unless we implement an override toggle.
|
|
3418 |
* @todo: Not currently used. Remove unless we implement an override toggle.
|
|
3319 | 3419 |
*/ |
3320 | 3420 |
function views_ui_edit_display_form_override($form, &$form_state) { |
3321 | 3421 |
$display = &$form_state['view']->display[$form_state['display_id']]; |
... | ... | |
3363 | 3463 |
} |
3364 | 3464 |
|
3365 | 3465 |
/** |
3366 |
* Submit handler for type configuration form |
|
3466 |
* Submit handler for type configuration form.
|
|
3367 | 3467 |
*/ |
3368 | 3468 |
function views_ui_config_type_form_submit($form, &$form_state) { |
3369 | 3469 |
$types = views_object_types(); |
3370 | 3470 |
$display = &$form_state['view']->display[$form_state['display_id']]; |
3371 | 3471 |
|
3372 |
// Store in cache |
|
3472 |
// Store in cache.
|
|
3373 | 3473 |
views_ui_cache_set($form_state['view']); |
3374 | 3474 |
} |
3375 | 3475 |
|
... | ... | |
3396 | 3496 |
|
3397 | 3497 |
$count = 0; |
3398 | 3498 |
|
3399 |
// Get relationship labels |
|
3499 |
// Get relationship labels.
|
|
3400 | 3500 |
$relationships = array(); |
3401 | 3501 |
foreach ($display->handler->get_handlers('relationship') as $id => $handler) { |
3402 | 3502 |
$relationships[$id] = $handler->label(); |
... | ... | |
3409 | 3509 |
} |
3410 | 3510 |
} |
3411 | 3511 |
|
3412 |
// Filters can now be grouped so we do a little bit extra:
|
|
3512 |
// Filters can now be grouped so we do a little bit extra.
|
|
3413 | 3513 |
$groups = array(); |
3414 | 3514 |
$grouping = FALSE; |
3415 | 3515 |
if ($type == 'filter') { |
... | ... | |
3448 | 3548 |
); |
3449 | 3549 |
} |
3450 | 3550 |
|
3451 |
// Add javascript settings that will be added via $.extend for tabledragging |
|
3551 |
// Add javascript settings that will be added via $.extend for tabledragging.
|
|
3452 | 3552 |
$form['#js']['tableDrag']['arrange']['weight'][0] = array( |
3453 | 3553 |
'target' => 'weight', |
3454 | 3554 |
'source' => NULL, |
... | ... | |
3468 | 3568 |
} |
3469 | 3569 |
|
3470 | 3570 |
/** |
3471 |
* Turn the rearrange form into a proper table |
|
3571 |
* Turn the rearrange form into a proper table.
|
|
3472 | 3572 |
*/ |
3473 | 3573 |
function theme_views_ui_rearrange_form($variables) { |
3474 | 3574 |
$form = $variables['form']; |
... | ... | |
3524 | 3624 |
$output .= '</div>'; |
3525 | 3625 |
} |
3526 | 3626 |
|
3527 |
// Only output the right column markup if there's a left column to begin with |
|
3627 |
// Only output the right column markup if there's a left column to begin with.
|
|
3528 | 3628 |
if (!empty($form['operator']['#type'])) { |
3529 | 3629 |
$output .= '<div class="views-right-60">'; |
3530 | 3630 |
$output .= drupal_render_children($form); |
... | ... | |
3539 | 3639 |
return $output; |
3540 | 3640 |
} |
3541 | 3641 |
|
3542 |
/**
|
|
3642 |
/** |
|
3543 | 3643 |
* Theme the build group filter form. |
3544 | 3644 |
*/ |
3545 | 3645 |
function theme_views_ui_build_group_filter_form($variables) { |
... | ... | |
3567 | 3667 |
$output .= drupal_render($form['description']); |
3568 | 3668 |
$output .= '</div>'; |
3569 | 3669 |
|
3570 |
|
|
3571 | 3670 |
$header = array( |
3572 | 3671 |
t('Default'), |
3573 | 3672 |
t('Weight'), |
... | ... | |
3581 | 3680 |
$form['default_group_multiple'] = form_process_checkboxes($form['default_group_multiple']); |
3582 | 3681 |
$form['default_group']['All']['#title'] = ''; |
3583 | 3682 |
|
3584 |
drupal_render($form['default_group_multiple']['All']); // Don't render |
|
3683 |
drupal_render($form['default_group_multiple']['All']); |
|
3684 |
// Don't render. |
|
3585 | 3685 |
$rows[] = array( |
3586 | 3686 |
drupal_render($form['default_group']['All']), |
3587 | 3687 |
'', |
... | ... | |
3600 | 3700 |
'title' => drupal_render($form['group_items'][$group_id]['title']), |
3601 | 3701 |
'operator' => drupal_render($form['group_items'][$group_id]['operator']), |
3602 | 3702 |
'value' => drupal_render($form['group_items'][$group_id]['value']), |
3603 |
'remove' => drupal_render($form['group_items'][$group_id]['remove']) . l('<span>' . t('Remove') . '</span>', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $group_id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => true)),
|
|
3703 |
'remove' => drupal_render($form['group_items'][$group_id]['remove']) . l('<span>' . t('Remove') . '</span>', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $group_id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => TRUE)),
|
|
3604 | 3704 |
); |
3605 | 3705 |
$rows[] = array('data' => $data, 'id' => 'views-row-' . $group_id, 'class' => array('draggable')); |
3606 | 3706 |
} |
... | ... | |
3612 | 3712 |
|
3613 | 3713 |
|
3614 | 3714 |
/** |
3615 |
* Submit handler for rearranging form |
|
3715 |
* Submit handler for rearranging form.
|
|
3616 | 3716 |
*/ |
3617 | 3717 |
function views_ui_rearrange_form_submit($form, &$form_state) { |
3618 | 3718 |
$types = views_object_types(); |
... | ... | |
3621 | 3721 |
$old_fields = $display->handler->get_option($types[$form_state['type']]['plural']); |
3622 | 3722 |
$new_fields = $order = array(); |
3623 | 3723 |
|
3624 |
// Make an array with the weights |
|
3724 |
// Make an array with the weights.
|
|
3625 | 3725 |
foreach ($form_state['values'] as $field => $info) { |
3626 | 3726 |
// add each value that is a field with a weight to our list, but only if |
3627 | 3727 |
// it has had its 'removed' checkbox checked. |
... | ... | |
3630 | 3730 |
} |
3631 | 3731 |
} |
3632 | 3732 |
|
3633 |
// Sort the array |
|
3733 |
// Sort the array.
|
|
3634 | 3734 |
asort($order); |
3635 | 3735 |
|
3636 | 3736 |
// Create a new list of fields in the new order. |
... | ... | |
3639 | 3739 |
} |
3640 | 3740 |
$display->handler->set_option($types[$form_state['type']]['plural'], $new_fields); |
3641 | 3741 |
|
3642 |
// Store in cache |
|
3742 |
// Store in cache.
|
|
3643 | 3743 |
views_ui_cache_set($form_state['view']); |
3644 | 3744 |
} |
3645 | 3745 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules