You are here

class context_metadata_reaction in Context Metadata 6

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

@file Output context maxage.

Hierarchy

Expanded class hierarchy of context_metadata_reaction

1 string reference to 'context_metadata_reaction'
context_metadata_context_plugins in ./context_metadata.module
Implements hook_context_plugins().

File

plugins/context_metadata_reaction.inc, line 7
Output context maxage.

View source
class context_metadata_reaction extends context_reaction {
  function options_form($context) {
    $values = $this
      ->fetch_from_context($context);
    $form['metadata_title'] = array(
      '#title' => t('Meta Title'),
      '#description' => t('Title goes here'),
      '#type' => 'textfield',
      '#maxlength' => 256,
      '#default_value' => isset($values['metadata_title']) ? $values['metadata_title'] : '',
    );
    $form['metadata_description'] = array(
      '#title' => t('Meta Description'),
      '#description' => t('Meta Description'),
      '#type' => 'textfield',
      '#maxlength' => 400,
      '#default_value' => isset($values['metadata_description']) ? $values['metadata_description'] : '',
    );
    $form['metadata_keywords'] = array(
      '#title' => t('Meta Keywords'),
      '#description' => t('Meta Keywords'),
      '#type' => 'textfield',
      '#maxlength' => 400,
      '#default_value' => isset($values['metadata_keywords']) ? $values['metadata_keywords'] : '',
    );
    $form['metadata_canonical'] = array(
      '#title' => t('Canonical URL'),
      '#description' => t('Canonical URL'),
      '#type' => 'textfield',
      '#maxlength' => 400,
      '#default_value' => isset($values['metadata_canonical']) ? $values['metadata_canonical'] : '',
    );
    if (module_exists('token')) {
      $form['token_help'] = array(
        '#title' => t('Replacement patterns'),
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $form['token_help']['help'] = array(
        '#value' => theme('token_help', 'node'),
      );
    }
    return $form;
  }

  /**
   * Outputs a list of active contexts.
   */
  function execute() {
    $contexts = context_active_contexts();
    foreach ($contexts as $context) {
      if (!empty($context->reactions['context_metadata'])) {
        $metadata_array = $context->reactions['context_metadata'];
        foreach ($metadata_array as $key => $value) {
          if (!empty($value)) {
            $static_metadata_array[$key] = t(check_plain($value));
          }
        }

        // Store the array.
        context_metadata_static_store($static_metadata_array);
      }
    }
  }

}

Members