You are here

class context_reaction_disable_context in Context Disable Context 7

Same name and namespace in other branches
  1. 6.3 plugins/context_reaction_disable_context.inc \context_reaction_disable_context
  2. 6 plugins/context_reaction_disable_context.inc \context_reaction_disable_context
  3. 7.3 plugins/context_reaction_disable_context.inc \context_reaction_disable_context

Expose themes as context reactions.

Hierarchy

Expanded class hierarchy of context_reaction_disable_context

2 string references to 'context_reaction_disable_context'
context_disable_context_context_plugins in ./context_disable_context.module
CTools plugin API hook for Context. Note that a proper entry in hook_ctools_plugin_api() must exist for this hook to be called.
context_disable_context_context_registry in ./context_disable_context.module
Registry hook for conditions & reactions.

File

plugins/context_reaction_disable_context.inc, line 7

View source
class context_reaction_disable_context extends context_reaction {

  /**
   * Allow admins to provide a section title, section subtitle and section class.
   */
  function options_form($context) {
    $defaults = $this
      ->fetch_from_context($context);
    $values = context_context_list();
    ksort($values);

    // TODO: exclude current context from $values
    $form = array();
    $form['disabled'] = array(
      '#title' => t('Contexts to disable'),
      '#decription' => t('Select the contexts that should be disabled'),
      '#type' => 'checkboxes',
      '#multiple' => TRUE,
      '#options' => $values,
      '#default_value' => isset($defaults['disabled']) ? $defaults['disabled'] : array(),
    );
    return $form;
  }

  /**
   * Options form submit handler.
   */
  function options_form_submit($values) {
    $values['disabled'] = array_filter($values['disabled']);
    return $values;
  }
  function execute() {
    $contexts = $this
      ->get_contexts();
    $processed = array();
    foreach ($contexts as $context) {
      $values = $this
        ->fetch_from_context($context);
      foreach ($values['disabled'] as $disable) {
        if (context_isset('context', $disable) && !in_array($disable, $processed)) {
          context_set('context', $disable, FALSE);
        }
      }

      // Add the current context to $processed so it is not removed by other contexts
      $processed[] = $context->name;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
context_reaction::$description property
context_reaction::$plugin property
context_reaction::$title property
context_reaction::fetch_from_context function Retrieve options from the context provided. 1
context_reaction::get_contexts function Retrieve active contexts that have values for this reaction.
context_reaction::settings_form function Settings form. Provide variable settings for your reaction. 2
context_reaction::__clone function Clone our references when we're being cloned.
context_reaction::__construct function Constructor. Do not override.
context_reaction_disable_context::execute function
context_reaction_disable_context::options_form function Allow admins to provide a section title, section subtitle and section class. Overrides context_reaction::options_form
context_reaction_disable_context::options_form_submit function Options form submit handler. Overrides context_reaction::options_form_submit