Commit 489a28a5 authored by tim.plunkett's avatar tim.plunkett Committed by tim.plunkett

Issue #1792860 by tim.plunkett, dawehner: Move procedural code from...

Issue #1792860 by tim.plunkett, dawehner: Move procedural code from views_ui().module and admin.inc to ViewUI.
parent 8e855ad1
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -45,7 +45,7 @@ public function summaryTitle() {
return t('Multiple roles');
}
else {
$rids = views_ui_get_roles();
$rids = user_roles();
$rid = reset($this->options['role']);
return check_plain($rids[$rid]);
}
......@@ -65,7 +65,7 @@ public function buildOptionsForm(&$form, &$form_state) {
'#type' => 'checkboxes',
'#title' => t('Role'),
'#default_value' => $this->options['role'],
'#options' => array_map('check_plain', views_ui_get_roles()),
'#options' => array_map('check_plain', $this->getRoles()),
'#description' => t('Only the checked roles will be able to access this display. Note that users with "access all views" can see any view, regardless of role.'),
);
}
......
......@@ -183,7 +183,7 @@ public function buildOptionsForm(&$form, &$form_state) {
);
$form['default_action'] = array(
'#type' => 'radios',
'#process' => array('views_ui_process_container_radios'),
'#process' => array(array($this, 'processContainerRadios')),
'#default_value' => $this->options['default_action'],
'#fieldset' => 'no_argument',
);
......@@ -1076,6 +1076,44 @@ function get_sort_name() {
return t('Default sort', array(), array('context' => 'Sort order'));
}
/**
* Custom form radios process function.
*
* Roll out a single radios element to a list of radios, using the options
* array as index. While doing that, create a container element underneath
* each option, which contains the settings related to that option.
*
* @see form_process_radios()
*/
public static function processContainerRadios($element) {
if (count($element['#options']) > 0) {
foreach ($element['#options'] as $key => $choice) {
$element += array($key => array());
// Generate the parents as the autogenerator does, so we will have a
// unique id for each radio button.
$parents_for_id = array_merge($element['#parents'], array($key));
$element[$key] += array(
'#type' => 'radio',
'#title' => $choice,
// The key is sanitized in drupal_attributes() during output from the
// theme function.
'#return_value' => $key,
'#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
'#attributes' => $element['#attributes'],
'#parents' => $element['#parents'],
'#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
'#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
);
$element[$key . '_options'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('views-admin-dependent')),
);
}
}
return $element;
}
}
/**
......
......@@ -1570,6 +1570,7 @@ public function buildOptionsForm(&$form, &$form_state) {
break;
case 'style':
$form['#title'] .= t('How should this view be styled');
$style = $this->getOption('style');
$form['style_plugin'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('style', $this->getStyleType(), array($this->view->storage->base_table)),
......@@ -1612,6 +1613,7 @@ public function buildOptionsForm(&$form, &$form_state) {
break;
case 'row':
$form['#title'] .= t('How should each row in this view be styled');
$row = $this->getOption('row');
$form['row_plugin'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('row', $this->getStyleType(), array($this->view->storage->base_table)),
......@@ -1630,7 +1632,7 @@ public function buildOptionsForm(&$form, &$form_state) {
break;
case 'link_display':
$form['#title'] .= t('Which display to use for path');
foreach ($this->view->display as $display_id => $display) {
foreach ($this->view->storage->display as $display_id => $display) {
if ($this->view->displayHandlers[$display_id]->hasPath()) {
$options[$display_id] = $display['display_title'];
}
......@@ -2170,7 +2172,7 @@ public function submitOptionsForm(&$form, &$form_state) {
$access = array('type' => $form_state['values']['access']['type']);
$this->setOption('access', $access);
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('access_options'));
$this->view->addFormToStack('display', $this->display['id'], array('access_options'));
}
}
}
......@@ -2193,7 +2195,7 @@ public function submitOptionsForm(&$form, &$form_state) {
$cache = array('type' => $form_state['values']['cache']['type']);
$this->setOption('cache', $cache);
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('cache_options'));
$this->view->addFormToStack('display', $this->display['id'], array('cache_options'));
}
}
}
......@@ -2254,7 +2256,7 @@ public function submitOptionsForm(&$form, &$form_state) {
// send ajax form to options page if we use it.
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('row_options'));
$this->view->addFormToStack('display', $this->display['id'], array('row_options'));
}
}
}
......@@ -2270,7 +2272,7 @@ public function submitOptionsForm(&$form, &$form_state) {
$this->setOption($section, $row);
// send ajax form to options page if we use it.
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('style_options'));
$this->view->addFormToStack('display', $this->display['id'], array('style_options'));
}
}
}
......@@ -2304,7 +2306,7 @@ public function submitOptionsForm(&$form, &$form_state) {
$exposed_form = array('type' => $form_state['values']['exposed_form']['type'], 'options' => array());
$this->setOption('exposed_form', $exposed_form);
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('exposed_form_options'));
$this->view->addFormToStack('display', $this->display['id'], array('exposed_form_options'));
}
}
}
......@@ -2331,7 +2333,7 @@ public function submitOptionsForm(&$form, &$form_state) {
$pager = array('type' => $form_state['values']['pager']['type'], 'options' => $plugin->options);
$this->setOption('pager', $pager);
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('pager_options'));
$this->view->addFormToStack('display', $this->display['id'], array('pager_options'));
}
}
}
......
......@@ -609,7 +609,7 @@ public function submitOptionsForm(&$form, &$form_state) {
$this->setOption('menu', $form_state['values']['menu']);
// send ajax form to options page if we use it.
if ($form_state['values']['menu']['type'] == 'default tab') {
views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('tab_options'));
$this->view->addFormToStack('display', $this->display['id'], array('tab_options'));
}
break;
case 'tab_options':
......
......@@ -165,12 +165,6 @@ class ViewExecutable {
*/
public $is_attachment = NULL;
// Stores the next steps of form items to handle.
// It's an array of stack items, which contain the form id, the type of form,
// the view, the display and some additional arguments.
// @see views_ui_add_form_to_stack()
// var $stack;
/**
* Identifier of the current display.
*
......@@ -1821,13 +1815,11 @@ public function createDuplicate() {
* This will completely wipe a view clean so it can be considered fresh.
*
* @return Drupal\views\ViewExecutable
* The cloned view.
* The cloned view.
*/
public function cloneView() {
$clone = clone $this->storage;
$clone = $clone->getExecutable(TRUE);
return $clone;
$storage = clone $this->storage;
return $storage->getExecutable(TRUE);
}
/**
......
......@@ -131,7 +131,7 @@ public function getOperations(EntityInterface $view) {
*/
public function render() {
$list = parent::render();
$list['#attached']['css'] = views_ui_get_admin_css();
$list['#attached']['css'] = ViewUI::getAdminCSS();
return $list;
}
......
......@@ -129,13 +129,22 @@ 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.
*
* @return Drupal\views\ViewExecutable
* The executable version of this view.
*/
public function getExecutable($reset = FALSE) {
public function getExecutable($reset = FALSE, $ui = FALSE) {
if (!isset($this->executable) || $reset) {
$this->setExecutable(new ViewExecutable($this));
// @todo Remove this approach and use proper dependency injection.
if ($ui) {
$executable = new ViewUI($this);
}
else {
$executable = new ViewExecutable($this);
}
$this->setExecutable($executable);
}
return $this->executable;
}
......
This diff is collapsed.
......@@ -66,14 +66,6 @@ function views_ui_menu() {
) + $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',
......@@ -150,21 +142,15 @@ function views_ui_menu() {
'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;
}
$items['admin/structure/views/nojs/preview/%views_ui_cache/%'] = array(
'page callback' => 'views_ui_preview',
'page arguments' => array(5, 6),
) + $base;
$items['admin/structure/views/ajax/preview/%views_ui_cache/%'] = array(
'page callback' => 'views_ui_preview',
'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
......
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