Commit 4406aa9f authored by tim.plunkett's avatar tim.plunkett

Issue #1792860 by tim.plunkett, dawehner: Move Views UI into its own module.

parent df6e7c15
......@@ -8,7 +8,7 @@
namespace Drupal\views\Plugin\views\wizard;
use Drupal\views\ViewStorage;
use Drupal\views\ViewUI;
use Drupal\views_ui\ViewUI;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\views\Plugin\views\wizard\WizardInterface;
......@@ -1029,7 +1029,7 @@ protected function set_override_options(array $options, DisplayPluginBase $displ
* @param bool $unset
* Should the view be removed from the list of validated views.
*
* @return Drupal\views\ViewUI $view
* @return Drupal\views_ui\ViewUI $view
* The validated view object.
*/
protected function retrieve_validated_view(array $form, array &$form_state, $unset = TRUE) {
......@@ -1050,7 +1050,7 @@ protected function retrieve_validated_view(array $form, array &$form_state, $uns
* The full wizard form array.
* @param array $form_state
* The current state of the wizard form.
* @param Drupal\views\ViewUI $view
* @param Drupal\views_ui\ViewUI $view
* The validated view object.
*/
protected function set_validated_view(array $form, array &$form_state, ViewUI $view) {
......
......@@ -8,6 +8,7 @@
namespace Drupal\views;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\views_ui\ViewUI;
/**
* Defines a ViewStorage configuration entity class.
......@@ -130,7 +131,7 @@ public function setExecutable(ViewExecutable $executable) {
* @param bool $reset
* Get a new Drupal\views\ViewExecutable instance.
* @param bool $ui
* If this should return Drupal\views\ViewUI instead.
* If this should return Drupal\views_ui\ViewUI instead.
*
* @return Drupal\views\ViewExecutable
* The executable version of this view.
......
......@@ -1082,14 +1082,6 @@ function theme_views_mini_pager($vars) {
}
}
/**
* Generic <div> container function.
*/
function theme_views_container($variables) {
$element = $variables['element'];
return '<div' . new Attribute($element['#attributes']) . '>' . $element['#children'] . '</div>';
}
/**
* @defgroup views_templates Views template files
* @{
......
......@@ -88,7 +88,7 @@ function views_entity_info() {
'label' => t('View'),
'entity class' => 'Drupal\views\ViewStorage',
'controller class' => 'Drupal\views\ViewStorageController',
'list controller class' => 'Drupal\views\ViewListController',
'list controller class' => 'Drupal\views_ui\ViewListController',
'list path' => 'admin/structure/views',
'form controller class' => array(
'default' => 'Drupal\node\NodeFormController',
......
This diff is collapsed.
......@@ -2,10 +2,10 @@
/**
* @file
* Definition of Drupal\views\ViewListController.
* Definition of Drupal\views_ui\ViewListController.
*/
namespace Drupal\views;
namespace Drupal\views_ui;
use Drupal\Core\Entity\EntityListController;
use Drupal\Core\Entity\EntityInterface;
......
......@@ -2,11 +2,12 @@
/**
* @file
* Definition of Drupal\views\ViewUI.
* Definition of Drupal\views_ui\ViewUI.
*/
namespace Drupal\views;
namespace Drupal\views_ui;
use Drupal\views\ViewExecutable;
use Drupal\views\TempStore\UserTempStore;
/**
......@@ -392,7 +393,7 @@ public function buildOptionForm($id, $option, $display) {
* Render the top of the display so it can be updated during ajax operations.
*/
public function renderDisplayTop($display_id) {
$element['#theme_wrappers'] = array('views_container');
$element['#theme_wrappers'] = array('views_ui_container');
$element['#attributes']['class'] = array('views-display-top', 'clearfix');
$element['#attributes']['id'] = array('views-display-top');
......@@ -939,7 +940,7 @@ public function getFormBucket($type, $display) {
if (!$uses_fields) {
$build['fields'][] = array(
'#markup' => t('The selected style or row format does not utilize fields.'),
'#theme_wrappers' => array('views_container'),
'#theme_wrappers' => array('views_ui_container'),
'#attributes' => array('class' => array('views-display-setting')),
);
return $build;
......@@ -1149,7 +1150,7 @@ public function submitBreakLock(&$form, &$form_state) {
drupal_set_message(t('The lock has been broken and you may now edit this view.'));
}
public static function addForm($form, &$form_state) {
public static function buildAddForm($form, &$form_state) {
$form['#attached']['css'] = static::getAdminCSS();
$form['#attached']['js'][] = drupal_get_path('module', 'views_ui') . '/js/views-admin.js';
$form['#attributes']['class'] = array('views-admin');
......@@ -1242,7 +1243,7 @@ public static function addForm($form, &$form_state) {
'#value' => t('Continue & edit'),
'#validate' => array('views_ui_wizard_form_validate'),
'#submit' => array('views_ui_add_form_store_edit_submit'),
'#process' => array_merge(array('views_ui_default_button'), element_info_property('submit', '#process', array())),
'#process' => array_merge(array(array(get_called_class(), 'processDefaultButton')), element_info_property('submit', '#process', array())),
);
$form['cancel'] = array(
'#type' => 'submit',
......@@ -1265,7 +1266,7 @@ public static function addForm($form, &$form_state) {
*
* @see views_ui_ajax_get_form()
*/
public function editForm($form, &$form_state, $display_id = NULL) {
public function buildEditForm($form, &$form_state, $display_id = NULL) {
// Do not allow the form to be cached, because $form_state['view'] can become
// stale between page requests.
// See views_ui_ajax_get_form() for how this affects #ajax.
......@@ -1487,7 +1488,7 @@ public function buildPreviewForm($form, &$form_state, $display_id = 'default') {
// as this button, not the Save button.
// @todo This only works for JS users. To make this work for nojs users,
// we may need to split Preview into a separate form.
'#process' => array_merge(array('views_ui_default_button'), element_info_property('submit', '#process', array())),
'#process' => array_merge(array(array($this, 'processDefaultButton')), element_info_property('submit', '#process', array())),
);
$form['#action'] = url('admin/structure/views/view/' . $this->storage->name .'/preview/' . $display_id);
......@@ -1613,7 +1614,7 @@ public function addFormToStack($key, $display_id, $args, $top = FALSE, $rebuild_
$this->stack = array();
}
$stack = array($this->buildIdentifier($key, $display_id, $args), $key, &$this, $display_id, $args);
$stack = array($this->buildIdentifier($key, $display_id, $args), $key, $display_id, $args);
// If we're being asked to add this form to the bottom of the stack, no
// special logic is required. Our work is equally easy if we were asked to add
// to the top of the stack, but there's nothing in it yet.
......@@ -1964,4 +1965,43 @@ public static function sortPosition($display1, $display2) {
return 0;
}
/**
* Build up a $form_state object suitable for use with drupal_build_form
* based on known information about a form.
*/
public function buildFormState($js, $key, $display_id, $args) {
$form = views_ui_ajax_forms($key);
// Build up form state
$form_state = array(
'form_key' => $key,
'form_id' => $form['form_id'],
'view' => &$this,
'ajax' => $js,
'display_id' => $display_id,
'no_redirect' => TRUE,
);
// If an method was specified, use that for the callback.
if (isset($form['callback'])) {
$form_state['build_info']['args'] = array();
$form_state['build_info']['callback'] = array($this, $form['callback']);
}
foreach ($form['args'] as $id) {
$form_state[$id] = (!empty($args)) ? array_shift($args) : NULL;
}
return $form_state;
}
/**
* #process callback for a button; makes implicit form submissions trigger as this button.
*
* @see Drupal.behaviors.viewsImplicitFormSubmission
*/
public static function processDefaultButton($element, &$form_state, $form) {
$setting['viewsImplicitFormSubmission'][$form['#id']]['defaultButton'] = $element['#id'];
$element['#attached']['js'][] = array('type' => 'setting', 'data' => $setting);
return $element;
}
}
This diff is collapsed.
......@@ -6,7 +6,7 @@
*/
use Drupal\views\ViewExecutable;
use Drupal\views\ViewUI;
use Drupal\views_ui\ViewUI;
use Drupal\views\Analyzer;
use Drupal\Core\Entity\EntityInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
......@@ -21,7 +21,7 @@ function views_ui_menu() {
$base = array(
'access callback' => 'user_access',
'access arguments' => array('administer views'),
'file' => 'includes/admin.inc',
'file' => 'admin.inc',
);
// Set up the base for AJAX callbacks.
$ajax_base = array(
......@@ -181,8 +181,7 @@ function views_ui_menu() {
* Implements hook_theme().
*/
function views_ui_theme() {
$path = drupal_get_path('module', 'views');
require_once DRUPAL_ROOT . "/$path/includes/admin.inc";
$path = drupal_get_path('module', 'views_ui');
return array(
// edit a view
......@@ -190,11 +189,13 @@ function views_ui_theme() {
'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",
'file' => 'theme.inc',
),
'views_ui_display_tab_bucket' => array(
'render element' => 'element',
'template' => 'views-ui-display-tab-bucket',
'path' => "$path/theme",
'file' => 'theme.inc',
),
'views_ui_edit_item' => array(
'variables' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE),
......@@ -203,26 +204,32 @@ function views_ui_theme() {
),
'views_ui_rearrange_form' => array(
'render element' => 'form',
'path' => "$path/theme",
'file' => 'theme.inc',
),
'views_ui_rearrange_filter_form' => array(
'render element' => 'form',
'file' => 'includes/admin.inc',
'path' => "$path/theme",
'file' => 'theme.inc',
),
'views_ui_expose_filter_form' => array(
'render element' => 'form',
'file' => 'includes/admin.inc',
'path' => "$path/theme",
'file' => 'theme.inc',
),
// list views
'views_ui_view_info' => array(
'variables' => array('view' => NULL, 'base' => NULL),
'file' => "includes/admin.inc",
'path' => "$path/theme",
'file' => 'theme.inc',
),
// Group of filters.
'views_ui_build_group_filter_form' => array(
'render element' => 'form',
'file' => 'includes/admin.inc',
'path' => "$path/theme",
'file' => 'theme.inc',
),
// tab themes
......@@ -234,24 +241,30 @@ function views_ui_theme() {
),
'views_ui_reorder_displays_form' => array(
'render element' => 'form',
'file' => 'includes/admin.inc',
'path' => "$path/theme",
'file' => 'theme.inc',
),
// On behalf of a plugin
'views_ui_style_plugin_table' => array(
'render element' => 'form',
'path' => "$path/theme",
'file' => 'theme.inc',
),
// When previewing a view.
'views_ui_view_preview_section' => array(
'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''),
'path' => "$path/theme",
'file' => 'theme.inc',
),
// Generic container wrapper, to use instead of theme_container when an id
// is not desired.
'views_container' => array(
'views_ui_container' => array(
'render element' => 'element',
'file' => 'theme/theme.inc',
'path' => "$path/theme",
'file' => 'theme.inc',
),
);
}
......@@ -275,7 +288,7 @@ function views_ui_custom_theme() {
* Page title callback for the Edit View page.
*/
function views_ui_edit_page_title(ViewUI $view) {
module_load_include('inc', 'views_ui', 'includes/admin');
module_load_include('inc', 'views_ui', 'admin');
$bases = views_fetch_base_tables();
$name = $view->storage->getHumanName();
if (isset($bases[$view->storage->base_table])) {
......@@ -368,7 +381,7 @@ function views_ui_preprocess_views_view(&$vars) {
'#view' => $view,
'#section' => $section,
'#content' => is_array($vars[$section]) ? drupal_render($vars[$section]) : $vars[$section],
'#theme_wrappers' => array('views_container'),
'#theme_wrappers' => array('views_ui_container'),
'#attributes' => array('class' => 'contextual-region'),
);
$vars[$section] = drupal_render($vars[$section]);
......@@ -377,83 +390,6 @@ function views_ui_preprocess_views_view(&$vars) {
}
}
/**
* 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' => '<div class="contextual">',
'#suffix' => '</div>',
'#theme' => 'links__contextual',
'#links' => $links,
'#attributes' => array('class' => array('contextual-links')),
'#attached' => array(
'library' => array(array('contextual', 'contextual-links')),
),
);
$vars['links'] = drupal_render($build);
}
$vars['theme_hook_suggestions'][] = 'views_ui_view_preview_section__' . $vars['section'];
}
/**
* Returns the HTML for a section of a View being previewed within the Views UI.
*/
function theme_views_ui_view_preview_section($vars) {
return '<h1 class="section-title">' . $vars['title'] . '</h1>'
. $vars['links']
. '<div class="preview-section">'. $vars['content'] . '</div>';
}
/**
* Returns contextual links for each handler of a certain section.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment