You are here

class SiteBannerContextReactionChangeBannerText in Site Banner 7

Handle changing the site banner text reaction.

Hierarchy

Expanded class hierarchy of SiteBannerContextReactionChangeBannerText

1 string reference to 'SiteBannerContextReactionChangeBannerText'
site_banner_context_plugins in ./site_banner.module
Implements hook_context_plugins().

File

./site_banner_context_reaction_functions.inc, line 56

View source
class SiteBannerContextReactionChangeBannerText extends context_reaction {

  /**
   * Administration panel for setting banner text for selected contexts.
   */
  public function options_form($context) {
    $default_prepend_text = site_banner_get_prepend_site_banner_text($context);
    $default_banner_text = site_banner_get_site_banner_text($context);
    $default_delimiter_text = site_banner_get_delimiter($context);
    $default_append_text = site_banner_get_append_text($context);

    // Get all enabled contexts and provide help on existing context values.
    $prepend_text_description = 'For all contexts tagged with this context\'s
      tag, this is text that will be added before all active context\'s
      banner text.';
    $delimiter_text_description = 'For all contexts tagged with this context\'s
      tag, this is text that will be added in between successive banner texts.
      This is typically a single character like a backslash \'\\\' or comma
      \',\'.';
    $append_text_description = 'For all contexts tagged with this context\'s
      tag, this is text that will be added after all active context\'s
      banner text.';
    $prepend_examples = '';
    $delimiter_examples = '';
    $append_examples = '';
    foreach (context_enabled_contexts() as $context_iterator) {
      if (isset($context_iterator->tag) && !empty($context_iterator->tag)) {
        $prefix = "{$context_iterator->name} (tag = {$context_iterator->tag},";
        $prepend_examples = " {$prefix} prepend text = " . filter_xss_admin(site_banner_get_prepend_site_banner_text($context_iterator)) . ')';
        $delimiter_examples = " {$prefix} delimiter text = " . filter_xss_admin(site_banner_get_delimiter($context_iterator)) . ')';
        $append_examples = " {$prefix} append text = " . filter_xss_admin(site_banner_get_append_text($context_iterator)) . ')';
      }
    }
    if (!empty($prepend_examples)) {
      $prepend_text_description .= " Existing values are: {$prepend_examples}.";
      $append_text_description .= " Existing values are: {$append_examples}.";
      $delimiter_text_description .= " Existing values are: {$delimiter_examples}.";
    }
    $form = site_banner_generate_banner_text_form_elements($default_banner_text);
    $form['site_banner_tag_prepend_text'] = array(
      '#title' => t('Prepended banner text'),
      '#description' => $prepend_text_description,
      '#type' => 'textfield',
      '#size' => 50,
      '#maxlength' => 100,
      '#default_value' => $default_prepend_text,
    );
    $form['site_banner_text']['#description'] = t('The text to be added to the site banner.');
    $form['site_banner_tag_delimiter_text'] = array(
      '#title' => t('Banner text delimiter'),
      '#description' => $delimiter_text_description,
      '#type' => 'textfield',
      '#size' => 50,
      '#maxlength' => 100,
      '#default_value' => $default_delimiter_text,
    );
    $form['site_banner_tag_append_text'] = array(
      '#title' => t('Appended banner text'),
      '#description' => $append_text_description,
      '#type' => 'textfield',
      '#size' => 50,
      '#maxlength' => 100,
      '#default_value' => $default_append_text,
    );
    return $form;
  }

  /**
   * Submit handler for context-specific site banner settings.
   */
  public function options_form_submit($values) {
    return $values;
  }

  /**
   * Output banner text for active contexts.
   */
  public function execute(&$banner_text) {
    $contexts = context_active_contexts();
    site_banner_generate_context_banner_text_from_contexts($contexts, $banner_text);
  }

}

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.
SiteBannerContextReactionChangeBannerText::execute public function Output banner text for active contexts.
SiteBannerContextReactionChangeBannerText::options_form public function Administration panel for setting banner text for selected contexts. Overrides context_reaction::options_form
SiteBannerContextReactionChangeBannerText::options_form_submit public function Submit handler for context-specific site banner settings. Overrides context_reaction::options_form_submit