View source
<?php
function context_layouts_help($path, $arg) {
switch ($path) {
case 'admin/help#context_layouts':
$output = file_get_contents(drupal_get_path('module', 'context_layouts') . '/README.txt');
return module_exists('markdown') ? filter_xss_admin(module_invoke('markdown', 'filter', 'process', 0, -1, $output)) : '<pre>' . check_plain($output) . '</pre>';
}
}
function context_layouts_context_plugins() {
return array(
'context_layouts_reaction_block' => array(
'handler' => array(
'path' => drupal_get_path('module', 'context_layouts') . '/plugins',
'file' => 'context_layouts_reaction_block.inc',
'class' => 'context_layouts_reaction_block',
'parent' => 'context_reaction_block',
),
),
);
}
function context_layouts_context_registry_alter(&$registry) {
if (isset($registry['reactions']['block'])) {
$registry['reactions']['block']['plugin'] = 'context_layouts_reaction_block';
}
}
function context_layouts_context_page_reaction() {
$plugin = context_get_plugin('reaction', 'block');
if ($plugin && method_exists($plugin, 'add_layout_stylesheet')) {
$plugin
->add_layout_stylesheet();
}
}
function context_layouts_preprocess_page(&$vars) {
$plugin = context_get_plugin('reaction', 'block');
if ($plugin && method_exists($plugin, 'add_layout_stylesheet')) {
$plugin
->add_layout_template($vars);
}
}
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();
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;
}
}
$themes = array_reverse($themes);
$themes[$theme] = context_get_info('theme', $theme);
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;
}
function context_layouts_get_active_layout($info = TRUE) {
$plugin = context_get_plugin('reaction', 'block');
if ($plugin && method_exists($plugin, 'add_layout_stylesheet')) {
return $plugin
->get_active_layout($info);
}
}