? views-pluggable-block.patch
? plugins/views-pluggable-blocks.patch
Index: includes/plugins.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/includes/plugins.inc,v
retrieving revision 1.152.2.3
diff -u -p -r1.152.2.3 plugins.inc
--- includes/plugins.inc	2 Jun 2009 20:22:24 -0000	1.152.2.3
+++ includes/plugins.inc	23 Aug 2009 11:44:36 -0000
@@ -267,6 +267,25 @@ function views_views_plugins() {
         'help topic' => 'cache-time',
       ),
     ),
+    'block' => array(
+      'parent' => array(
+        'no ui' => TRUE,
+        'handler' => 'views_plugin_block',
+        'parent' => '',
+      ),
+      'textarea' => array(
+        'title' => t('Basic Textarea'),
+        'help' => t('Basic html textarea'),
+        'handler' => 'views_plugin_block_textarea',
+        'help topic' => 'block-textarea',
+      ),
+      'php' => array(
+        'title' => t('PHP'),
+        'help' => t('PHP Code which is evaled'),
+        'handler' => 'views_plugin_block_php',
+        'help topic' => 'block-php',
+      ),
+    ),
   );
 }
 
Index: plugins/views_plugin_block.inc
===================================================================
RCS file: plugins/views_plugin_block.inc
diff -N plugins/views_plugin_block.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/views_plugin_block.inc	23 Aug 2009 11:44:36 -0000
@@ -0,0 +1,18 @@
+<?php
+// $Id$
+/**
+ * The base plugin to handle block.
+ */
+class views_plugin_block extends views_plugin {
+  function init($view, $display) {
+    $this->view = &$view;
+    $this->display = &$display;
+    $this->options = array();
+  }
+
+  function options_form(&$form, $&form_state) {
+  }
+
+  function render() { }
+}
+
Index: plugins/views_plugin_block_php.inc
===================================================================
RCS file: plugins/views_plugin_block_php.inc
diff -N plugins/views_plugin_block_php.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/views_plugin_block_php.inc	23 Aug 2009 11:44:36 -0000
@@ -0,0 +1,35 @@
+<?php
+// $Id$
+/**
+ * @file
+ *   Block plugin for textarea content.
+ */
+class views_plugin_block_php extends views_plugin_block {
+  function init($view, $display) {
+    parent::init($view, $display);
+  }
+
+  function options_form(&$form, $&form_state) {
+    $form['empty'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display even if view has no result'),
+    '#default_value' => $this->get_option('empty'),
+    );
+    $form['content'] = array(
+    '#type' => 'textarea',
+    '#default_value' => $this->get_option('content'),
+    '#rows' => 6,
+    '#description' => t('Php code to render the page.'),
+    );
+  }
+
+  function render($empty = FALSE) {
+    if (!$empty || $this->get_option('empty')) {
+      return drupal_eval($this->get_option('content'));
+    }
+    else {
+      return '';
+    }
+  }
+}
+
Index: plugins/views_plugin_block_textarea.inc
===================================================================
RCS file: plugins/views_plugin_block_textarea.inc
diff -N plugins/views_plugin_block_textarea.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/views_plugin_block_textarea.inc	23 Aug 2009 11:44:36 -0000
@@ -0,0 +1,37 @@
+<?php
+// $Id$
+/**
+ * @file
+ *   Block plugin for textarea content.
+ */
+class views_plugin_block_textarea extends views_plugin_block {
+  function init($view, $display) {
+    parent::init($view, $display);
+  }
+
+  function options_form(&$form, $&form_state) {
+    $form['empty'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display even if view has no result'),
+    '#default_value' => $this->get_option('empty'),
+    );
+    $form['content'] = array(
+    '#type' => 'textarea',
+    '#default_value' => $this->get_option('content'),
+    '#rows' => 6,
+    '#description' => t('Text to display at the top of the view. May contain an explanation or links or whatever you like. Optional.'),
+    );
+
+    $form['format'] = filter_form($this->get_option('format'), NULL, array('format'));
+  }
+
+  function render($empty = FALSE) {
+    if (!$empty || $this->get_option('empty')) {
+      return check_markup($this->get_option('content'), $this->get_option('format'), FALSE);
+    }
+    else {
+      return '';
+    }
+  }
+}
+
Index: plugins/views_plugin_display.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/plugins/views_plugin_display.inc,v
retrieving revision 1.20.2.6
diff -u -p -r1.20.2.6 views_plugin_display.inc
--- plugins/views_plugin_display.inc	26 Jun 2009 00:23:37 -0000	1.20.2.6
+++ plugins/views_plugin_display.inc	23 Aug 2009 11:44:37 -0000
@@ -160,9 +160,9 @@ class views_plugin_display extends views
       'access' => array('access'),
       'cache' => array('cache'),
       'title' => array('title'),
-      'header' => array('header', 'header_format', 'header_empty'),
-      'footer' => array('footer', 'footer_format', 'footer_empty'),
-      'empty' => array('empty', 'empty_format'),
+      'header' => array('block'),
+      'footer' => array('block'),
+      'empty' => array('block'),
       'use_ajax' => array('use_ajax'),
       'items_per_page' => array('items_per_page', 'offset', 'use_pager', 'pager_element'),
       'use_pager' => array('items_per_page', 'offset', 'use_pager', 'pager_element'),
