You are here

class dfp_context_reaction_outofpage in Doubleclick for Publishers (DFP) 7

Same name and namespace in other branches
  1. 7.2 plugins/contexts/dfp_context_reaction_outofpage.inc \dfp_context_reaction_outofpage

Expose DFP Out of page as context reactions.

Hierarchy

Expanded class hierarchy of dfp_context_reaction_outofpage

2 string references to 'dfp_context_reaction_outofpage'
dfp_context_plugins in ./dfp.module
Implements hook_context_plugins().
dfp_context_registry in ./dfp.module
Implements hook_context_registry().

File

plugins/contexts/dfp_context_reaction_outofpage.inc, line 11
Context reaction plugin for DFP Out of page.

View source
class dfp_context_reaction_outofpage extends context_reaction {

  /**
   * Allow admins to choose what tags show.
   */
  function options_form($context) {

    // Get existing values for this form.
    $values = $this
      ->fetch_from_context($context);

    // Get a list of tags.
    $options = array();
    $tags = dfp_tag_load_all();
    foreach ($tags as $tag) {
      if (!empty($tag->settings['out_of_page'])) {
        $options[$tag->machinename] = $tag->slot;
      }
    }
    $form = array(
      '#title' => t('Show these DFP Out of page tags'),
      '#description' => t('The following DFP tags will be added to the page.'),
      '#default_value' => isset($values) ? $values : array(),
    );
    if (!empty($options)) {
      $form['#type'] = 'checkboxes';
      $form['#options'] = $options;
    }
    else {
      $form['#markup'] = t('There are no "Out of page" slots available. You can create them on the !link page.', array(
        '!link' => l(t('DFP Ad Tags'), 'admin/structure/dfp_ads', array(
          'html' => TRUE,
        )),
      ));
    }
    return $form;
  }

  /**
   * Disable any tags that should be disabled based on context.
   */
  function execute() {

    // Check each currently set context to see if the DFP tag specified by
    // machinename should be displayed or not.
    foreach ($this
      ->get_contexts() as $context_name => $context) {
      if (isset($context->reactions['dfp_outofpage'])) {
        foreach ($context->reactions['dfp_outofpage'] as $key => $value) {
          if (!empty($value)) {
            $this->out_of_page_tags[$key] = $value;
          }
        }
        break;
      }
    }
  }

}

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::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.
dfp_context_reaction_outofpage::execute function Disable any tags that should be disabled based on context.
dfp_context_reaction_outofpage::options_form function Allow admins to choose what tags show. Overrides context_reaction::options_form