'user_access', 'access arguments' => array('administer views'), 'file' => 'includes/admin.inc', ); // Top-level Views module pages (not tied to a particular View). $items['admin/structure/views/add'] = array( 'title' => 'Add new view', 'page callback' => 'views_ui_add_page', 'type' => MENU_LOCAL_ACTION, ) + $base; // Top-level Views module pages (not tied to a particular View). $items['admin/structure/views/add-template'] = array( 'title' => 'Add view from template', 'page callback' => 'views_ui_add_template_page', // Don't show a local action link if there aren't any templates. 'type' => views_get_all_templates() ? MENU_LOCAL_ACTION : MENU_VISIBLE_IN_BREADCRUMB, ) + $base; $items['admin/structure/views/import'] = array( 'title' => 'Import', 'page callback' => 'drupal_get_form', 'page arguments' => array('views_ui_import_page'), 'access callback' => 'views_import_access', 'type' => MENU_LOCAL_ACTION, ) + $base; $items['admin/structure/views/settings'] = array( 'title' => 'Settings', 'page callback' => 'drupal_get_form', 'page arguments' => array('views_ui_admin_settings_basic'), 'type' => MENU_LOCAL_TASK, ) + $base; $items['admin/structure/views/settings/basic'] = array( 'title' => 'Basic', 'page arguments' => array('views_ui_admin_settings_basic'), 'type' => MENU_DEFAULT_LOCAL_TASK, ) + $base; $items['admin/structure/views/settings/advanced'] = array( 'title' => 'Advanced', 'page arguments' => array('views_ui_admin_settings_advanced'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ) + $base; // The primary Edit View page. Secondary tabs for each Display are added in // views_ui_menu_local_tasks_alter(). $items['admin/structure/views/view/%views_ui_cache'] = array( 'title callback' => 'views_ui_edit_page_title', 'title arguments' => array(4), 'page callback' => 'views_ui_edit_page', 'page arguments' => array(4), ) + $base; $items['admin/structure/views/view/%views_ui_cache/edit'] = array( 'title' => 'Edit view', 'type' => MENU_DEFAULT_LOCAL_TASK, 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, 'weight' => -10, 'theme callback' => 'ajax_base_page_theme', ) + $base; $items['admin/structure/views/view/%views_ui_cache/edit/%/ajax'] = array( 'page callback' => 'views_ui_ajax_get_form', 'page arguments' => array('views_ui_edit_form', 4, 6), 'delivery callback' => 'ajax_deliver', 'theme callback' => 'ajax_base_page_theme', 'type' => MENU_CALLBACK, ) + $base; $items['admin/structure/views/view/%views_ui_cache/preview/%'] = array( 'page callback' => 'views_ui_build_preview', 'page arguments' => array(4, 6), 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, 'type' => MENU_VISIBLE_IN_BREADCRUMB, ) + $base; $items['admin/structure/views/view/%views_ui_cache/preview/%/ajax'] = array( 'page callback' => 'views_ui_build_preview', 'page arguments' => array(4, 6), 'delivery callback' => 'ajax_deliver', 'theme callback' => 'ajax_base_page_theme', 'type' => MENU_CALLBACK, ) + $base; // Additional pages for acting on a View. $items['admin/structure/views/view/%views_ui_cache/break-lock'] = array( 'title' => 'Break lock', 'page callback' => 'drupal_get_form', 'page arguments' => array('views_ui_break_lock_confirm', 4), 'type' => MENU_VISIBLE_IN_BREADCRUMB, ) + $base; // NoJS/AJAX callbacks that can use the default Views AJAX form system. $items['admin/structure/views/nojs/%/%views_ui_cache'] = array( 'page callback' => 'views_ui_ajax_form', 'page arguments' => array(FALSE, 4, 5), 'type' => MENU_CALLBACK, ) + $base; $items['admin/structure/views/ajax/%/%views_ui_cache'] = array( 'page callback' => 'views_ui_ajax_form', 'page arguments' => array(TRUE, 4, 5), 'delivery callback' => 'ajax_deliver', 'type' => MENU_CALLBACK, ) + $base; // NoJS/AJAX callbacks that require custom page callbacks. $ajax_callbacks = array( 'preview' => 'views_ui_preview', ); foreach ($ajax_callbacks as $menu => $menu_callback) { $items['admin/structure/views/nojs/' . $menu . '/%views_ui_cache/%'] = array( 'page callback' => $menu_callback, 'page arguments' => array(5, 6), ) + $base; $items['admin/structure/views/ajax/' . $menu . '/%views_ui_cache/%'] = array( 'page callback' => $menu_callback, 'page arguments' => array(5, 6), 'delivery callback' => 'ajax_deliver', ) + $base; } // Autocomplete callback for tagging a View. // Views module uses admin/views/... instead of admin/structure/views/... for // autocomplete paths, so be consistent with that. // @todo Change to admin/structure/views/... when the change can be made to // Views module as well. $items['admin/views/ajax/autocomplete/tag'] = array( 'page callback' => 'views_ui_autocomplete_tag', 'type' => MENU_CALLBACK, ) + $base; // A page in the Reports section to show usage of fields in all views $items['admin/reports/fields/list'] = array( 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); $items['admin/reports/fields/views-fields'] = array( 'title' => 'Used in views', 'description' => 'Overview of fields used in all views.', 'page callback' => 'views_ui_field_list', 'type' => MENU_LOCAL_TASK, 'weight' => 0, ) + $base; // A page in the Reports section to show usage of plugins in all views. $items['admin/reports/views-plugins'] = array( 'title' => 'Views plugins', 'description' => 'Overview of plugins used in all views.', 'page callback' => 'views_ui_plugin_list', ) + $base; return $items; } /** * Implements hook_theme(). */ function views_ui_theme() { $path = drupal_get_path('module', 'views'); require_once DRUPAL_ROOT . "/$path/includes/admin.inc"; return array( // edit a view 'views_ui_display_tab_setting' => array( 'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()), 'template' => 'views-ui-display-tab-setting', 'path' => "$path/theme", ), 'views_ui_display_tab_bucket' => array( 'render element' => 'element', 'template' => 'views-ui-display-tab-bucket', 'path' => "$path/theme", ), 'views_ui_edit_item' => array( 'variables' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE), 'template' => 'views-ui-edit-item', 'path' => "$path/theme", ), 'views_ui_rearrange_form' => array( 'render element' => 'form', ), 'views_ui_rearrange_filter_form' => array( 'render element' => 'form', 'file' => 'includes/admin.inc', ), 'views_ui_expose_filter_form' => array( 'render element' => 'form', 'file' => 'includes/admin.inc', ), // list views 'views_ui_view_info' => array( 'variables' => array('view' => NULL, 'base' => NULL), 'file' => "includes/admin.inc", ), // Group of filters. 'views_ui_build_group_filter_form' => array( 'render element' => 'form', 'file' => 'includes/admin.inc', ), // tab themes 'views_tabset' => array( 'variables' => array('tabs' => NULL), ), 'views_tab' => array( 'variables' => array('body' => NULL), ), 'views_ui_reorder_displays_form' => array( 'render element' => 'form', 'file' => 'includes/admin.inc', ), // On behalf of a plugin 'views_ui_style_plugin_table' => array( 'render element' => 'form', ), // When previewing a view. 'views_ui_view_preview_section' => array( 'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''), ), // Generic container wrapper, to use instead of theme_container when an id // is not desired. 'views_container' => array( 'render element' => 'element', 'file' => 'theme/theme.inc', ), ); } /** * Impements hook_custom_theme() */ function views_ui_custom_theme() { $theme = config('views.settings')->get('ui.custom_theme'); if ($theme != '_default') { $available = list_themes(); if (isset($available[$theme]) && $available[$theme]->status && preg_match('/^admin\/structure\/views/', current_path())) { return $theme; } } } /** * Page title callback for the Edit View page. */ function views_ui_edit_page_title($view) { module_load_include('inc', 'views_ui', 'includes/admin'); $bases = views_fetch_base_tables(); $name = $view->getHumanName(); if (isset($bases[$view->base_table])) { $name .= ' (' . $bases[$view->base_table]['title'] . ')'; } return $name; } /** * Specialized menu callback to load a view and check its locked status. * * @param $name * The machine name of the view. * * @return * The view object, with a "locked" property indicating whether or not * someone else is already editing the view. */ function views_ui_cache_load($name) { $views_temp_store = views_temp_store(); $view = $views_temp_store->get($name); $original_view = views_get_view($name); if (empty($view)) { $view = $original_view; if (!empty($view)) { // Check to see if someone else is already editing this view. $view->locked = $views_temp_store->isLocked($view->name); // Set a flag to indicate that this view is being edited. // This flag will be used e.g. to determine whether strings // should be localized. $view->editing = TRUE; } } else { // Keep disabled/enabled status real. if ($original_view) { $view->disabled = !empty($original_view->disabled); } } if (empty($view)) { return FALSE; } else { return $view; } } /** * Specialized cache function to add a flag to our view, include an appropriate * include, and cache more easily. */ function views_ui_cache_set(&$view) { if (!empty($view->locked)) { drupal_set_message(t('Changes cannot be made to a locked view.'), 'error'); return; } $view->changed = TRUE; // let any future object know that this view has changed. if (isset($view->current_display)) { // Add the knowledge of the changed display, too. $view->changed_display[$view->current_display] = TRUE; unset($view->current_display); } // Unset handlers; we don't want to write these into the cache unset($view->display_handler); unset($view->default_display); $view->query = NULL; foreach (array_keys($view->display) as $id) { unset($view->display[$id]->handler); unset($view->display[$id]->default_display); } views_temp_store()->set($view->name, $view); } /** * Specialized menu callback to load a view that is only a default * view. */ function views_ui_default_load($name) { $view = views_get_view($name); if ($view->type == t('Default')) { return $view; } return FALSE; } /** * Theme preprocess for views-view.tpl.php. */ function views_ui_preprocess_views_view(&$vars) { $view = $vars['view']; if (!empty($view->views_ui_context) && module_exists('contextual')) { $view->hide_admin_links = TRUE; foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) { if (!empty($vars[$section])) { $vars[$section] = array( '#theme' => 'views_ui_view_preview_section', '#view' => $view, '#section' => $section, '#content' => is_array($vars[$section]) ? drupal_render($vars[$section]) : $vars[$section], '#theme_wrappers' => array('views_container'), '#attributes' => array('class' => 'contextual-region'), ); $vars[$section] = drupal_render($vars[$section]); } } } } /** * Theme preprocess for theme_views_ui_view_preview_section(). * * @TODO * Perhaps move this to includes/admin.inc or theme/theme.inc */ function template_preprocess_views_ui_view_preview_section(&$vars) { switch ($vars['section']) { case 'title': $vars['title'] = t('Title'); $links = views_ui_view_preview_section_display_category_links($vars['view'], 'title', $vars['title']); break; case 'header': $vars['title'] = t('Header'); $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); break; case 'empty': $vars['title'] = t('No results behavior'); $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); break; case 'exposed': // @todo Sorts can be exposed too, so we may need a better title. $vars['title'] = t('Exposed Filters'); $links = views_ui_view_preview_section_display_category_links($vars['view'], 'exposed_form_options', $vars['title']); break; case 'rows': // @todo The title needs to depend on what is being viewed. $vars['title'] = t('Content'); $links = views_ui_view_preview_section_rows_links($vars['view']); break; case 'pager': $vars['title'] = t('Pager'); $links = views_ui_view_preview_section_display_category_links($vars['view'], 'pager_options', $vars['title']); break; case 'more': $vars['title'] = t('More'); $links = views_ui_view_preview_section_display_category_links($vars['view'], 'use_more', $vars['title']); break; case 'footer': $vars['title'] = t('Footer'); $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); break; case 'attachment_before': // @todo: Add links to the attachment configuration page. $vars['title'] = t('Attachment before'); break; case 'attachment_after': // @todo: Add links to the attachment configuration page. $vars['title'] = t('Attachment after'); break; } if (isset($links)) { $build = array( '#prefix' => '