context_reaction_debug.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Output context debug information.
  4. */
  5. class context_reaction_debug extends context_reaction {
  6. function options_form($context) {
  7. return array('debug' => array('#type' => 'value', '#value' => TRUE));
  8. }
  9. function options_form_submit($values) {
  10. return array('debug' => 1);
  11. }
  12. /**
  13. * Settings form for variables.
  14. */
  15. function settings_form() {
  16. $form = array();
  17. $form['context_reaction_debug_enable_global'] = array(
  18. '#title' => t('Enable debug reaction on all contexts'),
  19. '#type' => 'checkbox',
  20. '#default_value' => variable_get('context_reaction_debug_enable_global', FALSE),
  21. '#description' => t('Enable the debug reaction on all contexts.')
  22. );
  23. return $form;
  24. }
  25. /**
  26. * Output a list of active contexts.
  27. */
  28. function execute() {
  29. $contexts = context_active_contexts();
  30. foreach ($contexts as $context) {
  31. if (!empty($context->reactions['debug']) || variable_get('context_reaction_debug_enable_global', FALSE)) {
  32. if (user_access('administer site configuration') && module_exists('context_ui')) {
  33. $name = l($context->name, "admin/structure/context/list/{$context->name}", array('query' => array('destination' => $_GET['q'])));
  34. }
  35. else {
  36. $name = check_plain($context->name);
  37. }
  38. drupal_set_message(t("Active context: !name", array('!name' => $name)));
  39. }
  40. }
  41. }
  42. }