@@ -520,6 +520,22 @@ class views_plugin_display extends views
   }
 
   /**
+   * Get the block plugin.
+   */
+  function get_block_plugin($name = NULL) {
+    if (!$name) {
+      $block = $this->get_option('block_'. $name);
+      $name = $block['type'];
+    }
+
+    $plugin = $views_get_plugin('block', $name);
+    if ($plugin) {
+      $plugin->init($this->view, $this->display);
+      return $plugin;
+    }
+  }
+
+  /**
    * Get the handler object for a single handler.
    */
   function &get_handler($type, $id) {
@@ -999,47 +1015,55 @@ class views_plugin_display extends views
         }
         break;
       case 'header':
+        $block = $this->get_option('header');
+        $plugin = $this->get_block_plugin('header');
         $form['#title'] .= t('Header');
-        $form['header_empty'] = array(
-          '#type' => 'checkbox',
-          '#title' => t('Display even if view has no result'),
-          '#default_value' => $this->get_option('header_empty'),
-        );
-        $form['header'] = array(
-          '#type' => 'textarea',
-          '#default_value' => $this->get_option('header'),
-          '#rows' => 6,
-          '#description' => t('Text to display at the top of the view. May contain an explanation or links or whatever you like. Optional.'),
-        );
+        if ($plugin) {
+          $form['#help_topic'] = $plugin->definition['help topic'];
 
-        $form['header_format'] = filter_form($this->get_option('header_format'), NULL, array('header_format'));
+          $form['header_options'] = array(
+            '#tree' => TRUE,
+          );
+          $form['header_options']['type'] = array(
+            '#type' => 'value',
+            '#value' => $block['type'],
+          );
+          $plugin->options_form($form['header_options'], $form_state);
+        }
         break;
       case 'footer':
+        $block = $this->get_option('footer');
+        $plugin = $this->get_block_plugin('footer');
         $form['#title'] .= t('Footer');
-        $form['footer_empty'] = array(
-          '#type' => 'checkbox',
-          '#title' => t('Display even if view has no result'),
-          '#default_value' => $this->get_option('footer_empty'),
-        );
-        $form['footer'] = array(
-          '#type' => 'textarea',
-          '#default_value' => $this->get_option('footer'),
-          '#rows' => 6,
-          '#description' => t('Text to display beneath the view. May contain an explanation or links or whatever you like. Optional.'),
-        );
+        if ($plugin) {
+          $form['#help_topic'] = $plugin->definition['help topic'];
 
-        $form['footer_format'] = filter_form($this->get_option('footer_format'), NULL, array('footer_format'));
+          $form['footer_options'] = array(
+            '#tree' => TRUE,
+          );
+          $form['footer_options']['type'] = array(
+            '#type' => 'value',
+            '#value' => $block['type'],
+          );
+          $plugin->options_form($form['footer_options'], $form_state);
+        }
         break;
       case 'empty':
+        $block = $this->get_option('empty');
+        $plugin = $this->get_block_plugin('empty');
         $form['#title'] .= t('Empty text');
-        $form['empty'] = array(
-          '#type' => 'textarea',
-          '#default_value' => $this->get_option('empty'),
-          '#rows' => 6,
-          '#description' => t('Text to display if the view has no results. Optional.'),
-        );
+        if ($plugin) {
+          $form['#help_topic'] = $plugin->definition['help topic'];
 
-        $form['empty_format'] = filter_form($this->get_option('empty_format'), NULL, array('empty_format'));
+          $form['empty_options'] = array(
+            '#tree' => TRUE,
+          );
+          $form['empty_options']['type'] = array(
+            '#type' => 'value',
+            '#value' => $block['type'],
+          );
+          $plugin->options_form($form['empty_options'], $form_state);
+        }
         break;
       case 'style_plugin':
         $form['#title'] .= t('How should this view be styled');
Index: theme/theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/theme/theme.inc,v
retrieving revision 1.73.2.5
diff -u -p -r1.73.2.5 theme.inc
--- theme/theme.inc	1 Jul 2009 22:52:42 -0000	1.73.2.5
+++ theme/theme.inc	23 Aug 2009 11:44:37 -0000
@@ -49,26 +49,26 @@ function template_preprocess_views_view(
   $vars['name']       = $view->name;
   $vars['display_id'] = $view->current_display;
 
+  $header = $view->display_handler->get_block_option('header');
+  $footer = $view->display_handler->get_block_option('footer');
+
   if (!$vars['rows']) {
-    $vars['empty']    = $view->display_handler->render_empty();
-    if (!$view->display_handler->get_option('header_empty')) {
-      $vars['header'] = '';
-    }
-    if (!$view->display_handler->get_option('footer_empty')) {
-      $vars['footer'] = '';
-    }
+    $empty = $view->display_handler->get_block_option('empty');
+    $vars['empty']    = $empty->render();
+    $vars['header'] = $header->render('empty');
+    $vars['footer'] = $footer->render('empty');
   }
   else {
-    $vars['empty']    = '';
+    $vars['empty'] = '';
     $header = TRUE;
   }
 
   $vars['exposed']    = !empty($view->exposed_widgets) ? $view->exposed_widgets : '';
   if (!isset($vars['header'])) {
-    $vars['header']   = $view->display_handler->render_header();
+    $vars['header']   = $header->render();
   }
   if (!isset($vars['footer'])) {
-    $vars['footer']   = $view->display_handler->render_footer();
+    $vars['footer']   = $footer->render();
   }
   $vars['more']       = $view->display_handler->render_more_link();
   $vars['feed_icon']  = !empty($view->feed_icon) ? $view->feed_icon : '';
