View source
<?php
function contextphp_context_plugins() {
$module_path = drupal_get_path('module', 'contextphp');
$plugins = array();
$plugins['contextphp_condition_php'] = array(
'handler' => array(
'path' => $module_path . '/plugins',
'file' => 'contextphp_condition_php.inc',
'class' => 'contextphp_condition_php',
'parent' => 'context_condition',
),
);
$plugins['contextphp_reaction_php'] = array(
'handler' => array(
'path' => $module_path . '/plugins',
'file' => 'contextphp_reaction_php.inc',
'class' => 'contextphp_reaction_php',
'parent' => 'context_reaction',
),
);
return $plugins;
}
function contextphp_context_registry() {
return array(
'conditions' => array(
'php' => array(
'title' => t('PHP code'),
'description' => t('Set this context when PHP code returns TRUE.'),
'plugin' => 'contextphp_condition_php',
),
),
'reactions' => array(
'php' => array(
'title' => t('PHP code'),
'description' => t('React with the PHP code.'),
'plugin' => 'contextphp_reaction_php',
),
),
);
}
function contextphp_init() {
$map = context_condition_map();
if (!empty($map['php']) && ($plugin = context_get_plugin('condition', 'php'))) {
$plugin
->execute();
}
$map = context_reactions();
if (!empty($map['php']) && ($plugin = context_get_plugin('reaction', 'php'))) {
$plugin
->execute();
}
}