Révision ef1afbb9
Ajouté par Assos Assos il y a plus de 6 ans
drupal7/sites/all/modules/views/views_ui.module | ||
---|---|---|
5 | 5 |
* Provide structure for the administrative interface to Views. |
6 | 6 |
*/ |
7 | 7 |
|
8 |
/** |
|
9 |
* Implements hook_help(). |
|
10 |
*/ |
|
11 |
function views_ui_help($path, $arg) { |
|
12 |
switch ($path) { |
|
13 |
case 'admin/help#views_ui': |
|
14 |
$output = ''; |
|
15 |
$output .= '<h3>' . t('About') . '</h3>'; |
|
16 |
$output .= '<p>' . t('The Views UI module provides an interface for managing views for the Views module. For more information, see the <a href="@views" target="blank">online documentation for the Views UI module</a>.', array('@views' => 'https://www.drupal.org/documentation/modules/views')) . '</p>'; |
|
17 |
$output .= '<h3>' . t('Uses') . '</h3>'; |
|
18 |
$output .= '<dl>'; |
|
19 |
$output .= '<dt>' . t('Creating and managing views') . '</dt>'; |
|
20 |
$output .= '<dd>' . t('Views can be created from the <a href="/admin/structure/views">Views list page</a> by using the "Add view" action. Existing views can be managed from the <a href="/admin/structure/views">Views list page</a> by locating the view in the "Enabled" or "Disabled" list and selecting the desired operation action, for example "Edit".') . '</dd>'; |
|
21 |
|
|
22 |
$output .= '<dt>' . t('Enabling and disabling views') . '</dt>'; |
|
23 |
$output .= '<dd>' . t('Views can be enabled or disabled from the <a href="/admin/structure/views">Views list page</a>. To enable a view, find the view within the "Disabled" list and select the "Enable" operation. To disable a view find the view within the "Enabled" list and select the "Disable" operation.') . '</dd>'; |
|
24 |
|
|
25 |
$output .= '<dt>' . t('Exporting and importing views') . '</dt>'; |
|
26 |
$output .= '<dd>' . t('Views can be exported and imported as configuration files by using the Configuration Manager module.') . '</dd>'; |
|
27 |
return $output; |
|
28 |
} |
|
29 |
} |
|
30 |
|
|
8 | 31 |
/** |
9 | 32 |
* Implements hook_menu(). |
10 | 33 |
*/ |
... | ... | |
96 | 119 |
) + $base; |
97 | 120 |
|
98 | 121 |
// Additional pages for acting on a View. |
99 |
|
|
100 | 122 |
$items['admin/structure/views/view/%views_ui_cache/break-lock'] = array( |
101 | 123 |
'title' => 'Break lock', |
102 | 124 |
'page callback' => 'drupal_get_form', |
... | ... | |
143 | 165 |
'type' => MENU_CALLBACK, |
144 | 166 |
) + $base; |
145 | 167 |
|
146 |
// A page in the Reports section to show usage of fields in all views |
|
168 |
// A page in the Reports section to show usage of fields in all views.
|
|
147 | 169 |
$items['admin/reports/fields/list'] = array( |
148 | 170 |
'title' => 'List', |
149 | 171 |
'type' => MENU_DEFAULT_LOCAL_TASK, |
... | ... | |
175 | 197 |
require_once DRUPAL_ROOT . "/$path/includes/admin.inc"; |
176 | 198 |
|
177 | 199 |
return array( |
178 |
// edit a view
|
|
200 |
// Edit a view.
|
|
179 | 201 |
'views_ui_display_tab_setting' => array( |
180 |
'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()), |
|
202 |
'variables' => array( |
|
203 |
'description' => '', |
|
204 |
'link' => '', |
|
205 |
'settings_links' => array(), |
|
206 |
'overridden' => FALSE, |
|
207 |
'defaulted' => FALSE, |
|
208 |
'description_separator' => TRUE, |
|
209 |
'class' => array(), |
|
210 |
), |
|
181 | 211 |
'template' => 'views-ui-display-tab-setting', |
182 | 212 |
'path' => "$path/theme", |
183 | 213 |
), |
... | ... | |
198 | 228 |
'file' => 'includes/admin.inc', |
199 | 229 |
), |
200 | 230 |
|
201 |
// list views
|
|
231 |
// List views.
|
|
202 | 232 |
'views_ui_view_info' => array( |
203 | 233 |
'variables' => array('view' => NULL, 'base' => NULL), |
204 | 234 |
'file' => "includes/admin.inc", |
... | ... | |
210 | 240 |
'file' => 'includes/admin.inc', |
211 | 241 |
), |
212 | 242 |
|
213 |
// tab themes
|
|
243 |
// Tab themes.
|
|
214 | 244 |
'views_tabset' => array( |
215 | 245 |
'variables' => array('tabs' => NULL), |
216 | 246 |
), |
... | ... | |
222 | 252 |
'file' => 'includes/admin.inc', |
223 | 253 |
), |
224 | 254 |
|
225 |
|
|
226 |
// On behalf of a plugin |
|
255 |
// On behalf of a plugin. |
|
227 | 256 |
'views_ui_style_plugin_table' => array( |
228 | 257 |
'render element' => 'form', |
229 | 258 |
), |
230 | 259 |
|
231 | 260 |
// When previewing a view. |
232 | 261 |
'views_ui_view_preview_section' => array( |
233 |
'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''), |
|
262 |
'variables' => array( |
|
263 |
'view' => NULL, |
|
264 |
'section' => NULL, |
|
265 |
'content' => NULL, |
|
266 |
'links' => '', |
|
267 |
), |
|
234 | 268 |
), |
235 | 269 |
|
236 | 270 |
// Generic container wrapper, to use instead of theme_container when an id |
... | ... | |
274 | 308 |
/** |
275 | 309 |
* Specialized menu callback to load a view and check its locked status. |
276 | 310 |
* |
277 |
* @param $name |
|
311 |
* @param string $name
|
|
278 | 312 |
* The machine name of the view. |
279 | 313 |
* |
280 |
* @return |
|
314 |
* @return object
|
|
281 | 315 |
* The view object, with a "locked" property indicating whether or not |
282 | 316 |
* someone else is already editing the view. |
283 | 317 |
*/ |
... | ... | |
315 | 349 |
} |
316 | 350 |
|
317 | 351 |
/** |
352 |
* Cache set. |
|
353 |
* |
|
318 | 354 |
* Specialized cache function to add a flag to our view, include an appropriate |
319 | 355 |
* include, and cache more easily. |
320 | 356 |
*/ |
... | ... | |
324 | 360 |
return; |
325 | 361 |
} |
326 | 362 |
ctools_include('object-cache'); |
327 |
$view->changed = TRUE; // let any future object know that this view has changed. |
|
363 |
// Let any future object know that this view has changed. |
|
364 |
$view->changed = TRUE; |
|
328 | 365 |
|
329 | 366 |
if (isset($view->current_display)) { |
330 | 367 |
// Add the knowledge of the changed display, too. |
... | ... | |
332 | 369 |
unset($view->current_display); |
333 | 370 |
} |
334 | 371 |
|
335 |
// Unset handlers; we don't want to write these into the cache |
|
372 |
// Unset handlers; we don't want to write these into the cache.
|
|
336 | 373 |
unset($view->display_handler); |
337 | 374 |
unset($view->default_display); |
338 | 375 |
$view->query = NULL; |
... | ... | |
343 | 380 |
ctools_object_cache_set('view', $view->name, $view); |
344 | 381 |
} |
345 | 382 |
|
346 |
|
|
347 | 383 |
/** |
384 |
* Default Load. |
|
385 |
* |
|
348 | 386 |
* Specialized menu callback to load a view that is only a default |
349 | 387 |
* view. |
350 | 388 |
*/ |
... | ... | |
364 | 402 |
$view = $vars['view']; |
365 | 403 |
if (!empty($view->views_ui_context) && module_exists('contextual')) { |
366 | 404 |
$view->hide_admin_links = TRUE; |
367 |
foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) { |
|
405 |
|
|
406 |
$sections = array( |
|
407 |
'title', |
|
408 |
'header', |
|
409 |
'exposed', |
|
410 |
'rows', |
|
411 |
'pager', |
|
412 |
'more', |
|
413 |
'footer', |
|
414 |
'empty', |
|
415 |
'attachment_after', |
|
416 |
'attachment_before', |
|
417 |
); |
|
418 |
|
|
419 |
foreach ($sections as $section) { |
|
368 | 420 |
if (!empty($vars[$section])) { |
369 | 421 |
$vars[$section] = array( |
370 | 422 |
'#theme' => 'views_ui_view_preview_section', |
... | ... | |
392 | 444 |
$vars['title'] = t('Title'); |
393 | 445 |
$links = views_ui_view_preview_section_display_category_links($vars['view'], 'title', $vars['title']); |
394 | 446 |
break; |
447 |
|
|
395 | 448 |
case 'header': |
396 | 449 |
$vars['title'] = t('Header'); |
397 | 450 |
$links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); |
398 | 451 |
break; |
452 |
|
|
399 | 453 |
case 'empty': |
400 | 454 |
$vars['title'] = t('No results behavior'); |
401 | 455 |
$links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); |
402 | 456 |
break; |
457 |
|
|
403 | 458 |
case 'exposed': |
404 | 459 |
// @todo Sorts can be exposed too, so we may need a better title. |
405 | 460 |
$vars['title'] = t('Exposed Filters'); |
406 | 461 |
$links = views_ui_view_preview_section_display_category_links($vars['view'], 'exposed_form_options', $vars['title']); |
407 | 462 |
break; |
463 |
|
|
408 | 464 |
case 'rows': |
409 | 465 |
// @todo The title needs to depend on what is being viewed. |
410 | 466 |
$vars['title'] = t('Content'); |
411 | 467 |
$links = views_ui_view_preview_section_rows_links($vars['view']); |
412 | 468 |
break; |
469 |
|
|
413 | 470 |
case 'pager': |
414 | 471 |
$vars['title'] = t('Pager'); |
415 | 472 |
$links = views_ui_view_preview_section_display_category_links($vars['view'], 'pager_options', $vars['title']); |
416 | 473 |
break; |
474 |
|
|
417 | 475 |
case 'more': |
418 | 476 |
$vars['title'] = t('More'); |
419 | 477 |
$links = views_ui_view_preview_section_display_category_links($vars['view'], 'use_more', $vars['title']); |
420 | 478 |
break; |
479 |
|
|
421 | 480 |
case 'footer': |
422 | 481 |
$vars['title'] = t('Footer'); |
423 | 482 |
$links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); |
424 | 483 |
break; |
484 |
|
|
425 | 485 |
case 'attachment_before': |
426 | 486 |
// @todo: Add links to the attachment configuration page. |
427 | 487 |
$vars['title'] = t('Attachment before'); |
428 | 488 |
break; |
489 |
|
|
429 | 490 |
case 'attachment_after': |
430 | 491 |
// @todo: Add links to the attachment configuration page. |
431 | 492 |
$vars['title'] = t('Attachment after'); |
... | ... | |
454 | 515 |
function theme_views_ui_view_preview_section($vars) { |
455 | 516 |
return '<h1 class="section-title">' . $vars['title'] . '</h1>' |
456 | 517 |
. $vars['links'] |
457 |
. '<div class="preview-section">'. $vars['content'] . '</div>'; |
|
518 |
. '<div class="preview-section">' . $vars['content'] . '</div>';
|
|
458 | 519 |
} |
459 | 520 |
|
460 | 521 |
/** |
461 | 522 |
* Returns contextual links for each handler of a certain section. |
462 | 523 |
* |
524 |
* @param string $title |
|
525 |
* Add a bolded title of this section. |
|
526 |
* |
|
463 | 527 |
* @TODO |
464 | 528 |
* Bring in relationships |
465 | 529 |
* Refactor this function to use much stuff of views_ui_edit_form_get_bucket. |
466 |
* |
|
467 |
* @param $title |
|
468 |
* Add a bolded title of this section. |
|
469 | 530 |
*/ |
470 | 531 |
function views_ui_view_preview_section_handler_links($view, $type, $title = FALSE) { |
471 | 532 |
$display = $view->display_handler->display; |
... | ... | |
516 | 577 |
* Returns all contextual links for the main content part of the view. |
517 | 578 |
*/ |
518 | 579 |
function views_ui_view_preview_section_rows_links($view) { |
519 |
$display = $view->display_handler->display; |
|
580 |
|
|
520 | 581 |
$links = array(); |
582 |
|
|
521 | 583 |
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'filter', TRUE)); |
522 | 584 |
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'field', TRUE)); |
523 | 585 |
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'sort', TRUE)); |
... | ... | |
527 | 589 |
return $links; |
528 | 590 |
} |
529 | 591 |
|
530 |
|
|
531 | 592 |
/** |
532 | 593 |
* Implments hook_ctools_plugin_directory(). |
533 | 594 |
* |
... | ... | |
542 | 603 |
/** |
543 | 604 |
* Fetch metadata on a specific views ui wizard plugin. |
544 | 605 |
* |
545 |
* @param $wizard_type |
|
606 |
* @param string $wizard_type
|
|
546 | 607 |
* Name of a wizard, or name of a base table. |
547 | 608 |
* |
548 |
* @return |
|
609 |
* @return array
|
|
549 | 610 |
* An array with information about the requested wizard type. |
550 | 611 |
*/ |
551 | 612 |
function views_ui_get_wizard($wizard_type) { |
... | ... | |
571 | 632 |
/** |
572 | 633 |
* Fetch metadata for all content_type plugins. |
573 | 634 |
* |
574 |
* @return |
|
635 |
* @return array
|
|
575 | 636 |
* An array of arrays with information about all available views wizards. |
576 | 637 |
*/ |
577 | 638 |
function views_ui_get_wizards() { |
578 | 639 |
ctools_include('plugins'); |
579 | 640 |
$wizard_plugins = ctools_get_plugins('views_ui', 'views_wizard'); |
580 | 641 |
$wizard_tables = array(); |
581 |
foreach ($wizard_plugins as $name => $info) {
|
|
642 |
foreach ($wizard_plugins as $info) { |
|
582 | 643 |
$wizard_tables[$info['base_table']] = TRUE; |
583 | 644 |
} |
584 | 645 |
$base_tables = views_fetch_base_tables(); |
... | ... | |
599 | 660 |
/** |
600 | 661 |
* Helper function to define the default values for a Views wizard plugin. |
601 | 662 |
* |
602 |
* @return |
|
663 |
* @return array
|
|
603 | 664 |
* An array of defaults for a views wizard. |
604 | 665 |
*/ |
605 | 666 |
function views_ui_views_wizard_defaults() { |
... | ... | |
607 | 668 |
// The children may, for example, be a different variant for each node type. |
608 | 669 |
'get children' => NULL, |
609 | 670 |
'get child' => NULL, |
610 |
// title and base table must be populated. They are empty here just
|
|
671 |
// Title and base table must be populated. They are empty here just
|
|
611 | 672 |
// so they are documented. |
612 | 673 |
'title' => '', |
613 | 674 |
'base_table' => NULL, |
... | ... | |
636 | 697 |
); |
637 | 698 |
} |
638 | 699 |
|
700 |
/** |
|
701 |
* Get form wizard instance. |
|
702 |
*/ |
|
639 | 703 |
function views_ui_get_form_wizard_instance($wizard) { |
640 | 704 |
if (isset($wizard['form_wizard_class']['class'])) { |
641 | 705 |
$class = $wizard['form_wizard_class']['class']; |
... | ... | |
705 | 769 |
* @see views_ui_contextual_links_suppress_pop() |
706 | 770 |
*/ |
707 | 771 |
function views_ui_contextual_links_suppress_push() { |
708 |
views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress())+1);
|
|
772 |
views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress()) + 1);
|
|
709 | 773 |
} |
710 | 774 |
|
711 | 775 |
/** |
... | ... | |
714 | 778 |
* @see views_ui_contextual_links_suppress_push() |
715 | 779 |
*/ |
716 | 780 |
function views_ui_contextual_links_suppress_pop() { |
717 |
views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress())-1);
|
|
781 |
views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress()) - 1);
|
|
718 | 782 |
} |
719 | 783 |
|
720 | 784 |
/** |
721 |
* Menu callback; handles AJAX form submissions similar to ajax_form_callback(), but can be used for uncached forms.
|
|
785 |
* Menu callback. |
|
722 | 786 |
* |
723 |
* ajax_form_callback(), the menu callback for the system/ajax path, requires |
|
787 |
* Handles AJAX form submissions similar to ajax_form_callback(), but can be |
|
788 |
* used for uncached forms. |
|
789 |
* |
|
790 |
* Ajax_form_callback(), the menu callback for the system/ajax path, requires |
|
724 | 791 |
* the form to be retrievable from the form cache, because it lacks a trusted |
725 | 792 |
* $form_id argument with which to call drupal_retrieve_form(). When AJAX is |
726 | 793 |
* wanted on a non-cacheable form, #ajax['path'] can be set to a path whose |
... | ... | |
760 | 827 |
return $callback($form, $form_state); |
761 | 828 |
} |
762 | 829 |
} |
763 |
// @todo move these when we can |
|
764 | 830 |
|
831 |
/** |
|
832 |
* @todo move these when we can |
|
833 |
*/ |
|
765 | 834 |
|
766 | 835 |
/** |
767 | 836 |
* Helper function to get a list of paths assigned to a view. |
768 | 837 |
* |
769 |
* @param $view |
|
838 |
* @param object $view
|
|
770 | 839 |
* The view. |
771 | 840 |
* |
772 |
* @return |
|
841 |
* @return array
|
|
773 | 842 |
* An array of links to this view's display paths. |
774 | 843 |
*/ |
775 | 844 |
function _views_ui_get_paths($view) { |
... | ... | |
778 | 847 |
$all_paths[] = t('Edit this view to add a display.'); |
779 | 848 |
} |
780 | 849 |
else { |
781 |
$view->init_display(); // Make sure all the handlers are set up |
|
850 |
// Make sure all the handlers are set up. |
|
851 |
$view->init_display(); |
|
782 | 852 |
foreach ($view->display as $display) { |
783 | 853 |
if (!empty($display->handler) && $display->handler->has_path()) { |
784 | 854 |
$one_path = $display->handler->get_option('path'); |
785 |
if (empty($path_sort)) { |
|
786 |
$path_sort = strtolower($one_path); |
|
787 |
} |
|
855 |
|
|
788 | 856 |
if (empty($view->disabled) && strpos($one_path, '%') === FALSE) { |
857 |
// @codingStandardsIgnoreLine |
|
789 | 858 |
$all_paths[] = l('/' . $one_path, $one_path); |
790 | 859 |
} |
791 | 860 |
else { |
... | ... | |
801 | 870 |
/** |
802 | 871 |
* Helper function to get a list of displays included in a view. |
803 | 872 |
* |
804 |
* @param $view |
|
873 |
* @param object $view
|
|
805 | 874 |
* The view. |
806 | 875 |
* |
807 |
* @return |
|
876 |
* @return array
|
|
808 | 877 |
* An array of display types that this view includes. |
809 | 878 |
*/ |
810 | 879 |
function _views_ui_get_displays_list($view) { |
... | ... | |
823 | 892 |
} |
824 | 893 |
|
825 | 894 |
/** |
826 |
* This is part of a patch to address a jQueryUI bug. The bug is responsible |
|
827 |
* for the inability to scroll a page when a modal dialog is active. If the content |
|
828 |
* of the dialog extends beyond the bottom of the viewport, the user is only able |
|
829 |
* to scroll with a mousewheel or up/down keyboard keys. |
|
895 |
* This is part of a patch to address a jQueryUI bug. |
|
896 |
* |
|
897 |
* The bug is responsible |
|
898 |
* for the inability to scroll a page when a modal dialog is active. If the |
|
899 |
* content of the dialog extends beyond the bottom of the viewport, the user is |
|
900 |
* only able to scroll with a mousewheel or up/down keyboard keys. |
|
830 | 901 |
* |
831 | 902 |
* @see http://bugs.jqueryui.com/ticket/4671 |
832 | 903 |
* @see https://bugs.webkit.org/show_bug.cgi?id=19033 |
833 | 904 |
* @see /js/jquery.ui.dialog.patch.js |
834 | 905 |
* @see /js/jquery.ui.dialog.min.js |
835 | 906 |
* |
836 |
* The javascript patch overwrites the $.ui.dialog.overlay.events object to remove
|
|
837 |
* the mousedown, mouseup and click events from the list of events that are bound
|
|
838 |
* in $.ui.dialog.overlay.create. |
|
907 |
* The javascript patch overwrites the $.ui.dialog.overlay.events object to |
|
908 |
* remove the mousedown, mouseup and click events from the list of events that
|
|
909 |
* are bound in $.ui.dialog.overlay.create.
|
|
839 | 910 |
*/ |
840 |
|
|
841 | 911 |
function views_ui_library_alter(&$libraries, $module) { |
842 | 912 |
if ($module == 'system' && isset($libraries['ui.dialog'])) { |
843 | 913 |
// Only apply the fix, if we don't have an up to date jQueryUI version. |
Formats disponibles : Unified diff
Weekly update of contrib modules