function context_layouts_get_layouts in Context 6.3
Same name and namespace in other branches
- 6 context_layouts/context_layouts.module \context_layouts_get_layouts()
- 7.3 context_layouts/context_layouts.module \context_layouts_get_layouts()
Retrieve layouts for the specified theme.
4 calls to context_layouts_get_layouts()
- context_layouts_reaction_block::get_active_layout in context_layouts/
plugins/ context_layouts_reaction_block.inc - Retrieve the first layout specified found by any active contexts.
- context_layouts_reaction_block::get_layout_options in context_layouts/
plugins/ context_layouts_reaction_block.inc - Get layout options for the given theme.
- context_layouts_reaction_block::get_layout_regions in context_layouts/
plugins/ context_layouts_reaction_block.inc - Get a layout to region map for the given theme.
- context_layouts_reaction_block::options_form_submit in context_layouts/
plugins/ context_layouts_reaction_block.inc - Override of submit handler.
File
- context_layouts/
context_layouts.module, line 63
Code
function context_layouts_get_layouts($theme = NULL, $reset = FALSE) {
static $layouts = array();
$layouts = $reset ? array() : $layouts;
global $theme_key;
$theme = isset($theme) ? $theme : $theme_key;
if (!isset($layouts[$theme])) {
$info = context_get_info('theme', $theme);
$themes = array();
// Find all our ancestor themes that use layouts.
if (isset($info['base theme'])) {
while (!empty($info['base theme'])) {
$base_theme = $info['base theme'];
$info = context_get_info('theme', $base_theme);
$themes[$base_theme] = $info;
}
}
// Assemble in inheritance order and add the theme on.
$themes = array_reverse($themes);
$themes[$theme] = context_get_info('theme', $theme);
// Merge layout info into a single array.
foreach ($themes as $key => $info) {
if (!empty($info['layouts'])) {
foreach ($info['layouts'] as $layout => $layout_info) {
$layout_info['theme'] = $key;
$layouts[$theme][$layout] = $layout_info;
}
}
}
}
return isset($layouts[$theme]) ? $layouts[$theme] : FALSE;
}