context_condition_context_all.inc

  1. cis7 sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc
  2. cle7 sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc
  3. ecd7 sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc
  4. elmsmedia7 sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc
  5. harmony7 sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc
  6. icor7 sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc
  7. meedjum_blog7 sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc
  8. mooc7 sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc

Classes

Namesort descending Description
context_condition_context_all Expose active contexts as a context condition.

File

sites/all/modules/ulmus/context/plugins/context_condition_context_all.inc
View source
  1. <?php
  2. /**
  3. * Expose active contexts as a context condition.
  4. */
  5. class context_condition_context_all extends context_condition_path {
  6. function execute() {
  7. if ($this->condition_used()) {
  8. $active_contexts = array_keys(context_active_contexts());
  9. foreach ($this->get_contexts() as $context) {
  10. // Only test contexts that haven't been activated yet,
  11. // and have values set.
  12. if (!in_array($context->name, $active_contexts, TRUE) && $values = $this->fetch_from_context($context, 'values')) {
  13. // The condition is met if all contexts are active.
  14. if (count(array_intersect($values, $active_contexts)) == count($values)) {
  15. $this->condition_met($context);
  16. }
  17. }
  18. }
  19. // If the list of active contexts has changed, we need to recurse.
  20. if ($active_contexts != array_keys(context_active_contexts())) {
  21. $this->execute();
  22. }
  23. }
  24. }
  25. }