View source
<?php
function dynamic_background_context_permission() {
return array(
'configure context dynamic background' => array(
'title' => t('Configure context dynamic background'),
),
);
}
function dynamic_background_context_menu() {
$items = array();
$items['admin/config/user-interface/backgrounds/context'] = array(
'title' => 'Context',
'description' => t('Configure context dynamic background'),
'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_style_form('dynamic_background_context_image_style');
$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();
}
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]['picture'],
'configuration' => variable_get('dynamic_background_context_css', array()),
'image_style' => $image_style ? $image_style['style'] : FALSE,
);
}
}
}
function dynamic_background_context_dynamic_background_weight() {
return array(
'weight' => -50,
);
}