You are here

class domaincontext_context_condition_domain in Domain Context 6

Same name and namespace in other branches
  1. 7 plugins/domaincontext_context_condition_domain.inc \domaincontext_context_condition_domain

Expose domains as a context condition.

Hierarchy

Expanded class hierarchy of domaincontext_context_condition_domain

2 string references to 'domaincontext_context_condition_domain'
domaincontext_context_plugins in ./domaincontext.module
Implements hook_context_plugins().
domaincontext_context_registry in ./domaincontext.module
Implements hook_context_registry().

File

plugins/domaincontext_context_condition_domain.inc, line 11
Context plugin to supply the domain as a context condition.

View source
class domaincontext_context_condition_domain extends context_condition {
  function condition_values() {
    $values = array();
    $format = domain_select_format();
    foreach (domain_domains() as $data) {
      $data['domain_id'] == 0 ? $key = -1 : ($key = $data['domain_id']);
      if ($data['valid'] || user_access('access inactive domains')) {
        $values[$key] = empty($format) ? check_plain($data['sitename']) : $data['sitename'];
      }
    }
    return $values;
  }
  function execute() {
    global $_domain;
    $domain_id = $_domain['domain_id'];
    if ($domain_id == 0) {
      $domain_id = -1;
    }
    $this->values[$domain_id] = array();
    $contexts = $this
      ->get_contexts($domain_id);
    foreach ($contexts as $context) {
      $this->values[$domain_id][] = $context->name;
      $this
        ->condition_met($context, $domain_id);
    }
  }

}

Members