dfp_context_reaction_settings.inc in Doubleclick for Publishers (DFP) 7
Context reaction plugin for DFP ads.
File
plugins/contexts/dfp_context_reaction_settings.inc
View source
<?php
class dfp_context_reaction_settings extends context_reaction {
function options_form($context) {
module_load_include('inc', 'dfp', 'dfp.admin');
$values = $this
->fetch_from_context($context);
$form = array();
_dfp_targeting_form($form, isset($values['targeting']) ? $values['targeting'] : array());
$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']);
}
}
$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;
}
function execute(&$tag) {
foreach ($this
->get_contexts() as $context_name => $context) {
foreach ($context->reactions['dfp_settings']['targeting'] as $key => $value) {
$tag->settings['targeting'][] = $value;
}
}
}
}
function dfp_contexts_more_targets_submit($form, &$form_state) {
$form_state['targeting'] = $form_state['input']['reactions']['plugins']['dfp_settings']['targeting'];
$form_state['rebuild'] = TRUE;
}
function dfp_contexts_more_targets_js($form, $form_state) {
return $form['reactions']['plugins']['dfp_settings']['targeting'];
}