View source
<?php
define('DFP_GOOGLE_TAG_SERVICES_URL', 'www.googletagservices.com/tag/js/gpt.js');
define('DFP_GOOGLE_SHORT_TAG_SERVICES_URL', 'pubads.g.doubleclick.net/gampad');
define('DFP_TOKEN_CACHE', 'dfp:tag_token_results');
function dfp_help($path, $arg) {
switch ($path) {
case 'admin/help#dfp':
$output = '<p>' . t('The Doubleclick For Publishers (DFP) module allows you to integrate Google Publisher Tags onto your site.') . '</p>';
$output .= '<p>' . t('This module provides you with a general settings form as well as the ability to create a tag (with all its associated data) in the database. You can display your ads as blocks, or add a simple bit of php to your tpl.php file(s) within your theme to indicate where specific tags should be displayed.') . '</p>';
return $output;
}
}
function dfp_permission() {
return array(
'administer DFP' => array(
'title' => t('Administer Doubleclick for Publisher ads'),
'description' => t('Users can create, edit, and delete Doubleclick for Publishers (dfp) ad tags and configure how and when they should be displayed.'),
'restrict access' => TRUE,
),
);
}
function dfp_theme($existing, $type, $theme, $path) {
$theme_hooks = array(
'dfp_tag' => array(
'variables' => array(
'tag' => NULL,
'slug' => NULL,
),
'template' => 'theme/dfp_tag',
),
'dfp_short_tag' => array(
'variables' => array(
'tag' => NULL,
),
'template' => 'theme/dfp_short_tag',
),
'dfp_target_settings' => array(
'render element' => 'form',
'file' => 'dfp.admin.inc',
),
'dfp_breakpoint_settings' => array(
'render element' => 'form',
'file' => 'dfp.admin.inc',
),
'dfp_adsense_color_settings' => array(
'render element' => 'form',
'file' => 'dfp.admin.inc',
),
'dfp_size_settings' => array(
'render element' => 'form',
'file' => 'dfp.admin.inc',
),
);
return $theme_hooks;
}
function dfp_menu() {
$items = array();
$items['admin/structure/dfp_ads/settings'] = array(
'title' => 'Global DFP Settings',
'type' => MENU_LOCAL_TASK,
'description' => "Configure your site-wide DFP settings.",
'page callback' => 'drupal_get_form',
'page arguments' => array(
'dfp_admin_settings',
),
'access arguments' => array(
'administer DFP',
),
'file' => 'dfp.admin.inc',
'weight' => 5,
);
$items['admin/structure/dfp_ads/test_page'] = array(
'title' => 'DFP Test Page',
'type' => MENU_LOCAL_TASK,
'description' => "View all your DFP tags on a single page",
'page callback' => 'dfp_adtest_page',
'access arguments' => array(
'administer DFP',
),
'file' => 'dfp.adtest.inc',
'weight' => 10,
);
return $items;
}
function dfp_menu_alter(&$items) {
$items['admin/structure/dfp_ads/list/%ctools_export_ui/edit']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
$items['admin/structure/dfp_ads/list/%ctools_export_ui/edit']['title'] = t('Edit DFP ad tag');
}
function dfp_block_info() {
$tags = dfp_tag_load_all();
$blocks = array();
$hashes = array();
foreach ($tags as $tag) {
if ($tag->block) {
if (drupal_strlen($tag->machinename) >= 32) {
$delta = md5($tag->machinename);
$hashes[$delta] = $tag->machinename;
}
else {
$delta = $tag->machinename;
}
$blocks[$delta]['info'] = t('DFP tag: @slotname', array(
'@slotname' => $tag->slot,
));
$blocks[$delta]['cache'] = DRUPAL_CACHE_PER_PAGE;
}
}
$old_hashes = variable_get('dfp_block_hashes', array());
if ($hashes != $old_hashes) {
variable_set('dfp_block_hashes', $hashes);
}
return $blocks;
}
function dfp_block_view($delta) {
$block = array();
if (drupal_strlen($delta) == 32) {
$hashes = variable_get('dfp_block_hashes', array());
if (!empty($hashes[$delta])) {
$delta = $hashes[$delta];
}
}
$tag = dfp_tag_load($delta);
if (empty($tag->disabled)) {
$block['content'] = dfp_tag($delta);
$block['content']['#contextual_links'] = array(
'dfp' => array(
'admin/structure/dfp_ads/list',
array(
$delta,
'edit',
),
),
);
}
return $block;
}
function dfp_entity_view($entity, $type, $view_mode, $langcode) {
$dfp_targeting_terms =& drupal_static('dfp_entity_targeting_terms', array());
if (variable_get('dfp_enable_ad_categories', 0) && $view_mode == 'full') {
if ($type == 'taxonomy_term') {
$dfp_targeting_terms[] = _dfp_get_ad_category($entity, TRUE);
}
foreach (element_children($entity->content) as $key) {
if (isset($entity->content[$key]['#field_type']) && $entity->content[$key]['#field_type'] == 'taxonomy_term_reference') {
$terms = field_view_field($type, $entity, $key);
if (isset($terms['#items']) && is_array($terms['#items'])) {
foreach ($terms['#items'] as $item) {
if (array_key_exists('taxonomy_term', $item)) {
$dfp_targeting_terms[] = _dfp_get_ad_category($item['taxonomy_term'], TRUE);
}
}
}
}
}
$dfp_targeting_terms = array_unique($dfp_targeting_terms);
}
}
function dfp_ctools_plugin_directory($module, $type) {
if ($type == 'export_ui' || $type == 'content_types') {
return 'plugins/' . $type;
}
}
function dfp_context_registry() {
return array(
'reactions' => array(
'dfp_tags' => array(
'title' => t('DFP Tags'),
'plugin' => 'dfp_context_reaction_tags',
),
'dfp_outofpage' => array(
'title' => t('DFP Out of page'),
'plugin' => 'dfp_context_reaction_outofpage',
),
'dfp_settings' => array(
'title' => t('DFP Variables'),
'plugin' => 'dfp_context_reaction_settings',
),
'dfp_adunit' => array(
'title' => t('DFP AdUnit'),
'plugin' => 'dfp_context_reaction_adunit',
),
'dfp_adsize' => array(
'title' => t('DFP Sizes'),
'plugin' => 'dfp_context_reaction_sizes',
),
),
);
}
function dfp_context_plugins() {
$plugins = array();
$plugins['dfp_context_reaction_tags'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'dfp') . '/plugins/contexts',
'file' => 'dfp_context_reaction_tags.inc',
'class' => 'dfp_context_reaction_tags',
'parent' => 'context_reaction',
),
);
$plugins['dfp_context_reaction_outofpage'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'dfp') . '/plugins/contexts',
'file' => 'dfp_context_reaction_outofpage.inc',
'class' => 'dfp_context_reaction_outofpage',
'parent' => 'context_reaction',
),
);
$plugins['dfp_context_reaction_settings'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'dfp') . '/plugins/contexts',
'file' => 'dfp_context_reaction_settings.inc',
'class' => 'dfp_context_reaction_settings',
'parent' => 'context_reaction',
),
);
$plugins['dfp_context_reaction_adunit'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'dfp') . '/plugins/contexts',
'file' => 'dfp_context_reaction_adunit.inc',
'class' => 'dfp_context_reaction_adunit',
'parent' => 'context_reaction',
),
);
$plugins['dfp_context_reaction_sizes'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'dfp') . '/plugins/contexts',
'file' => 'dfp_context_reaction_sizes.inc',
'class' => 'dfp_context_reaction_sizes',
'parent' => 'context_reaction',
),
);
return $plugins;
}
function dfp_token_info() {
$type = array(
'name' => t('DFP Ad Tags'),
'description' => t('Tokens related to a given DFP ad tag.'),
'needs-data' => 'tag',
);
$tag['slot'] = array(
'name' => t('Slot Name'),
'description' => t("The name of the ad slot defined by this tag."),
);
$tag['network_id'] = array(
'name' => t("Network ID"),
'description' => t("The unique ID provided by Google."),
);
$tag['ad_categories'] = array(
'name' => t("DFP Ad Categories"),
'description' => t("The DFP Ad Categories or uncategorized taxonomy terms attached to the entities currently being displayed to the user."),
);
$tag['url_parts'] = array(
'name' => t("URL Parts (n)"),
'description' => t('**Deprecated. See <a href="http://drupal.org/node/1812372" target="_blank">this issue<a> for alternitives.'),
);
return array(
'types' => array(
'dfp_tag' => $type,
),
'tokens' => array(
'dfp_tag' => $tag,
),
);
}
function dfp_tokens($type, $tokens, array $data = array(), array $options = array()) {
$replacements = array();
if ($type == 'dfp_tag') {
foreach ($tokens as $name => $original) {
switch ($name) {
case 'slot':
if (!empty($data['tag'])) {
$replacements[$original] = check_plain($data['tag']->slot);
}
break;
case 'network_id':
$replacements[$original] = check_plain(variable_get('dfp_network_id', ''));
break;
case 'ad_categories':
$term_names =& drupal_static('dfp_entity_targeting_terms', array());
$replacements[$original] = implode(',', $term_names);
break;
}
}
if ($created_tokens = token_find_with_prefix($tokens, 'url_parts')) {
foreach ($created_tokens as $name => $original) {
$url_parts = explode('/', $_GET['q']);
$replacements[$original] = implode('/', array_slice($url_parts, 0, $name));
}
}
}
return $replacements;
}
function dfp_preprocess_html(&$variables) {
$ignore_admin = variable_get('dfp_gtm_admin_pages', TRUE);
if ($ignore_admin) {
$is_admin = path_is_admin(current_path());
if ($is_admin) {
return;
}
}
$gtm_container_id = variable_get('dfp_gtm_container_id', '');
if (!empty($gtm_container_id)) {
$google_tag = array(
'#tag' => 'script',
'#attributes' => array(
'type' => 'text/javascript',
),
'#weight' => -100,
'#value' => "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push(\n{'gtm.start': new Date().getTime(),event:'gtm.js'}\n);var f=d.getElementsByTagName(s)[0],\nj=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer','GTM-" . $gtm_container_id . "');",
);
drupal_add_html_head($google_tag, 'dfp_google_tag_manager');
$src = "https://www.googletagmanager.com/ns.html?id=GTM-" . $gtm_container_id;
$variables['google_tag_iframe'] = '<noscript><iframe src="' . $src . '"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>';
}
_dfp_js_global_settings();
}
function dfp_tag($machinename) {
$tag = dfp_tag_load($machinename);
$render_array = array();
if (!$tag) {
watchdog('dfp', 'Unknown ad tag %machinename passed to dfp_tag().', array(
'%machinename' => $machinename,
), WATCHDOG_WARNING);
}
else {
$tag->slug = dfp_format_slug($tag->slug);
$slug_placement = variable_get('dfp_slug_placement', 0);
if (!empty($tag)) {
$render_array = array(
'dfp_wrapper' => array(
'#type' => 'container',
'#attributes' => array(
'id' => $tag->wrapper_id,
'class' => array(
'dfp-tag-wrapper',
),
),
'tag' => array(
'#theme' => $tag->short_tag ? 'dfp_short_tag' : 'dfp_tag',
'#tag' => $tag,
),
),
);
if (!empty($tag->slug) && $slug_placement == 0) {
$render_array['dfp_wrapper']['slug_wrapper'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'slug',
),
),
'slug' => array(
'#markup' => check_plain($tag->slug),
),
'#weight' => -1,
);
}
}
}
return $render_array;
}
function dfp_tag_load($machinename) {
ctools_include('export');
$tags =& drupal_static(__FUNCTION__, array());
if (!isset($tags[$machinename])) {
$result = ctools_export_load_object('dfp_tags', 'names', array(
$machinename,
));
if (isset($result[$machinename])) {
$tag = $result[$machinename];
}
else {
return NULL;
}
$tag->raw = clone $tag;
drupal_alter('dfp_tag_load', $tag);
foreach ($tag->settings as $key => $val) {
$tag->{$key} = $val;
}
$tag->wrapper_id = 'dfp-ad-' . $tag->machinename . '-wrapper';
$tag->placeholder_id = 'dfp-ad-' . $tag->machinename;
drupal_alter('dfp_tag', $tag);
$tags[$machinename] = $tag;
}
else {
$tag = $tags[$machinename];
}
return $tag;
}
function dfp_tag_load_all($include_disabled = FALSE) {
ctools_include('export');
$tags = ctools_export_crud_load_all('dfp_tags');
foreach ($tags as $key => $tag) {
if (!$include_disabled && isset($tag->disabled) && $tag->disabled) {
unset($tags[$key]);
}
}
return $tags;
}
function dfp_tag_save(&$tag) {
$update = isset($tag->adid) && is_numeric($tag->adid) ? array(
'adid',
) : array();
return drupal_write_record('dfp_tags', $tag, $update);
}
function dfp_dfp_tag_load_alter(&$tag) {
if (module_exists('context')) {
$contexts = dfp_context_registry();
foreach ($contexts['reactions'] as $key => $val) {
if ($plugin = context_get_plugin('reaction', $key)) {
$plugin
->execute($tag);
}
}
}
module_load_include('inc', 'dfp', 'dfp.adtest');
dfp_adtest_alter_tag($tag);
}
function dfp_exportable_scheduler_form_group_alter(&$group) {
$group = 'settings';
}
function dfp_form_ctools_export_ui_edit_item_form_alter(&$form, &$form_state) {
if (arg(2) == 'context') {
form_load_include($form_state, 'inc', 'dfp', 'dfp.admin');
}
}
function dfp_format_targeting($targeting, $tag = '') {
foreach ($targeting as $key => &$target) {
$target['target'] = check_plain($target['target']);
$target['value'] = dfp_token_replace(check_plain($target['value']), $tag, array(
'sanitize' => TRUE,
'clear' => TRUE,
));
if (empty($target['value'])) {
unset($targeting[$key]);
continue;
}
drupal_alter('dfp_target', $target);
$values = explode(',', $target['value']);
$values = array_map('trim', $values);
if (count($values) == 1) {
$target['value'] = $values[0];
}
elseif (count($values) > 1) {
$target['value'] = $values;
}
}
return $targeting;
}
function dfp_format_size($size) {
$formatted_sizes = array();
$sizes = explode(',', check_plain($size));
foreach ($sizes as $size) {
$formatted_size = explode('x', trim($size));
array_walk($formatted_size, function (&$arg) {
$arg = (int) $arg;
});
$formatted_sizes[] = $formatted_size;
}
return count($formatted_sizes) == 1 ? $formatted_sizes[0] : $formatted_sizes;
}
function dfp_format_slug($slug) {
$formatted_slug = variable_get('dfp_default_slug', '');
if ($slug == '<none>') {
$formatted_slug = "";
}
elseif (!empty($slug)) {
$formatted_slug = $slug;
}
return $formatted_slug;
}
function _dfp_get_ad_category($term, $clean_string = FALSE) {
if (!empty($term->field_dfp_ad_categories)) {
$term = taxonomy_term_load($term->field_dfp_ad_categories[LANGUAGE_NONE][0]['tid']);
}
$term_name = $term->name;
if ($clean_string) {
ctools_include('cleanstring');
$term_name = ctools_cleanstring($term_name, array(
'lower_case' => TRUE,
));
}
return $term->name;
}
function _dfp_js_global_settings() {
$options = array(
'type' => 'file',
'group' => JS_DEFAULT,
'every_page' => TRUE,
'weight' => 0,
'force header' => TRUE,
);
drupal_add_js(drupal_get_path('module', 'dfp') . '/js/dfp_googletag.js', $options);
$global_targets = array();
$targeting = variable_get('dfp_targeting', array());
drupal_alter('dfp_global_targeting', $targeting);
$targeting = dfp_format_targeting($targeting);
foreach ($targeting as $key => $target) {
if (!empty($target['target']) && !empty($target['value'])) {
$global_targets[] = array(
'target' => $target['target'],
'value' => $target['value'],
);
}
}
$viewport_breakpoints = array();
foreach (_dfp_targeting_viewport_breakpoints() as $viewport) {
$v_target = 'dfp_viewport_' . $viewport . '_breakpoint';
$var = variable_get($v_target, '');
if (!empty($var)) {
$viewport_breakpoints[$viewport] = (int) $var;
}
}
$options['weight'] += 1;
drupal_add_js(drupal_get_path('module', 'dfp') . '/js/jquery.googletag.js', $options);
$options['weight'] += 1;
drupal_add_js(drupal_get_path('module', 'dfp') . '/js/dfp_googletag.cmd.js', $options);
$settings = array(
'dfpGoogleTagCmd' => array(
'asyncRendering' => (int) variable_get('dfp_async_rendering', 1),
'singleRequest' => (int) variable_get('dfp_single_request', 1),
'collapseEmptyDivs' => (int) variable_get('dfp_collapse_empty_divs', 1),
'disableInitialLoad' => (int) variable_get('dfp_disable_init_load', 0),
'setCentering' => (int) variable_get('dfp_set_centering', 0),
'globalTargets' => $global_targets,
'viewportBreakpoints' => $viewport_breakpoints,
),
);
if (module_exists('prebid')) {
$settings['dfpGoogleTagCmd']['prebidEnabled'] = TRUE;
}
drupal_add_js($settings, 'setting');
}
function _dfp_js_slot_definition($tag) {
if (isset($tag->processed) && $tag->processed === TRUE) {
watchdog('dfp', 'DFP tag %machinename is being added to the page more than once.', array(
'%machinename' => $tag->machinename,
), WATCHDOG_WARNING);
return;
}
$bp_sizes = array();
if (!empty($tag->breakpoints)) {
$breakpoints = $tag->breakpoints;
foreach ($breakpoints as $breakpoint) {
$bp_sizes[] = array(
'browser' => dfp_format_size($breakpoint['browser_size']),
'ad' => dfp_format_size($breakpoint['ad_sizes']),
);
}
}
$click_url = variable_get('dfp_click_url', '');
if (!empty($click_url)) {
$click_url = url($click_url, array(
'absolute' => TRUE,
));
}
$adsense_colors = array();
foreach ($tag->adsense_colors as $key => $val) {
if (!empty($val)) {
$key = 'adsense_' . $key . '_color';
$val = '#' . drupal_strtoupper($val);
$adsense_colors[] = array(
'key' => $key,
'value' => $val,
);
}
}
$targeting = dfp_format_targeting($tag->targeting, $tag);
$settings = array(
'dfpTags' => array(
$tag->machinename => array(
'machinename' => $tag->machinename,
'breakpoints' => $bp_sizes,
'size' => $tag->size,
'adunit' => $tag->adunit,
'placeholder_id' => $tag->placeholder_id,
'out_of_page' => !empty($tag->settings['out_of_page']) ? TRUE : FALSE,
'click_url' => $click_url,
'adsense_ad_types' => $tag->adsense_ad_types,
'adsense_channel_ids' => $tag->adsense_channel_ids,
'adsense_colors' => $adsense_colors,
'targeting' => $targeting,
'banner' => !empty($tag->settings['banner']) ? TRUE : FALSE,
'companion' => !empty($tag->settings['companion']) ? TRUE : FALSE,
'disable_initial_load' => !empty($tag->settings['disable_initial_load']) ? TRUE : FALSE,
),
),
);
drupal_add_js($settings, 'setting');
}
function _dfp_targeting_viewport_breakpoints() {
$viewports = array(
'tablet',
'desktop',
);
drupal_alter('dfp_viewport_breakpoints', $viewports);
return $viewports;
}
function _dfp_prepare_tokens($tag = NULL) {
global $user;
$data = array();
$data['user'] = $user;
$data['node'] = menu_get_object();
$data['term'] = arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) ? taxonomy_term_load(arg(2)) : NULL;
if (!empty($tag)) {
$data['tag'] = $tag;
}
return $data;
}
function _dfp_prepare_adunit($tag) {
$global_adunit = variable_get('dfp_default_adunit', '');
if (empty($tag->adunit) && !empty($global_adunit)) {
$tag->adunit = $global_adunit;
}
return $tag;
}
function dfp_token_replace($text, $tag = NULL, array $options = array()) {
$text_tokens = token_scan($text);
if (empty($text_tokens)) {
return $text;
}
$data = _dfp_prepare_tokens($tag);
$dfp_token_cache_enabled = variable_get('dfp_token_cache_enabled', TRUE);
if ($dfp_token_cache_enabled && function_exists('entity_modified_last')) {
$replacement = _dfp_token_replace_cache($text, $data, $options);
}
else {
$replacement = token_replace($text, $data, $options);
}
return $replacement;
}
function _dfp_token_replace_cache($text, $data, array $options = array()) {
$processed_strings =& drupal_static(__FUNCTION__, NULL);
$key = _dfp_token_replace_make_key($text, $data);
$cache_item = DFP_TOKEN_CACHE . ':' . implode(':', drupal_render_cid_parts(DRUPAL_CACHE_PER_PAGE));
if (is_null($processed_strings)) {
$cache = cache_get($cache_item, 'cache');
$processed_strings = $cache ? $cache->data : array();
}
if (!isset($processed_strings[$key]) || is_null($processed_strings[$key])) {
$processed_strings[$key] = token_replace($text, $data, $options);
$lifetime = variable_get('dfp_token_cache_lifetime', 0);
$expire_at = $lifetime == 0 ? CACHE_TEMPORARY : REQUEST_TIME + $lifetime;
cache_set($cache_item, $processed_strings, 'cache', $expire_at);
}
return $processed_strings[$key];
}
function _dfp_token_replace_make_key($text, array $data) {
$keys[] = sha1($text);
$keys[] = isset($data['node']->nid) ? $data['node']->nid . '-' . entity_modified_last('node', $data['node']) : NULL;
$keys[] = isset($data['user']->uid) ? $data['user']->uid . '-' . entity_modified_last('user', $data['user']) : NULL;
$keys[] = isset($data['term']->tid) ? $data['term']->tid . '-' . entity_modified_last('taxonomy_term', $data['term']) : NULL;
$keys[] = isset($data['tag']->machinename) ? $data['tag']->machinename . '-' . entity_modified_last('tag', $data['tag']) : NULL;
return implode('|', array_filter($keys));
}
function template_preprocess_dfp_tag(&$variables) {
$tag = $variables['tag'];
$tag = _dfp_prepare_adunit($tag);
$slug_placement = variable_get('dfp_slug_placement', 0);
$tag->adunit = dfp_token_replace('[dfp_tag:network_id]/' . $tag->adunit, $tag, array(
'sanitize' => TRUE,
'clear' => TRUE,
));
$tag->size = dfp_format_size($tag->size);
$tag->slug = dfp_format_slug($tag->slug);
$variables['placeholder_attributes'] = array(
'id' => $tag->placeholder_id,
'class' => array(
'dfp-tag-wrapper',
),
);
if (!empty($tag->slug) && $slug_placement == 1) {
$variables['slug'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'slug',
),
),
'slug' => array(
'#markup' => check_plain($tag->slug),
),
'#weight' => -1,
);
}
_dfp_js_slot_definition($tag);
$variables['tag']->processed = TRUE;
}
function template_preprocess_dfp_short_tag(&$variables) {
static $tile = 0;
$tag = $variables['tag'];
$tag = _dfp_prepare_adunit($tag);
$keyvals = array();
$keyvals['iu'] = dfp_token_replace('/[dfp_tag:network_id]/' . $tag->adunit, $tag, array(
'sanitize' => TRUE,
'clear' => TRUE,
));
$keyvals['sz'] = str_replace(',', '|', check_plain($tag->raw->size));
$keyvals['c'] = rand(10000, 99999);
$targets = array();
foreach ($tag->targeting as $data) {
$targets[] = check_plain($data['target']) . '=' . check_plain($data['value']);
}
if (!empty($targets)) {
$keyvals['t'] = implode('&', $targets);
}
drupal_alter('dfp_short_tag_keyvals', $keyvals);
$variables['url_jump'] = 'http://' . DFP_GOOGLE_SHORT_TAG_SERVICES_URL . '/jump?' . drupal_http_build_query($keyvals);
$variables['url_ad'] = 'http://' . DFP_GOOGLE_SHORT_TAG_SERVICES_URL . '/ad?' . drupal_http_build_query($keyvals);
}
function dfp_page_build(&$page) {
$html = '';
$tags = dfp_tag_load_all();
foreach ($tags as $tag) {
if (isset($tag->settings['out_of_page']) && $tag->settings['out_of_page'] == TRUE) {
drupal_alter('dfp_tag_load', $tag);
}
}
if (module_exists('context')) {
if ($plugin = context_get_plugin('reaction', 'dfp_outofpage')) {
if (isset($plugin->out_of_page_tags)) {
foreach ($plugin->out_of_page_tags as $key => $machinename) {
$tag = dfp_tag_load($machinename);
if (empty($tag->disabled)) {
$dfp_tag = dfp_tag($machinename);
$dfp_tag['dfp_wrapper']['#attributes']['class'][] = 'element-hidden';
$html .= render($dfp_tag);
}
}
}
}
}
$page['page_top']['dfp_out_of_page'] = array(
'#weight' => -1000,
'#markup' => $html,
);
}