Skip to content

Commit

Permalink
Merge branch '7.x-1.x' into issue_2365665
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelovani committed Mar 17, 2017
2 parents 6e6e3b6 + 82ddbca commit 9f1b2bc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions dfp.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ function dfp_admin_settings($form, $form_state) {
),
),
);
$form['global_display_options']['dfp_set_centering'] = array(
'#type' => 'checkbox',
'#title' => t('Set DFP Ad Centering'),
'#default_value' => variable_get('dfp_set_centering', 0),
'#description' => t('Enables/disables centering of ads. This mode must be set before the service is enabled. Centering is disabled by default. In legacy gpt_mobile.js, centering is enabled by default.'),
);


// Global targeting options.
$form['targeting_settings'] = array(
Expand Down
8 changes: 8 additions & 0 deletions dfp.install
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ function dfp_install() {
}
}

/**
* Implements hook_uninstall().
*/
function dfp_uninstall() {
// Delete variables.
variable_del('dfp_set_centering');
}

/**
* Migrate existing DART tags to DFP tags. Note: this migration will destroy
* the any DFP global settings that have already been set.
Expand Down
3 changes: 3 additions & 0 deletions dfp.module
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,9 @@ function _dfp_js_global_settings() {
if (variable_get('dfp_disable_init_load', 0)) {
$js .= ' googletag.pubads().disableInitialLoad();' . "\n";
}
if (variable_get('dfp_set_centering', 0)) {
$js .= ' googletag.pubads().setCentering(true);' . "\n";
}

// Set global targeting values for this page.
$targeting = variable_get('dfp_targeting', array());
Expand Down
3 changes: 2 additions & 1 deletion tests/dfp.test
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class dfpDisplayTagTest extends dfpBaseTest {
variable_set('dfp_click_url', 'javascript://example.com?foo&bar');
$this->drupalGet('/');
$this->assertNoRaw('javascript://example.com');
$this->assertRaw('.setClickUrl("http://drupal7.dev/javascript%3A//example.com%3Ffoo%26bar")', 'Click URL is filtered for bad protocols and absolute.');
$pattern = '|.setClickUrl\("http(.*):\/\/(.*)javascript%3A\/\/example.com%3Ffoo%26bar"\)|';
$this->assertPattern($pattern, 'Click URL is filtered for bad protocols and absolute.');

variable_set('dfp_click_url', 'http://example.com?foo&bar');
$this->drupalGet('/');
Expand Down

0 comments on commit 9f1b2bc

Please sign in to comment.