Parent Directory
|
Revision Log
|
Revision Graph
|
Patch
| revision 1.66.2.10 by jcnventura, Mon Aug 18 23:24:37 2008 UTC | revision 1.66.2.11 by jcnventura, Mon Aug 18 23:45:13 2008 UTC | |
|---|---|---|
| # | Line 1 | Line 1 |
| 1 | <?php | <?php |
| 2 | // $Id: adsense.module,v 1.75 2008/08/18 19:35:13 jcnventura Exp $ | //$Id: adsense.module,v 1.66.2.9 2008/08/06 17:02:01 kbahey Exp $ |
| 3 | ||
| 4 | /** | // Copyright 2005-2008 Khalid Baheyeldin http://2bits.com |
| * @file | ||
| * Displays Google AdSense ads on Drupal pages | ||
| * | ||
| * This is the core module of the AdSense package, with the Drupal hooks | ||
| * and other administrative functions. | ||
| */ | ||
| // Ad types, link or ad | ||
| define('ADSENSE_TYPE_LINK', 1); | ||
| define('ADSENSE_TYPE_AD', 2); | ||
| define('ADSENSE_TYPE_SEARCH', 3); | ||
| define('ADSENSE_MAX_CHANNELS', 10); | ||
| require_once(drupal_get_path('module', 'adsense') .'/adsense.admin.inc'); | ||
| 5 | ||
| 6 | /** | /** |
| 7 | * This is the array that holds all ad formats. | * This is the array that holds all ad formats. |
| 8 | * | * All it has is a multi-dimensional array containing the dimensions as a key, then |
| 9 | * All it has is a multi-dimensional array indexed by a key, containing the ad type, | * the description and suffix of Google's javascript ad code. |
| 10 | * the description, Google's javascript ad code and the dimensions. | * Currently, we do not support duplicate dimensions in ad formats (for example, |
| 11 | * the same ad dimension cannot repeat for text and graphics, or for ads and ad links | |
| 12 | * | * |
| 13 | * To add a new code: | * To add a new code: |
| 14 | * - Make sure the key is not in use by a different format | * - Make sure the dimensions are not in use by a different format |
| 15 | * - Go to Google AdSense | * - Go to Google AdSense |
| 16 | * . Get the dimensions | * . Get the dimensions |
| 17 | * . Get the code | * . Get the code (suffix after the dimensions) |
| 18 | * - Add it below | * - Add it below in ascending order (width first, then height) |
| 19 | * | * @return returns an array of supported ad formats (desc: description, code: Google Ad code suffix) |
| * @param $key | ||
| * (optional) ad key for which the format is needed | ||
| * @return | ||
| * if no key is provided: array of supported ad formats as an array (type, desc(ription), code, width and height) | ||
| * if a key is provided, the array containing the ad format for that key, or NULL if there is no ad with that key | ||
| 20 | */ | */ |
| 21 | function adsense_ad_formats($key = NULL) { | function adsense_ad_formats() { |
| 22 | $ads = array( | return array( |
| 23 | '120x90' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('4-links 120x90'), 'code' => '120x90_0ads_al', 'width' => 120, 'height' => 90), | '120x90' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('Ad links 4-links 120x90'), 'code' => '_0ads_al'), |
| 24 | '160x90' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('4-links 160x90'), 'code' => '160x90_0ads_al', 'width' => 160, 'height' => 90), | '120x240' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Vertical banner'), 'code' => '_as'), |
| 25 | '180x90' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('4-links 180x90'), 'code' => '180x90_0ads_al', 'width' => 180, 'height' => 90), | '120x600' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Skyscraper'), 'code' => '_as'), |
| 26 | '200x90' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('4-links 200x90'), 'code' => '200x90_0ads_al', 'width' => 200, 'height' => 90), | '125x125' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Button'), 'code' => '_as'), |
| 27 | '468x15' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('4-links 468x15'), 'code' => '468x15_0ads_al', 'width' => 468, 'height' => 15), | '160x90' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('Ad links 4-links 160x90'), 'code' => '_0ads_al'), |
| 28 | '728x15' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('4-links 728x15'), 'code' => '728x15_0ads_al', 'width' => 728, 'height' => 15), | '160x600' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Wide skyscraper'), 'code' => '_as'), |
| 29 | '120x90_5' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('5-links 120x90'), 'code' => '120x90_0ads_al_s', 'width' => 120, 'height' => 90), | '180x90' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('Ad links 4-links 180x90'), 'code' => '_0ads_al'), |
| 30 | '160x90_5' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('5-links 160x90'), 'code' => '160x90_0ads_al_s', 'width' => 160, 'height' => 90), | '180x150' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Small rectangle'), 'code' => '_as'), |
| 31 | '180x90_5' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('5-links 180x90'), 'code' => '180x90_0ads_al_s', 'width' => 180, 'height' => 90), | '200x90' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('Ad links 4-links 200x90'), 'code' => '_0ads_al'), |
| 32 | '200x90_5' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('5-links 200x90'), 'code' => '200x90_0ads_al_s', 'width' => 200, 'height' => 90), | '200x200' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Small square'), 'code' => '_as'), |
| 33 | '468x15_5' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('5-links 468x15'), 'code' => '468x15_0ads_al_s', 'width' => 468, 'height' => 15), | '234x60' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Half banner'), 'code' => '_as'), |
| 34 | '728x15_5' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('5-links 728x15'), 'code' => '728x15_0ads_al_s', 'width' => 728, 'height' => 15), | '250x250' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Square'), 'code' => '_as'), |
| 35 | '120x240' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Vertical banner'), 'code' => '120x240_as', 'width' => 120, 'height' => 240), | '300x250' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Medium rectangle'), 'code' => '_as'), |
| 36 | '120x600' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Skyscraper'), 'code' => '120x600_as', 'width' => 120, 'height' => 600), | '336x280' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Large rectangle'), 'code' => '_as'), |
| 37 | '125x125' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Button'), 'code' => '125x125_as', 'width' => 125, 'height' => 125), | '468x15' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('Banner ad links 4-links'), 'code' => '_0ads_al'), |
| 38 | '160x600' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Wide Skyscraper'), 'code' => '160x600_as', 'width' => 160, 'height' => 600), | '468x60' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Banner'), 'code' => '_as'), |
| 39 | '180x150' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Small Rectangle'), 'code' => '180x150_as', 'width' => 180, 'height' => 150), | '728x15' => array('type' => ADSENSE_TYPE_LINK, 'desc' => t('Wide banner ad links 4-links'), 'code' => '_0ads_al'), |
| 40 | '200x200' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Small Square'), 'code' => '200x200_as', 'width' => 200, 'height' => 200), | '728x90' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Leaderboard'), 'code' => '_as'), |
| 41 | '234x60' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Half Banner'), 'code' => '234x60_as', 'width' => 234, 'height' => 60), | ADSENSE_SEARCH_BOX => array('type' => ADSENSE_TYPE_SEARCH, 'desc' => t('AdSense for Search'), 'code' => '') |
| 42 | '250x250' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Square'), 'code' => '250x250_as', 'width' => 250, 'height' => 250), | ); |
| 43 | '300x250' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Medium Rectangle'), 'code' => '300x250_as', 'width' => 300, 'height' => 250), | } |
| '336x280' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Large Rectangle'), 'code' => '336x280_as', 'width' => 336, 'height' => 280), | ||
| '468x60' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Banner'), 'code' => '468x60_as', 'width' => 468, 'height' => 60), | ||
| '728x90' => array('type' => ADSENSE_TYPE_AD, 'desc' => t('Leaderboard'), 'code' => '728x90_as', 'width' => 728, 'height' => 90), | ||
| ); | ||
| if (!empty($key)) { | ||
| if (array_key_exists($key, $ads)) { | ||
| return $ads[$key]; | ||
| } | ||
| elseif ($key == 'Search Box') { | ||
| return array('type' => ADSENSE_TYPE_SEARCH, 'desc' => t('AdSense for Search')); | ||
| } | ||
| else { | ||
| return NULL; | ||
| } | ||
| } | ||
| 44 | ||
| 45 | return $ads; | // Ad types, link or ad |
| 46 | define('ADSENSE_TYPE_LINK', 1); | |
| 47 | define('ADSENSE_TYPE_AD', 2); | |
| 48 | define('ADSENSE_TYPE_SEARCH', 3); | |
| 49 | ||
| 50 | define('ADSENSE_ID_MODULE', 'adsense_id_module'); | |
| 51 | ||
| 52 | define('ADSENSE_ERROR_NO_MODULE', 1); | |
| 53 | define('ADSENSE_ERROR_NOT_CONFIGURED', 2); | |
| 54 | ||
| 55 | define('ADSENSE_MAX_GROUPS', 5); | |
| 56 | define('ADSENSE_MAX_CHANNELS', 10); | |
| 57 | define('ADSENSE_MAX_BLOCKS', 8); | |
| 58 | define('ADSENSE_VISIBILITY', 'adsense_visibility'); | |
| 59 | define('ADSENSE_ACCESS_PAGES', 'adsense_access_pages'); | |
| 60 | define('ADSENSE_AD_TYPE', 'adsense_ad_type_'); | |
| 61 | define('ADSENSE_COLOR_TEXT', 'adsense_color_text_'); | |
| 62 | define('ADSENSE_COLOR_BORDER', 'adsense_color_border_'); | |
| 63 | define('ADSENSE_COLOR_BG', 'adsense_color_bg_'); | |
| 64 | define('ADSENSE_COLOR_LINK', 'adsense_color_link_'); | |
| 65 | define('ADSENSE_COLOR_URL', 'adsense_color_url_'); | |
| 66 | define('ADSENSE_ALT', 'adsense_alt_'); | |
| 67 | define('ADSENSE_GROUP_TITLE', 'adsense_group_title_'); | |
| 68 | define('ADSENSE_ALT_INFO', 'adsense_alt_info_'); | |
| 69 | define('ADSENSE_AD_CHANNEL', 'adsense_ad_channel_'); | |
| 70 | define('ADSENSE_PERCENTAGE_AUTHOR', 'adsense_percentage_author'); | |
| 71 | define('ADSENSE_PERCENTAGE_REFER', 'adsense_percentage_refer'); | |
| 72 | define('ADSENSE_NODE_TYPE', 'adsense_node_type_'); | |
| 73 | define('ADSENSE_DISABLE', 'adsense_disable'); | |
| 74 | define('ADSENSE_TEST_MODE', 'adsense_test_mode'); | |
| 75 | define('ADSENSE_PLACEHOLDER', 'adsense_placeholder'); | |
| 76 | define('ADSENSE_PLACEHOLDER_TEXT', 'adsense_placeholder_text'); | |
| 77 | define('ADSENSE_SECTION_TARGETING', 'adsense_section_targeting'); | |
| 78 | define('ADSENSE_CLICK_TRACKING', 'adsense_click_tracking'); | |
| 79 | define('ADSENSE_AD_BLOCK', 'adsense_ad_block_'); | |
| 80 | define('ADSENSE_CLICK_TRACKING_NAME_RESOLVE', 'adsense_click_tracking_name_resolve'); | |
| 81 | define('ADSENSE_SECTION_START', '<!-- google_ad_section_start -->'); | |
| 82 | define('ADSENSE_SECTION_IGNORE', '<!-- google_ad_section_start(weight=ignore) -->'); | |
| 83 | define('ADSENSE_SECTION_END', '<!-- google_ad_section_end -->'); | |
| 84 | ||
| 85 | define('ADSENSE_SEARCH_RESULT_START', '<!-- Google Search Result Snippet Starts -->'); | |
| 86 | define('ADSENSE_SEARCH_RESULT_END', '<!-- Google Search Result Snippet Ends -->'); | |
| 87 | define('ADSENSE_SEARCH_COLOR_TEXT', 'adsense_search_color_text'); | |
| 88 | define('ADSENSE_SEARCH_COLOR_BORDER', 'adsense_search_color_border'); | |
| 89 | define('ADSENSE_SEARCH_COLOR_BG', 'adsense_search_color_bg'); | |
| 90 | define('ADSENSE_SEARCH_COLOR_TITLE', 'adsense_search_color_title'); | |
| 91 | define('ADSENSE_SEARCH_COLOR_URL', 'adsense_search_color_url'); | |
| 92 | define('ADSENSE_SEARCH_COLOR_VISITED_URL', 'adsense_search_color_visited_url'); | |
| 93 | define('ADSENSE_SEARCH_COLOR_LIGHT_URL', 'adsense_search_color_light_url'); | |
| 94 | define('ADSENSE_SEARCH_COLOR_BOX_BACKGROUND', 'adsense_search_color_box_background'); | |
| 95 | define('ADSENSE_SEARCH_COLOR_BOX_TEXT', 'adsense_search_color_box_text'); | |
| 96 | define('ADSENSE_SEARCH_COLOR_WHITE', 'white'); | |
| 97 | define('ADSENSE_SEARCH_COLOR_BLACK', '#000000'); | |
| 98 | define('ADSENSE_SEARCH_COLOR_GRAY', '#cccccc'); | |
| 99 | define('ADSENSE_SEARCH_DOMAIN', 'adsense_search_domain'); | |
| 100 | define('ADSENSE_SEARCH_LANGUAGE', 'adsense_search_language'); | |
| 101 | define('ADSENSE_SEARCH_ENCODING', 'adsense_search_encoding'); | |
| 102 | define('ADSENSE_SEARCH_COUNTRY', 'adsense_search_country'); | |
| 103 | define('ADSENSE_SEARCH_TEXTBOX_LENGTH', 'adsense_search_textbox_length'); | |
| 104 | define('ADSENSE_SEARCH_LOGO', 'adsense_search_logo'); | |
| 105 | define('ADSENSE_SEARCH_LOGO_GOOGLE', 'adsense_search_logo_google'); | |
| 106 | define('ADSENSE_SEARCH_LOGO_ABOVE_TEXTBOX', 'adsense_search_logo_above_textbox'); | |
| 107 | define('ADSENSE_SEARCH_LOGO_ON_BUTTON', 'adsense_search_logo_on_button'); | |
| 108 | define('ADSENSE_SEARCH_BUTTON', 'adsense_search_button'); | |
| 109 | define('ADSENSE_SEARCH_FRAME_WIDTH', 'adsense_search_frame_width'); | |
| 110 | define('ADSENSE_SEARCH_BOX', 'Search Box'); | |
| 111 | define('ADSENSE_SEARCH_PATH', 'adsense/search'); | |
| 112 | define('ADSENSE_SITE_SEARCH', '<!-- SiteSearch Google -->'); | |
| 113 | ||
| 114 | function adsense_get_ad_code($format) { | |
| 115 | $all_ads = adsense_ad_formats(); | |
| 116 | return $all_ads[$format]['code']; | |
| 117 | } | } |
| 118 | ||
| 119 | /** | /** |
| 120 | * Implementation of hook_perm(). | * Implementation of hook_help(). |
| 121 | */ | */ |
| 122 | function adsense_perm() { | function adsense_help($section) { |
| 123 | return array('administer adsense', 'hide adsense'); | switch ($section) { |
| 124 | case 'admin/settings/adsense': | |
| 125 | return t('<p>@revision @date</p>', array('@revision' => trim('$Revision: 1.66.2.9 $', ' $'), '@date' => trim('$Date: 2008/08/06 17:02:01 $', ' $'))); | |
| 126 | } | |
| 127 | } | } |
| 128 | ||
| 129 | /** | /** |
| # | Line 93 function adsense_perm() { | Line 132 function adsense_perm() { |
| 132 | function adsense_menu($may_cache) { | function adsense_menu($may_cache) { |
| 133 | $items = array(); | $items = array(); |
| 134 | ||
| 135 | $access = user_access('administer site configuration'); | |
| 136 | if ($may_cache) { | if ($may_cache) { |
| 137 | $items[] = array( | $items[] = array( |
| 138 | 'path' => 'admin/settings/adsense', | 'path' => 'admin/settings/adsense', |
| 139 | 'title' => t('AdSense'), | 'title' => t('AdSense'), |
| 140 | 'description' => t('Configure Google AdSense Ads.'), | 'description' => t('Configure Google AdSense Ads. Choose colors, channels, revenue sharing modules and many other options.'), |
| 141 | 'callback' => 'drupal_get_form', | 'callback' => 'drupal_get_form', |
| 142 | 'callback arguments' => array('adsense_main_settings'), | 'callback arguments' => 'adsense_admin_settings', |
| 143 | 'access' => user_access('administer adsense'), | 'type' => MENU_NORMAL_ITEM, |
| 144 | ); | 'access' => $access, |
| 145 | $items[] = array( | ); |
| 146 | 'path' => 'admin/settings/adsense/main', | |
| 147 | 'title' => t('Settings'), | $module_list = module_implements('adsense'); |
| 148 | 'weight' => 10, | foreach ($module_list as $key => $module) { |
| 149 | 'type' => MENU_DEFAULT_LOCAL_TASK, | $items[] = array( |
| 150 | ); | 'path' => 'admin/settings/adsense/'. $module, |
| 151 | $items[] = array( | 'title' => $module, |
| 152 | 'path' => 'admin/settings/adsense/id', | 'callback' => 'drupal_get_form', |
| 153 | 'title' => t('Publisher ID'), | 'callback arguments' => array('adsense_admin_module_settings', $module), |
| 154 | 'callback' => 'drupal_get_form', | 'type' => MENU_NORMAL_ITEM, |
| 155 | 'callback arguments' => array('adsense_id_settings'), | 'access' => $access, |
| 156 | 'access' => user_access('administer adsense'), | ); |
| 157 | 'weight' => 0, | } |
| 'type' => MENU_LOCAL_TASK, | ||
| ); | ||
| $items[] = array( | ||
| 'path' => 'admin/settings/adsense/id/site', | ||
| 'title' => t('Site ID'), | ||
| 'weight' => -1, | ||
| 'type' => MENU_DEFAULT_LOCAL_TASK, | ||
| ); | ||
| } | ||
| 158 | ||
| 159 | return $items; | if (variable_get(ADSENSE_CLICK_TRACKING, 0)) { |
| 160 | } | $access = user_access('view clicks'); |
| 161 | $items[] = array( | |
| 162 | 'path' => 'admin/logs/adsense', | |
| 163 | 'title' => t('AdSense clicks'), | |
| 164 | 'description' => t('Track AdSense clicks.'), | |
| 165 | 'callback' => 'adsense_click_log', | |
| 166 | 'type' => MENU_NORMAL_ITEM, | |
| 167 | 'access' => $access, | |
| 168 | ); | |
| 169 | ||
| 170 | /** | $items[] = array( |
| 171 | * Implementation of hook_requirements(). | 'path' => 'admin/logs/adsense/top_pages', |
| 172 | */ | 'title' => t('Top pages'), |
| 173 | function adsense_requirements($phase) { | 'callback' => 'adsense_click_top_pages', |
| 174 | $requirements = array(); | 'type' => MENU_NORMAL_ITEM, |
| 175 | $t = get_t(); | 'access' => $access, |
| switch ($phase) { | ||
| // At runtime, make sure that we have a publisher ID | ||
| case 'runtime': | ||
| $basic_id = variable_get('adsense_basic_id', ''); | ||
| if (empty($basic_id)) { | ||
| $requirements['adsense_basic_id'] = array( | ||
| 'title' => $t('AdSense'), | ||
| 'value' => $t('Publisher ID is not set. Please configure it in the <a href="@url">AdSense settings page</a>.', array('@url' => url('admin/settings/adsense/id'))), | ||
| 'severity' => REQUIREMENT_ERROR, | ||
| 176 | ); | ); |
| } | ||
| break; | ||
| } | ||
| return $requirements; | ||
| } | ||
| 177 | ||
| 178 | /** | $items[] = array( |
| 179 | * Implementation of hook_help(). | 'path' => 'admin/logs/adsense/by_day', |
| 180 | */ | 'title' => t('By day'), |
| 181 | function adsense_help($path) { | 'callback' => 'adsense_click_by_day', |
| 182 | switch ($path) { | 'type' => MENU_NORMAL_ITEM, |
| 183 | case 'admin/help#adsense': | 'access' => $access, |
| 184 | return '<p>'. trim('$Revision: 1.75 $', ' $') .' '. trim('$Date: 2008/08/18 19:35:13 $', ' $') .'</p>'; | ); |
| 185 | } | |
| 186 | } | } |
| 187 | } | else { |
| 188 | $items[] = array( | |
| 189 | /** | 'path' => 'adsense/counter', |
| 190 | * Implementation of hook_filter(). | 'callback' => 'adsense_counter', |
| 191 | */ | 'access' => TRUE, |
| 192 | function adsense_filter($op, $delta = 0, $format = -1, $text = '') { | 'type' => MENU_CALLBACK, |
| 193 | switch ($op) { | ); |
| case 'list': | ||
| return array(0 => t('AdSense tag')); | ||
| case 'no cache': | ||
| return TRUE; | ||
| case 'description': | ||
| return t('Substitutes an AdSense special tag with an ad.'); | ||
| case 'process': | ||
| return _adsense_process_tags($text); | ||
| default: | ||
| return $text; | ||
| 194 | } | } |
| 195 | $items[] = array( | |
| 196 | 'path' => ADSENSE_SEARCH_PATH, | |
| 197 | 'callback' => 'adsense_search', | |
| 198 | 'access' => user_access('access adsense search result page'), | |
| 199 | 'type' => MENU_CALLBACK, | |
| 200 | ); | |
| 201 | return $items; | |
| 202 | } | } |
| 203 | ||
| 204 | /** | /** |
| 205 | * Implementation of hook_nodeapi(). | * Implementation of hook_perm(). |
| 206 | */ | */ |
| 207 | function adsense_nodeapi(&$node, $op = 'view', $teaser, $page) { | function adsense_perm() { |
| 208 | switch ($op) { | return array('hide adsense', 'view clicks', 'access adsense search result page'); |
| case 'view': | ||
| if (variable_get('adsense_section_targeting', 1)) { | ||
| $node->content['adsense_start'] = array( | ||
| '#value' => '<!-- google_ad_section_start -->', | ||
| '#weight' => -1, | ||
| ); | ||
| $node->content['adsense_end'] = array( | ||
| '#value' => '<!-- google_ad_section_end -->', | ||
| '#weight' => 1, | ||
| ); | ||
| } | ||
| } | ||
| 209 | } | } |
| 210 | ||
| 211 | /** | function adsense_admin_module_settings($module) { |
| 212 | * Implementation of hook_filter_tips(). | $function = $module .'_adsense'; |
| 213 | */ | $form = $function('settings'); |
| 214 | function adsense_filter_tips($delta, $format, $long = FALSE) { | |
| 215 | return t('Use the special tag [adsense:<em>format</em>:<em>slot</em>] or [adsense:<em>format</em>:<em>[group]</em>:<em>[channel]</em><em>[:slot]</em>] or [adsense:block:<em>location</em>] to display Google AdSense ads.'); | return system_settings_form($form); |
| 216 | } | } |
| 217 | ||
| 218 | /** | function adsense_admin_settings() { |
| 219 | * Helper function to process the adsense input filter | // force a display of errors, if any |
| 220 | * | $module = variable_get(ADSENSE_ID_MODULE, 'adsense_basic'); |
| 221 | * @param $text | $function = $module .'_adsense'; |
| 222 | * text of the node being processed | if (function_exists($function)) { |
| 223 | * @return | $error = $function('status'); |
| 224 | * modified text with the adsense tags replaced by Google AdSense ads | } |
| 225 | * @see adsense_filter() | |
| 226 | * @see adsense_display() | $form = array(); |
| 227 | */ | cache_clear_all('adsense', 'cache', TRUE); |
| 228 | function _adsense_process_tags($text) { | |
| 229 | $patterns = array( | // We only load the help text if we are in settings, to save memory |
| 230 | 'block' => '/\[adsense:block:([^\]]+)\]/x', | $module = 'adsense'; |
| 231 | 'oldtag' => '/\[adsense:([^:]+):(\d*):(\d*):?(\w*)\]/x', | include_once(drupal_get_path('module', $module) .'/'. $module .'_help.inc'); |
| 232 | 'tag' => '/\[adsense:([^:]+):([^\]]+)\]/x', | |
| 233 | $form['help'] = array( | |
| 234 | '#type' => 'fieldset', | |
| 235 | '#collapsible' => TRUE, | |
| 236 | '#collapsed' => TRUE, | |
| 237 | '#title' => t('Help and instructions'), | |
| 238 | ); | ); |
| 239 | ||
| 240 | foreach ($patterns as $mode => $pattern) { | $help_function = $module .'_help_text'; |
| 241 | if (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) { | $form['help']['help'] = array( |
| 242 | foreach ($matches as $match) { | '#type' => 'markup', |
| 243 | switch ($mode) { | '#value' => $help_function(), |
| 244 | case 'block': | ); |
| $mods = array( | ||
| 'adsense_managed', | ||
| 'adsense_cse', | ||
| 'adsense_oldcode', | ||
| 'adsense_search', | ||
| ); | ||
| foreach ($mods as $module) { | ||
| $module_blocks = module_invoke($module, 'block', 'list'); | ||
| if ($module_blocks) { | ||
| foreach ($module_blocks as $delta => $block) { | ||
| if ($block['info'] == $match[1]) { | ||
| // Found the block with the same name as the passed arg | ||
| $block = module_invoke($module, 'block', 'view', $delta); | ||
| $ad = $block['content']; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| break; | ||
| case 'oldtag': | ||
| // If not specified, default group and channel to 1 | ||
| if (empty($match[2])) { | ||
| $match[2] = 1; | ||
| } | ||
| if (empty($match[3])) { | ||
| $match[3] = 1; | ||
| } | ||
| $args = array( | ||
| 'format' => $match[1], | ||
| 'group' => $match[2], | ||
| 'channel' => $match[3], | ||
| 'slot' => $match[4], | ||
| ); | ||
| $ad = adsense_display($args); | ||
| unset($args); | ||
| break; | ||
| case 'tag': | ||
| $args = array( | ||
| 'format' => $match[1], | ||
| 'slot' => $match[2], | ||
| ); | ||
| $ad = adsense_display($args); | ||
| unset($args); | ||
| break; | ||
| } | ||
| // Replace the first occurance of the tag, in case we have the same | ||
| // tag more than once. | ||
| $str = '/\\'. $match[0] .'/'; | ||
| $text = preg_replace($str, $ad, $text, 1); | ||
| } | ||
| } | ||
| } | ||
| 245 | ||
| 246 | // In Drupal <= 6.3 we need to remove any HTML comments as the HTML corrector has a bug | $form['required'] = array( |
| 247 | sscanf(VERSION, "%d.%d", $major, $minor); | '#type' => 'fieldset', |
| 248 | if (($major == 6) && ($minor <= 3)) { | '#collapsible' => TRUE, |
| 249 | $text = preg_replace('/<!--.*?-->/', '', $text); | '#collapsed' => FALSE, |
| 250 | '#title' => t('Required parameters'), | |
| 251 | ); | |
| 252 | ||
| 253 | foreach (module_implements('adsense') as $key => $val) { | |
| 254 | $list[$val] = $val .' '. l(t('(Settings)'), 'admin/settings/adsense/'. $val); | |
| 255 | } | } |
| 256 | ||
| 257 | return $text; | $form['required'][ADSENSE_ID_MODULE] = array( |
| 258 | } | '#type' => 'radios', |
| 259 | '#title' => t('Adsense Client ID selection modules'), | |
| 260 | '#default_value' => variable_get(ADSENSE_ID_MODULE, 'adsense_basic'), | |
| 261 | '#options' => $list, | |
| 262 | '#description' => t('This provides a list of modules that are able to select a valid Adsense Client ID. You have to chose one module that selects the Adsense ID for each page view. Only one module can be selected. You can write your own module that selects the ID based on criteria you chose.'), | |
| 263 | ); | |
| 264 | ||
| 265 | /** | $client = adsense_get_client_id(); |
| 266 | * Provides the Google AdSense Publisher ID / slot ID to be used in the ad | if (!$client) { |
| 267 | * | adsense_error(ADSENSE_ERROR_NOT_CONFIGURED); |
| 268 | * If revenue sharing modules are installed, this function will call the | return system_settings_form($form); |
| * appropriate function in those modules. | ||
| * | ||
| * @param $format | ||
| * format of the ad being generated (optional) | ||
| * @return | ||
| * If the format parameter is supplied, array with 'client' and 'slot' | ||
| * fields, otherwise just the Publisher ID string is returned | ||
| */ | ||
| function adsense_get_client_slot_id($format = NULL) { | ||
| // Get the configured function | ||
| $function = variable_get('adsense_id_module', 'adsense_basic'); | ||
| if ($function != 'adsense_basic') { | ||
| // Call the function | ||
| if (function_exists($function)) { | ||
| $client_id = $function('client_id', $format); | ||
| if ($client_id) { | ||
| return $client_id; | ||
| } | ||
| } | ||
| 269 | } | } |
| return variable_get('adsense_basic_id', ''); | ||
| } | ||
| 270 | ||
| 271 | /** | $form['types_colors'] = array( |
| 272 | * Generates the Google AdSense Ad | '#type' => 'fieldset', |
| 273 | * | '#collapsible' => TRUE, |
| 274 | * This function is capable of handling two types of arguments: | '#collapsed' => TRUE, |
| 275 | * 1. an array of arguments (format, group, channel or slot) | '#title' => t('Ad groups'), |
| 276 | * 2. 0 to 4 arguments: | ); |
| * - 1st arg: format (default '160x600') | ||
| * - 2nd arg: group (default 1) | ||
| * - 3rd arg: channel (default 1) | ||
| * - 4th arg: slot (default '') | ||
| * | ||
| * A valid format must always be provided. If a slot is provided, the ad is generated by the | ||
| * new format modules, if not then the 'old' format modules are attempted. | ||
| * | ||
| * @return | ||
| * Publisher ID string | ||
| * @see adsense_ad_formats() | ||
| * @see _adsense_page_match() | ||
| * @see _adsense_check_if_enabled() | ||
| * @see _adsense_format_placeholder() | ||
| * @see _adsense_can_insert_another() | ||
| * @see _adsense_cse_get_searchbox() | ||
| * @see _adsense_search_get_searchbox() | ||
| * @see _adsense_managed_get_ad() | ||
| * @see _adsense_oldcode_get_ad() | ||
| */ | ||
| function adsense_display() { | ||
| $numargs = func_num_args(); | ||
| if (($numargs == 1) && is_array(func_get_arg(0))) { | ||
| $args = func_get_arg(0); | ||
| } | ||
| else { | ||
| // handle the 'old' method of calling this function | ||
| // adsense_display($format = '160x600', $group = 1, $channel = 1, $slot = '', $referral = 0, $cpa = '') | ||
| 277 | ||
| 278 | $args['format'] = '160x600'; | for ($group=1; $group<ADSENSE_MAX_GROUPS+1; $group++) { |
| 279 | $args['group'] = 1; | |
| 280 | $args['channel'] = 1; | $title = $group .' '. variable_get(ADSENSE_GROUP_TITLE . $group, ''); |
| 281 | switch ($numargs) { | |
| 282 | case 6: | $form['types_colors']['groups'][$group] = array( |
| 283 | // cpa isn't used anymore | '#type' => 'fieldset', |
| 284 | case 5: | '#collapsible' => TRUE, |
| 285 | // referral is obsolete | '#collapsed' => TRUE, |
| 286 | case 4: | '#title' => t('Group @group attributes', array('@group' => $title)), |
| 287 | $args['slot'] = func_get_arg(3); | ); |
| 288 | case 3: | |
| 289 | $args['channel'] = func_get_arg(2); | $form['types_colors']['groups'][$group][ADSENSE_GROUP_TITLE . $group] = array( |
| 290 | case 2: | '#type' => 'textfield', |
| 291 | $args['group'] = func_get_arg(1); | '#title' => t('Title'), |
| 292 | case 1: | '#default_value' => variable_get(ADSENSE_GROUP_TITLE . $group, ''), |
| 293 | $args['format'] = func_get_arg(0); | '#size' => 100, |
| 294 | } | '#maxlength' => 100, |
| 295 | } | '#description' => t('Title of the group.'), |
| 296 | ); | |
| 297 | ||
| 298 | $form['types_colors']['groups'][$group][ADSENSE_AD_TYPE . $group] = array( | |
| 299 | '#type' => 'radios', | |
| 300 | '#title' => t('Ad type'), | |
| 301 | '#default_value' => variable_get(ADSENSE_AD_TYPE . $group, '000000'), | |
| 302 | '#options' => array(t('Text'), t('Image'), t('Both')), | |
| 303 | ); | |
| 304 | ||
| 305 | $form['types_colors']['groups'][$group][ADSENSE_COLOR_TEXT . $group] = array( | |
| 306 | '#type' => 'textfield', | |
| 307 | '#title' => t('Ad text color'), | |
| 308 | '#default_value' => variable_get(ADSENSE_COLOR_TEXT . $group, '000000'), | |
| 309 | '#size' => 6, | |
| 310 | '#maxlength' => 6, | |
| 311 | ); | |
| 312 | ||
| 313 | $form['types_colors']['groups'][$group][ADSENSE_COLOR_BORDER . $group] = array( | |
| 314 | '#type' => 'textfield', | |
| 315 | '#title' => t('Ad border color'), | |
| 316 | '#default_value' => variable_get(ADSENSE_COLOR_BORDER . $group, '336699'), | |
| 317 | '#size' => 6, | |
| 318 | '#maxlength' => 6, | |
| 319 | ); | |
| 320 | ||
| 321 | $form['types_colors']['groups'][$group][ADSENSE_COLOR_BG . $group] = array( | |
| 322 | '#type' => 'textfield', | |
| 323 | '#title' => t('Ad background color'), | |
| 324 | '#default_value' => variable_get(ADSENSE_COLOR_BG . $group, 'FFFFFF'), | |
| 325 | '#size' => 6, | |
| 326 | '#maxlength' => 6, | |
| 327 | ); | |
| 328 | ||
| 329 | $form['types_colors']['groups'][$group][ADSENSE_COLOR_LINK . $group] = array( | |
| 330 | '#type' => 'textfield', | |
| 331 | '#title' => t('Ad title color'), | |
| 332 | '#default_value' => variable_get(ADSENSE_COLOR_LINK . $group, '336699'), | |
| 333 | '#size' => 6, | |
| 334 | '#maxlength' => 6, | |
| 335 | ); | |
| 336 | ||
| 337 | $form['types_colors']['groups'][$group][ADSENSE_COLOR_URL . $group] = array( | |
| 338 | '#type' => 'textfield', | |
| 339 | '#title' => t('Ad URL color'), | |
| 340 | '#default_value' => variable_get(ADSENSE_COLOR_URL . $group, 'FF8C00'), | |
| 341 | '#size' => 6, | |
| 342 | '#maxlength' => 6, | |
| 343 | ); | |
| 344 | ||
| 345 | $form['types_colors']['groups'][$group][ADSENSE_ALT . $group] = array( | |
| 346 | '#type' => 'select', | |
| 347 | '#title' => t('Alternate URL color'), | |
| 348 | '#default_value' => variable_get(ADSENSE_ALT . $group, 0), | |
| 349 | '#options' => array(t('None'), t('Alternate URL'), t('Alternate color')), | |
| 350 | ); | |
| 351 | ||
| 352 | $form['types_colors']['groups'][$group][ADSENSE_ALT_INFO . $group] = array( | |
| 353 | '#type' => 'textfield', | |
| 354 | '#title' => t('Alternate info'), | |
| 355 | '#default_value' => variable_get(ADSENSE_ALT_INFO . $group, ''), | |
| 356 | '#size' => 100, | |
| 357 | '#maxlength' => 100, | |
| 358 | '#description' => t('Enter either 6 letter alternate color code, or alternate URL to use'), | |
| 359 | ); | |
| 360 | } | |
| 361 | ||
| 362 | $form['types_colors']['search'] = array( | |
| 363 | '#type' => 'fieldset', | |
| 364 | '#collapsible' => TRUE, | |
| 365 | '#collapsed' => TRUE, | |
| 366 | '#title' => t('AdSense for Search attributes'), | |
| 367 | ); | |
| 368 | ||
| 369 | $ad = adsense_ad_formats($args['format']); | $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_TEXT] = array( |
| 370 | '#type' => 'textfield', | |
| 371 | '#title' => t('Text color'), | |
| 372 | '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_TEXT, '000000'), | |
| 373 | '#size' => 6, | |
| 374 | '#maxlength' => 6 | |
| 375 | ); | |
| 376 | ||
| 377 | if ($ad === NULL) { | $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_BORDER] = array( |
| 378 | $ad = '<!--adsense: invalid format: '. $args['format'] .'-->'; | '#type' => 'textfield', |
| 379 | } | '#title' => t('Border color'), |
| 380 | elseif (!_adsense_page_match()) { | '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_BORDER, '336699'), |
| 381 | // Check first if disabled or if we are at adsense limit or if this page doesn't allow adsense | '#size' => 6, |
| 382 | $ad = '<!--adsense: page not in match list-->'; | '#maxlength' => 6 |
| 383 | } | ); |
| 384 | elseif (!_adsense_check_if_enabled()) { | |
| 385 | // Ads are disabled | $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_BG] = array( |
| 386 | if (variable_get('adsense_placeholder', '1')) { | '#type' => 'textfield', |
| 387 | $ad = "<!--adsense: placeholder-->\n". _adsense_format_placeholder($ad); | '#title' => t('Background color'), |
| 388 | } | '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_BG, 'FFFFFF'), |
| 389 | else { | '#size' => 6, |
| 390 | $ad = '<!--adsense: ads disabled -->'; | '#maxlength' => 6 |
| 391 | } | ); |
| 392 | ||
| 393 | $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_TITLE] = array( | |
| 394 | '#type' => 'textfield', | |
| 395 | '#title' => t('Title color'), | |
| 396 | '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_TITLE, '0000FF'), | |
| 397 | '#size' => 6, | |
| 398 | '#maxlength' => 6 | |
| 399 | ); | |
| 400 | ||
| 401 | $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_URL] = array( | |
| 402 | '#type' => 'textfield', | |
| 403 | '#title' => t('URL color'), | |
| 404 | '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_URL, '008000'), | |
| 405 | '#size' => 6, | |
| 406 | '#maxlength' => 6 | |
| 407 | ); | |
| 408 | ||
| 409 | $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_VISITED_URL] = array( | |
| 410 | '#type' => 'textfield', | |
| 411 | '#title' => t('Visited URL color'), | |
| 412 | '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_VISITED_URL, '663399'), | |
| 413 | '#size' => 6, | |
| 414 | '#maxlength' => 6 | |
| 415 | ); | |
| 416 | ||
| 417 | $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_LIGHT_URL] = array( | |
| 418 | '#type' => 'textfield', | |
| 419 | '#title' => t('Light URL color'), | |
| 420 | '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_LIGHT_URL, '0000FF'), | |
| 421 | '#size' => 6, | |
| 422 | '#maxlength' => 6 | |
| 423 | ); | |
| 424 | ||
| 425 | $form['channels'] = array( | |
| 426 | '#type' => 'fieldset', | |
| 427 | '#collapsible' => TRUE, | |
| 428 | '#collapsed' => TRUE, | |
| 429 | '#title' => t('Custom channels'), | |
| 430 | '#description' => t('Enter up to !channels custom channels that you have configured in Google AdSense. If you are not using custom channels, or you are only using URL channels, then leave this empty.', array('!channels' => ADSENSE_MAX_CHANNELS)), | |
| 431 | ); | |
| 432 | ||
| 433 | for ($channel=1; $channel<ADSENSE_MAX_CHANNELS+1; $channel++) { | |
| 434 | $form['channels'][ADSENSE_AD_CHANNEL . $channel] = array( | |
| 435 | '#type' => 'textfield', | |
| 436 | '#title' => t('Custom channel ID ') . $channel, | |
| 437 | '#default_value' => variable_get(ADSENSE_AD_CHANNEL . $channel, ''), | |
| 438 | '#size' => 30, | |
| 439 | '#maxlength' => 30, | |
| 440 | ); | |
| 441 | } | } |
| 442 | elseif (!_adsense_can_insert_another($ad['type'])) { | |
| 443 | $ad = '<!--adsense: ad limit reached for type-->'; | $form['visibility'] = array( |
| 444 | '#type' => 'fieldset', | |
| 445 | '#collapsible' => TRUE, | |
| 446 | '#collapsed' => TRUE, | |
| 447 | '#title' => t('Visibility'), | |
| 448 | ); | |
| 449 | ||
| 450 | $form['visibility']['adsense_visibility'] = array( | |
| 451 | '#type' => 'radios', | |
| 452 | '#title' => t('Show AdSense on specific pages'), | |
| 453 | '#default_value' => variable_get(ADSENSE_VISIBILITY, 0), | |
| 454 | '#options' => array(t('Show on every page except the listed pages.'), | |
| 455 | t('Show on only the listed pages.')), | |
| 456 | ); | |
| 457 | ||
| 458 | $form['visibility']['adsense_access_pages'] = array( | |
| 459 | '#type' => 'textarea', | |
| 460 | '#title' => t('Pages'), | |
| 461 | '#default_value' => variable_get(ADSENSE_ACCESS_PAGES, ''), | |
| 462 | '#cols' => 70, | |
| 463 | '#rows' => 5, | |
| 464 | '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '<em>blog</em>' for the blog page and '<em>blog/*</em>' for every personal blog. '<em><front></em>' is the front page."), | |
| 465 | ); | |
| 466 | ||
| 467 | $form['click_tracking'] = array( | |
| 468 | '#type' => 'fieldset', | |
| 469 | '#collapsible' => TRUE, | |
| 470 | '#collapsed' => TRUE, | |
| 471 | '#title' => t('Click tracking'), | |
| 472 | ); | |
| 473 | ||
| 474 | $form['click_tracking'][ADSENSE_CLICK_TRACKING] = array( | |
| 475 | '#type' => 'checkbox', | |
| 476 | '#title' => t('Enable AdSense click tracking?'), | |
| 477 | '#return_value' => 1, | |
| 478 | '#default_value' => variable_get(ADSENSE_CLICK_TRACKING, 0), | |
| 479 | '#description' => t('Logs IP and time of <a href=!url>AdSense clicks</a>. This can be very useful in tracking which of your pages generate the most clicks, as well as help if click fraud is suspected.', array('!url' => url('admin/logs/adsense'))), | |
| 480 | ); | |
| 481 | ||
| 482 | $form['click_tracking'][ADSENSE_CLICK_TRACKING_NAME_RESOLVE] = array( | |
| 483 | '#type' => 'checkbox', | |
| 484 | '#title' => t('Enable name resolution of IP addresses?'), | |
| 485 | '#return_value' => 1, | |
| 486 | '#default_value' => variable_get(ADSENSE_CLICK_TRACKING_NAME_RESOLVE, 0), | |
| 487 | '#description' => t('Display the domain name instead of the IP address. This can slow down the display of the logs page and tie up a PHP process for several seconds. On some hosting providers it may not be available.'), | |
| 488 | ); | |
| 489 | ||
| 490 | $form['search'] = array( | |
| 491 | '#type' => 'fieldset', | |
| 492 | '#collapsible' => TRUE, | |
| 493 | '#collapsed' => TRUE, | |
| 494 | '#title' => t('AdSense Search') | |
| 495 | ); | |
| 496 | ||
| 497 | $form['search']['box'] = array( | |
| 498 | '#type' => 'fieldset', | |
| 499 | '#collapsible' => TRUE, | |
| 500 | '#collapsed' => FALSE, | |
| 501 | '#title' => t('Search Box Options'), | |
| 502 | '#description' => t('Allows users to search the web or the specific site(s) of your choice. Enter the site\'s URL without the last \'/\''), | |
| 503 | ); | |
| 504 | ||
| 505 | global $base_url; | |
| 506 | $form['search']['box'][ADSENSE_SEARCH_DOMAIN .'_0'] = array( | |
| 507 | '#type' => 'textfield', | |
| 508 | '#field_prefix' => 'http://', | |
| 509 | '#default_value' => variable_get(str_replace('http://', '', ADSENSE_SEARCH_DOMAIN .'_0'), str_replace('http://', '', $base_url)), | |
| 510 | '#size' => 32, | |
| 511 | '#maxlength' => 255 | |
| 512 | ); | |
| 513 | ||
| 514 | $form['search']['box'][ADSENSE_SEARCH_DOMAIN .'_1'] = array( | |
| 515 | '#type' => 'textfield', | |
| 516 | '#field_prefix' => 'http://', | |
| 517 | '#default_value' => variable_get(str_replace('http://', '', ADSENSE_SEARCH_DOMAIN .'_1'), ''), | |
| 518 | '#size' => 32, | |
| 519 | '#maxlength' => 255 | |
| 520 | ); | |
| 521 | ||
| 522 | $form['search']['box'][ADSENSE_SEARCH_DOMAIN .'_2'] = array( | |
| 523 | '#type' => 'textfield', | |
| 524 | '#field_prefix' => 'http://', | |
| 525 | '#default_value' => variable_get(str_replace('http://', '', ADSENSE_SEARCH_DOMAIN .'_2'), ''), | |
| 526 | '#size' => 32, | |
| 527 | '#maxlength' => 255 | |
| 528 | ); | |
| 529 | ||
| 530 | $form['search']['box'][ADSENSE_SEARCH_LOGO] = array( | |
| 531 | '#type' => 'radios', | |
| 532 | '#title' => t('Logo Type'), | |
| 533 | '#default_value' => variable_get(ADSENSE_SEARCH_LOGO, ADSENSE_SEARCH_LOGO_GOOGLE), | |
| 534 | '#options' => array( | |
| 535 | ADSENSE_SEARCH_LOGO_GOOGLE => t('Google Logo'), | |
| 536 | ADSENSE_SEARCH_LOGO_ABOVE_TEXTBOX => t('Logo above text box'), | |
| 537 | ADSENSE_SEARCH_LOGO_ON_BUTTON => t('"Google Search" on button'), | |
| 538 | ) | |
| 539 | ); | |
| 540 | ||
| 541 | $form['search']['box'][ADSENSE_SEARCH_BUTTON] = array( | |
| 542 | '#type' => 'checkbox', | |
| 543 | '#title' => t('Search button below text box'), | |
| 544 | '#return_value' => 1, | |
| 545 | '#default_value' => variable_get(ADSENSE_SEARCH_BUTTON, 0) | |
| 546 | ); | |
| 547 | ||
| 548 | $box_background_color = variable_get(ADSENSE_SEARCH_COLOR_BOX_BACKGROUND, ADSENSE_SEARCH_COLOR_WHITE); | |
| 549 | $form['search']['box'][ADSENSE_SEARCH_COLOR_BOX_BACKGROUND] = array( | |
| 550 | '#type' => 'select', | |
| 551 | '#title' => t('Background Color'), | |
| 552 | '#default_value' => $box_background_color, | |
| 553 | '#options' => array( | |
| 554 | ADSENSE_SEARCH_COLOR_WHITE => t('White'), | |
| 555 | ADSENSE_SEARCH_COLOR_BLACK => t('Black'), | |
| 556 | ADSENSE_SEARCH_COLOR_GRAY => t('Gray'), | |
| 557 | ) | |
| 558 | ); | |
| 559 | ||
| 560 | $box_text_color = variable_get(ADSENSE_SEARCH_COLOR_BOX_TEXT, ADSENSE_SEARCH_COLOR_BLACK); | |
| 561 | if ($box_background_color == ADSENSE_SEARCH_COLOR_BLACK) { | |
| 562 | $box_text_color = ADSENSE_SEARCH_COLOR_WHITE; | |
| 563 | } | |
| 564 | elseif ($box_background_color == ADSENSE_SEARCH_COLOR_WHITE) { | |
| 565 | $box_text_color = ADSENSE_SEARCH_COLOR_BLACK; | |
| 566 | } | |
| 567 | ||
| 568 | $form['search']['box'][ADSENSE_SEARCH_COLOR_BOX_TEXT] = array( | |
| 569 | '#type' => 'select', | |
| 570 | '#title' => t('Text Color'), | |
| 571 | '#default_value' => $box_text_color, | |
| 572 | '#options' => array( | |
| 573 | ADSENSE_SEARCH_COLOR_BLACK => t('Black'), | |
| 574 | ADSENSE_SEARCH_COLOR_WHITE => t('White') | |
| 575 | ) | |
| 576 | ); | |
| 577 | ||
| 578 | $form['search']['result'] = array( | |
| 579 | '#type' => 'fieldset', | |
| 580 | '#collapsible' => TRUE, | |
| 581 | '#collapsed' => FALSE, | |
| 582 | '#title' => t('Search Results Style') | |
| 583 | ); | |
| 584 | ||
| 585 | $form['search']['result'][ADSENSE_SEARCH_COUNTRY] = array( | |
| 586 | '#type' => 'select', | |
| 587 | '#title' => t('Country or territory for Google domain'), | |
| 588 | '#default_value' => variable_get(ADSENSE_SEARCH_COUNTRY, 'www.google.com'), | |
| 589 | '#options' => array( | |
| 590 | 'www.google.co.uk' => t('United Kingdom'), | |
| 591 | 'www.google.ca' => t('Canada'), | |
| 592 | 'www.google.de' => t('Germany'), | |
| 593 | 'www.google.co.jp' => t('Japan'), | |
| 594 | 'www.google.fr' => t('France'), | |
| 595 | 'www.google.com.au' => t('Australia'), | |
| 596 | 'www.google.it' => t('Italy'), | |
| 597 | 'www.google.at' => t('Austria'), | |
| 598 | 'www.google.ch' => t('Switzerland'), | |
| 599 | 'www.google.es' => t('Spain'), | |
| 600 | 'www.google.nl' => t('Netherlands'), | |
| 601 | 'www.google.be' => t('Belgium'), | |
| 602 | 'www.google.dk' => t('Denmark'), | |
| 603 | 'www.google.se' => t('Sweden'), | |
| 604 | 'www.google.no' => t('Norway'), | |
| 605 | 'www.google.com.br' => t('Brazil'), | |
| 606 | 'www.google.pt' => t('Portugal'), | |
| 607 | 'www.google.fi' => t('Finland'), | |
| 608 | 'www.google.co.kr' => t('South Korea'), | |
| 609 | 'www.google.cn' => t('China'), | |
| 610 | 'www.google.com.hk' => t('Hong Kong'), | |
| 611 | 'www.google.com.tw' => t('Taiwan'), | |
| 612 | 'www.google.com.sg' => t('Singapore'), | |
| 613 | 'www.google.com.af' => t('Afghanistan'), | |
| 614 | 'www.google.com' => t('Albania'), | |
| 615 | 'www.google.com' => t('Algeria'), | |
| 616 | 'www.google.as' => t('American Samoa'), | |
| 617 | 'www.google.com' => t('Andorra'), | |
| 618 | 'www.google.com' => t('Angola'), | |
| 619 | 'www.google.off.ai' => t('Anguilla'), | |
| 620 | 'www.google.com' => t('Antarctica'), | |
| 621 | 'www.google.com.ag' => t('Antigua and Barbuda'), | |
| 622 | 'www.google.com.ar' => t('Argentina'), | |
| 623 | 'www.google.am' => t('Armenia'), | |
| 624 | 'www.google.com' => t('Aruba'), | |
| 625 | 'www.google.az' => t('Azerbaijan'), | |
| 626 | 'www.google.bs' => t('Bahamas'), | |
| 627 | 'www.google.com.bh' => t('Bahrain'), | |
| 628 | 'www.google.com.bd' => t('Bangladesh'), | |
| 629 | 'www.google.com' => t('Barbados'), | |
| 630 | 'www.google.com' => t('Belarus'), | |
| 631 | 'www.google.com.bz' => t('Belize'), | |
| 632 | 'www.google.com' => t('Benin'), | |
| 633 | 'www.google.com' => t('Bermuda'), | |
| 634 | 'www.google.com' => t('Bhutan'), | |
| 635 | 'www.google.com.bo' => t('Bolivia'), | |
| 636 | 'www.google.ba' => t('Bosnia and Herzegovina'), | |
| 637 | 'www.google.co.bw' => t('Botswana'), | |
| 638 | 'www.google.com' => t('Bouvet Island'), | |
| 639 | 'www.google.com' => t('British Indian Ocean Territory'), | |
| 640 | 'www.google.com.bn' => t('Brunei Darussalam'), | |
| 641 | 'www.google.bg' => t('Bulgaria'), | |
| 642 | 'www.google.com' => t('Burkina Faso'), | |
| 643 | 'www.google.bi' => t('Burundi'), | |
| 644 | 'www.google.com.kh' => t('Cambodia'), | |
| 645 | 'www.google.com' => t('Cameroon'), | |
| 646 | 'www.google.com' => t('Cape Verde'), | |
| 647 | 'www.google.com' => t('Cayman Islands'), | |
| 648 | 'www.google.com' => t('Central African Republic'), | |
| 649 | 'www.google.com' => t('Chad'), | |
| 650 | 'www.google.cl' => t('Chile'), | |
| 651 | 'www.google.com' => t('Christmas Island'), | |
| 652 | 'www.google.com' => t('Cocos (Keeling) Islands'), | |
| 653 | 'www.google.com.co' => t('Colombia'), | |
| 654 | 'www.google.com' => t('Comoros'), | |
| 655 | 'www.google.cg' => t('Congo'), | |
| 656 | 'www.google.cd' => t('Congo, Democratic Republic'), | |
| 657 | 'www.google.co.ck' => t('Cook Islands'), | |
| 658 | 'www.google.co.cr' => t('Costa Rica'), | |
| 659 | 'www.google.ci' => t('Cote d'Ivoire'), | |
| 660 | 'www.google.hr' => t('Croatia'), | |
| 661 | 'www.google.com.cu' => t('Cuba'), | |
| 662 | 'www.google.com' => t('Cyprus'), | |
| 663 | 'www.google.cz' => t('Czech Republic'), | |
| 664 | 'www.google.dj' => t('Djibouti'), | |
| 665 | 'www.google.dm' => t('Dominica'), | |
| 666 | 'www.google.com.do' => t('Dominican Republic'), | |
| 667 | 'www.google.tp' => t('East Timor'), | |
| 668 | 'www.google.com.ec' => t('Ecuador'), | |
| 669 | 'www.google.com.eg' => t('Egypt'), | |
| 670 | 'www.google.com.sv' => t('El Salvador'), | |
| 671 | 'www.google.com' => t('Equatorial Guinea'), | |
| 672 | 'www.google.com' => t('Eritrea'), | |
| 673 | 'www.google.ee' => t('Estonia'), | |
| 674 | 'www.google.com.et' => t('Ethiopia'), | |
| 675 | 'www.google.com' => t('Falkland Islands (Malvinas)'), | |
| 676 | 'www.google.com' => t('Faroe Islands'), | |
| 677 | 'www.google.com.fj' => t('Fiji'), | |
| 678 | 'www.google.com' => t('French Guiana'), | |
| 679 | 'www.google.com' => t('French Polynesia'), | |
| 680 | 'www.google.com' => t('French Southern Territories'), | |
| 681 | 'www.google.com' => t('Gabon'), | |
| 682 | 'www.google.gm' => t('Gambia'), | |
| 683 | 'www.google.ge' => t('Georgia'), | |
| 684 | 'www.google.com' => t('Ghana'), | |
| 685 | 'www.google.com.gi' => t('Gibraltar'), | |
| 686 | 'www.google.gr' => t('Greece'), | |
| 687 | 'www.google.gl' => t('Greenland'), | |
| 688 | 'www.google.com' => t('Grenada'), | |
| 689 | 'www.google.gp' => t('Guadeloupe'), | |
| 690 | 'www.google.com' => t('Guam'), | |
| 691 | 'www.google.com.gt' => t('Guatemala'), | |
| 692 | 'www.google.com' => t('Guinea'), | |
| 693 | 'www.google.com' => t('Guinea-Bissau'), | |
| 694 | 'www.google.gy' => t('Guyana'), | |
| 695 | 'www.google.ht' => t('Haiti'), | |
| 696 | 'www.google.com' => t('Heard and McDonald Islands'), | |
| 697 | 'www.google.hn' => t('Honduras'), | |
| 698 | 'www.google.hu' => t('Hungary'), | |
| 699 | 'www.google.is' => t('Iceland'), | |
| 700 | 'www.google.co.in' => t('India'), | |
| 701 | 'www.google.co.id' => t('Indonesia'), | |
| 702 | 'www.google.com' => t('Iran'), | |
| 703 | 'www.google.com' => t('Iraq'), | |
| 704 | 'www.google.ie' => t('Ireland'), | |
| 705 | 'www.google.co.il' => t('Israel'), | |
| 706 | 'www.google.com.jm' => t('Jamaica'), | |
| 707 | 'www.google.jo' => t('Jordan'), | |
| 708 | 'www.google.kz' => t('Kazakhstan'), | |
| 709 | 'www.google.co.ke' => t('Kenya'), | |
| 710 | 'www.google.ki' => t('Kiribati'), | |
| 711 | 'www.google.com' => t('Kuwait'), | |
| 712 | 'www.google.kg' => t('Kyrgyzstan'), | |
| 713 | 'www.google.la' => t('Lao People's Democratic Republic'), | |
| 714 | 'www.google.lv' => t('Latvia'), | |
| 715 | 'www.google.com' => t('Lebanon'), | |
| 716 | 'www.google.co.ls' => t('Lesotho'), | |
| 717 | 'www.google.com' => t('Liberia'), | |
| 718 | 'www.google.com.ly' => t('Libya'), | |
| 719 | 'www.google.li' => t('Liechtenstein'), | |
| 720 | 'www.google.lt' => t('Lithuania'), | |
| 721 | 'www.google.lu' => t('Luxembourg'), | |
| 722 | 'www.google.com' => t('Macau'), | |
| 723 | 'www.google.com' => t('Macedonia'), | |
| 724 | 'www.google.com' => t('Madagascar'), | |
| 725 | 'www.google.mw' => t('Malawi'), | |
| 726 | 'www.google.com.my' => t('Malaysia'), | |
| 727 | 'www.google.mv' => t('Maldives'), | |
| 728 | 'www.google.com' => t('Mali'), | |
| 729 | 'www.google.com.mt' => t('Malta'), | |
| 730 | 'www.google.com' => t('Marshall Islands'), | |
| 731 | 'www.google.com' => t('Martinique'), | |
| 732 | 'www.google.com' => t('Mauritania'), | |
| 733 | 'www.google.mu' => t('Mauritius'), | |
| 734 | 'www.google.com' => t('Mayotte'), | |
| 735 | 'www.google.com.mx' => t('Mexico'), | |
| 736 | 'www.google.fm' => t('Micronesia'), | |
| 737 | 'www.google.md' => t('Moldova'), | |
| 738 | 'www.google.com' => t('Monaco'), | |
| 739 | 'www.google.mn' => t('Mongolia'), | |
| 740 | 'www.google.ms' => t('Montserrat'), | |
| 741 | 'www.google.co.ma' => t('Morocco'), | |
| 742 | 'www.google.com' => t('Mozambique'), | |
| 743 | 'www.google.com' => t('Myanmar'), | |
| 744 | 'www.google.com.na' => t('Namibia'), | |
| 745 | 'www.google.nr' => t('Nauru'), | |
| 746 | 'www.google.com.np' => t('Nepal'), | |
| 747 | 'www.google.com' => t('Netherlands Antilles'), | |
| 748 | 'www.google.com' => t('New Caledonia'), | |
| 749 | 'www.google.co.nz' => t('New Zealand'), | |
| 750 | 'www.google.com.ni' => t('Nicaragua'), | |
| 751 | 'www.google.com' => t('Niger'), | |
| 752 | 'www.google.com.ng' => t('Nigeria'), | |
| 753 | 'www.google.nu' => t('Niue'), | |
| 754 | 'www.google.com.nf' => t('Norfolk Island'), | |
| 755 | 'www.google.com' => t('Northern Mariana Islands'), | |
| 756 | 'www.google.com' => t('North Korea'), | |
| 757 | 'www.google.com.om' => t('Oman'), | |
| 758 | 'www.google.com.pk' => t('Pakistan'), | |
| 759 | 'www.google.com' => t('Palau'), | |
| 760 | 'www.google.com' => t('Palestinian Territory'), | |
| 761 | 'www.google.com.pa' => t('Panama'), | |
| 762 | 'www.google.com' => t('Papua New Guinea'), | |
| 763 | 'www.google.com.py' => t('Paraguay'), | |
| 764 | 'www.google.com.pe' => t('Peru'), | |
| 765 | 'www.google.com.ph' => t('Philippines'), | |
| 766 | 'www.google.pn' => t('Pitcairn'), | |
| 767 | 'www.google.pl' => t('Poland'), | |
| 768 | 'www.google.com.pr' => t('Puerto Rico'), | |
| 769 | 'www.google.com.qa' => t('Qatar'), | |
| 770 | 'www.google.com' => t('Reunion'), | |
| 771 | 'www.google.ro' => t('Romania'), | |
| 772 | 'www.google.ru' => t('Russian Federation'), | |
| 773 | 'www.google.rw' => t('Rwanda'), | |
| 774 | 'www.google.com' => t('Saint Kitts and Nevis'), | |
| 775 | 'www.google.com' => t('Saint Lucia'), | |
| 776 | 'www.google.com.vc' => t('Saint Vincent and the Grenadines'), | |
| 777 | 'www.google.ws' => t('Samoa'), | |
| 778 | 'www.google.sm' => t('San Marino'), | |
| 779 | 'www.google.st' => t('Sao Tome and Principe'), | |
| 780 | 'www.google.com.sa' => t('Saudi Arabia'), | |
| 781 | 'www.google.sn' => t('Senegal'), | |
| 782 | 'www.google.com' => t('Serbia and Montenegro'), | |
| 783 | 'www.google.sc' => t('Seychelles'), | |
| 784 | 'www.google.com' => t('Sierra Leone'), | |
| 785 | 'www.google.sk' => t('Slovakia'), | |
| 786 | 'www.google.si' => t('Slovenia'), | |
| 787 | 'www.google.com.sb' => t('Solomon Islands'), | |
| 788 | 'www.google.com' => t('Somalia'), | |
| 789 | 'www.google.co.za' => t('South Africa'), | |
| 790 | 'www.google.com' => t('South Georgia and The South Sandwich Islands'), | |
| 791 | 'www.google.lk' => t('Sri Lanka'), | |
| 792 | 'www.google.sh' => t('St. Helena'), | |
| 793 | 'www.google.com' => t('St. Pierre and Miquelon'), | |
| 794 | 'www.google.com' => t('Sudan'), | |
| 795 | 'www.google.com' => t('Suriname'), | |
| 796 | 'www.google.com' => t('Svalbard and Jan Mayen Islands'), | |
| 797 | 'www.google.com' => t('Swaziland'), | |
| 798 | 'www.google.com' => t('Syria'), | |
| 799 | 'www.google.com.tj' => t('Tajikistan'), | |
| 800 | 'www.google.com' => t('Tanzania'), | |
| 801 | 'www.google.co.th' => t('Thailand'), | |
| 802 | 'www.google.com' => t('Togo'), | |
| 803 | 'www.google.tk' => t('Tokelau'), | |
| 804 | 'www.google.to' => t('Tonga'), | |
| 805 | 'www.google.tt' => t('Trinidad and Tobago'), | |
| 806 | 'www.google.com' => t('Tunisia'), | |
| 807 | 'www.google.com.tr' => t('Turkey'), | |
| 808 | 'www.google.tm' => t('Turkmenistan'), | |
| 809 | 'www.google.com' => t('Turks and Caicos Islands'), | |
| 810 | 'www.google.com' => t('Tuvalu'), | |
| 811 | 'www.google.co.ug' => t('Uganda'), | |
| 812 | 'www.google.com.ua' => t('Ukraine'), | |
| 813 | 'www.google.ae' => t('United Arab Emirates'), | |
| 814 | 'www.google.com' => t('United States Minor Outlying Islands'), | |
| 815 | 'www.google.com.uy' => t('Uruguay'), | |
| 816 | 'www.google.co.uz' => t('Uzbekistan'), | |
| 817 | 'www.google.vu' => t('Vanuatu'), | |
| 818 | 'www.google.com' => t('Vatican'), | |
| 819 | 'www.google.co.ve' => t('Venezuela'), | |
| 820 | 'www.google.com.vn' => t('Viet Nam'), | |
| 821 | 'www.google.vg' => t('Virgin Islands (British)'), | |
| 822 | 'www.google.co.vi' => t('Virgin Islands (U.S.)'), | |
| 823 | 'www.google.com' => t('Wallis and Futuna Islands'), | |
| 824 | 'www.google.com' => t('Western Sahara'), | |
| 825 | 'www.google.com' => t('Yemen'), | |
| 826 | 'www.google.co.zm' => t('Zambia'), | |
| 827 | 'www.google.co.zw' => t('Zimbabwe'), | |
| 828 | 'www.google.com' => t('United States'), | |
| 829 | ) | |
| 830 | ); | |
| 831 | ||
| 832 | $form['search']['box'][ADSENSE_SEARCH_LANGUAGE] = array( | |
| 833 | '#type' => 'select', | |
| 834 | '#title' => t('Site Language'), | |
| 835 | '#default_value' => variable_get(ADSENSE_SEARCH_LANGUAGE, 'en'), | |
| 836 | '#options' => array( | |
| 837 | 'ar' => t('Arabic'), | |
| 838 | 'bg' => t('Bulgarian'), | |
| 839 | 'zh-CN' => t('Chinese (simplified)'), | |
| 840 | 'zh-TW' => t('Chinese (traditional)'), | |
| 841 | 'hr' => t('Croatian'), | |
| 842 | 'cs' => t('Czech'), | |
| 843 | 'da' => t('Danish'), | |
| 844 | 'nl' => t('Dutch'), | |
| 845 | 'en' => t('English'), | |
| 846 | 'fi' => t('Finnish'), | |
| 847 | 'fr' => t('French'), | |
| 848 | 'de' => t('German'), | |
| 849 | 'el' => t('Greek'), | |
| 850 | 'iw' => t('Hebrew'), | |
| 851 | 'hu' => t('Hungarian'), | |
| 852 | 'in' => t('Indonesian'), | |
| 853 | 'it' => t('Italian'), | |
| 854 | 'ja' => t('Japanese'), | |
| 855 | 'ko' => t('Korean'), | |
| 856 | 'no' => t('Norwegian'), | |
| 857 | 'pl' => t('Polish'), | |
| 858 | 'pt' => t('Portuguese'), | |
| 859 | 'ro' => t('Romanian'), | |
| 860 | 'ru' => t('Russian'), | |
| 861 | 'sk' => t('Slovak'), | |
| 862 | 'es' => t('Spanish'), | |
| 863 | 'sv' => t('Swedish'), | |
| 864 | 'tr' => t('Turkish') | |
| 865 | ) | |
| 866 | ); | |
| 867 | ||
| 868 | $form['search']['box'][ADSENSE_SEARCH_ENCODING] = array( | |
| 869 | '#type' => 'select', | |
| 870 | '#title' => t('Site Encoding'), | |
| 871 | '#default_value' => variable_get(ADSENSE_SEARCH_ENCODING, 'UTF-8'), | |
| 872 | '#options' => array( | |
| 873 | 'ISO-8859-1' => t('West European Latin-1 (ISO-8859-1)'), | |
| 874 | 'ISO-8859-15' => t('West European Latin-9 (ISO-8859-15)'), | |
| 875 | 'windows-1252' => t('Western (Windows-1252)'), | |
| 876 | 'ISO-8859-10' => t('Nordic Latin-6 (ISO-8859-10)'), | |
| 877 | 'ISO-8859-7' => t('Greek (ISO-8859-7)'), | |
| 878 | 'Shift_JIS' => t('Japanese (Shift_JIS)'), | |
| 879 | 'EUC-JP' => t('Japanese (EUC-JP)'), | |
| 880 | 'ISO-2022-JP' => t('Japanese (ISO-2022-JP)'), | |
| 881 | 'GB2312' => t('Chinese Simplified (GB2312)'), | |
| 882 | 'GB18030' => t('Chinese Simplified (GB18030)'), | |
| 883 | 'big5' => t('Chinese Traditional (Big5)'), | |
| 884 | 'EUC-KR' => t('Korean (EUC-KR)'), | |
| 885 | 'windows-874' => t('Thai (Windows-874)'), | |
| 886 | 'windows-1258' => t('Vietnamese (Windows-1258)'), | |
| 887 | 'ISO-8859-2' => t('Central European Latin-2 (ISO-8859-2)'), | |
| 888 | 'windows-1250' => t('Central European (Windows-1250)'), | |
| 889 | 'cp852' => t('Central European (CP852)'), | |
| 890 | 'ISO-8859-9' => t('Turkish Latin-5 (ISO-8859-9)'), | |
| 891 | 'windows-1254' => t('Turkish (Windows-1254)'), | |
| 892 | 'ISO-8859-3' => t('South European Latin-3 (ISO-8859-3)'), | |
| 893 | 'ISO-8859-8-I' => t('Hebrew (ISO-8859-8-I)'), | |
| 894 | 'windows-1255' => t('Hebrew (Windows-1255)'), | |
| 895 | 'windows-1256' => t('Arabic (Windows-1256)'), | |
| 896 | 'ISO-8859-5' => t('Cyrillic (ISO-8859-5)'), | |
| 897 | 'KOI8-R' => t('Cyrillic (KOI8-R)'), | |
| 898 | 'windows-1251' => t('Cyrillic (Windows-1251)'), | |
| 899 | 'cp-866' => t('Cyrillic/Russian (CP-866)'), | |
| 900 | 'UTF-8' => t('Unicode (UTF-8)') | |
| 901 | ) | |
| 902 | ); | |
| 903 | ||
| 904 | $textbox_length = $textbox_length > 64 ? 64 : variable_get(ADSENSE_SEARCH_TEXTBOX_LENGTH, 15); | |
| 905 | $form['search']['box'][ADSENSE_SEARCH_TEXTBOX_LENGTH] = array( | |
| 906 | '#type' => 'textfield', | |
| 907 | '#title' => t('Length of text box (Max 64): '), | |
| 908 | '#default_value' => $textbox_length, | |
| 909 | '#size' => 2, | |
| 910 | '#maxlength' => 2 | |
| 911 | ); | |
| 912 | ||
| 913 | $form['search']['result'][ADSENSE_SEARCH_FRAME_WIDTH] = array( | |
| 914 | '#type' => 'textfield', | |
| 915 | '#title' => t('Width of results area'), | |
| 916 | '#default_value' => variable_get(ADSENSE_SEARCH_FRAME_WIDTH, 500), | |
| 917 | '#size' => 3, | |
| 918 | '#maxlength' => 3 | |
| 919 | ); | |
| 920 | $form['advanced'] = array( | |
| 921 | '#type' => 'fieldset', | |
| 922 | '#collapsible' => TRUE, | |
| 923 | '#collapsed' => TRUE, | |
| 924 | '#title' => t('Advanced options'), | |
| 925 | ); | |
| 926 | ||
| 927 | $form['advanced'][ADSENSE_TEST_MODE] = array( | |
| 928 | '#type' => 'checkbox', | |
| 929 | '#title' => t('Enable test mode?'), | |
| 930 | '#return_value' => 1, | |
| 931 | '#default_value' => variable_get(ADSENSE_TEST_MODE, 0), | |
| 932 | '#description' => t('This enables you to test the AdSense module settings. This can be useful in some situations: for example, testing whether revenue sharing is working properly or not without having to display real ads on your site. It is best to test this after you log out.'), | |
| 933 | ); | |
| 934 | ||
| 935 | $form['advanced'][ADSENSE_DISABLE] = array( | |
| 936 | '#type' => 'checkbox', | |
| 937 | '#title' => t('Disable Google AdSense ads?'), | |
| 938 | '#return_value' => 1, | |
| 939 | '#default_value' => variable_get(ADSENSE_DISABLE, 0), | |
| 940 | '#description' => t('This disables all display of Google AdSense ads from your web site. This is useful in certain situations, such as site upgrades, or if you make a copy of the site for development and test purposes.'), | |
| 941 | ); | |
| 942 | ||
| 943 | $form['advanced'][ADSENSE_PLACEHOLDER] = array( | |
| 944 | '#type' => 'checkbox', | |
| 945 | '#title' => t('Placeholder when ads are disabled?'), | |
| 946 | '#return_value' => 1, | |
| 947 | '#default_value' => variable_get(ADSENSE_PLACEHOLDER, 1), | |
| 948 | '#description' => t('This causes an empty box to be displayed in place of the ads when they are disabled.'), | |
| 949 | ); | |
| 950 | ||
| 951 | $form['advanced'][ADSENSE_PLACEHOLDER_TEXT] = array( | |
| 952 | '#type' => 'textarea', | |
| 953 | '#title' => t('Placeholder text to display'), | |
| 954 | '#default_value' => variable_get(ADSENSE_PLACEHOLDER_TEXT, t('Google AdSense')), | |
| 955 | '#cols' => 70, | |
| 956 | '#rows' => 3, | |
| 957 | '#description' => t('Enter any text to display as a placeholder when ads are disabled.'), | |
| 958 | ); | |
| 959 | ||
| 960 | $form['advanced'][ADSENSE_SECTION_TARGETING] = array( | |
| 961 | '#type' => 'checkbox', | |
| 962 | '#title' => t('Enable AdSense section targeting?'), | |
| 963 | '#return_value' => 1, | |
| 964 | '#default_value' => variable_get(ADSENSE_SECTION_TARGETING, 1), | |
| 965 | '#description' => t('This better targets Google ads to the teaser and body of nodes.'), | |
| 966 | ); | |
| 967 | ||
| 968 | ||
| 969 | return system_settings_form($form); | |
| 970 | } | |
| 971 | ||
| 972 | function adsense_display($format = '160x600', $group = 1, $channel = 1) { | |
| 973 | if (!_adsense_validate_dimensions($format)) { | |
| 974 | $ad = '<!--adsense: invalid format: '. $format .'-->'; | |
| 975 | } | } |
| 976 | else { | else { |
| 977 | // If site Slot ID for this ad was passed, pass the format as argument | // This ad format is not cached, generate it |
| 978 | // in case Publisher ID modules are enabled that can return different | // Check first if disabled or if we are at adsense limit or if this page doesn't allow adsense |
| 979 | // Slot IDs per ad format | if (_adsense_check_if_enabled()) { |
| 980 | $client_id_arg = isset($args['slot']) ? $args['format'] : NULL; | if (_adsense_can_insert_another($format)) { |
| 981 | $client = adsense_get_client_slot_id($client_id_arg); | if (_adsense_page_match()) { |
| 982 | // Ad should be displayed | |
| 983 | if (is_array($client)) { | // Check cache first |
| 984 | // An array was received, use that Slot ID | $ad = $format != ADSENSE_SEARCH_BOX |
| 985 | $slot = $client['slot']; | ? _adsense_get_ad($format, $group, $channel) |
| 986 | $client = $client['client']; | : _adsense_get_searchbox($group, $channel); |
| } | ||
| else { | ||
| // Use the original site Slot ID | ||
| $slot = $args['slot']; | ||
| } | ||
| // Ad should be displayed | ||
| switch ($args['format']) { | ||
| case 'Search Box': | ||
| if (!empty($slot) && module_exists('adsense_cse')) { | ||
| $ad = _adsense_cse_get_searchbox($client, $slot); | ||
| } | ||
| elseif (module_exists('adsense_search')) { | ||
| $ad = _adsense_search_get_searchbox($client, $args['channel']); | ||
| 987 | } | } |
| 988 | else { | else { |
| 989 | $ad = '<!--adsense: no AdSense for Search module found-->'; | $ad = '<!--adsense: page not in match list-->'; |
| 990 | } | } |
| 991 | break; | } |
| 992 | default: | else { |
| 993 | if (!empty($slot) && module_exists('adsense_managed')) { | $ad = '<!--adsense: ad limit reached for type-->'; |
| 994 | $ad = _adsense_managed_get_ad($args['format'], $client, $slot); | } |
| 995 | } | } |
| 996 | elseif (module_exists('adsense_oldcode')) { | else { |
| 997 | $ad = _adsense_oldcode_get_ad($args['format'], $client, $args['group'], $args['channel']); | // Ads are disabled |
| 998 | if (_adsense_page_match()) { | |
| 999 | if (_adsense_check_placeholder()) { | |
| 1000 | $ad = '<!--adsense: placeholder-->'. _adsense_format_placeholder($format); | |
| 1001 | } | } |