function panels_flexible_render_items in Panels 6.3
Same name and namespace in other branches
- 7.3 plugins/layouts/flexible/flexible.inc \panels_flexible_render_items()
Render a piece of a flexible layout.
2 calls to panels_flexible_render_items()
- 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 439
Code
function panels_flexible_render_items($renderer, $list, $owner_id) {
$output = '';
$groups = array(
'left' => '',
'middle' => '',
'right' => '',
);
$max = count($list) - 1;
$prev = NULL;
foreach ($list as $position => $id) {
$item = $renderer->settings['items'][$id];
$location = isset($renderer->positions[$id]) ? $renderer->positions[$id] : 'middle';
if ($renderer->admin && $item['type'] != 'row' && $prev) {
$groups[$location] .= panels_flexible_render_splitter($renderer, $prev, $id);
}
switch ($item['type']) {
case 'column':
$content = panels_flexible_render_items($renderer, $item['children'], $renderer->base['column'] . '-' . $id);
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max);
break;
case 'row':
$content = panels_flexible_render_items($renderer, $item['children'], $renderer->base['row'] . '-' . $id);
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max, TRUE);
break;
case 'region':
$content = isset($renderer->content[$id]) ? $renderer->content[$id] : " ";
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max);
break;
}
// If all items are fixed then we have a special splitter on the right to
// control the overall width.
if (!empty($renderer->admin) && $max == $position && $location == 'left') {
$groups[$location] .= panels_flexible_render_splitter($renderer, $id, NULL);
}
$prev = $id;
}
$group_count = count(array_filter($groups));
// Render each group. We only render the group div if we're in admin mode
// or if there are multiple groups.
foreach ($groups as $position => $content) {
if (!empty($content) || $renderer->admin) {
if ($group_count > 1 || $renderer->admin) {
$output .= '<div class="' . $owner_id . '-' . $position . '">' . $content . '</div>';
}
else {
$output .= $content;
}
}
}
return $output;
}