Revert "Issue #1770772 by damiankloip, dawehner, tim.plunkett: Move row_plugin() from style_plugin() to the main view object."
This reverts commit 386bfa9fd3
.
8.0.x
parent
252d05b0ea
commit
2fcadb11fa
|
@ -91,7 +91,7 @@ class EntityReference extends StylePluginBase {
|
|||
foreach ($sets as $records) {
|
||||
foreach ($records as $values) {
|
||||
// Sanitize HTML, remove line breaks and extra whitespace.
|
||||
$output = $this->view->rowPlugin->render($values);
|
||||
$output = $this->row_plugin->render($values);
|
||||
$output = drupal_render($output);
|
||||
$results[$values->{$id_field_alias}] = filter_xss_admin(preg_replace('/\s\s+/', ' ', str_replace("\n", '', $output)));
|
||||
$this->view->row_index++;
|
||||
|
|
|
@ -650,7 +650,7 @@ function node_views_data() {
|
|||
*/
|
||||
function node_row_node_view_preprocess_node(&$vars) {
|
||||
$node = $vars['node'];
|
||||
$options = $vars['view']->rowPlugin->options;
|
||||
$options = $vars['view']->style_plugin->row_plugin->options;
|
||||
|
||||
// Prevent the comment form from showing up if this is not a page display.
|
||||
if ($vars['view_mode'] == 'full' && !$vars['view']->display_handler->hasPath()) {
|
||||
|
|
|
@ -66,7 +66,7 @@ class Serializer extends StylePluginBase {
|
|||
// is used, $rows will not contain objects and will pass directly to the
|
||||
// Encoder.
|
||||
foreach ($this->view->result as $row) {
|
||||
$rows[] = $this->view->rowPlugin->render($row);
|
||||
$rows[] = $this->row_plugin->render($row);
|
||||
}
|
||||
|
||||
return $this->serializer->serialize($rows, $this->displayHandler->getContentType());
|
||||
|
|
|
@ -255,16 +255,17 @@ class Feed extends PathPluginBase {
|
|||
|
||||
// Defer to the feed style; it may put in meta information, and/or
|
||||
// attach a feed icon.
|
||||
$plugin = $this->getPlugin('style');
|
||||
if ($plugin) {
|
||||
$clone->setDisplay($this->display['id']);
|
||||
$clone->buildTitle();
|
||||
if ($plugin = $clone->display_handler->getPlugin('style')) {
|
||||
$plugin->attach_to($display_id, $this->getPath(), $clone->getTitle());
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
$clone->destroy();
|
||||
unset($clone);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::usesLinkDisplay().
|
||||
|
|
|
@ -108,7 +108,7 @@ class Rss extends StylePluginBase {
|
|||
}
|
||||
|
||||
function render() {
|
||||
if (empty($this->view->rowPlugin)) {
|
||||
if (empty($this->row_plugin)) {
|
||||
debug('Drupal\views\Plugin\views\style\Rss: Missing row plugin');
|
||||
return;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class Rss extends StylePluginBase {
|
|||
|
||||
foreach ($this->view->result as $row_index => $row) {
|
||||
$this->view->row_index = $row_index;
|
||||
$rows .= $this->view->rowPlugin->render($row);
|
||||
$rows .= $this->row_plugin->render($row);
|
||||
}
|
||||
|
||||
$output = theme($this->themeFunctions(),
|
||||
|
|
|
@ -41,6 +41,14 @@ abstract class StylePluginBase extends PluginBase {
|
|||
*/
|
||||
var $row_tokens = array();
|
||||
|
||||
/**
|
||||
* Contains the row plugin, if it's initialized
|
||||
* and the style itself supports it.
|
||||
*
|
||||
* @var views_plugin_row
|
||||
*/
|
||||
var $row_plugin;
|
||||
|
||||
/**
|
||||
* Does the style plugin allows to use style plugins.
|
||||
*
|
||||
|
@ -92,7 +100,7 @@ abstract class StylePluginBase extends PluginBase {
|
|||
parent::init($view, $display, $options);
|
||||
|
||||
if ($this->usesRowPlugin() && $display->getOption('row')) {
|
||||
$this->view->rowPlugin = $display->getPlugin('row');
|
||||
$this->row_plugin = $display->getPlugin('row');
|
||||
}
|
||||
|
||||
$this->options += array(
|
||||
|
@ -104,8 +112,8 @@ abstract class StylePluginBase extends PluginBase {
|
|||
public function destroy() {
|
||||
parent::destroy();
|
||||
|
||||
if (isset($this->view->rowPlugin)) {
|
||||
$this->view->rowPlugin->destroy();
|
||||
if (isset($this->row_plugin)) {
|
||||
$this->row_plugin->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,8 +154,8 @@ abstract class StylePluginBase extends PluginBase {
|
|||
// If we use a row plugin, ask the row plugin. Chances are, we don't
|
||||
// care, it does.
|
||||
$row_uses_fields = FALSE;
|
||||
if ($this->usesRowPlugin() && !empty($this->view->rowPlugin)) {
|
||||
$row_uses_fields = $this->view->rowPlugin->usesFields();
|
||||
if ($this->usesRowPlugin() && !empty($this->row_plugin)) {
|
||||
$row_uses_fields = $this->row_plugin->usesFields();
|
||||
}
|
||||
// Otherwise, check the definition or the option.
|
||||
return $row_uses_fields || $this->usesFields || !empty($this->options['uses_fields']);
|
||||
|
@ -388,8 +396,8 @@ abstract class StylePluginBase extends PluginBase {
|
|||
* The full array of results from the query.
|
||||
*/
|
||||
function pre_render($result) {
|
||||
if (!empty($this->view->rowPlugin)) {
|
||||
$this->view->rowPlugin->pre_render($result);
|
||||
if (!empty($this->row_plugin)) {
|
||||
$this->row_plugin->pre_render($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,7 +405,7 @@ abstract class StylePluginBase extends PluginBase {
|
|||
* Render the display in this style.
|
||||
*/
|
||||
function render() {
|
||||
if ($this->usesRowPlugin() && empty($this->view->rowPlugin)) {
|
||||
if ($this->usesRowPlugin() && empty($this->row_plugin)) {
|
||||
debug('Drupal\views\Plugin\views\style\StylePluginBase: Missing row plugin');
|
||||
return;
|
||||
}
|
||||
|
@ -447,7 +455,7 @@ abstract class StylePluginBase extends PluginBase {
|
|||
if ($this->usesRowPlugin()) {
|
||||
foreach ($set['rows'] as $index => $row) {
|
||||
$this->view->row_index = $index;
|
||||
$render = $this->view->rowPlugin->render($row);
|
||||
$render = $this->row_plugin->render($row);
|
||||
// Row render arrays cannot be contained by style render arrays.
|
||||
$set['rows'][$index] = drupal_render($render);
|
||||
}
|
||||
|
@ -676,8 +684,8 @@ abstract class StylePluginBase extends PluginBase {
|
|||
|
||||
public function query() {
|
||||
parent::query();
|
||||
if (isset($this->view->rowPlugin)) {
|
||||
$this->view->rowPlugin->query();
|
||||
if (isset($this->row_plugin)) {
|
||||
$this->row_plugin->query();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,10 +80,10 @@ class StyleTest extends ViewTestBase {
|
|||
$view->style_plugin->setUsesRowPlugin(TRUE);
|
||||
// Reinitialize the style as it supports row plugins now.
|
||||
$view->style_plugin->init($view, $view->display_handler);
|
||||
$this->assertTrue($view->rowPlugin instanceof RowTest, 'Make sure the right row plugin class is loaded.');
|
||||
$this->assertTrue($view->style_plugin->row_plugin instanceof RowTest, 'Make sure the right row plugin class is loaded.');
|
||||
|
||||
$random_text = $this->randomName();
|
||||
$view->rowPlugin->setOutput($random_text);
|
||||
$view->style_plugin->row_plugin->setOutput($random_text);
|
||||
|
||||
$output = $view->preview();
|
||||
$this->assertTrue(strpos($output, $random_text) !== FALSE, 'Take sure that the rendering of the row plugin appears in the output of the view.');
|
||||
|
|
|
@ -14,8 +14,6 @@ use Drupal\views\DisplayBag;
|
|||
use Drupal\views\Plugin\views\display\DefaultDisplay;
|
||||
use Drupal\views\Plugin\views\display\Page;
|
||||
use Drupal\views\Plugin\views\style\DefaultStyle;
|
||||
use Drupal\views\Plugin\views\style\Grid;
|
||||
use Drupal\views\Plugin\views\row\Fields;
|
||||
use Drupal\views\Plugin\views\query\Sql;
|
||||
|
||||
/**
|
||||
|
@ -194,21 +192,6 @@ class ViewExecutableTest extends ViewUnitTestBase {
|
|||
$view->setDisplay('invalid');
|
||||
$this->assertEqual($view->current_display, 'default', 'If setDisplay is called with an invalid display id the default display should be used.');
|
||||
$this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers->get('default')));
|
||||
|
||||
// Test the style and row plugins are replaced correctly when setting the
|
||||
// display.
|
||||
$view->setDisplay('page_1');
|
||||
$view->initStyle();
|
||||
$this->assertTrue($view->style_plugin instanceof DefaultStyle);
|
||||
$this->assertTrue($view->rowPlugin instanceof Fields);
|
||||
$this->assertEqual($view->plugin_name, 'default');
|
||||
|
||||
$view->setDisplay('page_2');
|
||||
$view->initStyle();
|
||||
$this->assertTrue($view->style_plugin instanceof Grid);
|
||||
// @todo Change this rowPlugin type too.
|
||||
$this->assertTrue($view->rowPlugin instanceof Fields);
|
||||
$this->assertEqual($view->plugin_name, 'grid');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -211,13 +211,6 @@ class ViewExecutable {
|
|||
*/
|
||||
public $style_plugin;
|
||||
|
||||
/**
|
||||
* The current used row plugin, if the style plugin supports row plugins.
|
||||
*
|
||||
* @var \Drupal\views\Plugin\views\row\RowPluginBase
|
||||
*/
|
||||
public $rowPlugin;
|
||||
|
||||
/**
|
||||
* Stores the current active row while rendering.
|
||||
*
|
||||
|
@ -678,18 +671,9 @@ class ViewExecutable {
|
|||
}
|
||||
}
|
||||
|
||||
// Reset if the display has changed. It could be called multiple times for
|
||||
// the same display, especially in the UI.
|
||||
if ($this->current_display != $display_id) {
|
||||
// Set the current display.
|
||||
$this->current_display = $display_id;
|
||||
|
||||
// Reset the style and row plugins.
|
||||
$this->style_plugin = NULL;
|
||||
$this->plugin_name = NULL;
|
||||
$this->rowPlugin = NULL;
|
||||
}
|
||||
|
||||
// Ensure requested display has a working handler.
|
||||
if (!$this->displayHandlers->has($display_id)) {
|
||||
return FALSE;
|
||||
|
@ -1753,7 +1737,7 @@ class ViewExecutable {
|
|||
$this->style_plugin->destroy();
|
||||
}
|
||||
|
||||
$keys = array('current_display', 'display_handler', 'displayHandlers', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'result', 'inited', 'style_plugin', 'rowPlugin', 'plugin_name', 'exposed_data', 'exposed_input', 'many_to_one_tables');
|
||||
$keys = array('current_display', 'display_handler', 'displayHandlers', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'result', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'many_to_one_tables');
|
||||
foreach ($keys as $key) {
|
||||
unset($this->$key);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,6 @@ display:
|
|||
display_title: 'Page 2'
|
||||
id: page_2
|
||||
position: '2'
|
||||
display_options:
|
||||
defaults:
|
||||
style: '0'
|
||||
style:
|
||||
type: grid
|
||||
human_name: ''
|
||||
id: test_executable_displays
|
||||
tag: ''
|
||||
|
|
|
@ -100,7 +100,7 @@ class StyleTest extends StylePluginBase {
|
|||
else {
|
||||
foreach ($this->view->result as $index => $row) {
|
||||
$this->view->row_index = $index;
|
||||
$output .= $this->view->rowPlugin->render($row) . "\n";
|
||||
$output .= $this->row_plugin->render($row) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -864,15 +864,10 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
* Add information about a section to a display.
|
||||
*/
|
||||
public function getFormBucket(ViewUI $view, $type, $display) {
|
||||
$executable = $view->get('executable');
|
||||
$executable->setDisplay($display['id']);
|
||||
$executable->initStyle();
|
||||
|
||||
$types = $executable->viewsHandlerTypes();
|
||||
|
||||
$build = array(
|
||||
'#theme_wrappers' => array('views_ui_display_tab_bucket'),
|
||||
);
|
||||
$types = ViewExecutable::viewsHandlerTypes();
|
||||
|
||||
$build['#overridden'] = FALSE;
|
||||
$build['#defaulted'] = FALSE;
|
||||
|
@ -896,7 +891,7 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
break;
|
||||
case 'field':
|
||||
// Fetch the style plugin info so we know whether to list fields or not.
|
||||
$style_plugin = $executable->style_plugin;
|
||||
$style_plugin = $view->get('executable')->displayHandlers->get($display['id'])->getPlugin('style');
|
||||
$uses_fields = $style_plugin && $style_plugin->usesFields();
|
||||
if (!$uses_fields) {
|
||||
$build['fields'][] = array(
|
||||
|
@ -910,7 +905,7 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
case 'header':
|
||||
case 'footer':
|
||||
case 'empty':
|
||||
if (!$executable->display_handler->usesAreas()) {
|
||||
if (!$view->get('executable')->displayHandlers->get($display['id'])->usesAreas()) {
|
||||
$build[$type][] = array(
|
||||
'#markup' => t('The selected display type does not utilize @type plugins', array('@type' => $type)),
|
||||
'#theme_wrappers' => array('views_ui_container'),
|
||||
|
@ -923,7 +918,7 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
|
||||
// Create an array of actions to pass to theme_links
|
||||
$actions = array();
|
||||
$count_handlers = count($executable->display_handler->getHandlers($type));
|
||||
$count_handlers = count($view->get('executable')->displayHandlers->get($display['id'])->getHandlers($type));
|
||||
$actions['add'] = array(
|
||||
'title' => t('Add'),
|
||||
'href' => "admin/structure/views/nojs/add-item/{$view->id()}/{$display['id']}/$type",
|
||||
|
@ -948,8 +943,8 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
),
|
||||
);
|
||||
|
||||
if (!$executable->display_handler->isDefaultDisplay()) {
|
||||
if (!$executable->display_handler->isDefaulted($types[$type]['plural'])) {
|
||||
if (!$view->get('executable')->displayHandlers->get($display['id'])->isDefaultDisplay()) {
|
||||
if (!$view->get('executable')->displayHandlers->get($display['id'])->isDefaulted($types[$type]['plural'])) {
|
||||
$build['#overridden'] = TRUE;
|
||||
}
|
||||
else {
|
||||
|
@ -961,7 +956,7 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
if (!isset($relationships)) {
|
||||
// Get relationship labels
|
||||
$relationships = array();
|
||||
foreach ($executable->display_handler->getHandlers('relationship') as $id => $handler) {
|
||||
foreach ($view->get('executable')->displayHandlers->get($display['id'])->getHandlers('relationship') as $id => $handler) {
|
||||
$relationships[$id] = $handler->label();
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +965,7 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
$groups = array();
|
||||
$grouping = FALSE;
|
||||
if ($type == 'filter') {
|
||||
$group_info = $executable->display_handler->getOption('filter_groups');
|
||||
$group_info = $view->get('executable')->displayHandlers->get('default')->getOption('filter_groups');
|
||||
// If there is only one group but it is using the "OR" filter, we still
|
||||
// treat it as a group for display purposes, since we want to display the
|
||||
// "OR" label next to items within the group.
|
||||
|
@ -982,12 +977,12 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
|
||||
$build['fields'] = array();
|
||||
|
||||
foreach ($executable->display_handler->getOption($types[$type]['plural']) as $id => $field) {
|
||||
foreach ($view->get('executable')->displayHandlers->get($display['id'])->getOption($types[$type]['plural']) as $id => $field) {
|
||||
// Build the option link for this handler ("Node: ID = article").
|
||||
$build['fields'][$id] = array();
|
||||
$build['fields'][$id]['#theme'] = 'views_ui_display_tab_setting';
|
||||
|
||||
$handler = $executable->display_handler->getHandler($type, $id);
|
||||
$handler = $view->get('executable')->displayHandlers->get($display['id'])->getHandler($type, $id);
|
||||
if (empty($handler)) {
|
||||
$build['fields'][$id]['#class'][] = 'broken';
|
||||
$field_name = t('Broken/missing handler: @table > @field', array('@table' => $field['table'], '@field' => $field['field']));
|
||||
|
@ -1009,7 +1004,7 @@ class ViewEditFormController extends ViewFormControllerBase {
|
|||
$build['fields'][$id]['#link'] = l($link_text, "admin/structure/views/nojs/config-item/{$view->id()}/{$display['id']}/$type/$id", array('attributes' => $link_attributes, 'html' => TRUE));
|
||||
$build['fields'][$id]['#class'][] = drupal_clean_css_identifier($display['id']. '-' . $type . '-' . $id);
|
||||
|
||||
if ($executable->display_handler->useGroupBy() && $handler->usesGroupBy()) {
|
||||
if ($view->get('executable')->displayHandlers->get($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/{$view->id()}/{$display['id']}/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => TRUE));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue