Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented support for adding OpenX javascript on init instead of bl…
…ock render. This is useful if ouput from OpenX blocks is cached in panels or the like.
- Loading branch information
Showing
1 changed file
with
29 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
<?php | ||
|
||
function openx_extras_form_alter(&$form, &$form_state, $form_id) { | ||
if ($form_id == '_openx_settings') { | ||
$form['extras'] = array( | ||
'#type' => 'fieldset', | ||
/** | ||
* Adds additional settings to OpenX configuration form. | ||
*/ | ||
function openx_extras_form__openx_settings_alter(&$form, &$form_state) { | ||
$form['extras'] = array( | ||
'#type' => 'fieldset', | ||
'#title' => t('Extra options'), | ||
); | ||
$form['extras']['openx_extras_options'] = array( | ||
'#type' => 'checkboxes', | ||
'#title' => t('Options'), | ||
'#options' => array( | ||
'block' => t('Dont show a banner multiple times on the same page'), | ||
), | ||
'#default_value' => variable_get('openx_extras_options'), | ||
); | ||
); | ||
$form['extras']['openx_extras_options'] = array( | ||
'#type' => 'checkboxes', | ||
'#title' => t('Options'), | ||
'#options' => array( | ||
'block' => t('Dont show a banner multiple times on the same page'), | ||
'init_js' => t('Add javascipt on every page. This is required for OpenX to work if output from OpenX blocks are cached.'), | ||
), | ||
'#default_value' => variable_get('openx_extras_options'), | ||
); | ||
} | ||
|
||
/** | ||
* Implementation of hook_init(). | ||
*/ | ||
function openx_extras_init() { | ||
$options = variable_get('openx_extras_options', array()); | ||
if (isset($options['init_js'])) { | ||
//Add OpenX javascript in case output from OpenX blocks are cached. | ||
module_load_include('inc', 'openx'); | ||
_openx_javascript(); | ||
} | ||
} | ||
|
||
function openx_extras_preprocess_page(&$vars) { | ||
$options = variable_get('openx_extras_options', array()); | ||
if (isset($options['block'])) { | ||
$vars['head'] = str_replace('spcjs.php', 'spcjs.php?block=1', $vars['head']); | ||
//We need to do string replacement as we can't modify Javascript previously | ||
$vars['head'] = str_replace('spcjs.php', 'spcjs.php?block=1', $vars['head']); | ||
} | ||
} |