function panels_renderer_standard::prepare_regions in Panels 7.3
Same name and namespace in other branches
- 6.3 plugins/display_renderers/panels_renderer_standard.class.php \panels_renderer_standard::prepare_regions()
Prepare the list of regions to be rendered.
This method is primarily about properly initializing the style plugin that will be used to render the region. This is crucial as regions cannot be rendered without a style plugin (in keeping with Panels' philosophy of hardcoding none of its output), but for most regions no style has been explicitly set. The logic here is what accommodates that situation:
- If a region has had its style explicitly set, then we fetch that plugin and continue.
- If the region has no explicit style, but a style was set at the display level, then inherit the style from the display.
- If neither the region nor the dispay have explicitly set styles, then fall back to the hardcoded 'default' style, a very minimal style.
The other important task accomplished by this method is ensuring that even regions without any panes are still properly prepared for the rendering process. This is essential because the way Panels loads display objects (contain panes - not necessarily all the regions defined by the layout plugin, which can only be determined by asking the plugin at runtime. This method consults that retrieved list of regions and prepares all of those, ensuring none are inadvertently skipped.
Parameters
array $region_pane_list: An associative array of pane ids, keyed on the region to which those pids are assigned. In the default case, this is $display->panels.
array $settings: All known region style settings, including both the top-level display's settings (if any) and all region-specific settings (if any).
Return value
array An array of regions prepared for rendering.
See also
panels_load_displays) results only in a list of regions that
1 call to panels_renderer_standard::prepare_regions()
- panels_renderer_standard::prepare in plugins/
display_renderers/ panels_renderer_standard.class.php - Prepare the attached display for rendering.
File
- plugins/
display_renderers/ panels_renderer_standard.class.php, line 334
Class
Code
function prepare_regions($region_pane_list, $settings) {
// Initialize defaults to be used for regions without their own explicit
// settings. Use display settings if they exist, else hardcoded defaults.
$default = array(
'style' => panels_get_style(!empty($settings['style']) ? $settings['style'] : 'default'),
'style settings' => isset($settings['style_settings']['default']) ? $settings['style_settings']['default'] : array(),
);
$regions = array();
if (empty($settings)) {
// No display/panel region settings exist, init all with the defaults.
foreach ($this->plugins['layout']['regions'] as $region_id => $title) {
// Ensure this region has at least an empty panes array.
$panes = !empty($region_pane_list[$region_id]) ? $region_pane_list[$region_id] : array();
$regions[$region_id] = $default;
$regions[$region_id]['pids'] = $panes;
}
}
else {
// Some settings exist; iterate through each region and set individually.
foreach ($this->plugins['layout']['regions'] as $region_id => $title) {
// Ensure this region has at least an empty panes array.
$panes = !empty($region_pane_list[$region_id]) ? $region_pane_list[$region_id] : array();
if (empty($settings[$region_id]['style']) || $settings[$region_id]['style'] == -1) {
$regions[$region_id] = $default;
}
else {
$regions[$region_id]['style'] = panels_get_style($settings[$region_id]['style']);
$regions[$region_id]['style settings'] = isset($settings['style_settings'][$region_id]) ? $settings['style_settings'][$region_id] : array();
}
$regions[$region_id]['pids'] = $panes;
}
}
$this->prepared['regions'] = $regions;
return $this->prepared['regions'];
}