}
/**
+ * Implementation of hook_theme().
+ * Declares each theme's layouts as a page template suggestion.
+ */
+function context_layouts_theme() {
+ $info = array();
+ foreach (list_themes() as $theme) {
+ if (!empty($theme->status) && $layouts = context_layouts_get_layouts($theme->name)) {
+ foreach ($layouts as $layout) {
+ $info["page__context_layouts_{$theme->name}_{$layout['layout']}"] = array(
+ 'template' => $layout['template'],
+ 'path' => drupal_get_path('theme', $theme->name),
+ );
+ }
+ }
+ }
+ return $info;
+}
+
+/**
* Implementation of hook_context_page_reaction().
*/
function context_layouts_context_page_reaction() {
$theme = isset($theme) ? $theme : $theme_key;
if (!isset($layouts[$theme])) {
- $info = context_get_info('theme', $theme);
+ $info = system_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);
+ $info = system_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);
+ $themes[$theme] = system_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['layout'] = str_replace('-', '_', $layout);
$layout_info['theme'] = $key;
$layouts[$theme][$layout] = $layout_info;
}
function add_layout_template(&$vars) {
if ($layout = $this->get_active_layout()) {
if (!empty($layout['template'])) {
- $vars['template_files'][] = $layout['template'];
+ global $theme;
+ $vars['theme_hook_suggestion'] = "page__context_layouts_{$theme}_{$layout['layout']}";
}
}
}
'#options' => $layouts,
'#type' => 'select',
'#weight' => -100,
- '#default_value' => $options['layout'] ? $options['layout'] : NULL,
- '#attributes' => array('class' => 'context-blockform-layout'),
+ '#default_value' => !empty($options['layout']) ? $options['layout'] : NULL,
+ '#attributes' => array('class' => array('context-blockform-layout')),
);
// Add js.