summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--panels.module62
-rw-r--r--plugins/display_renderers/panels_renderer_simple.class.php32
-rw-r--r--plugins/display_renderers/panels_renderer_standard.class.php53
-rw-r--r--plugins/display_renderers/simple.inc11
-rw-r--r--plugins/layouts/flexible/flexible.inc9
5 files changed, 139 insertions, 28 deletions
diff --git a/panels.module b/panels.module
index 3ce2f71..7336424 100644
--- a/panels.module
+++ b/panels.module
@@ -1490,6 +1490,45 @@ function panels_goto($destination) {
}
}
+
+/**
+ * For external use: Given a layout ID and a $content array, return the
+ * panel display.
+ *
+ * The content array is filled in based upon the content available in the
+ * layout. If it's a two column with a content array defined like
+ * @code
+ * array(
+ * 'left' => t('Left side'),
+ * 'right' => t('Right side')
+ * ),
+ * @endcode
+ *
+ * Then the $content array should be
+ * @code
+ * array(
+ * 'left' => $output_left,
+ * 'right' => $output_right,
+ * )
+ * @endcode
+ *
+ * The output within each panel region can be either a single rendered
+ * HTML string or an array of rendered HTML strings as though they were
+ * panes. They will simply be concatenated together without separators.
+ */
+function panels_print_layout($layout, $content, $meta = 'standard') {
+ ctools_include('plugins', 'panels');
+
+ // Create a temporary display for this.
+ $display = panels_new_display();
+ $display->layout = is_array($layout) ? $layout['name'] : $layout;
+ $display->content = $content;
+
+ // Get our simple renderer
+ $renderer = panels_get_renderer_handler('simple', $display);
+ return $renderer->render();
+}
+
// --------------------------------------------------------------------------
// Deprecated functions
//
@@ -1518,29 +1557,6 @@ function panels_get_path($file, $base_path = FALSE, $module = 'panels') {
}
/**
- * For external use: Given a layout ID and a $content array, return the
- * panel display. The content array is filled in based upon the content
- * available in the layout. If it's a two column with a content
- * array defined like array('left' => t('Left side'), 'right' =>
- * t('Right side')), then the $content array should be array('left' =>
- * $output_left, 'right' => $output_right)
- *
- * @deprecated This function represents an old approach to rendering, and is
- * retained only as a temporary support for other modules still using that
- * approach. It will be removed in the next major version of Panels.
- */
-function panels_print_layout($id, $content) {
- ctools_include('display-render', 'panels');
- ctools_include('plugins', 'panels');
- $layout = panels_get_layout($id);
- if (!$layout) {
- return;
- }
-
- return panels_render_layout($layout, $content);
-}
-
-/**
* Given a full layout structure and a content array, render a panel display.
*
* @deprecated This function represents an old approach to rendering, and is
diff --git a/plugins/display_renderers/panels_renderer_simple.class.php b/plugins/display_renderers/panels_renderer_simple.class.php
new file mode 100644
index 0000000..a4c1577
--- /dev/null
+++ b/plugins/display_renderers/panels_renderer_simple.class.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * @file
+ * Contains the simple display renderer.
+ */
+
+/**
+ * The simple display renderer renders a display normally, except each pane
+ * is already rendered content, rather than a pane containing CTools content
+ * to be rendered. Styles are not supported.
+ */
+class panels_renderer_simple extends panels_renderer_standard {
+ function render_regions() {
+ $this->rendered['regions'] = array();
+ foreach ($this->display->content as $region_id => $content) {
+ if (is_array($content)) {
+ $content = implode('', $content);
+ }
+
+ $this->rendered['regions'][$region_id] = $content;
+ }
+ return $this->rendered['regions'];
+ }
+
+ function render_panes() {
+ // NOP
+ }
+
+ function prepare() {
+ $this->prep_run = TRUE;
+ }
+}
diff --git a/plugins/display_renderers/panels_renderer_standard.class.php b/plugins/display_renderers/panels_renderer_standard.class.php
index 14d1946..4e80e35 100644
--- a/plugins/display_renderers/panels_renderer_standard.class.php
+++ b/plugins/display_renderers/panels_renderer_standard.class.php
@@ -129,6 +129,30 @@ class panels_renderer_standard {
var $admin = FALSE;
/**
+ * Where to add standard meta information. There are three possibilities:
+ * - standard: Put the meta information in the normal location. Default.
+ * - inline: Put the meta information directly inline. This will
+ * not work for javascript.
+ *
+ * @var string
+ */
+ var $meta_location = 'standard';
+
+ /**
+ * Include rendered HTML prior to the layout.
+ *
+ * @var string
+ */
+ var $prefix = '';
+
+ /**
+ * Include rendered HTML after the layout.
+ *
+ * @var string
+ */
+ var $suffix = '';
+
+ /**
* Receive and store the display object to be rendered.
*
* This is a psuedo-constructor that should typically be called immediately
@@ -353,7 +377,7 @@ class panels_renderer_standard {
$theme = $this->plugins['layout']['theme'];
}
$this->rendered['layout'] = theme($theme, check_plain($this->display->css_id), $this->rendered['regions'], $this->display->layout_settings, $this->display, $this->plugins['layout'], $this);
- return $this->rendered['layout'];
+ return $this->prefix . $this->rendered['layout'] . $this->suffix;
}
/**
@@ -365,15 +389,36 @@ class panels_renderer_standard {
function add_meta() {
if (!empty($this->plugins['layout']['css'])) {
if (file_exists(path_to_theme() . '/' . $this->plugins['layout']['css'])) {
- drupal_add_css(path_to_theme() . '/' . $this->plugins['layout']['css']);
+ $this->add_css(path_to_theme() . '/' . $this->plugins['layout']['css']);
}
else {
- drupal_add_css($this->plugins['layout']['path'] . '/' . $this->plugins['layout']['css']);
+ $this->add_css($this->plugins['layout']['path'] . '/' . $this->plugins['layout']['css']);
}
}
if ($this->admin && isset($this->plugins['layout']['admin css'])) {
- drupal_add_css($this->plugins['layout']['path'] . '/' . $this->plugins['layout']['admin css']);
+ $this->add_css($this->plugins['layout']['path'] . '/' . $this->plugins['layout']['admin css']);
+ }
+ }
+
+ function add_css($filename, $type = 'module', $media = 'all', $preprocess = TRUE) {
+ switch ($this->meta_location) {
+ case 'standard':
+ $path = file_create_path($filename);
+ if ($path) {
+ // Use CTools CSS add because it can handle temporary CSS in private
+ // filesystem.
+ ctools_include('css');
+ ctools_css_add_css($filename, $type, $media, $preprocess);
+ }
+ else {
+ drupal_add_css($filename, $type, $media, $preprocess);
+ }
+ break;
+ case 'inline':
+ $url = file_create_url($filename);
+ $this->prefix .= '<link type="text/css" rel="stylesheet" media="' . $media . '" href="' . $url . '" />'."\n";
+ break;
}
}
diff --git a/plugins/display_renderers/simple.inc b/plugins/display_renderers/simple.inc
new file mode 100644
index 0000000..4c04fca
--- /dev/null
+++ b/plugins/display_renderers/simple.inc
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Create a simple renderer plugin that renders a layout but the content is
+ * already rendered, not in panes.
+ */
+$plugin = array(
+ 'handler' => array(
+ 'class' => 'panels_renderer_simple',
+ 'parent' => 'standard',
+ ),
+); \ No newline at end of file
diff --git a/plugins/layouts/flexible/flexible.inc b/plugins/layouts/flexible/flexible.inc
index 7a323d5..5da535c 100644
--- a/plugins/layouts/flexible/flexible.inc
+++ b/plugins/layouts/flexible/flexible.inc
@@ -356,7 +356,14 @@ function theme_panels_flexible($id, $content, $settings, $display, $layout, $han
if (!$filename) {
$filename = ctools_css_store($renderer->css_cache_name, $css, FALSE);
}
- ctools_css_add_css($filename, 'module', 'all', FALSE);
+
+ // Give the CSS to the renderer to put where it wants.
+ if ($handler) {
+ $handler->add_css($filename, 'module', 'all', FALSE);
+ }
+ else {
+ ctools_css_add_css($filename, 'module', 'all', FALSE);
+ }
}
else {
// If the id is 'new' we can't reliably cache the CSS in the filesystem