class context_reaction_active_theme in Context Reaction: Theme 7
Same name and namespace in other branches
- 6.2 plugins/context_reaction_active_theme.inc \context_reaction_active_theme
Expose themes as context reactions.
Hierarchy
- class \context_reaction
Expanded class hierarchy of context_reaction_active_theme
2 string references to 'context_reaction_active_theme'
File
- plugins/
context_reaction_theme.inc, line 11 - Context plugin file to provide changing the active theme as a context reaction.
View source
class context_reaction_active_theme extends context_reaction {
/**
* Grab the available themes and provide them as a reaction for context.
*
* @param $context
* The context as passed from context module.
*
* @return array
* The FAPI array as read by context module.
*/
function options_form($context) {
$options = array();
$themes = list_themes();
foreach ($themes as $name => $theme) {
// only allow active themes
if ($theme->status == 1) {
$options[$name] = $name;
}
}
$settings = $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($settings['theme']) ? $settings['theme'] : variable_get('theme_default', ''),
),
);
return $form;
}
/**
* Return the active theme based on the context
*
* @return string | null
* String of the theme name, or NULL if not to be altered.
*/
function execute() {
$theme = NULL;
foreach ($this
->get_contexts() as $context) {
if (isset($context->reactions['active_theme']['theme'])) {
$theme = $context->reactions['active_theme']['theme'];
}
}
return $theme;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
context_reaction:: |
property | |||
context_reaction:: |
property | |||
context_reaction:: |
property | |||
context_reaction:: |
function | Retrieve options from the context provided. | 1 | |
context_reaction:: |
function | Retrieve active contexts that have values for this reaction. | ||
context_reaction:: |
function | Options form submit handler. | 3 | |
context_reaction:: |
function | Settings form. Provide variable settings for your reaction. | 2 | |
context_reaction:: |
function | Clone our references when we're being cloned. | ||
context_reaction:: |
function | Constructor. Do not override. | ||
context_reaction_active_theme:: |
function | Return the active theme based on the context | ||
context_reaction_active_theme:: |
function |
Grab the available themes and provide them as a reaction for context. Overrides context_reaction:: |