diff --git a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php index 584ac00..998fb6f 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php @@ -78,7 +78,7 @@ public function execute() { // Prior to this being called, the $view should already be set to this // display, and arguments should be set on the view. $info['content'] = $this->view->render(); - $info['subject'] = filter_xss_admin($this->view->getTitle()); + $info['#title'] = filter_xss_admin($this->view->getTitle()); if (!empty($this->view->result) || $this->getOption('empty') || !empty($this->view->style_plugin->definition['even empty'])) { return $info; } @@ -138,7 +138,7 @@ protected function blockCachingModes() { * Provide a single method to figure caching type, keeping a sensible default * for when it's unset. */ - protected function getCacheType() { + public function getCacheType() { $cache_type = $this->getOption('block_caching'); if (empty($cache_type)) { $cache_type = DRUPAL_NO_CACHE; diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php new file mode 100644 index 0000000..f39b5ed --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php @@ -0,0 +1,55 @@ +derivatives) && !empty($this->derivatives[$derivative_id])) { + return $this->derivatives[$derivative_id]; + } + $this->getDerivativeDefinitions($base_plugin_definition); + return $this->derivatives[$derivative_id]; + } + + /** + * Implements DerivativeInterface::getDerivativeDefinitions(). + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + foreach (views_get_all_views() as $view) { + // disabled views get nothing. + if (!$view->isEnabled()) { + continue; + } + $executable = $view->get('executable'); + $executable->initDisplay(); + foreach ($executable->displayHandlers as $display) { + if (isset($display) && !empty($display->definition['uses_hook_block'])) { + $delta = $view->get('name') . '-' . $display->display['id']; + $desc = $display->getOption('block_description'); + + if (empty($desc)) { + if ($display->display['display_title'] == $display->definition['title']) { + $desc = t('View: !view', array('!view' => $view->getHumanName())); + } + else { + $desc = t('View: !view: !display', array('!view' => $view->getHumanName(), '!display' => $display->display['display_title'])); + } + } + $this->derivatives[$delta] = array( + 'subject' => $desc, + 'cache' => $display->getCacheType() + ); + $this->derivatives[$delta] += $base_plugin_definition; + } + } + } + return $this->derivatives; + } +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php new file mode 100644 index 0000000..98e67bd --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php @@ -0,0 +1,48 @@ +derivatives) && !empty($this->derivatives[$derivative_id])) { + return $this->derivatives[$derivative_id]; + } + $this->getDerivativeDefinitions($base_plugin_definition); + return $this->derivatives[$derivative_id]; + } + + /** + * Implements DerivativeInterface::getDerivativeDefinitions(). + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + foreach (views_get_all_views() as $view) { + // disabled views get nothing. + if (!$view->isEnabled()) { + continue; + } + $executable = $view->get('executable'); + $executable->initDisplay(); + foreach ($executable->displayHandlers as $display) { + if (isset($display) && $display->getOption('exposed_block')) { + if ($display->usesExposedFormInBlock()) { + $delta = $view->get('name') . '-' . $display->display['id']; + $desc = t('Exposed form: @view-@display_id', array('@view' => $view->get('name'), '@display_id' => $display->display['id'])); + $this->derivatives[$delta] = array( + 'subject' => $desc, + 'cache' => DRUPAL_NO_CACHE, + ); + $this->derivatives[$delta] += $base_plugin_definition; + } + } + } + } + return $this->derivatives; + } +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php new file mode 100644 index 0000000..09a6c01 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php @@ -0,0 +1,57 @@ +getPluginId()); + + $start = microtime(TRUE); + + list($name, $display_id) = explode('-', $delta, 2); + $this->display_id = $display_id; + // Load the view + $this->view = views_get_view($name); + $this->view->setDisplay($display_id); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + return $this->view->access($this->display_id); + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + $output = $this->view->executeDisplay($this->display_id); + // Before returning the block output, convert it to a renderable array + // with contextual links. + views_add_block_contextual_links($output, $this->view, $this->display_id); + $this->view->destroy(); + return $output; + } +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php new file mode 100644 index 0000000..ef9feae --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php @@ -0,0 +1,30 @@ +view->display_handler->viewSpecialBlocks($type); + // Before returning the block output, convert it to a renderable + // array with contextual links. + views_add_block_contextual_links($output, $this->view, $this->display_id, 'special_block_' . $type); + $this->view->destroy(); + return $output; + } +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index cf68a49..64ef2ae 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -2666,7 +2666,7 @@ public function getSpecialBlocks() { * Render any special blocks provided for this display. */ public function viewSpecialBlocks($type) { - if ($type == '-exp') { + if ($type == 'exp') { // avoid interfering with the admin forms. if (arg(0) == 'admin' && arg(1) == 'structure' && arg(2) == 'views') { return;