diff --git a/core/git b/core/git new file mode 100644 index 0000000..e69de29 diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/style/StylePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/style/StylePluginBase.php index 032c823..a221f8f 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/style/StylePluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/style/StylePluginBase.php @@ -158,8 +158,8 @@ function usesFields() { // 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() && ($row_plugin = $this->displayHandler->getPlugin('row'))) { + $row_uses_fields = $row_plugin->usesFields(); } // Otherwise, check the definition or the option. return $row_uses_fields || $this->usesFields || !empty($this->options['uses_fields']); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php index e0a3495..25a10f3 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php @@ -9,6 +9,7 @@ use Drupal\views\Tests\ViewTestBase; use Drupal\views_test_data\Plugin\views\row\RowTest; +use Drupal\views\Plugin\views\row\Fields; use Drupal\views_test_data\Plugin\views\style\StyleTest as StyleTestPlugin; /** @@ -50,45 +51,47 @@ protected function setUp() { * Tests the general renderering of styles. */ public function testStyle() { + // This run use the test row plugin and render with it. $view = views_get_view('test_view'); $view->setDisplay(); $style = $view->display_handler->getOption('style'); $style['type'] = 'test_style'; $view->display_handler->setOption('style', $style); + $row = $view->display_handler->getOption('row'); + $row['type'] = 'test_row'; + $view->display_handler->setOption('row', $row); $view->initDisplay(); $view->initStyle(); - $this->assertTrue($view->style_plugin instanceof StyleTestPlugin, 'Make sure the right style plugin class is loaded.'); + // 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.'); $random_text = $this->randomName(); - // Set some custom text to the output and make sure that this value is - // rendered. - $view->style_plugin->setOutput($random_text); + $view->rowPlugin->setOutput($random_text); + $output = $view->preview(); $output = drupal_render($output); - $this->assertTrue(strpos($output, $random_text) !== FALSE, 'Take sure that the rendering of the style plugin appears in the output of the view.'); + $this->assertTrue(strpos($output, $random_text) !== FALSE, 'Make sure that the rendering of the row plugin appears in the output of the view.'); - // This run use the test row plugin and render with it. + // Test without row plugin support. $view = views_get_view('test_view'); $view->setDisplay(); $style = $view->display_handler->getOption('style'); $style['type'] = 'test_style'; $view->display_handler->setOption('style', $style); - $row = $view->display_handler->getOption('row'); - $row['type'] = 'test_row'; - $view->display_handler->setOption('row', $row); $view->initDisplay(); $view->initStyle(); - $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.'); + $view->style_plugin->setUsesRowPlugin(FALSE); + $this->assertTrue($view->style_plugin instanceof StyleTestPlugin, 'Make sure the right style plugin class is loaded.'); + $this->assertTrue($view->rowPlugin instanceof Fields, 'Make sure that rowPlugin is now a fields instance.'); $random_text = $this->randomName(); - $view->rowPlugin->setOutput($random_text); - + // Set some custom text to the output and make sure that this value is + // rendered. + $view->style_plugin->setOutput($random_text); $output = $view->preview(); $output = drupal_render($output); - $this->assertTrue(strpos($output, $random_text) !== FALSE, 'Take sure that the rendering of the row plugin appears in the output of the view.'); + $this->assertTrue(strpos($output, $random_text) !== FALSE, 'Make sure that the rendering of the style plugin appears in the output of the view.'); } function testGrouping() { diff --git a/core/modules/views/tests/modules/views_test_data/lib/Drupal/views_test_data/Plugin/views/style/StyleTest.php b/core/modules/views/tests/modules/views_test_data/lib/Drupal/views_test_data/Plugin/views/style/StyleTest.php index f7d2c7d..26a3112 100644 --- a/core/modules/views/tests/modules/views_test_data/lib/Drupal/views_test_data/Plugin/views/style/StyleTest.php +++ b/core/modules/views/tests/modules/views_test_data/lib/Drupal/views_test_data/Plugin/views/style/StyleTest.php @@ -34,6 +34,13 @@ class StyleTest extends StylePluginBase { public $output; /** + * Can the style plugin use row plugins. + * + * @var bool + */ + protected $usesRowPlugin = TRUE; + + /** * Overrides Drupal\views\Plugin\views\style\StylePluginBase::defineOptions(). */ protected function defineOptions() { @@ -56,10 +63,6 @@ public function buildOptionsForm(&$form, &$form_state) { ); } - function usesRowPlugin() { - return parent::usesRowPlugin(); - } - /** * Sets the usesRowPlugin property. * diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php index 5666547..4a39c82 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php @@ -64,6 +64,13 @@ public function testStyleUI() { $style = $view->display_handler->getOption('style'); $this->assertEqual($style['type'], 'test_style', 'Make sure that the test_style got saved as used style plugin.'); $this->assertEqual($style['options']['test_option'], $random_name, 'Make sure that the custom settings field got saved as expected.'); + + // Test that fields are working correctly in the UI for style plugins when + // a field row plguin is selected. + $this->drupalPost("admin/structure/views/view/$view_name/edit", array(), 'Add Page'); + $this->drupalPost("admin/structure/views/nojs/display/$view_name/page_1/row", array('row' => 'fields'), t('Apply')); + // If fields are being used this text will not be shown. + $this->assertNoText(t('The selected style or row format does not utilize fields.')); } }