You are here

function context_condition_default::execute in Context 7.3

File

plugins/context_condition_default.inc, line 19

Class

context_condition_default
Simple condition that sets context active if no other non-default and non sitewide context is active.

Code

function execute() {
  if ($this
    ->condition_used()) {
    $active_contexts = context_active_contexts();
    foreach ($active_contexts as $name => $context) {
      foreach (array_keys($context->conditions) as $cond) {
        if (!in_array($cond, array(
          'default',
          'sitewide',
        ))) {
          return;
        }
      }
    }
    foreach ($this
      ->get_contexts('context_condition_default') as $context) {
      $this
        ->condition_met($context, 'context_condition_default');
    }
  }
}