}
}
+
+/**
+ * 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
//
}
/**
- * 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
--- /dev/null
+<?php\r
+/**\r
+ * @file\r
+ * Contains the simple display renderer.\r
+ */\r
+\r
+/**\r
+ * The simple display renderer renders a display normally, except each pane\r
+ * is already rendered content, rather than a pane containing CTools content\r
+ * to be rendered. Styles are not supported.\r
+ */\r
+class panels_renderer_simple extends panels_renderer_standard {\r
+ function render_regions() {\r
+ $this->rendered['regions'] = array();\r
+ foreach ($this->display->content as $region_id => $content) {\r
+ if (is_array($content)) {\r
+ $content = implode('', $content);\r
+ }\r
+\r
+ $this->rendered['regions'][$region_id] = $content;\r
+ }\r
+ return $this->rendered['regions'];\r
+ }\r
+\r
+ function render_panes() {\r
+ // NOP\r
+ }\r
+\r
+ function prepare() {\r
+ $this->prep_run = TRUE;\r
+ }\r
+}\r
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
$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;
}
/**
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;
}
}
--- /dev/null
+<?php\r
+/**\r
+ * Create a simple renderer plugin that renders a layout but the content is\r
+ * already rendered, not in panes.\r
+ */\r
+$plugin = array(\r
+ 'handler' => array(\r
+ 'class' => 'panels_renderer_simple',\r
+ 'parent' => 'standard',\r
+ ),\r
+);
\ No newline at end of file
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