Index: openads.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openads/openads.module,v
retrieving revision 1.7.2.4.2.1
diff -U3 -r1.7.2.4.2.1 openads.module
--- openads.module 14 Apr 2008 12:01:16 -0000 1.7.2.4.2.1
+++ openads.module 14 May 2008 17:26:42 -0000
@@ -1,4 +1,4 @@
- 'OpenX (Openads) adserver configuration',
- 'description' => 'Configure OpenX (Openads) AdServer integration behavior and appearance.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('openads_admin_settings'),
- 'access callback' => 'user_access',
- 'access arguments' => array('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM, // optional
+ 'file' => 'openads.admin.inc',
+ 'title' => 'OpenX (Openads) adserver configuration',
+ 'description' => 'Configure OpenX (Openads) AdServer integration behavior and appearance.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('openads_admin_settings'),
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_NORMAL_ITEM, // optional
);
- return $items;
+ return $items;
}
/**
@@ -100,7 +101,7 @@
$form['adserver']['openads_delivery_method'] = array(
'#type' => 'radios',
'#title' => t('Delivery Method'),
- '#description' => t('Select the delivery method to use.
Note: To use the Local method OpenX and your banners must be stored on the same machine with the same top level domain.
Note: To use XML-RPC method you must have the PEAR XML-RPC package installed and the OpenX openads-xmlrpc.inc.php file must be in your PHP include path. '. ($PEAR_missing ? '
PEAR XML-RPC appears to not be installed! You must install the PEAR XML-RPC package.' : '') . ($openads_xmlrpc_missing ? '
opeands-xmlrpc.inc.php file appears to not be installed! You must put the file openads-xmlrpc.inc.php from the OpenX installation files into your PHP path.' : ''), array('@link' => 'http://pear.php.net/package/XML_RPC')),
+ '#description' => t('Select the delivery method to use.
Note: To use the Local method OpenX and your banners must be stored on the same machine with the same top level domain.
Note: To use XML-RPC method you must have the PEAR XML-RPC package installed and the OpenX openads-xmlrpc.inc.php file must be in your PHP include path. '. ($PEAR_missing ? '
PEAR XML-RPC appears to not be installed! You must install the PEAR XML-RPC package.' : '') . ($openads_xmlrpc_missing ? '
opeands-xmlrpc.inc.php file appears to not be installed! You must put the file openads-xmlrpc.inc.php from the OpenX installation files into your PHP path.' : ''), array('@link' => 'http://pear.php.net/package/XML_RPC')),
'#options' => array('js' => 'Javascript', 'remote' => 'Remote', 'local' => 'Local', 'xmlrpc' => 'XML-RPC'),
'#default_value' => variable_get('openads_delivery_method', 'js'),
);
@@ -117,18 +118,18 @@
'#description' => t('This group of settings defines access paths to specific elements of your OpenX server. These settings are located on your OpenX server at Settings -> Main Settings -> Delivery Settings'),
);
$form['adserver']['server_access_paths']['openads_delivery_url'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_delivery_url', ''),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_delivery_url', ''),
'#title' => t('The OpenX delivery url'),
'#description' => t('The OpenX server address, for example "ads.example.org/delivery". "http://" is automatically prefixed.'),
'#required' => TRUE,
- );
+ );
$form['adserver']['server_access_paths']['openads_delivery_url_https'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_delivery_url_https', ''),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_delivery_url_https', ''),
'#title' => t('The OpenX https delivery url'),
'#description' => t('The OpenX server address, for example "ads.example.org/delivery". "https://" is automatically prefixed.')
- );
+ );
$form['adserver']['javascript_options'] = array(
'#type' => 'fieldset',
@@ -138,12 +139,12 @@
'#collapsed' => TRUE,
);
$form['adserver']['javascript_options']['openads_js_delivery_filename'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_js_delivery_filename', 'ajs.php'),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_js_delivery_filename', 'ajs.php'),
'#title' => t('The OpenX JavaScript delivery filename'),
'#description' => t('The OpenX JavaScript delivery filename for example "ajs.php"'),
'#required' => TRUE,
- );
+ );
$form['adserver']['remote_options'] = array(
'#type' => 'fieldset',
@@ -153,17 +154,17 @@
'#collapsed' => TRUE,
);
$form['adserver']['remote_options']['openads_remote_delivery_click_filename'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_remote_delivery_click_filename', 'ck.php'),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_remote_delivery_click_filename', 'ck.php'),
'#title' => t('The OpenX Remote delivery click filename'),
'#description' => t('The OpenX Remote delivery click filename for example "ck.php"')
- );
+ );
$form['adserver']['remote_options']['openads_remote_delivery_view_filename'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_remote_delivery_view_filename', 'avw.php'),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_remote_delivery_view_filename', 'avw.php'),
'#title' => t('The OpenX Remote delivery view filename'),
'#description' => t('The OpenX Remote delivery view filename for example "avw.php"')
- );
+ );
$form['adserver']['local_options'] = array(
'#type' => 'fieldset',
@@ -173,17 +174,17 @@
'#collapsed' => TRUE,
);
$form['adserver']['local_options']['openads_local_delivery_base_path'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_local_delivery_base_path', ''),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_local_delivery_base_path', ''),
'#title' => t('The OpenX Local delivery base path'),
'#description' => t('The base path of the OpenX installation for example "/opt/www/openx.example.com"')
- );
+ );
$form['adserver']['local_options']['openads_local_delivery_filename'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_local_delivery_filename', 'alocal.php'),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_local_delivery_filename', 'alocal.php'),
'#title' => t('The OpenX Local delivery filename'),
'#description' => t('The OpenX Local delivery filename for example "alocal.php"')
- );
+ );
$form['adserver']['xmlrpc_options'] = array(
'#type' => 'fieldset',
@@ -193,11 +194,11 @@
'#collapsed' => TRUE,
);
$form['adserver']['xmlrpc_options']['openads_xmlrpc_delivery_filename'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_xmlrpc_delivery_filename', 'axmlrpc.php'),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_xmlrpc_delivery_filename', 'axmlrpc.php'),
'#title' => t('The OpenX XML-RPC delivery filename'),
'#description' => t('The OpenX XML-RPC delivery filename for example "axmlrpc.php"')
- );
+ );
$form['adserver']['xmlrpc_options']['openads_xmlrpc_port'] = array(
'#type' => 'textfield',
'#title' => t('XML-RPC Port'),
@@ -226,21 +227,21 @@
'#collapsible' => TRUE,
);
$form['publisher']['openads_id'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_id', ''),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_id', ''),
'#title' => t('Publisher ID'),
'#description' => t("This is the publisher ID of the publisher you wish to serve ads from."),
'#required' => TRUE,
'#size' => 6,
- );
+ );
$form['publisher']['openads_num_zones'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('openads_num_zones', '5'),
+ '#type' => 'textfield',
+ '#default_value' => variable_get('openads_num_zones', '5'),
'#title' => t('The number of zones defined'),
'#description' => t('This is the number of zones you can enter below'),
'#size' => 6,
);
-
+
$form['openads_zones'] = array(
'#theme' => 'openads_admin_settings_form',
'#type' => 'fieldset',
@@ -258,34 +259,34 @@
);
$zones = openads_get_zones();
$roles = user_roles();
- $i = 0;
+ $i = 0;
foreach ($zones as $zone) {
$form['openads_zones'][$i]['openads_zones_id_'. $i] = array(
- '#type' => 'textfield',
+ '#type' => 'textfield',
'#default_value' => $zone['id'],
'#size' => 6,
- );
+ );
$form['openads_zones'][$i]['openads_zones_name_'. $i] = array(
- '#type' => 'textfield',
+ '#type' => 'textfield',
'#default_value' => $zone['name'],
'#size' => 20,
);
$form['openads_zones'][$i]['openads_zones_code_'. $i] = array(
- '#type' => 'textfield',
+ '#type' => 'textfield',
'#default_value' => $zone['code'],
'#size' => 10,
);
foreach ($roles as $key => $display) {
$element_key = 'openads_zones_roles_'. $key .'_'. $i;
$form['openads_zones'][$i][$element_key] = array(
- '#type' => 'checkbox',
+ '#type' => 'checkbox',
'#default_value' => $zone['roles'][$key],
- );
+ );
}
- $i++;
+ $i++;
}
- return system_settings_form($form);
+ return system_settings_form($form);
}
/**
@@ -353,7 +354,7 @@
}
$output .= theme('table', $header, $rows);
- return $output;
+ return $output;
}
/**
@@ -367,8 +368,8 @@
$blocks[$index] = array(
'info' => t('OpenX Zone '. $zone['id'] .' ('. ($zone['name'] != '' ? $zone['name'] : 'untitled') .')'),
'cache' => BLOCK_NO_CACHE,
- 'weight' => 0,
- 'enabled' => 0,
+ 'weight' => 0,
+ 'enabled' => 0,
'region' => 'left'
);
}
@@ -381,8 +382,8 @@
'content' => theme('openads_block', $delta)
);
return $block;
- }
-}
+ }
+}
/**
* Theme function for openads_block()
@@ -406,7 +407,7 @@
';
drupal_set_html_head($channel);
- drupal_add_js(drupal_get_path('module', 'openads') .'/openads.js');
+ drupal_add_js(drupal_get_path('module', 'openads') .'/openads.js');
}
/**
@@ -417,14 +418,14 @@
}
/**
- * Returns all stored zones
+ * Returns all stored zones
*/
function openads_get_zones() {
static $ret = NULL;
if ($ret) {
return $ret;
}
-
+
$c = variable_get('openads_num_zones', 5);
$ret = array();
for ($i = 0; $i < $c; $i ++) {
@@ -462,7 +463,7 @@
* Builds and returns at_channel content
*/
function openads_channel() {
- return theme('openads_channel');
+ return theme('openads_channel');
}
/**
@@ -472,7 +473,7 @@
global $user;
$url = check_plain($_GET['q']);
$channel[] = variable_get('openads_id', '') .'/'. $url;
-
+
if ($user) {
if ($user->uid == 1) {
$channel[] = 'type_admin';
@@ -480,14 +481,14 @@
foreach ($user->roles as $roleid => $rolename) {
$channel[] = 'type_'. str_replace(' ', '_', $rolename);
}
- }
-
- $channel[] = 'url_'. $url;
+ }
+
+ $channel[] = 'url_'. $url;
return implode(',', $channel);
}
/**
- * Builds the call to OpenX
+ * Builds the call to OpenX
*/
function openads_invoke($index_or_key) {
$zone = openads_get_zone($index_or_key);
@@ -503,7 +504,7 @@
return '';
}
}
-
+
return theme('openads_invoke', $id, $code);
}
@@ -557,12 +558,12 @@
$local = variable_get('openads_local_delivery_filename', 'alocal.php');
if (@include_once($path .'/www/delivery/'. $local)) {
- if (!isset($phpAds_context)) {
- $phpAds_context = array();
+ if (!isset($php_ads_context)) {
+ $php_ads_context = array();
}
$use_text = variable_get('opends_use_text_below_image', 0);
- $phpAds_raw = view_local('', $zoneid, 0, 0, '', '', $use_text, $phpAds_context);
- return $phpAds_raw['html'];
+ $php_ads_raw = view_local('', $zoneid, 0, 0, '', '', $use_text, $php_ads_context);
+ return $php_ads_raw['html'];
}
else {
return '';
@@ -573,18 +574,18 @@
* Theme function for XML-RPC delivery.
*/
function theme_openads_xmlrpc($zoneid) {
- static $oaXmlRpc;
+ static $oa_xml_rpc;
static $OA_context;
if (!isset($OA_context)) {
$OA_context = array();
}
- if (!$oaXmlRpc) {
+ if (!$oa_xml_rpc) {
$xmlrpc_settings = _openads_get_xmlrpc_settings();
- $oaXmlRpc = _openads_connect_xmlrpc($xmlrpc_settings);
+ $oa_xml_rpc = _openads_connect_xmlrpc($xmlrpc_settings);
}
$use_text = variable_get('openads_use_text_below_image', 0);
- $ad = $oaXmlRpc->view('zone:'. $zoneid, 0, '', '', $use_text, $OA_context);
+ $ad = $oa_xml_rpc->view('zone:'. $zoneid, 0, '', '', $use_text, $OA_context);
return $ad['html'];
}
@@ -608,8 +609,8 @@
*/
function _openads_connect_xmlrpc($xmlrpc_settings) {
require('openads-xmlrpc.inc.php');
- $oaXmlRpc = new OA_XmlRpc($xmlrpc_settings['host'], '/'. $xmlrpc_settings['path'] .'/'. $xmlrpc_settings['file'], $xmlrpc_settings['port'], $xmlrpc_settings['ssl'], $xmlrpc_settings['timeout']);
- return $oaXmlRpc;
+ $oa_xml_rpc = new OA_XmlRpc($xmlrpc_settings['host'], '/'. $xmlrpc_settings['path'] .'/'. $xmlrpc_settings['file'], $xmlrpc_settings['port'], $xmlrpc_settings['ssl'], $xmlrpc_settings['timeout']);
+ return $oa_xml_rpc;
}
/**