You are here

class context_field_context_condition in Context Field 7

Expose node views/node forms of specific node types as a context condition.

Hierarchy

Expanded class hierarchy of context_field_context_condition

2 string references to 'context_field_context_condition'
context_field_context_plugins in ./context_field.module
Implements hook_context_plugins().
context_field_context_registry in ./context_field.module
Implements hook_context_registry().

File

plugins/context_field_context_condition.inc, line 10
context_field_context_condition.inc

View source
class context_field_context_condition extends context_condition {
  function condition_values() {

    // needs to return array of nid => titles
    $values = array();
    $values = array(
      1 => t('Yes'),
      2 => t('Default'),
    );
    return $values;
  }
  function get_context_name($node) {
    return "sf-{$node->nid}";
  }
  function options_form($context) {
    $defaults = $this
      ->fetch_from_context($context, 'options');
    $form = array();
    $form['context_field_category'] = array(
      '#type' => 'textfield',
      '#title' => t('Category'),
      '#description' => t('The category of contexts for which you\'d like to utilize this context. For example, a category named blog for blog related contexts, which would differ from the contexts that could be used for basic pages.'),
      '#default_value' => isset($defaults['context_field_category']) ? $defaults['context_field_category'] : '',
    );
    return $form;
  }
  function create_context($context_name) {
    $context = (object) array(
      'name' => $context_name,
      'tag' => 'Context Field',
      'reactions' => array(),
      'conditions' => array(
        'context_field' => array(
          'values' => array(
            1 => 1,
          ),
        ),
      ),
    );
    context_save($context);
    return $context;
  }
  function execute($context_name) {

    //If the context exist lets met its context_field condition
    $contexts = $this
      ->get_contexts();
    if ($context = isset($contexts[$context_name]) ? $contexts[$context_name] : FALSE) {
      $this
        ->condition_met($context, 'context_field');
    }
  }

}

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_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.
context_field_context_condition::condition_values function Condition values. Overrides context_condition::condition_values
context_field_context_condition::create_context function
context_field_context_condition::execute function
context_field_context_condition::get_context_name function
context_field_context_condition::options_form function Options form. Provide additional options for your condition. Overrides context_condition::options_form