context_reaction_debug.inc 921 B

1234567891011121314151617181920212223242526272829303132
  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. * Output a list of active contexts.
  14. */
  15. function execute() {
  16. $contexts = context_active_contexts();
  17. foreach ($contexts as $context) {
  18. if (!empty($context->reactions['debug'])) {
  19. if (user_access('administer site configuration') && module_exists('context_ui')) {
  20. $name = l($context->name, "admin/structure/context/list/{$context->name}", array('query' => array('destination' => $_GET['q'])));
  21. }
  22. else {
  23. $name = check_plain($context->name);
  24. }
  25. drupal_set_message(t("Active context: !name", array('!name' => $name)));
  26. }
  27. }
  28. }
  29. }