class DynamicBackgroundReaction in Dynamic Background 6
Same name and namespace in other branches
- 7.2 modules/dynamic_background_context/plugins/dynamic_background_context_reaction.inc \DynamicBackgroundReaction
- 7 modules/dynamic_background_context/plugins/dynamic_background_context_reaction.inc \DynamicBackgroundReaction
Hierarchy
- class \DynamicBackgroundReaction extends \context_reaction
Expanded class hierarchy of DynamicBackgroundReaction
1 string reference to 'DynamicBackgroundReaction'
- dynamic_background_context_context_plugins in modules/
dynamic_background_context/ dynamic_background_context.module - Implements hook_context_plugins().
File
- modules/
dynamic_background_context/ plugins/ dynamic_background_context_reaction.inc, line 3
View source
class DynamicBackgroundReaction extends context_reaction {
function options_form($context) {
$form = array();
$form['dynamic_background'] = array(
'#type' => 'fieldset',
'#title' => t('Dynamic background'),
'#description' => t('Select the image that you want for the current context.'),
'#collapsed' => FALSE,
'#collapsible' => TRUE,
'#tree' => TRUE,
);
// Add the image selection part of the form.
$form['dynamic_background'] += dynamic_background_image_selector_form($this
->find_selected_image($context));
return $form;
}
/**
* Options form submit handler.
*/
function options_form_submit($values) {
// Remove the extra level, that the field set above creates.
return array_pop($values);
}
/**
* Find the selected image and return its id.
*/
function execute() {
$image_id = NULL;
foreach ($this
->get_contexts() as $context) {
$image_id = $this
->find_selected_image($context);
}
return $image_id;
}
function find_selected_image($context) {
// Find the currently selected image
if (isset($context->reactions['dynamic_background'])) {
foreach ($context->reactions['dynamic_background'] as $id => $value) {
if (isset($value['selected']) && $value['selected']) {
return $id;
}
}
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DynamicBackgroundReaction:: |
function | Find the selected image and return its id. | ||
DynamicBackgroundReaction:: |
function | |||
DynamicBackgroundReaction:: |
function | |||
DynamicBackgroundReaction:: |
function | Options form submit handler. |