From e881ee2fd0c6212b60370d1db6ec39ca493e4905 Mon Sep 17 00:00:00 2001
From: Earl Miles <merlin@logrus.com>
Date: Thu, 30 Apr 2009 20:55:22 +0000
Subject: [PATCH] #361309 by duellj: Make sure empty views do not appear as
 panes.

---
 includes/context.inc                                | 7 +++++++
 views_content/plugins/content_types/views.inc       | 5 ++++-
 views_content/plugins/content_types/views_panes.inc | 6 +++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/includes/context.inc b/includes/context.inc
index cf292570..3348c5e8 100644
--- a/includes/context.inc
+++ b/includes/context.inc
@@ -157,6 +157,13 @@ class ctools_context_required {
       $contexts = array($contexts);
     }
 
+    // Due to a bug, some contexts got recorded with an id of 0. This will
+    // convert them to the correct ID allowing for some earlier panels
+    // to continue to work.
+    if (!empty($context) && $context[strlen($context) - 1] == 0) {
+      $context[strlen($context) -1 ] = 1;
+    }
+
     if (empty($context) || empty($contexts[$context])) {
       return FALSE;
     }
diff --git a/views_content/plugins/content_types/views.inc b/views_content/plugins/content_types/views.inc
index 8a9c535f..3f75f2f4 100644
--- a/views_content/plugins/content_types/views.inc
+++ b/views_content/plugins/content_types/views.inc
@@ -195,9 +195,12 @@ function views_content_views_content_type_render($subtype, $conf, $panel_args, $
 
   $stored_feeds = drupal_add_feed();
   $block->content = $view->preview();
-
   $block->title = $view->get_title();
 
+  if (empty($view->result) && !$view->display_handler->get_option('empty') && empty($view->style_plugin->definition['even empty'])) {
+    return;
+  }
+
   if (!empty($conf['feed_icons'])) {
     $new_feeds = drupal_add_feed();
     if ($diff = array_diff(array_keys($new_feeds), array_keys($stored_feeds))) {
diff --git a/views_content/plugins/content_types/views_panes.inc b/views_content/plugins/content_types/views_panes.inc
index de4be224..a87f36b3 100644
--- a/views_content/plugins/content_types/views_panes.inc
+++ b/views_content/plugins/content_types/views_panes.inc
@@ -199,7 +199,6 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
   $block = new stdClass();
   $block->module = 'views';
   $block->delta  = $view->name . $display;
-  $block->title = $view->get_title();
 
   if (($allow['link_to_view'] && !empty($conf['link_to_view'])) ||
       (!$allow['link_to_view'] && $view->display_handler->get_option('link_to_view'))) {
@@ -230,6 +229,11 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
   $stored_feeds = drupal_add_feed();
 
   $block->content = $view->preview();
+  if (empty($view->result) && !$view->display_handler->get_option('empty') && empty($view->style_plugin->definition['even empty'])) {
+    return;
+  }
+
+  $block->title = $view->get_title();
 
   if (empty($view->total_rows) || $view->total_rows <= $view->display_handler->get_option('items_per_page')) {
     unset($block->more);
-- 
GitLab