function panels_export_display in Panels 6.3
Same name and namespace in other branches
- 8.3 panels.module \panels_export_display()
- 5.2 panels.module \panels_export_display()
- 6.2 panels.module \panels_export_display()
- 7.3 panels.module \panels_export_display()
Exports the provided display into portable code.
This function is primarily intended as a mechanism for cloning displays. It generates an exact replica (in code) of the provided $display, with the exception that it replaces all ids (dids and pids) with 'new-*' values. Only once panels_save_display() is called on the code version of $display will the exported display written to the database and permanently saved.
Parameters
object $display instanceof panels_display \n: This export function does no loading of additional data about the provided display. Consequently, the caller should make sure that all the desired data has been loaded into the $display before calling this function.
string $prefix: A string prefix that is prepended to each line of exported code. This is primarily used for prepending a double space when exporting so that the code indents and lines up nicely.
Return value
string $output The passed-in $display expressed as code, ready to be imported. Import by running eval($output) in the caller function; doing so will create a new $display variable with all the exported values. Note that if you have already defined a $display variable in the same scope as where you eval(), your existing $display variable WILL be overwritten.
See also
panels_page_export() or _panels_page_fetch_display() for sample implementations.
Related topics
5 calls to panels_export_display()
- panels_mini_export in panels_mini/
panels_mini.module - Export a mini panel.
- panels_node_export_node_alter in panels_node/
panels_node.module - Implementation of hook_export_node_alter()
- panels_panel_context_clone in plugins/
task_handlers/ panel_context.inc - When a handler is cloned, we have to clone the display.
- panels_panel_context_export in plugins/
task_handlers/ panel_context.inc - Special handling for exporting a panel task handler.
- _panels_update_create_handler in ./
panels.install
1 string reference to 'panels_export_display'
- panels_schema_1 in ./
panels.install - Schema version 1 for Panels in D6.
File
- ./
panels.module, line 962 - panels.module
Code
function panels_export_display($display, $prefix = '') {
ctools_include('export');
$output = ctools_export_object('panels_display', $display, $prefix);
// Initialize empty properties.
$output .= $prefix . '$display->content = array()' . ";\n";
$output .= $prefix . '$display->panels = array()' . ";\n";
$panels = array();
$title_pid = 0;
if (!empty($display->content)) {
$pid_counter = 0;
$region_counters = array();
foreach ($display->content as $pane) {
$pid = 'new-' . ++$pid_counter;
if ($pane->pid == $display->title_pane) {
$title_pid = $pid;
}
$pane->pid = $pid;
$output .= ctools_export_object('panels_pane', $pane, $prefix . ' ');
$output .= "{$prefix} " . '$display->content[\'' . $pane->pid . '\'] = $pane' . ";\n";
if (!isset($region_counters[$pane->panel])) {
$region_counters[$pane->panel] = 0;
}
$output .= "{$prefix} " . '$display->panels[\'' . $pane->panel . '\'][' . $region_counters[$pane->panel]++ . '] = \'' . $pane->pid . "';\n";
}
}
$output .= $prefix . '$display->hide_title = ';
switch ($display->hide_title) {
case PANELS_TITLE_FIXED:
$output .= 'PANELS_TITLE_FIXED';
break;
case PANELS_TITLE_NONE:
$output .= 'PANELS_TITLE_NONE';
break;
case PANELS_TITLE_PANE:
$output .= 'PANELS_TITLE_PANE';
break;
}
$output .= ";\n";
$output .= $prefix . '$display->title_pane =' . " '{$title_pid}';\n";
return $output;
}