View source
<?php
function dynamic_background_context_perm() {
return array(
'configure context dynamic background',
);
}
function dynamic_background_context_menu() {
$items = array();
$items['admin/build/backgrounds/context'] = array(
'title' => 'Context',
'description' => t('Configure dynamic background context'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'dynamic_background_context_admin_form',
),
'access arguments' => array(
'configure context dynamic background',
),
'type' => MENU_LOCAL_TASK,
'weight' => -10,
);
return $items;
}
function dynamic_background_context_admin_form() {
$form = array(
'#tree' => TRUE,
);
$form += dynamic_background_image_presents_form('dynamic_background_context_imagecache');
$form += dynamic_background_css_behaviour_form('dynamic_background_context_css');
return system_settings_form($form);
}
function dynamic_background_context_context_plugins() {
return array(
'dynamic_background_context_reaction' => array(
'handler' => array(
'path' => drupal_get_path('module', 'dynamic_background_context') . '/plugins',
'file' => 'dynamic_background_context_reaction.inc',
'class' => 'DynamicBackgroundReaction',
'parent' => 'context_reaction',
),
),
);
}
function dynamic_background_context_context_registry() {
return array(
'reactions' => array(
'dynamic_background' => array(
'title' => t('Dynamic background'),
'description' => t('Enable different backgrounds base on a given context.'),
'plugin' => 'dynamic_background_context_reaction',
),
),
);
}
function dynamic_background_context_dynamic_background_css($vars) {
$image_id = NULL;
$plugin = context_get_plugin('reaction', 'dynamic_background');
if ($plugin) {
$image_id = $plugin
->execute();
}
$imagecache = variable_get('dynamic_background_context_imagecache', FALSE);
if (!is_null($image_id)) {
$backgrounds = variable_get('dynamic_background_images', array());
if (isset($backgrounds[$image_id]['picture'])) {
$image_style = variable_get('dynamic_background_context_image_style', FALSE);
return array(
'image' => $backgrounds[$image_id]['default'],
'configuration' => variable_get('dynamic_background_context_css', array()),
'imagecache' => $imagecache ? $imagecache['present'] : FALSE,
'weight' => 225,
);
}
}
}