context_reaction_delta.inc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Expose themes as context reactions.
  4. */
  5. class context_reaction_delta extends context_reaction {
  6. /**
  7. * @todo
  8. */
  9. function options_form($context) {
  10. $values = $this->fetch_from_context($context);
  11. $options = _delta_options();
  12. $form = array(
  13. '#tree' => TRUE,
  14. '#title' => t('Delta Override Template'),
  15. );
  16. $form['delta_template'] = array(
  17. '#type' => count($options) > 10 ? 'select' : 'radios',
  18. '#title' => t('Select Custom theme settings template.'),
  19. '#description' => empty($options) ? t('There are no valid (enabled) Delta templates available.') : t('The theme settings of the selected Delta template will override the default theme settings for all pages that match this context.'),
  20. '#default_value' => isset($values['delta_template']) ? $values['delta_template'] : NULL,
  21. '#options' => $options,
  22. );
  23. return $form;
  24. }
  25. /**
  26. * @todo
  27. */
  28. function execute() {
  29. foreach (context_active_contexts() as $context) {
  30. if (!empty($context->reactions['delta']['delta_template'])) {
  31. $template = $context->reactions['delta']['delta_template'];
  32. if (delta_enabled($template)) {
  33. delta_inject($template);
  34. }
  35. }
  36. }
  37. }
  38. }
  39. /**
  40. * @todo
  41. */
  42. function _delta_options() {
  43. $options = array();
  44. foreach (delta_load_all() as $item) {
  45. if (delta_enabled($item->machine_name)) {
  46. $options[$item->machine_name] = $item->name;
  47. }
  48. }
  49. return $options;
  50. }