context_reaction_region.inc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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, 'context_reaction_region::collapseRegion'),
  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 collapseRegion($a, $b) {
  29. return $a || $b;
  30. }
  31. function execute(&$page) {
  32. global $theme;
  33. foreach ($this->get_contexts() as $k => $v) {
  34. if (isset($v->reactions[$this->plugin][$theme])) {
  35. $regions = $v->reactions[$this->plugin][$theme]['disable'];
  36. foreach ($regions as $region => $disable) {
  37. if ($disable && isset($page[$region])) {
  38. unset($page[$region]);
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }