context_reaction_region.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. class context_reaction_region extends context_reaction {
  3. function editor_form($context) {
  4. }
  5. function options_form($context) {
  6. $values = $this->fetch_from_context($context);
  7. $form = array();
  8. foreach (list_themes() as $theme) {
  9. if ($theme->status) {
  10. $regions = system_region_list($theme->name);
  11. $default = isset($values[$theme->name]) ? $values[$theme->name]['disable'] : array();
  12. $form[$theme->name] = array(
  13. '#type' => 'fieldset',
  14. '#title' => "Disable Regions in {$theme->name} Theme",
  15. '#collapsible' => TRUE,
  16. '#collapsed' => !array_reduce($default, create_function('$a, $b', 'return $a || $b;')),
  17. );
  18. $form[$theme->name]['disable'] = array(
  19. '#type' => 'checkboxes',
  20. '#title' => t("Disable the following"),
  21. '#options' => $regions,
  22. '#default_value' => $default,
  23. );
  24. }
  25. }
  26. return $form;
  27. }
  28. function execute(&$page) {
  29. global $theme;
  30. foreach ($this->get_contexts() as $k => $v) {
  31. if (isset($v->reactions[$this->plugin][$theme])) {
  32. $regions = $v->reactions[$this->plugin][$theme]['disable'];
  33. foreach ($regions as $region => $disable) {
  34. if ($disable && isset($page[$region])) {
  35. unset($page[$region]);
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }