You are here

class domaincontext_context_condition_domain in Domain Context 7

Same name and namespace in other branches
  1. 6 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 10
Context plugin to supply the domain as a context condition.

View source
class domaincontext_context_condition_domain extends context_condition {

  /**
   * Fetches condition values.
   */
  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;
  }

  /**
   * Executes condition callback.
   */
  function execute() {
    $domain = domain_get_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

Namesort descending Modifiers Type Description Overrides
context_condition::$description property
context_condition::$plugin property
context_condition::$title property
context_condition::$values property
context_condition::condition_form function Condition form. 3
context_condition::condition_form_submit function Condition form submit handler. 2
context_condition::condition_met function Marks a context as having met this particular condition.
context_condition::condition_used function Check whether this condition is used by any contexts. Can be used to prevent expensive condition checks from being triggered when no contexts use this condition.
context_condition::editor_form function Context editor form for conditions. 2
context_condition::editor_form_submit function Context editor form submit handler.
context_condition::fetch_from_context function Retrieve options from the context provided.
context_condition::get_contexts function Retrieve all contexts with the condition value provided. 2
context_condition::options_form function Options form. Provide additional options for your condition. 4
context_condition::options_form_submit function Options form submit handler.
context_condition::settings_form function Settings form. Provide variable settings for your condition.
context_condition::__clone function Clone our references when we're being cloned.
context_condition::__construct function Constructor. Do not override.
domaincontext_context_condition_domain::condition_values function Fetches condition values. Overrides context_condition::condition_values
domaincontext_context_condition_domain::execute function Executes condition callback.