You are here

class dfp_context_reaction_settings in Doubleclick for Publishers (DFP) 7

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

Expose DFP variables as context reactions.

Hierarchy

Expanded class hierarchy of dfp_context_reaction_settings

2 string references to 'dfp_context_reaction_settings'
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_settings.inc, line 11
Context reaction plugin for DFP ads.

View source
class dfp_context_reaction_settings extends context_reaction {

  /**
   * Allow admins to choose what DART tags to hide.
   */
  function options_form($context) {
    module_load_include('inc', 'dfp', 'dfp.admin');

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

    // Build the targeting form.
    $form = array();
    _dfp_targeting_form($form, isset($values['targeting']) ? $values['targeting'] : array());

    // Modify the #parents property to make sure values are stored in the
    // location that contexts expects them.
    $parents = array(
      'reactions',
      'plugins',
      'dfp_settings',
    );
    foreach (element_children($form['targeting']) as $key) {
      if (is_numeric($key)) {
        $form['targeting'][$key]['target']['#parents'] = array_merge($parents, $form['targeting'][$key]['target']['#parents']);
        $form['targeting'][$key]['value']['#parents'] = array_merge($parents, $form['targeting'][$key]['value']['#parents']);
      }
    }

    // Modify form to call the contexts-specific versions of certain functions.
    $form['targeting']['dfp_more_targets']['#submit'] = array(
      'dfp_contexts_more_targets_submit',
    );
    $form['targeting']['dfp_more_targets']['#ajax']['callback'] = 'dfp_contexts_more_targets_js';
    return $form;
  }

  /**
   * Return a keyed array containing the settings.
   */
  function execute(&$tag) {
    foreach ($this
      ->get_contexts() as $context_name => $context) {
      foreach ($context->reactions['dfp_settings']['targeting'] as $key => $value) {
        $tag->settings['targeting'][] = $value;
      }
    }
  }

}

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_settings::execute function Return a keyed array containing the settings.
dfp_context_reaction_settings::options_form function Allow admins to choose what DART tags to hide. Overrides context_reaction::options_form