context_reaction_region.inc

Go to the documentation of this file.
00001 <?php
00002 
00003 class context_reaction_region extends context_reaction {
00004 
00005   function editor_form($context) {
00006   }
00007 
00008   function options_form($context) {
00009     $values = $this->fetch_from_context($context);
00010     $form = array();
00011     foreach (list_themes() as $theme) {
00012       if ($theme->status) {
00013         $regions = system_region_list($theme->name);
00014         $default = isset($values[$theme->name]) ? $values[$theme->name]['disable'] : array();
00015 
00016         $form[$theme->name] = array(
00017           '#type' => 'fieldset',
00018           '#title' => "Disable Regions in {$theme->name} Theme",
00019           '#collapsible' => TRUE,
00020           '#collapsed' => !array_reduce($default, create_function('$a, $b', 'return $a || $b;')),
00021         );
00022         $form[$theme->name]['disable'] = array(
00023           '#type' => 'checkboxes',
00024           '#title' => t("Disable the following"),
00025           '#options' => $regions,
00026           '#default_value' => $default,
00027         );
00028       }
00029     }
00030     return $form;
00031   }
00032   
00033   function execute(&$page) {  
00034     global $theme;
00035     foreach ($this->get_contexts() as $k => $v) { 
00036       if (isset($v->reactions[$this->plugin][$theme])) {
00037         $regions = $v->reactions[$this->plugin][$theme]['disable'];
00038         foreach ($regions as $region => $disable) {
00039           if ($disable && isset($page[$region])) {
00040             unset($page[$region]);
00041           }
00042         }
00043       }
00044     }
00045   }
00046 }

Generated on Tue Jun 18 02:24:16 2013 for Context by  doxygen 1.4.7