You are here

class context_breadcrumb_current_page_reaction in Context Breadcrumb Current Page 7

@file Define class and override.

Hierarchy

Expanded class hierarchy of context_breadcrumb_current_page_reaction

2 string references to 'context_breadcrumb_current_page_reaction'
context_breadcrumb_current_page_context_plugins in ./context_breadcrumb_current_page.module
Implements hook_context_plugins().
context_breadcrumb_current_page_context_registry in ./context_breadcrumb_current_page.module
Implements hook_context_registry().

File

plugins/context_breadcrumb_current_page_reaction.inc, line 7
Define class and override.

View source
class context_breadcrumb_current_page_reaction extends context_reaction {

  /**
   * Prevent editor form.
   */
  function editor_form($context) {
  }

  /**
   * Add options.
   */
  function options_form($context) {
    $values = $this
      ->fetch_from_context($context);
    $form = array(
      'breadcrumb_show_current_page' => array(
        '#title' => t('Show the Current Page in the Breadrumbs'),
        '#description' => t('Have the last element in the breadcrumbs be the current page title.'),
        '#type' => 'checkbox',
        '#default_value' => isset($values['breadcrumb_show_current_page']) ? $values['breadcrumb_show_current_page'] : '',
      ),
      'breadcrumb_show_current_page_title' => array(
        '#title' => t('Title Override'),
        '#description' => t('Show this as the breadcrumb title'),
        '#type' => 'textfield',
        '#default_value' => isset($values['breadcrumb_show_current_page_title']) ? $values['breadcrumb_show_current_page_title'] : '',
      ),
      'breadcrumb_show_current_page_only' => array(
        '#title' => t('Remove parent Breadcurmbs'),
        '#description' => t('Have the only item in the breadcrumbs be the title.'),
        '#type' => 'checkbox',
        '#default_value' => isset($values['breadcrumb_show_current_page_only']) ? $values['breadcrumb_show_current_page_only'] : '',
      ),
    );
    return $form;
  }

  /**
   * Set the breadcrumb.
   */
  function execute(&$vars) {
    foreach ($this
      ->get_contexts() as $k => $v) {
      if (isset($v->reactions[$this->plugin]) && $v->reactions[$this->plugin]['breadcrumb_show_current_page']) {
        $breadcrumb = drupal_get_breadcrumb();
        if ($v->reactions[$this->plugin]['breadcrumb_show_current_page_only']) {
          $breadcrumb = array(
            $breadcrumb[0],
          );
        }
        $title = $v->reactions[$this->plugin]['breadcrumb_show_current_page_title'] ? $v->reactions[$this->plugin]['breadcrumb_show_current_page_title'] : drupal_get_title();
        $breadcrumb[] = $title;
        drupal_set_breadcrumb($breadcrumb);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
context_breadcrumb_current_page_reaction::editor_form function Prevent editor form.
context_breadcrumb_current_page_reaction::execute function Set the breadcrumb.
context_breadcrumb_current_page_reaction::options_form function Add options. Overrides context_reaction::options_form
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::options_form_submit function Options form submit handler. 3
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.