diff --git context.module context.module
index ea1ef30..0de8972 100644
--- context.module
+++ context.module
@@ -518,3 +518,14 @@ function context_block_view_alter(&$data, $block) {
$data['content']['#markup'] = "
". t('This block appears empty when displayed on this page.') . "
";
}
}
+
+/**
+ * implement hook_page_alter()
+ *
+ * used for region context
+ */
+function context_page_alter(&$page) {
+ if ($plugin = context_get_plugin('reaction', 'region')) {
+ $plugin->execute($page);
+ }
+}
diff --git context.plugins.inc context.plugins.inc
index d5f18f7..b8b7d34 100644
--- context.plugins.inc
+++ context.plugins.inc
@@ -88,6 +88,11 @@ function _context_context_registry() {
'description' => t('Control block visibility using context.'),
'plugin' => 'context_reaction_block',
),
+ 'region' => array(
+ 'title' => t('Regions'),
+ 'description' => t('Control Region visiblity using context.'),
+ 'plugin' => 'context_reaction_region',
+ ),
'breadcrumb' => array(
'title' => t('Breadcrumb'),
'description' => t('Set the breadcrumb trail to the selected menu item.'),
@@ -273,6 +278,14 @@ function _context_context_plugins() {
'parent' => 'context_reaction',
),
);
+ $plugins['context_reaction_region'] = array(
+ 'handler' => array(
+ 'path' => drupal_get_path('module', 'context') .'/plugins',
+ 'file' => 'context_reaction_region.inc',
+ 'class' => 'context_reaction_region',
+ 'parent' => 'context_reaction',
+ ),
+ );
$plugins['context_reaction_breadcrumb'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') .'/plugins',
diff --git plugins/context_reaction_region.inc plugins/context_reaction_region.inc
new file mode 100644
index 0000000..02272d4
--- /dev/null
+++ plugins/context_reaction_region.inc
@@ -0,0 +1,46 @@
+fetch_from_context($context);
+ $form = array();
+ foreach (list_themes() as $theme) {
+ if ($theme->status) {
+ $regions = system_region_list($theme->name);
+ $default = isset($values[$theme->name]) ? $values[$theme->name]['disable'] : array();
+
+ $form[$theme->name] = array(
+ '#type' => 'fieldset',
+ '#title' => "Disable Regions in {$theme->name} Theme",
+ '#collapsible' => TRUE,
+ '#collapsed' => !array_reduce($default, create_function('$a, $b','return $a || $b;')),
+ );
+ $form[$theme->name]['disable'] = array(
+ '#type' => 'checkboxes',
+ '#title' => "Disable the following",
+ '#options' => $regions,
+ '#default_value' => $default,
+ );
+ }
+ }
+ return $form;
+ }
+
+ function execute(&$page) {
+ global $theme;
+ foreach ($this->get_contexts() as $k => $v) {
+ if (isset($v->reactions[$this->plugin][$theme])) {
+ $regions = $v->reactions[$this->plugin][$theme]['disable'];
+ foreach($regions as $region => $disable) {
+ if ($disable && isset($page[$region])) {
+ unset($page[$region]);
+ }
+ }
+ }
+ }
+ }
+}
diff --git tests/context.reactions.test tests/context.reactions.test
index 42bcfa6..9e9aadb 100644
--- tests/context.reactions.test
+++ tests/context.reactions.test
@@ -227,3 +227,46 @@ class ContextReactionThemeHtmlTest extends DrupalWebTestCase {
context_delete($context);
}
}
+
+class ContextReactionRegionTest extends DrupalWebTestCase {
+ protected $profile = 'testing';
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Reaction: Region',
+ 'description' => 'Test Region disable reaction.',
+ 'group' => 'Context',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('context', 'ctools');
+ $admin_user = $this->drupalCreateUser(array(
+ 'access administration pages',
+ 'administer nodes',
+ 'administer site configuration'
+ ));
+ $this->drupalLogin($admin_user);
+ }
+
+ function test() {
+ ctools_include('export');
+ theme_enable(array('bartik'));
+ variable_set('theme_default', 'bartik');
+ global $theme;
+ $context = ctools_export_new_object('context');
+ $context->name = 'testcontext';
+ $context->conditions = array('sitewide' => array('values' => array(1)));
+ $context->reactions = array('region' => array( 'bartik' => array('disable'=> array('content' => 'Content'))));
+ $saved = context_save($context);
+ $this->assertTrue($saved, "Context 'testcontext' saved.");
+
+ $output = $this->drupalGet('node');
+ $this->assertNoRaw('first-time');
+ $this->assertNoRaw('pager');
+
+
+ // Cleanup
+ context_delete($context);
+ }
+}