class context_reaction_theme in Context 6
Same name and namespace in other branches
- 6.3 plugins/context_reaction_theme.inc \context_reaction_theme
- 7.3 plugins/context_reaction_theme.inc \context_reaction_theme
Expose themes as context reactions.
Hierarchy
- class \context_reaction
- class \context_reaction_theme
Expanded class hierarchy of context_reaction_theme
2 string references to 'context_reaction_theme'
- _context_context_plugins in ./
context.plugins.inc - Context plugins.
- _context_context_registry in ./
context.plugins.inc - Context registry.
File
- plugins/
context_reaction_theme.inc, line 6
View source
class context_reaction_theme extends context_reaction {
/**
* Editor form.
*/
function editor_form($context) {
$form = $this
->options_form($context);
// Hide descriptions which take up too much space.
unset($form['title']['#description']);
unset($form['subtitle']['#description']);
unset($form['class']['#description']);
return $form;
}
/**
* Submit handler for editor form.
*/
function editor_form_submit($context, $values) {
return $values;
}
/**
* Allow admins to provide a section title, section subtitle and section class.
*/
function options_form($context) {
$values = $this
->fetch_from_context($context);
$form = array(
'#tree' => TRUE,
'#title' => t('Theme variables'),
'title' => array(
'#title' => t('Section title'),
'#description' => t('Provides this text as a <strong>$section_title</strong> variable for display in page.tpl.php when this context is active.'),
'#type' => 'textfield',
'#maxlength' => 255,
'#default_value' => isset($values['title']) ? $values['title'] : '',
),
'subtitle' => array(
'#title' => t('Section subtitle'),
'#description' => t('Provides this text as a <strong>$section_subtitle</strong> variable for display in page.tpl.php when this context is active.'),
'#type' => 'textfield',
'#maxlength' => 255,
'#default_value' => isset($values['subtitle']) ? $values['subtitle'] : '',
),
'class' => array(
'#title' => t('Section class'),
'#description' => t('Provides this text as an additional body class (in <strong>$body_classes</strong> in page.tpl.php) when this section is active.'),
'#type' => 'textfield',
'#maxlength' => 64,
'#default_value' => isset($values['class']) ? $values['class'] : '',
),
);
return $form;
}
/**
* Set 'section_title', and 'section_subtitle' if not set and merge all
* additional classes onto the 'body_classes'.
*/
function execute(&$vars) {
$classes = array();
foreach ($this
->get_contexts() as $k => $v) {
if (!empty($v->reactions[$this->plugin]['title']) && !isset($vars['section_title'])) {
$vars['section_title'] = t($v->reactions[$this->plugin]['title']);
}
if (!empty($v->reactions[$this->plugin]['subtitle']) && !isset($vars['section_subtitle'])) {
$vars['section_subtitle'] = t($v->reactions[$this->plugin]['subtitle']);
}
if (!empty($v->reactions[$this->plugin]['class'])) {
$vars['classes_array'][] = $v->reactions[$this->plugin]['class'];
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
context_reaction:: |
property | |||
context_reaction:: |
property | |||
context_reaction:: |
property | |||
context_reaction:: |
function | Retrieve options from the context provided. | ||
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. | 1 | |
context_reaction:: |
function | Clone our references when we're being cloned. | ||
context_reaction:: |
function | Constructor. Do not override. | ||
context_reaction_theme:: |
function | Editor form. | ||
context_reaction_theme:: |
function | Submit handler for editor form. | ||
context_reaction_theme:: |
function | Set 'section_title', and 'section_subtitle' if not set and merge all additional classes onto the 'body_classes'. | ||
context_reaction_theme:: |
function |
Allow admins to provide a section title, section subtitle and section class. Overrides context_reaction:: |