00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 function hook_context_plugins() {
00013 $plugins = array();
00014 $plugins['foo_context_condition_bar'] = array(
00015 'handler' => array(
00016 'path' => drupal_get_path('module', 'foo') .'/plugins',
00017 'file' => 'foo_context_condition_bar.inc',
00018 'class' => 'foo_context_condition_bar',
00019 'parent' => 'context_condition',
00020 ),
00021 );
00022 $plugins['foo_context_reaction_baz'] = array(
00023 'handler' => array(
00024 'path' => drupal_get_path('module', 'foo') .'/plugins',
00025 'file' => 'foo_context_reaction_baz.inc',
00026 'class' => 'foo_context_reaction_baz',
00027 'parent' => 'context_reaction',
00028 ),
00029 );
00030 return $plugins;
00031 }
00032
00033
00034
00035
00036
00037
00038
00039 function hook_context_registry() {
00040 return array(
00041 'conditions' => array(
00042 'bar' => array(
00043 'title' => t('Name of condition "bar"'),
00044 'plugin' => 'foo_context_condition_bar',
00045 ),
00046 ),
00047 'reactions' => array(
00048 'baz' => array(
00049 'title' => t('Name of reaction "baz"'),
00050 'plugin' => 'foo_context_reaction_baz',
00051 ),
00052 ),
00053 );
00054 }
00055
00056
00057
00058
00059
00060
00061
00062 function hook_context_page_condition() {
00063 if ($plugin = context_get_plugin('condition', 'bar')) {
00064 $plugin->execute();
00065 }
00066 }
00067
00068
00069
00070
00071
00072
00073
00074 function hook_context_page_reaction() {
00075 if ($plugin = context_get_plugin('reaction', 'baz')) {
00076 $plugin->execute();
00077 }
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 function hook_context_registry_alter(&$registry) {
00090 if (isset($registry['reactions']['baz'])) {
00091 $registry['reactions']['baz']['plugin'] = 'custom_context_reaction_baz';
00092 }
00093 }
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 function hook_context_node_condition_alter(&$node, $op) {
00107 if ($plugin = context_get_plugin('condition', 'bar')) {
00108 $plugin->execute($node, $op);
00109 }
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 function hook_context_load_alter(&$context) {
00122 if ($context->name === 'foo' && isset($context->reactions['block'])) {
00123 $context->reactions['block']['blocks']['locale-0'] = array(
00124 'module' => 'locale',
00125 'delta' => '0',
00126 'region' => 'header',
00127 'weight' => '2',
00128 );
00129 }
00130 }