function panels_flexible_create_renderer in Panels 6.3
Same name and namespace in other branches
- 7.3 plugins/layouts/flexible/flexible.inc \panels_flexible_create_renderer()
Create a renderer object.
The renderer object contains data that is passed around from function to function allowing us to render our CSS and HTML easily.
@todo Convert the functions to methods and make this properly OO.
5 calls to panels_flexible_create_renderer()
- panels_ajax_flexible_edit_add in plugins/
layouts/ flexible/ flexible.inc - AJAX responder to add a new row, column or region to a flexible layout.
- panels_ajax_flexible_edit_remove in plugins/
layouts/ flexible/ flexible.inc - AJAX responder to remove an existing row, column or region from a flexible layout.
- panels_ajax_flexible_edit_settings in plugins/
layouts/ flexible/ flexible.inc - AJAX responder to edit flexible settings for an item.
- theme_panels_flexible in plugins/
layouts/ flexible/ flexible.inc - Draw the flexible layout.
- theme_panels_flexible_admin in plugins/
layouts/ flexible/ flexible.inc - Draw the flexible layout.
File
- plugins/
layouts/ flexible/ flexible.inc, line 274
Code
function panels_flexible_create_renderer($admin, $id, $content, $settings, &$display, $layout, $handler) {
$renderer = new stdClass();
$renderer->settings = $settings;
$renderer->content = $content;
$renderer->css_id = $id;
$renderer->did =& $display->did;
if ($admin) {
// always scale in admin mode.
$renderer->scale_base = 99.0;
}
else {
$renderer->scale_base = !empty($settings['items']['canvas']['no_scale']) ? 100.0 : 99.0;
}
$renderer->id_str = $id ? 'id="' . $id . '"' : '';
$renderer->admin = $admin;
$renderer->handler = $handler;
// Set up basic classes for all of our components.
$renderer->name = !empty($layout['layout']) ? $layout['layout']->name : $display->did;
$renderer->base_class = $renderer->name;
$renderer->item_class['column'] = 'panels-flexible-column';
$renderer->item_class['row'] = 'panels-flexible-row';
$renderer->item_class['region'] = 'panels-flexible-region';
$renderer->base['canvas'] = 'panels-flexible-' . $renderer->base_class;
// Override these if selected from the UI and not in admin mode.
if (!$admin) {
if (!empty($settings['items']['canvas']['class'])) {
$renderer->base_class = $settings['items']['canvas']['class'];
$renderer->base['canvas'] = $renderer->base_class;
}
if (!empty($settings['items']['canvas']['column_class'])) {
$renderer->item_class['column'] = $settings['items']['canvas']['column_class'];
}
if (!empty($settings['items']['canvas']['row_class'])) {
$renderer->item_class['row'] = $settings['items']['canvas']['row_class'];
}
if (!empty($settings['items']['canvas']['region_class'])) {
$renderer->item_class['region'] = $settings['items']['canvas']['region_class'];
}
}
// Get the separation values out of the canvas settings.
$renderer->column_separation = !empty($settings['items']['canvas']['column_separation']) ? $settings['items']['canvas']['column_separation'] : '0.5em';
$renderer->region_separation = !empty($settings['items']['canvas']['region_separation']) ? $settings['items']['canvas']['region_separation'] : '0.5em';
$renderer->row_separation = !empty($settings['items']['canvas']['row_separation']) ? $settings['items']['canvas']['row_separation'] : '0.5em';
// Make some appended classes so it's easier to reference them.
$renderer->base['column'] = $renderer->item_class['column'] . '-' . $renderer->base_class;
$renderer->base['row'] = $renderer->item_class['row'] . '-' . $renderer->base_class;
$renderer->base['region'] = $renderer->item_class['region'] . '-' . $renderer->base_class;
if ($renderer->name != 'new') {
// Use v2 to guarantee all CSS gets regenerated to account for changes in
// how some divs will be rendered.
$renderer->css_cache_name = 'flexiblev2:' . $renderer->name;
if ($admin) {
ctools_include('css');
ctools_css_clear($renderer->css_cache_name);
}
}
return $renderer;
}