Issue #1792844 by tim.plunkett: Change more public properties to protected in ViewExecutable and ViewStorage.

8.0.x
webchick 2012-10-26 22:19:41 -07:00
parent 805fa869d9
commit cc38404bcd
34 changed files with 233 additions and 200 deletions

View File

@ -52,7 +52,7 @@ class Block extends DisplayPluginBase {
* stuff with it.
*/
public function executeHookBlockList($delta = 0, $edit = array()) {
$delta = $this->view->storage->name . '-' . $this->display['id'];
$delta = $this->view->storage->get('name') . '-' . $this->display['id'];
$desc = $this->getOption('block_description');
if (empty($desc)) {
@ -193,14 +193,14 @@ class Block extends DisplayPluginBase {
parent::submitOptionsForm($form, $form_state);
switch ($form_state['section']) {
case 'display_id':
$this->updateBlockBid($form_state['view']->storage->name, $this->display['id'], $this->display['new_id']);
$this->updateBlockBid($form_state['view']->storage->get('name'), $this->display['id'], $this->display['new_id']);
break;
case 'block_description':
$this->setOption('block_description', $form_state['values']['block_description']);
break;
case 'block_caching':
$this->setOption('block_caching', $form_state['values']['block_caching']);
$this->saveBlockCache($form_state['view']->storage->name . '-'. $form_state['display_id'], $form_state['values']['block_caching']);
$this->saveBlockCache($form_state['view']->storage->get('name') . '-'. $form_state['display_id'], $form_state['values']['block_caching']);
break;
}
}

View File

@ -115,7 +115,7 @@ class Field extends FieldPluginBase {
function get_base_table() {
if (!isset($this->base_table)) {
// This base_table is coming from the entity not the field.
$this->base_table = $this->view->storage->base_table;
$this->base_table = $this->view->storage->get('base_table');
// If the current field is under a relationship you can't be sure that the
// base table of the view is the base table of the current field.

View File

@ -26,7 +26,7 @@ class TaxonomyIndexTid extends PrerenderList {
public function init(ViewExecutable $view, &$options) {
parent::init($view, $options);
// @todo: Wouldn't it be possible to use $this->base_table and no if here?
if ($view->storage->base_table == 'node_revision') {
if ($view->storage->get('base_table') == 'node_revision') {
$this->additional_fields['nid'] = array('table' => 'node_revision', 'field' => 'nid');
}
else {

View File

@ -35,7 +35,7 @@ class View extends AreaPluginBase {
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$view_display = $this->view->storage->name . ':' . $this->view->current_display;
$view_display = $this->view->storage->get('name') . ':' . $this->view->current_display;
$options = array('' => t('-Select-'));
$options += views_get_views_as_options(FALSE, 'all', $view_display, FALSE, TRUE);

View File

@ -196,7 +196,7 @@ abstract class CachePluginBase extends PluginBase {
* to be sure that we catch everything. Maybe that's a bad idea.
*/
function cache_flush() {
cache($this->table)->invalidateTags(array($this->view->storage->name => TRUE));
cache($this->table)->invalidateTags(array($this->view->storage->get('name') => TRUE));
}
/**
@ -324,7 +324,7 @@ abstract class CachePluginBase extends PluginBase {
}
}
$this->resultsKey = $this->view->storage->name . ':' . $this->displayHandler->display['id'] . ':results:' . md5(serialize($key_data));
$this->resultsKey = $this->view->storage->get('name') . ':' . $this->displayHandler->display['id'] . ':results:' . md5(serialize($key_data));
}
return $this->resultsKey;
@ -348,7 +348,7 @@ abstract class CachePluginBase extends PluginBase {
'base_url' => $GLOBALS['base_url'],
);
$this->outputKey = $this->view->storage->name . ':' . $this->displayHandler->display['id'] . ':output:' . md5(serialize($key_data));
$this->outputKey = $this->view->storage->get('name') . ':' . $this->displayHandler->display['id'] . ':output:' . md5(serialize($key_data));
}
return $this->outputKey;

View File

@ -754,7 +754,7 @@ abstract class DisplayPluginBase extends PluginBase {
// Query plugins allow specifying a specific query class per base table.
if ($type == 'query') {
$views_data = views_fetch_data($this->view->storage->base_table);
$views_data = views_fetch_data($this->view->storage->get('base_table'));
$name = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
}
@ -764,7 +764,7 @@ abstract class DisplayPluginBase extends PluginBase {
// Initialize the plugin. Query has a unique method signature.
if ($type == 'query') {
$plugin->init($this->view->storage->base_table, $this->view->storage->base_field, $options['options']);
$plugin->init($this->view->storage->get('base_table'), $this->view->storage->get('base_field'), $options['options']);
}
else {
$plugin->init($this->view, $this, $options['options']);
@ -939,7 +939,7 @@ abstract class DisplayPluginBase extends PluginBase {
$title = $text;
}
return l($text, 'admin/structure/views/nojs/display/' . $this->view->storage->name . '/' . $this->display['id'] . '/' . $section, array('attributes' => array('class' => 'views-ajax-link ' . $class, 'title' => $title, 'id' => drupal_html_id('views-' . $this->display['id'] . '-' . $section)), 'html' => TRUE));
return l($text, 'admin/structure/views/nojs/display/' . $this->view->storage->get('name') . '/' . $this->display['id'] . '/' . $section, array('attributes' => array('class' => 'views-ajax-link ' . $class, 'title' => $title, 'id' => drupal_html_id('views-' . $this->display['id'] . '-' . $section)), 'html' => TRUE));
}
/**
@ -1433,7 +1433,7 @@ abstract class DisplayPluginBase extends PluginBase {
$access = $this->getOption('access');
$form['access']['type'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('access', NULL, array($this->view->storage->base_table)),
'#options' => views_fetch_plugin_names('access', NULL, array($this->view->storage->get('base_table'))),
'#default_value' => $access['type'],
);
@ -1468,7 +1468,7 @@ abstract class DisplayPluginBase extends PluginBase {
$cache = $this->getOption('cache');
$form['cache']['type'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('cache', NULL, array($this->view->storage->base_table)),
'#options' => views_fetch_plugin_names('cache', NULL, array($this->view->storage->get('base_table'))),
'#default_value' => $cache['type'],
);
@ -1529,7 +1529,7 @@ abstract class DisplayPluginBase extends PluginBase {
// Doesn't make sense to show a field setting here if we aren't querying
// an entity base table. Also, we make sure that there's at least one
// entity type with a translation handler attached.
if (in_array($this->view->storage->base_table, $entity_tables) && $has_translation_handlers) {
if (in_array($this->view->storage->get('base_table'), $entity_tables) && $has_translation_handlers) {
$languages = array(
'***CURRENT_LANGUAGE***' => t("Current user's language"),
'***DEFAULT_LANGUAGE***' => t("Default site language"),
@ -1559,7 +1559,7 @@ abstract class DisplayPluginBase extends PluginBase {
$style_plugin = $this->getPlugin('style');
$form['style'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('style', $this->getStyleType(), array($this->view->storage->base_table)),
'#options' => views_fetch_plugin_names('style', $this->getStyleType(), array($this->view->storage->get('base_table'))),
'#default_value' => $style_plugin->definition['id'],
'#description' => t('If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.'),
);
@ -1601,7 +1601,7 @@ abstract class DisplayPluginBase extends PluginBase {
$row_plugin_instance = $this->getPlugin('row');
$form['row'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('row', $this->getStyleType(), array($this->view->storage->base_table)),
'#options' => views_fetch_plugin_names('row', $this->getStyleType(), array($this->view->storage->get('base_table'))),
'#default_value' => $row_plugin_instance->definition['id'],
);
@ -1616,7 +1616,7 @@ abstract class DisplayPluginBase extends PluginBase {
break;
case 'link_display':
$form['#title'] .= t('Which display to use for path');
foreach ($this->view->storage->display as $display_id => $display) {
foreach ($this->view->storage->get('display') as $display_id => $display) {
if ($this->view->displayHandlers[$display_id]->hasPath()) {
$options[$display_id] = $display['display_title'];
}
@ -1955,7 +1955,7 @@ abstract class DisplayPluginBase extends PluginBase {
$exposed_form = $this->getOption('exposed_form');
$form['exposed_form']['type'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('exposed_form', NULL, array($this->view->storage->base_table)),
'#options' => views_fetch_plugin_names('exposed_form', NULL, array($this->view->storage->get('base_table'))),
'#default_value' => $exposed_form['type'],
);
@ -1989,7 +1989,7 @@ abstract class DisplayPluginBase extends PluginBase {
$pager = $this->getOption('pager');
$form['pager']['type'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('pager', !$this->usesPager() ? 'basic' : NULL, array($this->view->storage->base_table)),
'#options' => views_fetch_plugin_names('pager', !$this->usesPager() ? 'basic' : NULL, array($this->view->storage->get('base_table'))),
'#default_value' => $pager['type'],
);
@ -2646,8 +2646,8 @@ abstract class DisplayPluginBase extends PluginBase {
$blocks = array();
if ($this->usesExposedFormInBlock()) {
$delta = '-exp-' . $this->view->storage->name . '-' . $this->display['id'];
$desc = t('Exposed form: @view-@display_id', array('@view' => $this->view->storage->name, '@display_id' => $this->display['id']));
$delta = '-exp-' . $this->view->storage->get('name') . '-' . $this->display['id'];
$desc = t('Exposed form: @view-@display_id', array('@view' => $this->view->storage->get('name'), '@display_id' => $this->display['id']));
$blocks[$delta] = array(
'info' => $desc,

View File

@ -50,7 +50,7 @@ class Feed extends Page {
// Set the default row style. Ideally this would be part of the option
// definition, but in this case it's dependent on the view's base table,
// which we don't know until init().
$row_plugins = views_fetch_plugin_names('row', $this->getStyleType(), array($view->storage->base_table));
$row_plugins = views_fetch_plugin_names('row', $this->getStyleType(), array($view->storage->get('base_table')));
$default_row_plugin = key($row_plugins);
if (empty($this->options['row']['type'])) {
$this->options['row']['type'] = $default_row_plugin;
@ -151,8 +151,9 @@ class Feed extends Page {
}
elseif (count($displays) == 1) {
$display = array_shift($displays);
if (!empty($this->view->storage->display[$display])) {
$attach_to = check_plain($this->view->storage->display[$display]['display_title']);
$displays = $this->view->storage->get('display');
if (!empty($displays[$display])) {
$attach_to = check_plain($displays[$display]['display_title']);
}
}
@ -194,7 +195,7 @@ class Feed extends Page {
case 'displays':
$form['#title'] .= t('Attach to');
$displays = array();
foreach ($this->view->storage->display as $display_id => $display) {
foreach ($this->view->storage->get('display') as $display_id => $display) {
// @todo The display plugin should have display_title and id as well.
if (!empty($this->view->displayHandlers[$display_id]) && $this->view->displayHandlers[$display_id]->acceptAttachments()) {
$displays[$display_id] = $display['display_title'];

View File

@ -80,7 +80,7 @@ class Page extends DisplayPluginBase {
// views_arg_load -- which lives in views.module
$bits = explode('/', $this->getOption('path'));
$page_arguments = array($this->view->storage->name, $this->display['id']);
$page_arguments = array($this->view->storage->get('name'), $this->display['id']);
$this->view->initHandlers();
$view_arguments = $this->view->argument;
@ -141,7 +141,7 @@ class Page extends DisplayPluginBase {
'access callback' => 'views_access',
'access arguments' => $access_arguments,
// Identify URL embedded arguments and correlate them to a handler
'load arguments' => array($this->view->storage->name, $this->display['id'], '%index'),
'load arguments' => array($this->view->storage->get('name'), $this->display['id'], '%index'),
);
$menu = $this->getOption('menu');
if (empty($menu)) {
@ -202,7 +202,7 @@ class Page extends DisplayPluginBase {
'access callback' => 'views_access',
'access arguments' => $access_arguments,
// Identify URL embedded arguments and correlate them to a handler
'load arguments' => array($this->view->storage->name, $this->display['id'], '%index'),
'load arguments' => array($this->view->storage->get('name'), $this->display['id'], '%index'),
'title' => $tab_options['title'],
'description' => $tab_options['description'],
'menu_name' => $tab_options['name'],

View File

@ -299,8 +299,8 @@ abstract class ExposedFormPluginBase extends PluginBase {
// remember settings.
$display_id = ($this->view->display_handler->isDefaulted('filters')) ? 'default' : $this->view->current_display;
if (isset($_SESSION['views'][$this->view->storage->name][$display_id])) {
unset($_SESSION['views'][$this->view->storage->name][$display_id]);
if (isset($_SESSION['views'][$this->view->storage->get('name')][$display_id])) {
unset($_SESSION['views'][$this->view->storage->get('name')][$display_id]);
}
// Set the form to allow redirect.

View File

@ -1597,19 +1597,19 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
$display = $this->view->display_handler->display;
if (!empty($display)) {
$themes[] = $hook . '__' . $this->view->storage->name . '__' . $display['id'] . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->storage->name . '__' . $display['id'];
$themes[] = $hook . '__' . $this->view->storage->get('name') . '__' . $display['id'] . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->storage->get('name') . '__' . $display['id'];
$themes[] = $hook . '__' . $display['id'] . '__' . $this->options['id'];
$themes[] = $hook . '__' . $display['id'];
if ($display['id'] != $display['display_plugin']) {
$themes[] = $hook . '__' . $this->view->storage->name . '__' . $display['display_plugin'] . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->storage->name . '__' . $display['display_plugin'];
$themes[] = $hook . '__' . $this->view->storage->get('name') . '__' . $display['display_plugin'] . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->storage->get('name') . '__' . $display['display_plugin'];
$themes[] = $hook . '__' . $display['display_plugin'] . '__' . $this->options['id'];
$themes[] = $hook . '__' . $display['display_plugin'];
}
}
$themes[] = $hook . '__' . $this->view->storage->name . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->storage->name;
$themes[] = $hook . '__' . $this->view->storage->get('name') . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->storage->get('name');
$themes[] = $hook . '__' . $this->options['id'];
$themes[] = $hook;

View File

@ -1241,8 +1241,8 @@ abstract class FilterPluginBase extends HandlerBase {
// false means that we got a setting that means to recuse ourselves,
// so we should erase whatever happened to be there.
if ($status === FALSE && isset($_SESSION['views'][$this->view->storage->name][$display_id])) {
$session = &$_SESSION['views'][$this->view->storage->name][$display_id];
if ($status === FALSE && isset($_SESSION['views'][$this->view->storage->get('name')][$display_id])) {
$session = &$_SESSION['views'][$this->view->storage->get('name')][$display_id];
if (isset($session[$this->options['group_info']['identifier']])) {
unset($session[$this->options['group_info']['identifier']]);
@ -1250,11 +1250,11 @@ abstract class FilterPluginBase extends HandlerBase {
}
if ($status !== FALSE) {
if (!isset($_SESSION['views'][$this->view->storage->name][$display_id])) {
$_SESSION['views'][$this->view->storage->name][$display_id] = array();
if (!isset($_SESSION['views'][$this->view->storage->get('name')][$display_id])) {
$_SESSION['views'][$this->view->storage->get('name')][$display_id] = array();
}
$session = &$_SESSION['views'][$this->view->storage->name][$display_id];
$session = &$_SESSION['views'][$this->view->storage->get('name')][$display_id];
$session[$this->options['group_info']['identifier']] = $input[$this->options['group_info']['identifier']];
}
@ -1335,8 +1335,8 @@ abstract class FilterPluginBase extends HandlerBase {
// false means that we got a setting that means to recuse ourselves,
// so we should erase whatever happened to be there.
if (!$status && isset($_SESSION['views'][$this->view->storage->name][$display_id])) {
$session = &$_SESSION['views'][$this->view->storage->name][$display_id];
if (!$status && isset($_SESSION['views'][$this->view->storage->get('name')][$display_id])) {
$session = &$_SESSION['views'][$this->view->storage->get('name')][$display_id];
if ($operator && isset($session[$this->options['expose']['operator_id']])) {
unset($session[$this->options['expose']['operator_id']]);
}
@ -1347,11 +1347,11 @@ abstract class FilterPluginBase extends HandlerBase {
}
if ($status) {
if (!isset($_SESSION['views'][$this->view->storage->name][$display_id])) {
$_SESSION['views'][$this->view->storage->name][$display_id] = array();
if (!isset($_SESSION['views'][$this->view->storage->get('name')][$display_id])) {
$_SESSION['views'][$this->view->storage->get('name')][$display_id] = array();
}
$session = &$_SESSION['views'][$this->view->storage->name][$display_id];
$session = &$_SESSION['views'][$this->view->storage->get('name')][$display_id];
if ($operator && isset($input[$this->options['expose']['operator_id']])) {
$session[$this->options['expose']['operator_id']] = $input[$this->options['expose']['operator_id']];

View File

@ -1281,7 +1281,7 @@ class Sql extends QueryPluginBase {
$query = Database::getConnection($target, $key)
->select($this->base_table, $this->base_table, $options)
->addTag('views')
->addTag('views_' . $this->view->storage->name);
->addTag('views_' . $this->view->storage->get('name'));
// Add the tags added to the view itself.
foreach ($this->tags as $tag) {
@ -1512,7 +1512,7 @@ class Sql extends QueryPluginBase {
drupal_set_message($e->getMessage(), 'error');
}
else {
throw new DatabaseExceptionWrapper(format_string('Exception in @human_name[@view_name]: @message', array('@human_name' => $view->storage->getHumanName(), '@view_name' => $view->storage->name, '@message' => $e->getMessage())));
throw new DatabaseExceptionWrapper(format_string('Exception in @human_name[@view_name]: @message', array('@human_name' => $view->storage->getHumanName(), '@view_name' => $view->storage->get('name'), '@message' => $e->getMessage())));
}
}
@ -1643,7 +1643,7 @@ class Sql extends QueryPluginBase {
}
function add_signature(ViewExecutable $view) {
$view->query->add_field(NULL, "'" . $view->storage->name . ':' . $view->current_display . "'", 'view_name');
$view->query->add_field(NULL, "'" . $view->storage->get('name') . ':' . $view->current_display . "'", 'view_name');
}
function get_aggregation_info() {

View File

@ -132,10 +132,10 @@ class GroupwiseMax extends RelationshipPluginBase {
// TODO: check the field is the correct sort?
// or let users hang themselves at this stage and check later?
if ($view->type == 'Default') {
$views[t('Default Views')][$view->storage->name] = $view->storage->name;
$views[t('Default Views')][$view->storage->get('name')] = $view->storage->get('name');
}
else {
$views[t('Existing Views')][$view->storage->name] = $view->storage->name;
$views[t('Existing Views')][$view->storage->get('name')] = $view->storage->get('name');
}
}
}
@ -171,7 +171,7 @@ class GroupwiseMax extends RelationshipPluginBase {
* When the form is submitted, take sure to clear the subquery string cache.
*/
public function submitOptionsForm(&$form, &$form_state) {
$cid = 'views_relationship_groupwise_max:' . $this->view->storage->name . ':' . $this->view->current_display . ':' . $this->options['id'];
$cid = 'views_relationship_groupwise_max:' . $this->view->storage->get('name') . ':' . $this->view->current_display . ':' . $this->options['id'];
cache('views_results')->delete($cid);
}
@ -362,7 +362,7 @@ class GroupwiseMax extends RelationshipPluginBase {
}
else {
// Get the stored subquery SQL string.
$cid = 'views_relationship_groupwise_max:' . $this->view->storage->name . ':' . $this->view->current_display . ':' . $this->options['id'];
$cid = 'views_relationship_groupwise_max:' . $this->view->storage->get('name') . ':' . $this->view->current_display . ':' . $this->options['id'];
$cache = cache('views_results')->get($cid);
if (isset($cache->data)) {
$def['left_query'] = $cache->data;

View File

@ -124,7 +124,7 @@ class DefaultViewsTest extends WebTestBase {
foreach ($views as $name => $view_storage) {
$view = new ViewExecutable($view_storage);
$view->initDisplay();
foreach ($view->storage->display as $display_id => $display) {
foreach ($view->storage->get('display') as $display_id => $display) {
$view->setDisplay($display_id);
// Add any args if needed.
@ -132,7 +132,7 @@ class DefaultViewsTest extends WebTestBase {
$view->preExecute($this->viewArgMap[$name]);
}
$this->assert(TRUE, format_string('View @view will be executed.', array('@view' => $view->storage->name)));
$this->assert(TRUE, format_string('View @view will be executed.', array('@view' => $view->storage->get('name'))));
$view->execute();
$tokens = array('@name' => $name, '@display_id' => $display_id);

View File

@ -39,7 +39,7 @@ class CacheTest extends PluginTestBase {
// Create the basic view.
$view = $this->createViewFromConfig('test_view');
$view->storage->addDisplay('default');
$view->storage->base_table = 'views_test_data';
$view->storage->set('base_table', 'views_test_data');
// Set up the fields we need.
$display = $view->storage->newDisplay('default', 'Master', 'default');
@ -167,7 +167,7 @@ class CacheTest extends PluginTestBase {
// Some hook_views_pre_render in views_test_data.module adds the test css/js file.
// so they should be added to the css/js storage.
$view = $this->getView();
$view->storage->name = 'test_cache_header_storage';
$view->storage->set('name', 'test_cache_header_storage');
$view->display_handler->overrideOption('cache', array(
'type' => 'time',
'options' => array(
@ -193,7 +193,7 @@ class CacheTest extends PluginTestBase {
// Now add some css/jss before running the view.
// Make sure that this css is not added when running the cached view.
$view->storage->name = 'test_cache_header_storage_2';
$view->storage->set('name', 'test_cache_header_storage_2');
$system_css_path = drupal_get_path('module', 'system') . '/system.maintenance.css';
drupal_add_css($system_css_path);

View File

@ -53,8 +53,9 @@ class DisplayTest extends PluginTestBase {
// Add a new 'display_test' display and test it's there.
$view->storage->addDisplay('display_test');
$displays = $view->storage->get('display');
$this->assertTrue(isset($view->storage->display['display_test_1']), 'Added display has been assigned to "display_test_1"');
$this->assertTrue(isset($displays['display_test_1']), 'Added display has been assigned to "display_test_1"');
// Check the the display options are like expected.
$options = array(
@ -64,7 +65,7 @@ class DisplayTest extends PluginTestBase {
'display_title' => 'Display test',
'position' => NULL,
);
$this->assertEqual($view->storage->display['display_test_1'], $options);
$this->assertEqual($displays['display_test_1'], $options);
$view->setDisplay('display_test_1');

View File

@ -27,7 +27,7 @@ class DisplayExtenderUITest extends UITestBase {
config('views.settings')->set('display_extenders', array('display_extender_test'))->save();
$view = $this->getView();
$view_edit_url = "admin/structure/views/view/{$view->storage->name}/edit";
$view_edit_url = "admin/structure/views/view/{$view->storage->get('name')}/edit";
$display_option_url = 'admin/structure/views/nojs/display/test_view/default/test_extender_test_option';
$this->drupalGet($view_edit_url);
@ -37,7 +37,7 @@ class DisplayExtenderUITest extends UITestBase {
$this->drupalPost($display_option_url, array('test_extender_test_option' => $random_text), t('Apply'));
$this->assertLink($random_text);
$this->drupalPost(NULL, array(), t('Save'));
$view = views_get_view($view->storage->name);
$view = views_get_view($view->storage->get('name'));
$view->initDisplay();
$this->assertEqual($view->display_handler->getOption('test_extender_test_option'), $random_text, 'Make sure that the display extender option got saved.');
}

View File

@ -117,9 +117,10 @@ class DisplayTest extends UITestBase {
$this->drupalPost(NULL, array(), t('Save'));
$view = views_get_view($view['name']);
$this->assertEqual($view->storage->display['default']['position'], 0, 'Make sure the master display comes first.');
$this->assertEqual($view->storage->display['block_1']['position'], 1, 'Make sure the block display comes before the page display.');
$this->assertEqual($view->storage->display['page_1']['position'], 2, 'Make sure the page display comes after the block display.');
$displays = $view->storage->get('display');
$this->assertEqual($displays['default']['position'], 0, 'Make sure the master display comes first.');
$this->assertEqual($displays['block_1']['position'], 1, 'Make sure the block display comes before the page display.');
$this->assertEqual($displays['page_1']['position'], 2, 'Make sure the page display comes after the block display.');
}
/**

View File

@ -27,7 +27,7 @@ class RedirectTest extends UITestBase {
$view = $this->getBasicView();
$random_destination = $this->randomName();
$edit_path = "admin/structure/views/view/{$view->storage->name}/edit";
$edit_path = "admin/structure/views/view/{$view->storage->get('name')}/edit";
$this->drupalPost($edit_path, array(), t('Save') , array('query' => array('destination' => $random_destination)));
$this->assertUrl($random_destination, array(), 'Make sure the user got redirected to the expected page defined in the destination.');
@ -39,8 +39,8 @@ class RedirectTest extends UITestBase {
$random_destination = $this->randomName();
$new_path = $this->randomName();
$edit_path = "admin/structure/views/view/{$view->storage->name}/edit";
$path_edit_path = "admin/structure/views/nojs/display/{$view->storage->name}/page_1/path";
$edit_path = "admin/structure/views/view/{$view->storage->get('name')}/edit";
$path_edit_path = "admin/structure/views/nojs/display/{$view->storage->get('name')}/page_1/path";
$this->drupalPost($path_edit_path, array('path' => $new_path), t('Apply'));
$this->drupalPost($edit_path, array(), t('Save'), array('query' => array('destination' => 'test-redirect-view')));

View File

@ -27,10 +27,10 @@ class RowUITest extends UITestBase {
*/
public function testRowUI() {
$view = $this->getView();
$view_edit_url = "admin/structure/views/view/{$view->storage->name}/edit";
$view_edit_url = "admin/structure/views/view/{$view->storage->get('name')}/edit";
$row_plugin_url = "admin/structure/views/nojs/display/{$view->storage->name}/default/row";
$row_options_url = "admin/structure/views/nojs/display/{$view->storage->name}/default/row_options";
$row_plugin_url = "admin/structure/views/nojs/display/{$view->storage->get('name')}/default/row";
$row_options_url = "admin/structure/views/nojs/display/{$view->storage->get('name')}/default/row_options";
$this->drupalGet($row_plugin_url);
$this->assertFieldByName('row', 'fields', 'The default row plugin selected in the UI should be fields.');
@ -51,7 +51,7 @@ class RowUITest extends UITestBase {
$this->drupalPost($view_edit_url, array(), t('Save'));
$this->assertLink(t('Test row plugin'), 0, 'Make sure the test row plugin is shown in the UI');
$view = views_get_view($view->storage->name);
$view = views_get_view($view->storage->get('name'));
$view->initDisplay();
$row = $view->display_handler->getOption('row');
$this->assertEqual($row['type'], 'test_row', 'Make sure that the test_row got saved as used row plugin.');

View File

@ -28,7 +28,7 @@ class StorageTest extends UITestBase {
public function testDetails() {
$view = $this->getBasicView();
$path = "admin/structure/views/nojs/edit-details/{$view->storage->name}";
$path = "admin/structure/views/nojs/edit-details/{$view->storage->get('name')}";
$edit = array(
'human_name' => $this->randomName(),
'tag' => $this->randomName(),
@ -37,7 +37,7 @@ class StorageTest extends UITestBase {
$this->drupalPost($path, $edit, t('Apply'));
$this->drupalPost(NULL, array(), t('Save'));
$view = views_get_view($view->storage->name);
$view = views_get_view($view->storage->get('name'));
foreach (array('human_name', 'tag', 'description') as $property) {
$this->assertEqual($view->storage->{$property}, $edit[$property], format_string('Make sure the property @property got probably saved.', array('@property' => $property)));

View File

@ -27,10 +27,10 @@ class StyleUITest extends UITestBase {
*/
public function testStyleUI() {
$view = $this->getView();
$view_edit_url = "admin/structure/views/view/{$view->storage->name}/edit";
$view_edit_url = "admin/structure/views/view/{$view->storage->get('name')}/edit";
$style_plugin_url = "admin/structure/views/nojs/display/{$view->storage->name}/default/style";
$style_options_url = "admin/structure/views/nojs/display/{$view->storage->name}/default/style_options";
$style_plugin_url = "admin/structure/views/nojs/display/{$view->storage->get('name')}/default/style";
$style_options_url = "admin/structure/views/nojs/display/{$view->storage->get('name')}/default/style_options";
$this->drupalGet($style_plugin_url);
$this->assertFieldByName('style', 'default', 'The default style plugin selected in the UI should be unformatted list.');
@ -51,7 +51,7 @@ class StyleUITest extends UITestBase {
$this->drupalPost($view_edit_url, array(), t('Save'));
$this->assertLink(t('Test style plugin'), 0, 'Make sure the test style plugin is shown in the UI');
$view = views_get_view($view->storage->name);
$view = views_get_view($view->storage->get('name'));
$view->initDisplay();
$style = $view->display_handler->getOption('style');
$this->assertEqual($style['type'], 'test_style', 'Make sure that the test_style got saved as used style plugin.');

View File

@ -464,7 +464,7 @@ class ViewStorageTest extends ViewTestBase {
}
// Check the displays are the same.
foreach ($view->storage->display as $id => $display) {
foreach ($view->storage->get('display') as $id => $display) {
// assertIdentical will not work here.
$this->assertEqual($display, $copy->display[$id], format_string('The @display display has been copied correctly.', array('@display' => $id)));
}

View File

@ -558,8 +558,8 @@ class ViewExecutable {
// remember settings.
$display_id = ($this->display_handler->isDefaulted('filters')) ? 'default' : $this->current_display;
if (empty($this->exposed_input) && !empty($_SESSION['views'][$this->storage->name][$display_id])) {
$this->exposed_input = $_SESSION['views'][$this->storage->name][$display_id];
if (empty($this->exposed_input) && !empty($_SESSION['views'][$this->storage->get('name')][$display_id])) {
$this->exposed_input = $_SESSION['views'][$this->storage->get('name')][$display_id];
}
}
@ -575,11 +575,12 @@ class ViewExecutable {
}
// Instantiate all displays
foreach (array_keys($this->storage->display) as $id) {
$this->displayHandlers[$id] = views_get_plugin('display', $this->storage->display[$id]['display_plugin']);
foreach ($this->storage->get('display') as $id => $display) {
$this->displayHandlers[$id] = views_get_plugin('display', $display['display_plugin']);
if (!empty($this->displayHandlers[$id])) {
// Initialize the new display handler with data.
$this->displayHandlers[$id]->init($this, $this->storage->display[$id]);
// @todo Refactor display to not need the handler data by reference.
$this->displayHandlers[$id]->init($this, $this->storage->getDisplay($id));
// If this is NOT the default display handler, let it know which is
// since it may well utilize some data from the default.
// This assumes that the 'default' handler is always first. It always
@ -650,7 +651,7 @@ class ViewExecutable {
if (empty($this->displayHandlers[$display_id])) {
$display_id = 'default';
if (empty($this->displayHandlers[$display_id])) {
debug('set_display() called with invalid display ID @display.', array('@display' => $display_id));
debug(format_string('set_display() called with invalid display ID @display.', array('@display' => $display_id)));
return FALSE;
}
}
@ -753,7 +754,7 @@ class ViewExecutable {
*/
public function getBaseTables() {
$base_tables = array(
$this->storage->base_table => TRUE,
$this->storage->get('base_table') => TRUE,
'#global' => TRUE,
);
@ -937,8 +938,8 @@ class ViewExecutable {
}
// Create and initialize the query object.
$views_data = views_fetch_data($this->storage->base_table);
$this->storage->base_field = !empty($views_data['table']['base']['field']) ? $views_data['table']['base']['field'] : '';
$views_data = views_fetch_data($this->storage->get('base_table'));
$this->storage->set('base_field', !empty($views_data['table']['base']['field']) ? $views_data['table']['base']['field'] : '');
if (!empty($views_data['table']['base']['database'])) {
$this->base_database = $views_data['table']['base']['database'];
}
@ -954,7 +955,7 @@ class ViewExecutable {
return FALSE;
}
$this->query->init($this->storage->base_table, $this->storage->base_field, $query_options['options']);
$this->query->init($this->storage->get('base_table'), $this->storage->get('base_field'), $query_options['options']);
return TRUE;
}
@ -1434,7 +1435,7 @@ class ViewExecutable {
}
// Allow hook_views_pre_view() to set the dom_id, then ensure it is set.
$this->dom_id = !empty($this->dom_id) ? $this->dom_id : md5($this->storage->name . REQUEST_TIME . rand());
$this->dom_id = !empty($this->dom_id) ? $this->dom_id : md5($this->storage->get('name') . REQUEST_TIME . rand());
// Allow the display handler to set up for execution
$this->display_handler->preExecute();
@ -2210,7 +2211,8 @@ class ViewExecutable {
*/
public function &newDisplay($id) {
// Create a handler.
$this->displayHandlers[$id] = views_get_plugin('display', $this->storage->display[$id]['display_plugin']);
$display = $this->storage->get('display');
$this->displayHandlers[$id] = views_get_plugin('display', $display[$id]['display_plugin']);
if (empty($this->displayHandlers[$id])) {
// provide a 'default' handler as an emergency. This won't work well but
// it will keep things from crashing.
@ -2219,13 +2221,14 @@ class ViewExecutable {
if (!empty($this->displayHandlers[$id])) {
// Initialize the new display handler with data.
$this->displayHandlers[$id]->init($this, $this->storage->display[$id]);
$this->displayHandlers[$id]->init($this, $display[$id]);
// If this is NOT the default display handler, let it know which is
if ($id != 'default') {
// @todo is the '&' still required in php5?
$this->displayHandlers[$id]->default_display = &$this->displayHandlers['default'];
}
}
$this->storage->set('display', $display);
return $this->displayHandlers[$id];
}

View File

@ -329,6 +329,19 @@ class ViewStorage extends ConfigEntityBase implements ViewStorageInterface {
return $this->getExecutable()->newDisplay($id);
}
/**
* Retrieves a specific display's configuration by reference.
*
* @param string $display_id
* The display ID to retrieve, e.g., 'default', 'page_1', 'block_2'.
*
* @return array
* A reference to the specified display configuration.
*/
public function &getDisplay($display_id) {
return $this->display[$display_id];
}
/**
* Gets a list of displays included in the view.
*

View File

@ -75,7 +75,7 @@ function views_test_data_handler_test_access_callback_argument($argument = FALSE
* Implements hook_views_pre_render().
*/
function views_test_data_views_pre_render(ViewExecutable $view) {
if ($view->storage->name == 'test_cache_header_storage') {
if ($view->storage->get('name') == 'test_cache_header_storage') {
drupal_add_js(drupal_get_path('module', 'views_test_data') . '/views_cache.test.js');
drupal_add_css(drupal_get_path('module', 'views_test_data') . '/views_cache.test.css');
$view->build_info['pre_render_called'] = TRUE;
@ -86,7 +86,7 @@ function views_test_data_views_pre_render(ViewExecutable $view) {
* Implements hook_views_post_build().
*/
function views_test_data_views_post_build(ViewExecutable $view) {
if ($view->storage->name == 'test_page_display') {
if ($view->storage->get('name') == 'test_page_display') {
if ($view->current_display == 'page_1') {
$view->build_info['denied'] = TRUE;
}

View File

@ -22,19 +22,19 @@ function _views_theme_functions($hook, ViewExecutable $view, $display = NULL) {
$themes = array();
if ($display) {
$themes[] = $hook . '__' . $view->storage->name . '__' . $display['id'];
$themes[] = $hook . '__' . $view->storage->get('name') . '__' . $display['id'];
$themes[] = $hook . '__' . $display['id'];
// Add theme suggestions for each single tag.
foreach (drupal_explode_tags($view->storage->tag) as $tag) {
foreach (drupal_explode_tags($view->storage->get('tag')) as $tag) {
$themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '_', strtolower($tag));
}
if ($display['id'] != $display['display_plugin']) {
$themes[] = $hook . '__' . $view->storage->name . '__' . $display['display_plugin'];
$themes[] = $hook . '__' . $view->storage->get('name') . '__' . $display['display_plugin'];
$themes[] = $hook . '__' . $display['display_plugin'];
}
}
$themes[] = $hook . '__' . $view->storage->name;
$themes[] = $hook . '__' . $view->storage->get('name');
$themes[] = $hook;
return $themes;
}
@ -49,8 +49,8 @@ function template_preprocess_views_view(&$vars) {
$vars['rows'] = (!empty($view->result) || $view->style_plugin->even_empty()) ? $view->style_plugin->render($view->result) : '';
$vars['css_name'] = drupal_clean_css_identifier($view->storage->name);
$vars['name'] = $view->storage->name;
$vars['css_name'] = drupal_clean_css_identifier($view->storage->get('name'));
$vars['name'] = $view->storage->get('name');
$vars['display_id'] = $view->current_display;
// Basic classes
@ -125,7 +125,7 @@ function template_preprocess_views_view(&$vars) {
'ajax_path' => url('views/ajax'),
'ajaxViews' => array(
'views_dom_id:' . $vars['dom_id'] => array(
'view_name' => $view->storage->name,
'view_name' => $view->storage->get('name'),
'view_display_id' => $view->current_display,
'view_args' => check_plain(implode('/', $view->args)),
'view_path' => check_plain(current_path()),

View File

@ -70,7 +70,7 @@ function views_forms($form_id, $args) {
function views_form_id($view) {
$parts = array(
'views_form',
$view->storage->name,
$view->storage->get('name'),
$view->current_display,
);
@ -333,7 +333,7 @@ function views_plugin_list() {
}
// Add this view to the list for this plugin.
$plugins[$key]['views'][$view->storage->name] = $view->storage->name;
$plugins[$key]['views'][$view->storage->get('name')] = $view->storage->get('name');
}
}
}
@ -350,11 +350,11 @@ function views_plugin_list() {
*/
function views_preprocess_node(&$vars) {
// The 'view' attribute of the node is added in views_preprocess_node()
if (!empty($vars['node']->view) && !empty($vars['node']->view->storage->name)) {
if (!empty($vars['node']->view) && $vars['node']->view->storage->get('name')) {
$vars['view'] = $vars['node']->view;
$vars['theme_hook_suggestions'][] = 'node__view__' . $vars['node']->view->storage->name;
$vars['theme_hook_suggestions'][] = 'node__view__' . $vars['node']->view->storage->get('name');
if (!empty($vars['node']->view->current_display)) {
$vars['theme_hook_suggestions'][] = 'node__view__' . $vars['node']->view->storage->name . '__' . $vars['node']->view->current_display;
$vars['theme_hook_suggestions'][] = 'node__view__' . $vars['node']->view->storage->get('name') . '__' . $vars['node']->view->current_display;
// If a node is being rendered in a view, and the view does not have a path,
// prevent drupal from accidentally setting the $page variable:
@ -376,11 +376,11 @@ function views_preprocess_node(&$vars) {
*/
function views_preprocess_comment(&$vars) {
// The 'view' attribute of the node is added in template_preprocess_views_view_row_comment()
if (!empty($vars['comment']->view) && !empty($vars['comment']->view->storage->name)) {
if (!empty($vars['comment']->view) && $vars['comment']->view->storage->get('name')) {
$vars['view'] = &$vars['comment']->view;
$vars['theme_hook_suggestions'][] = 'comment__view__' . $vars['comment']->view->storage->name;
$vars['theme_hook_suggestions'][] = 'comment__view__' . $vars['comment']->view->storage->get('name');
if (!empty($vars['node']->view->current_display)) {
$vars['theme_hook_suggestions'][] = 'comment__view__' . $vars['comment']->view->storage->name . '__' . $vars['comment']->view->current_display;
$vars['theme_hook_suggestions'][] = 'comment__view__' . $vars['comment']->view->storage->get('name') . '__' . $vars['comment']->view->current_display;
}
}
}
@ -903,7 +903,7 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable
$render_element['#views_contextual_links_info'][$module] = array(
'location' => $location,
'view' => $view,
'view_name' => $view->storage->name,
'view_name' => $view->storage->get('name'),
'view_display_id' => $display_id,
);
}
@ -1796,7 +1796,7 @@ function views_exposed_form($form, &$form_state) {
// Let form plugins know this is for exposed widgets.
$form_state['exposed'] = TRUE;
// Check if the form was already created
if ($cache = views_exposed_form_cache($view->storage->name, $view->current_display)) {
if ($cache = views_exposed_form_cache($view->storage->get('name'), $view->current_display)) {
return $cache;
}
@ -1830,12 +1830,12 @@ function views_exposed_form($form, &$form_state) {
'#name' => '',
'#type' => 'submit',
'#value' => t('Apply'),
'#id' => drupal_html_id('edit-submit-' . $view->storage->name),
'#id' => drupal_html_id('edit-submit-' . $view->storage->get('name')),
);
$form['#action'] = url($view->display_handler->getUrl());
$form['#theme'] = views_theme_functions('views_exposed_form', $view, $display);
$form['#id'] = drupal_clean_css_identifier('views_exposed_form-' . check_plain($view->storage->name) . '-' . check_plain($display['id']));
$form['#id'] = drupal_clean_css_identifier('views_exposed_form-' . check_plain($view->storage->get('name')) . '-' . check_plain($display['id']));
// $form['#attributes']['class'] = array('views-exposed-form');
// If using AJAX, we need the form plugin.
@ -1847,7 +1847,7 @@ function views_exposed_form($form, &$form_state) {
$exposed_form_plugin->exposed_form_alter($form, $form_state);
// Save the form
views_exposed_form_cache($view->storage->name, $view->current_display, $form);
views_exposed_form_cache($view->storage->get('name'), $view->current_display, $form);
return $form;
}

View File

@ -86,11 +86,11 @@ function views_tokens($type, $tokens, array $data = array(), array $options = ar
break;
case 'description':
$replacements[$original] = $sanitize ? check_plain($view->storage->description) : $view->storage->description;
$replacements[$original] = $sanitize ? check_plain($view->storage->get('description')) : $view->storage->get('description');
break;
case 'machine-name':
$replacements[$original] = $view->storage->name;
$replacements[$original] = $view->storage->get('name');
break;
case 'title':
@ -104,10 +104,10 @@ function views_tokens($type, $tokens, array $data = array(), array $options = ar
}
break;
case 'base-table':
$replacements[$original] = $view->storage->base_table;
$replacements[$original] = $view->storage->get('base_table');
break;
case 'base-field':
$replacements[$original] = $view->storage->base_field;
$replacements[$original] = $view->storage->get('base_field');
break;
case 'total-rows':
$replacements[$original] = count($view->result);

View File

@ -369,7 +369,7 @@ function views_ui_add_form_store_edit_submit($form, &$form_state) {
$destination = drupal_get_destination();
$query->remove('destination');
}
$form_state['redirect'] = array('admin/structure/views/view/' . $view->storage->name, array('query' => $destination));
$form_state['redirect'] = array('admin/structure/views/view/' . $view->storage->get('name'), array('query' => $destination));
}
/**
@ -435,19 +435,19 @@ function views_ui_break_lock_confirm($form, &$form_state, ViewUI $view) {
$form = array();
if (empty($view->locked)) {
$form['message']['#markup'] = t('There is no lock on view %name to break.', array('%name' => $view->storage->name));
$form['message']['#markup'] = t('There is no lock on view %name to break.', array('%name' => $view->storage->get('name')));
return $form;
}
$cancel = drupal_container()->get('request')->query->get('cancel');
if (empty($cancel)) {
$cancel = 'admin/structure/views/view/' . $view->storage->name . '/edit';
$cancel = 'admin/structure/views/view/' . $view->storage->get('name') . '/edit';
}
$account = user_load($view->locked->owner);
$form = confirm_form($form,
t('Are you sure you want to break the lock on view %name?',
array('%name' => $view->storage->name)),
array('%name' => $view->storage->get('name'))),
$cancel,
t('By breaking this lock, any unsaved changes made by !user will be lost!', array('!user' => theme('username', array('account' => $account)))),
t('Break lock'),
@ -598,10 +598,11 @@ function views_ui_edit_view_form_validate($form, &$form_state) {
*/
function views_ui_edit_view_form_submit($form, &$form_state) {
// Go through and remove displayed scheduled for removal.
foreach ($form_state['view']->storage->display as $id => $display) {
$displays = $form_state['view']->storage->get('display');
foreach ($displays as $id => $display) {
if (!empty($display['deleted'])) {
unset($form_state['view']->displayHandlers[$id]);
unset($form_state['view']->storage->display[$id]);
unset($displays[$id]);
}
}
// Rename display ids if needed.
@ -611,12 +612,13 @@ function views_ui_edit_view_form_submit($form, &$form_state) {
$form_state['view']->displayHandlers[$new_id] = $form_state['view']->displayHandlers[$id];
$form_state['view']->displayHandlers[$new_id]->display['id'] = $new_id;
$form_state['view']->storage->display[$new_id] = $form_state['view']->storage->display[$id];
unset($form_state['view']->storage->display[$id]);
$displays[$new_id] = $displays[$id];
unset($displays[$id]);
// Redirect the user to the renamed display to be sure that the page itself exists and doesn't throw errors.
$form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->storage->name . '/edit/' . $new_id;
$form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->storage->get('name') . '/edit/' . $new_id;
}
}
$form_state['view']->storage->set('display', $displays);
// Direct the user to the right url, if the path of the display has changed.
$query = drupal_container()->get('request')->query;
@ -624,7 +626,7 @@ function views_ui_edit_view_form_submit($form, &$form_state) {
$destination = $query->get('destination');
if (!empty($destination)) {
// Find out the first display which has a changed path and redirect to this url.
$old_view = views_get_view($form_state['view']->storage->name);
$old_view = views_get_view($form_state['view']->storage->get('name'));
$old_view->initDisplay();
foreach ($old_view->displayHandlers as $id => $display) {
// Only check for displays with a path.
@ -648,7 +650,7 @@ function views_ui_edit_view_form_submit($form, &$form_state) {
drupal_set_message(t('The view %name has been saved.', array('%name' => $form_state['view']->storage->getHumanName())));
// Remove this view from cache so we can edit it properly.
drupal_container()->get('user.tempstore')->get('views')->delete($form_state['view']->storage->name);
drupal_container()->get('user.tempstore')->get('views')->delete($form_state['view']->storage->get('name'));
}
/**
@ -656,7 +658,7 @@ function views_ui_edit_view_form_submit($form, &$form_state) {
*/
function views_ui_edit_view_form_cancel($form, &$form_state) {
// Remove this view from cache so edits will be lost.
drupal_container()->get('user.tempstore')->get('views')->delete($form_state['view']->storage->name);
drupal_container()->get('user.tempstore')->get('views')->delete($form_state['view']->storage->get('name'));
if (empty($form['view']->vid)) {
// I seem to have to drupal_goto here because I can't get fapi to
// honor the redirect target. Not sure what I screwed up here.
@ -797,7 +799,7 @@ function views_ui_ajax_forms($key = NULL) {
function views_ui_build_form_url($form_state) {
$form = views_ui_ajax_forms($form_state['form_key']);
$ajax = empty($form_state['ajax']) ? 'nojs' : 'ajax';
$name = $form_state['view']->storage->name;
$name = $form_state['view']->storage->get('name');
$url = "admin/structure/views/$ajax/$form_state[form_key]/$name/$form_state[display_id]";
foreach ($form['args'] as $arg) {
$url .= '/' . $form_state[$arg];
@ -878,7 +880,7 @@ function views_ui_ajax_form($js, $key, ViewUI $view, $display_id = '') {
}
elseif (!$js) {
// if nothing on the stack, non-js forms just go back to the main view editor.
return drupal_goto("admin/structure/views/view/{$view->storage->name}/edit");
return drupal_goto("admin/structure/views/view/{$view->storage->get('name')}/edit");
}
else {
$output = array();
@ -927,7 +929,7 @@ function views_ui_analyze_view_form($form, &$form_state) {
* Submit handler for views_ui_analyze_view_form
*/
function views_ui_analyze_view_form_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->storage->name . '/edit';
$form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->storage->get('name') . '/edit';
}
/**
@ -953,14 +955,14 @@ function views_ui_edit_details_form($form, &$form_state) {
'#type' => 'textfield',
'#title' => t('View tag'),
'#description' => t('Optionally, enter a comma delimited list of tags for this view to use in filtering and sorting views on the administrative page.'),
'#default_value' => $view->storage->tag,
'#default_value' => $view->storage->get('tag'),
'#autocomplete_path' => 'admin/views/ajax/autocomplete/tag',
);
$form['details']['description'] = array(
'#type' => 'textfield',
'#title' => t('View description'),
'#description' => t('This description will appear on the Views administrative UI to tell you what the view is about.'),
'#default_value' => $view->storage->description,
'#default_value' => $view->storage->get('description'),
);
$view->getStandardButtons($form, $form_state, 'views_ui_edit_details_form');
@ -1702,7 +1704,7 @@ function views_ui_config_item_form($form, &$form_state) {
if (!empty($relationship_options)) {
// Make sure the existing relationship is even valid. If not, force
// it to none.
$base_fields = views_fetch_fields($view->storage->base_table, $form_state['type'], $view->display_handler->useGroupBy());
$base_fields = views_fetch_fields($view->storage->get('base_table'), $form_state['type'], $view->display_handler->useGroupBy());
if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
$relationship_options = array_merge(array('none' => t('Do not use a relationship')), $relationship_options);
}
@ -2593,7 +2595,7 @@ function views_ui_field_list() {
&& $data = $data[$item['field']][$type]) {
// The final check that we have a fieldapi field now.
if (isset($data['field_name'])) {
$fields[$data['field_name']][$view->storage->name] = $view->storage->name;
$fields[$data['field_name']][$view->storage->get('name')] = $view->storage->get('name');
}
}
}

View File

@ -38,8 +38,8 @@ class ViewListController extends EntityListController {
return array(
'data' => array(
'view_name' => theme('views_ui_view_info', array('view' => $view)),
'description' => $view->description,
'tag' => $view->tag,
'description' => $view->get('description'),
'tag' => $view->get('tag'),
'path' => implode(', ', $view->getPaths()),
'operations' => array(
'data' => $this->buildOperations($view),

View File

@ -105,7 +105,8 @@ class ViewUI extends ViewExecutable {
* @todo Remove this function once editing the display title is possible.
*/
public function getDisplayLabel($display_id, $check_changed = TRUE) {
$title = $display_id == 'default' ? t('Master') : $this->storage->display[$display_id]['display_title'];
$display = $this->storage->get('display');
$title = $display_id == 'default' ? t('Master') : $display[$display_id]['display_title'];
$title = views_ui_truncate($title, 25);
if ($check_changed && !empty($this->changed_display[$display_id])) {
@ -395,21 +396,21 @@ class ViewUI extends ViewExecutable {
'#links' => array(
'edit-details' => array(
'title' => t('edit view name/description'),
'href' => "admin/structure/views/nojs/edit-details/{$this->storage->name}",
'href' => "admin/structure/views/nojs/edit-details/{$this->storage->get('name')}",
'attributes' => array('class' => array('views-ajax-link')),
),
'analyze' => array(
'title' => t('analyze view'),
'href' => "admin/structure/views/nojs/analyze/{$this->storage->name}/$display_id",
'href' => "admin/structure/views/nojs/analyze/{$this->storage->get('name')}/$display_id",
'attributes' => array('class' => array('views-ajax-link')),
),
'clone' => array(
'title' => t('clone view'),
'href' => "admin/structure/views/view/{$this->storage->name}/clone",
'href' => "admin/structure/views/view/{$this->storage->get('name')}/clone",
),
'reorder' => array(
'title' => t('reorder displays'),
'href' => "admin/structure/views/nojs/reorder-displays/{$this->storage->name}/$display_id",
'href' => "admin/structure/views/nojs/reorder-displays/{$this->storage->get('name')}/$display_id",
'attributes' => array('class' => array('views-ajax-link')),
),
),
@ -422,14 +423,14 @@ class ViewUI extends ViewExecutable {
if ($this->type == t('Overridden')) {
$element['extra_actions']['#links']['revert'] = array(
'title' => t('revert view'),
'href' => "admin/structure/views/view/{$this->storage->name}/revert",
'query' => array('destination' => "admin/structure/views/view/{$this->storage->name}"),
'href' => "admin/structure/views/view/{$this->storage->get('name')}/revert",
'query' => array('destination' => "admin/structure/views/view/{$this->storage->get('name')}"),
);
}
else {
$element['extra_actions']['#links']['delete'] = array(
'title' => t('delete view'),
'href' => "admin/structure/views/view/{$this->storage->name}/delete",
'href' => "admin/structure/views/view/{$this->storage->get('name')}/delete",
);
}
}
@ -445,7 +446,7 @@ class ViewUI extends ViewExecutable {
}
// Buttons for adding a new display.
foreach (views_fetch_plugin_names('display', NULL, array($this->storage->base_table)) as $type => $label) {
foreach (views_fetch_plugin_names('display', NULL, array($this->storage->get('base_table'))) as $type => $label) {
$element['add_display'][$type] = array(
'#type' => 'submit',
'#value' => t('Add !display', array('!display' => $label)),
@ -481,13 +482,15 @@ class ViewUI extends ViewExecutable {
$tabs = array();
// Create a tab for each display.
uasort($this->storage->display, array('static', 'sortPosition'));
foreach ($this->storage->display as $id => $display) {
$displays = $this->storage->get('display');
uasort($displays, array('static', 'sortPosition'));
$this->storage->set('display', $displays);
foreach ($displays as $id => $display) {
$tabs[$id] = array(
'#theme' => 'menu_local_task',
'#link' => array(
'title' => $this->getDisplayLabel($id),
'href' => 'admin/structure/views/view/' . $this->storage->name . '/edit/' . $id,
'href' => 'admin/structure/views/view/' . $this->storage->get('name') . '/edit/' . $id,
'localized_options' => array(),
),
);
@ -506,7 +509,7 @@ class ViewUI extends ViewExecutable {
// Mark the display tab as red to show validation errors.
$this->validate();
foreach ($this->storage->display as $id => $display) {
foreach ($this->storage->get('display') as $id => $display) {
if (!empty($this->display_errors[$id])) {
// Always show the tab.
$tabs[$id]['#access'] = TRUE;
@ -617,7 +620,7 @@ class ViewUI extends ViewExecutable {
views_ui_cache_set($this);
}
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name . '/edit';
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->get('name') . '/edit';
}
/**
@ -778,7 +781,7 @@ class ViewUI extends ViewExecutable {
views_ui_cache_set($this);
// Redirect to the new display's edit page.
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name . '/edit/' . $display_id;
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->get('name') . '/edit/' . $display_id;
}
/**
@ -788,10 +791,11 @@ class ViewUI extends ViewExecutable {
$display_id = $form_state['display_id'];
// Create the new display.
$display = $this->storage->display[$display_id];
$new_display_id = $this->storage->addDisplay($display['display_plugin']);
$this->storage->display[$new_display_id] = $display;
$this->storage->display[$new_display_id]['id'] = $new_display_id;
$displays = $this->storage->get('display');
$new_display_id = $this->storage->addDisplay($displays[$display_id]['display_plugin']);
$displays[$new_display_id] = $displays[$display_id];
$displays[$new_display_id]['id'] = $new_display_id;
$this->storage->set('display', $displays);
// By setting the current display the changed marker will appear on the new
// display.
@ -799,7 +803,7 @@ class ViewUI extends ViewExecutable {
views_ui_cache_set($this);
// Redirect to the new display's edit page.
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name . '/edit/' . $new_display_id;
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->get('name') . '/edit/' . $new_display_id;
}
/**
@ -809,12 +813,14 @@ class ViewUI extends ViewExecutable {
$display_id = $form_state['display_id'];
// Mark the display for deletion.
$this->storage->display[$display_id]['deleted'] = TRUE;
$displays = $this->storage->get('display');
$displays[$display_id]['deleted'] = TRUE;
$this->storage->set('display', $displays);
views_ui_cache_set($this);
// Redirect to the top-level edit page. The first remaining display will
// become the active display.
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name;
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->get('name');
}
/**
@ -859,7 +865,7 @@ class ViewUI extends ViewExecutable {
views_ui_cache_set($this);
// Redirect to the top-level edit page.
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name . '/edit/' . $id;
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->get('name') . '/edit/' . $id;
}
/**
@ -873,7 +879,7 @@ class ViewUI extends ViewExecutable {
views_ui_cache_set($this);
// Redirect to the top-level edit page.
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name . '/edit/' . $id;
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->get('name') . '/edit/' . $id;
}
/**
@ -882,13 +888,15 @@ class ViewUI extends ViewExecutable {
public function submitDisplayUndoDelete($form, &$form_state) {
// Create the new display
$id = $form_state['display_id'];
$this->storage->display[$id]['deleted'] = FALSE;
$displays = $this->storage->get('display');
$displays[$id]['deleted'] = FALSE;
$this->storage->set('display', $displays);
// Store in cache
views_ui_cache_set($this);
// Redirect to the top-level edit page.
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name . '/edit/' . $id;
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->get('name') . '/edit/' . $id;
}
/**
@ -909,7 +917,7 @@ class ViewUI extends ViewExecutable {
// to get the right one.
switch ($type) {
case 'filter':
$rearrange_url = "admin/structure/views/nojs/rearrange-$type/{$this->storage->name}/{$display['id']}/$type";
$rearrange_url = "admin/structure/views/nojs/rearrange-$type/{$this->storage->get('name')}/{$display['id']}/$type";
$rearrange_text = t('And/Or, Rearrange');
// TODO: Add another class to have another symbol for filter rearrange.
$class = 'icon compact rearrange';
@ -928,7 +936,7 @@ class ViewUI extends ViewExecutable {
}
default:
$rearrange_url = "admin/structure/views/nojs/rearrange/{$this->storage->name}/{$display['id']}/$type";
$rearrange_url = "admin/structure/views/nojs/rearrange/{$this->storage->get('name')}/{$display['id']}/$type";
$rearrange_text = t('Rearrange');
$class = 'icon compact rearrange';
}
@ -938,7 +946,7 @@ class ViewUI extends ViewExecutable {
$count_handlers = count($this->displayHandlers[$display['id']]->getHandlers($type));
$actions['add'] = array(
'title' => t('Add'),
'href' => "admin/structure/views/nojs/add-item/{$this->storage->name}/{$display['id']}/$type",
'href' => "admin/structure/views/nojs/add-item/{$this->storage->get('name')}/{$display['id']}/$type",
'attributes' => array('class' => array('icon compact add', 'views-ajax-link'), 'title' => t('Add'), 'id' => 'views-add-' . $type),
'html' => TRUE,
);
@ -1003,7 +1011,7 @@ class ViewUI extends ViewExecutable {
if (empty($handler)) {
$build['fields'][$id]['#class'][] = 'broken';
$field_name = t('Broken/missing handler: @table > @field', array('@table' => $field['table'], '@field' => $field['field']));
$build['fields'][$id]['#link'] = l($field_name, "admin/structure/views/nojs/config-item/{$this->storage->name}/{$display['id']}/$type/$id", array('attributes' => array('class' => array('views-ajax-link')), 'html' => TRUE));
$build['fields'][$id]['#link'] = l($field_name, "admin/structure/views/nojs/config-item/{$this->storage->get('name')}/{$display['id']}/$type/$id", array('attributes' => array('class' => array('views-ajax-link')), 'html' => TRUE));
continue;
}
@ -1018,15 +1026,15 @@ class ViewUI extends ViewExecutable {
if (!empty($field['exclude'])) {
$link_attributes['class'][] = 'views-field-excluded';
}
$build['fields'][$id]['#link'] = l($link_text, "admin/structure/views/nojs/config-item/{$this->storage->name}/{$display['id']}/$type/$id", array('attributes' => $link_attributes, 'html' => TRUE));
$build['fields'][$id]['#link'] = l($link_text, "admin/structure/views/nojs/config-item/{$this->storage->get('name')}/{$display['id']}/$type/$id", array('attributes' => $link_attributes, 'html' => TRUE));
$build['fields'][$id]['#class'][] = drupal_clean_css_identifier($display['id']. '-' . $type . '-' . $id);
if ($this->displayHandlers[$display['id']]->useGroupBy() && $handler->usesGroupBy()) {
$build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Aggregation settings') . '</span>', "admin/structure/views/nojs/config-item-group/{$this->storage->name}/{$display['id']}/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => TRUE));
$build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Aggregation settings') . '</span>', "admin/structure/views/nojs/config-item-group/{$this->storage->get('name')}/{$display['id']}/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => TRUE));
}
if ($handler->hasExtraOptions()) {
$build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Settings') . '</span>', "admin/structure/views/nojs/config-item-extra/{$this->storage->name}/{$display['id']}/$type/$id", array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => t('Settings')), 'html' => TRUE));
$build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Settings') . '</span>', "admin/structure/views/nojs/config-item-extra/{$this->storage->get('name')}/{$display['id']}/$type/$id", array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => t('Settings')), 'html' => TRUE));
}
if ($grouping) {
@ -1119,8 +1127,8 @@ class ViewUI extends ViewExecutable {
* Submit handler to break_lock a view.
*/
public function submitBreakLock(&$form, &$form_state) {
drupal_container()->get('user.tempstore')->get('views')->delete($this->storage->name);
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name . '/edit';
drupal_container()->get('user.tempstore')->get('views')->delete($this->storage->get('name'));
$form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->get('name') . '/edit';
drupal_set_message(t('The lock has been broken and you may now edit this view.'));
}
@ -1294,7 +1302,7 @@ class ViewUI extends ViewExecutable {
$form['locked'] = array(
'#theme_wrappers' => array('container'),
'#attributes' => array('class' => array('view-locked', 'messages', 'warning')),
'#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($this->locked->owner))), '!age' => format_interval(REQUEST_TIME - $this->locked->updated), '!break' => url('admin/structure/views/view/' . $this->storage->name . '/break-lock'))),
'#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($this->locked->owner))), '!age' => format_interval(REQUEST_TIME - $this->locked->updated), '!break' => url('admin/structure/views/view/' . $this->storage->get('name') . '/break-lock'))),
);
}
else {
@ -1383,7 +1391,8 @@ class ViewUI extends ViewExecutable {
$form['displays']['settings']['settings_content']['tab_content']['#attributes'] = array('class' => array('views-display-tab'));
$form['displays']['settings']['settings_content']['tab_content']['#id'] = 'views-tab-' . $display_id;
// Mark deleted displays as such.
if (!empty($this->storage->display[$display_id]['deleted'])) {
$display = $this->storage->get('display');
if (!empty($display[$display_id]['deleted'])) {
$form['displays']['settings']['settings_content']['tab_content']['#attributes']['class'][] = 'views-display-deleted';
}
// Mark disabled displays as such.
@ -1456,7 +1465,7 @@ class ViewUI extends ViewExecutable {
'#suffix' => '</div>',
'#id' => 'preview-submit',
'#ajax' => array(
'path' => 'admin/structure/views/view/' . $this->storage->name . '/preview/' . $display_id . '/ajax',
'path' => 'admin/structure/views/view/' . $this->storage->get('name') . '/preview/' . $display_id . '/ajax',
'wrapper' => 'views-preview-wrapper',
'event' => 'click',
'progress' => array('type' => 'throbber'),
@ -1468,7 +1477,7 @@ class ViewUI extends ViewExecutable {
// we may need to split Preview into a separate form.
'#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);
$form['#action'] = url('admin/structure/views/view/' . $this->storage->get('name') .'/preview/' . $display_id);
return $form;
}
@ -1483,10 +1492,12 @@ class ViewUI extends ViewExecutable {
$form['#tree'] = TRUE;
$count = count($this->storage->display);
$count = count($this->storage->get('display'));
uasort($this->storage->display, array('static', 'sortPosition'));
foreach ($this->storage->display as $display) {
$displays = $this->storage->get('display');
uasort($displays, array('static', 'sortPosition'));
$this->storage->set('display', $displays);
foreach ($displays as $display) {
$form[$display['id']] = array(
'title' => array('#markup' => $display['display_title']),
'weight' => array(
@ -1529,7 +1540,7 @@ class ViewUI extends ViewExecutable {
'limit' => 0,
);
$form['#action'] = url('admin/structure/views/nojs/reorder-displays/' . $this->storage->name . '/' . $display_id);
$form['#action'] = url('admin/structure/views/nojs/reorder-displays/' . $this->storage->get('name') . '/' . $display_id);
$this->getStandardButtons($form, $form_state, 'views_ui_reorder_displays_form');
$form['buttons']['submit']['#submit'] = array(array($this, 'submitDisplaysReorderForm'));
@ -1560,27 +1571,28 @@ class ViewUI extends ViewExecutable {
}
// Setting up position and removing deleted displays
$displays = $this->storage->display;
$displays = $this->storage->get('display');
foreach ($displays as $display_id => $display) {
// Don't touch the default !!!
if ($display_id === 'default') {
$this->storage->display[$display_id]['position'] = 0;
$displays[$display_id]['position'] = 0;
continue;
}
if (isset($order[$display_id])) {
$this->storage->display[$display_id]['position'] = $order[$display_id];
$displays[$display_id]['position'] = $order[$display_id];
}
else {
$this->storage->display[$display_id]['deleted'] = TRUE;
$displays[$display_id]['deleted'] = TRUE;
}
}
// Sorting back the display array as the position is not enough
uasort($this->storage->display, array('static', 'sortPosition'));
uasort($displays, array('static', 'sortPosition'));
$this->storage->set('display', $displays);
// Store in cache
views_ui_cache_set($this);
$form_state['redirect'] = array('admin/structure/views/view/' . $this->storage->name . '/edit', array('fragment' => 'views-tab-default'));
$form_state['redirect'] = array('admin/structure/views/view/' . $this->storage->get('name') . '/edit', array('fragment' => 'views-tab-default'));
}
/**
@ -1747,7 +1759,7 @@ class ViewUI extends ViewExecutable {
}
// Make view links come back to preview.
$this->override_path = 'admin/structure/views/nojs/preview/' . $this->storage->name . '/' . $display_id;
$this->override_path = 'admin/structure/views/nojs/preview/' . $this->storage->get('name') . '/' . $display_id;
// Also override the current path so we get the pager.
$original_path = current_path();
@ -1929,7 +1941,7 @@ class ViewUI extends ViewExecutable {
$form = views_ui_ajax_forms($key);
// Automatically remove the single-form cache if it exists and
// does not match the key.
$identifier = implode('-', array($key, $this->storage->name, $display_id));
$identifier = implode('-', array($key, $this->storage->get('name'), $display_id));
foreach ($form['args'] as $id) {
$arg = (!empty($args)) ? array_shift($args) : NULL;

View File

@ -21,7 +21,7 @@
<?php print $quick_links ?>
</div>
<?php print t('View %name, displaying items of type <strong>@base</strong>.',
array('%name' => $view->storage->name, '@base' => $base_table)); ?>
array('%name' => $view->storage->get('name'), '@base' => $base_table)); ?>
</div>
<?php print $tabs; ?>

View File

@ -291,8 +291,8 @@ function views_ui_edit_page_title(ViewUI $view) {
module_load_include('inc', 'views_ui', 'admin');
$bases = views_fetch_base_tables();
$name = $view->storage->getHumanName();
if (isset($bases[$view->storage->base_table])) {
$name .= ' (' . $bases[$view->storage->base_table]['title'] . ')';
if (isset($bases[$view->storage->get('base_table')])) {
$name .= ' (' . $bases[$view->storage->get('base_table')]['title'] . ')';
}
return $name;
@ -327,14 +327,14 @@ function views_ui_cache_load($name) {
else {
// Keep disabled/enabled status real.
if ($original_view) {
$view->storage->disabled = $original_view->storage->disabled;
$view->storage->set('disabled', $original_view->storage->get('disabled'));
}
}
if (empty($view)) {
return FALSE;
}
$view->locked = $views_temp_store->getMetadata($view->storage->name);
$view->locked = $views_temp_store->getMetadata($view->storage->get('name'));
return $view;
}
@ -362,7 +362,7 @@ function views_ui_cache_set(ViewUI $view) {
unset($view->default_display);
$view->query = NULL;
$view->displayHandlers = array();
drupal_container()->get('user.tempstore')->get('views')->set($view->storage->name, $view);
drupal_container()->get('user.tempstore')->get('views')->set($view->storage->get('name'), $view);
}
/**
@ -414,13 +414,13 @@ function views_ui_view_preview_section_handler_links(ViewUI $view, $type, $title
$field_name = $handler->adminLabel(TRUE);
$links[$type . '-edit-' . $id] = array(
'title' => t('Edit @section', array('@section' => $field_name)),
'href' => "admin/structure/views/nojs/config-item/{$view->storage->name}/{$display['id']}/$type/$id",
'href' => "admin/structure/views/nojs/config-item/{$view->storage->get('name')}/{$display['id']}/$type/$id",
'attributes' => array('class' => array('views-ajax-link')),
);
}
$links[$type . '-add'] = array(
'title' => t('Add new'),
'href' => "admin/structure/views/nojs/add-item/{$view->storage->name}/{$display['id']}/$type",
'href' => "admin/structure/views/nojs/add-item/{$view->storage->get('name')}/{$display['id']}/$type",
'attributes' => array('class' => array('views-ajax-link')),
);
@ -435,7 +435,7 @@ function views_ui_view_preview_section_display_category_links(ViewUI $view, $typ
$links = array(
$type . '-edit' => array(
'title' => t('Edit @section', array('@section' => $title)),
'href' => "admin/structure/views/nojs/display/{$view->storage->name}/{$display['id']}/$type",
'href' => "admin/structure/views/nojs/display/{$view->storage->get('name')}/{$display['id']}/$type",
'attributes' => array('class' => array('views-ajax-link')),
),
);