class context_reaction_active_theme in Context Reaction: Theme 6.2
Same name and namespace in other branches
- 7 plugins/context_reaction_theme.inc \context_reaction_active_theme
Expose themes as context reactions.
Hierarchy
- class \context_reaction_active_theme extends \context_reaction
Expanded class hierarchy of context_reaction_active_theme
3 string references to 'context_reaction_active_theme'
- context_reaction_theme_context_plugins in ./
context_reaction_theme.module - CTools plugin API hook for Context
- context_reaction_theme_context_registry in ./
context_reaction_theme.module - Registry hook for conditions & reactions.
- context_reaction_theme_init in ./
context_reaction_theme.module - Implementation of hook_init().
File
- plugins/
context_reaction_active_theme.inc, line 6
View source
class context_reaction_active_theme extends context_reaction {
/**
* Allow admins to choose the theme to be set.
*/
function options_form($context) {
$options = array();
foreach (list_themes() as $name => $theme) {
if ($theme->status) {
$options[$name] = $name;
}
}
$values = $this
->fetch_from_context($context);
$form = array(
'#tree' => TRUE,
'#title' => t('Theme'),
'theme' => array(
'#title' => t('Active theme'),
'#description' => t('Choose a theme to activate when this context is active.'),
'#type' => 'select',
'#options' => $options,
'#default_value' => isset($values['theme']) ? $values['theme'] : '',
),
);
return $form;
}
/**
* Set the active theme.
*/
function execute() {
foreach (context_active_contexts() as $context) {
if (!empty($context->reactions[$this->plugin]['theme'])) {
global $custom_theme;
$custom_theme = $context->reactions[$this->plugin]['theme'];
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
context_reaction_active_theme:: |
function | Set the active theme. | ||
context_reaction_active_theme:: |
function | Allow admins to choose the theme to be set. |