You are here

function adsense_admin_settings in Google AdSense integration 5

Same name and namespace in other branches
  1. 5.2 adsense.module \adsense_admin_settings()
1 string reference to 'adsense_admin_settings'
adsense_menu in ./adsense.module
Implementation of hook_menu().

File

./adsense.module, line 191

Code

function adsense_admin_settings() {
  $form = array();
  cache_clear_all('adsense', 'cache', TRUE);

  // We only load the help text if we are in settings, to save memory
  include_once drupal_get_path('module', 'adsense') . '/adsense_help.inc';

  // Get the ad formats
  $headers = array(
    t('Ad type'),
    t('Dimensions'),
  );
  $rows = array();
  foreach (adsense_ad_formats() as $format => $data) {
    $rows[] = array(
      $data['desc'],
      $format,
    );
  }

  // Create the ad format text
  $help_text = theme('table', $headers, $rows);
  $form['help'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('Help and instructions'),
  );
  $form['help']['help'] = array(
    '#type' => 'markup',
    '#value' => adsense_help_text($help_text),
  );
  $error_flag = false;
  if (!module_exists('profile')) {
    drupal_set_message('The profile module is not enabled. Please enable it and define a field as per instructions.', 'error');
    $error_flag = true;
  }
  if (!_adsense_get_site_owner_client_id()) {
    drupal_set_message('There is no site owner Google AdSense client ID defined. Please define a profile field, and select it below as per instructions, and enter a value for user id 1 as explained below.', 'error');
    $error_flag = true;
  }
  $form['required'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => false,
    '#title' => t('Required parameters'),
  );
  $form['required'][ADSENSE_CLIENT_ID_PROFILE_FIELD] = array(
    '#type' => 'select',
    '#title' => t('Google AdSense client ID profile field'),
    '#default_value' => variable_get(ADSENSE_CLIENT_ID_PROFILE_FIELD, 0),
    '#options' => _adsense_get_profile_fields(),
    '#required' => true,
    '#description' => t('This is the profile field that holds the AdSense Client ID for the site owner as well as (optionally) for site users who participate in revenue sharing. You must enabled the profile module and create a new field for this.'),
  );
  if ($error_flag) {
    return system_settings_form($form);
  }
  $form['types_colors'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('Ad groups'),
  );
  for ($group = 1; $group < ADSENSE_MAX_GROUPS + 1; $group++) {
    $form['types_colors']['groups'][$group] = array(
      '#type' => 'fieldset',
      '#collapsible' => true,
      '#collapsed' => true,
      '#title' => t('Group @group attributes', array(
        '@group' => $group,
      )),
    );
    $form['types_colors']['groups'][$group][ADSENSE_AD_TYPE . $group] = array(
      '#type' => 'radios',
      '#title' => t('Ad type'),
      '#default_value' => variable_get(ADSENSE_AD_TYPE . $group, '000000'),
      '#options' => array(
        t('Text'),
        t('Image'),
        t('Both'),
      ),
    );
    $form['types_colors']['groups'][$group][ADSENSE_COLOR_TEXT . $group] = array(
      '#type' => 'textfield',
      '#title' => t('Ad text color'),
      '#default_value' => variable_get(ADSENSE_COLOR_TEXT . $group, '000000'),
      '#size' => 6,
      '#maxlength' => 6,
    );
    $form['types_colors']['groups'][$group][ADSENSE_COLOR_BORDER . $group] = array(
      '#type' => 'textfield',
      '#title' => t('Ad border color'),
      '#default_value' => variable_get(ADSENSE_COLOR_BORDER . $group, '336699'),
      '#size' => 6,
      '#maxlength' => 6,
    );
    $form['types_colors']['groups'][$group][ADSENSE_COLOR_BG . $group] = array(
      '#type' => 'textfield',
      '#title' => t('Ad background color'),
      '#default_value' => variable_get(ADSENSE_COLOR_BG . $group, 'FFFFFF'),
      '#size' => 6,
      '#maxlength' => 6,
    );
    $form['types_colors']['groups'][$group][ADSENSE_COLOR_LINK . $group] = array(
      '#type' => 'textfield',
      '#title' => t('Ad title color'),
      '#default_value' => variable_get(ADSENSE_COLOR_LINK . $group, '336699'),
      '#size' => 6,
      '#maxlength' => 6,
    );
    $form['types_colors']['groups'][$group][ADSENSE_COLOR_URL . $group] = array(
      '#type' => 'textfield',
      '#title' => t('Ad URL color'),
      '#default_value' => variable_get(ADSENSE_COLOR_URL . $group, 'FF8C00'),
      '#size' => 6,
      '#maxlength' => 6,
    );
    $form['types_colors']['groups'][$group][ADSENSE_ALT . $group] = array(
      '#type' => 'select',
      '#title' => t('Alternate URL color'),
      '#default_value' => variable_get(ADSENSE_ALT . $group, 0),
      '#options' => array(
        t('None'),
        t('Alternate URL'),
        t('Alternate color'),
      ),
    );
    $form['types_colors']['groups'][$group][ADSENSE_ALT_INFO . $group] = array(
      '#type' => 'textfield',
      '#title' => t('Alternate info'),
      '#default_value' => variable_get(ADSENSE_ALT_INFO . $group, ''),
      '#size' => 100,
      '#maxlength' => 100,
      '#description' => t('Enter either 6 letter alternate color code, or alternate URL to use'),
    );
  }
  $form['types_colors']['search'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('AdSense for Search attributes'),
  );
  $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_TEXT] = array(
    '#type' => 'textfield',
    '#title' => t('Text color'),
    '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_TEXT, '000000'),
    '#size' => 6,
    '#maxlength' => 6,
  );
  $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_BORDER] = array(
    '#type' => 'textfield',
    '#title' => t('Border color'),
    '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_BORDER, '336699'),
    '#size' => 6,
    '#maxlength' => 6,
  );
  $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_BG] = array(
    '#type' => 'textfield',
    '#title' => t('Background color'),
    '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_BG, 'FFFFFF'),
    '#size' => 6,
    '#maxlength' => 6,
  );
  $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_TITLE] = array(
    '#type' => 'textfield',
    '#title' => t('Title color'),
    '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_TITLE, '0000FF'),
    '#size' => 6,
    '#maxlength' => 6,
  );
  $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_URL] = array(
    '#type' => 'textfield',
    '#title' => t('URL color'),
    '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_URL, '008000'),
    '#size' => 6,
    '#maxlength' => 6,
  );
  $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_VISITED_URL] = array(
    '#type' => 'textfield',
    '#title' => t('Visited URL color'),
    '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_VISITED_URL, '663399'),
    '#size' => 6,
    '#maxlength' => 6,
  );
  $form['types_colors']['search'][ADSENSE_SEARCH_COLOR_LIGHT_URL] = array(
    '#type' => 'textfield',
    '#title' => t('Light URL color'),
    '#default_value' => variable_get(ADSENSE_SEARCH_COLOR_LIGHT_URL, '0000FF'),
    '#size' => 6,
    '#maxlength' => 6,
  );
  $form['channels'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('Custom channels'),
    '#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,
    )),
  );
  for ($channel = 1; $channel < ADSENSE_MAX_CHANNELS + 1; $channel++) {
    $form['channels'][ADSENSE_AD_CHANNEL . $channel] = array(
      '#type' => 'textfield',
      '#title' => t('Custom channel ID ') . $channel,
      '#default_value' => variable_get(ADSENSE_AD_CHANNEL . $channel, ''),
      '#size' => 30,
      '#maxlength' => 30,
    );
  }
  $form['revenue'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('Revenue sharing options'),
  );
  $form['revenue'][ADSENSE_REVENUE_ENABLE] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable revenue sharing'),
    '#return_value' => 1,
    '#default_value' => variable_get(ADSENSE_REVENUE_ENABLE, 0),
    '#description' => t('Note that enabling this will disable AdSense code caching, which can cause more resource usage for busy sites. The referral feature requires the referral module to be installed.'),
  );
  $form['revenue'][ADSENSE_PERCENTAGE_AUTHOR] = array(
    '#type' => 'select',
    '#title' => t('Percentage of node views going to author'),
    '#default_value' => variable_get(ADSENSE_PERCENTAGE_AUTHOR, 0),
    '#options' => drupal_map_assoc(array(
      0,
      5,
      10,
      15,
      20,
      25,
      30,
      40,
      50,
      60,
      70,
      75,
      80,
      90,
      100,
    )),
  );
  if (module_exists('referral')) {
    $list = drupal_map_assoc(array(
      0,
      5,
      10,
      15,
      20,
      25,
      30,
      40,
      50,
      60,
      70,
      75,
      80,
      90,
      100,
    ));
    $form['revenue'][ADSENSE_PERCENTAGE_REFER] = array(
      '#type' => 'select',
      '#title' => t('Percentage of node views going to user who referred the author'),
      '#default_value' => variable_get(ADSENSE_PERCENTAGE_REFER, 0),
      '#options' => $list,
      '#description' => t('This feature requires the referral module to be installed.'),
    );
  }
  $form['revenue']['content'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('Content types'),
    '#description' => t('Content types that have revenue sharing enabled.'),
  );
  foreach (node_get_types() as $type => $name) {
    $form['revenue']['content'][ADSENSE_NODE_TYPE . $type] = array(
      '#type' => 'checkbox',
      '#title' => $name->name,
      '#return_value' => 1,
      '#default_value' => variable_get(ADSENSE_NODE_TYPE . $type, 0),
    );
  }
  $form['visibility'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('Visibility'),
  );
  $form['visibility']['adsense_visibility'] = array(
    '#type' => 'radios',
    '#title' => t('Show AdSense on specific pages'),
    '#default_value' => variable_get(ADSENSE_VISIBILITY, 0),
    '#options' => array(
      t('Show on every page except the listed pages.'),
      t('Show on only the listed pages.'),
    ),
  );
  $form['visibility']['adsense_access_pages'] = array(
    '#type' => 'textarea',
    '#title' => t('Pages'),
    '#default_value' => variable_get(ADSENSE_ACCESS_PAGES, ''),
    '#cols' => 70,
    '#rows' => 5,
    '#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>&lt;front&gt;</em>' is the front page."),
  );
  $form['click_tracking'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('Click tracking'),
  );
  $form['click_tracking'][ADSENSE_CLICK_TRACKING] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable AdSense click tracking?'),
    '#return_value' => 1,
    '#default_value' => variable_get(ADSENSE_CLICK_TRACKING, 0),
    '#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'),
    )),
  );
  $form['click_tracking'][ADSENSE_CLICK_TRACKING_NAME_RESOLVE] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable name resolution of IP addresses?'),
    '#return_value' => 1,
    '#default_value' => variable_get(ADSENSE_CLICK_TRACKING_NAME_RESOLVE, 0),
    '#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.'),
  );
  $form['search'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('AdSense Search'),
  );
  $form['search']['box'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => FALSE,
    '#title' => t('Search Box Options'),
    '#description' => t('Allows users to search the web or the specific site(s) of your choice. Enter the site\'s URL without the last \'/\''),
  );
  global $base_url;
  $form['search']['box'][ADSENSE_SEARCH_DOMAIN . '_0'] = array(
    '#type' => 'textfield',
    '#field_prefix' => 'http://',
    '#default_value' => variable_get(str_replace('http://', '', ADSENSE_SEARCH_DOMAIN . '_0'), str_replace('http://', '', $base_url)),
    '#size' => 32,
    '#maxlength' => 255,
  );
  $form['search']['box'][ADSENSE_SEARCH_DOMAIN . '_1'] = array(
    '#type' => 'textfield',
    '#field_prefix' => 'http://',
    '#default_value' => variable_get(str_replace('http://', '', ADSENSE_SEARCH_DOMAIN . '_1'), ''),
    '#size' => 32,
    '#maxlength' => 255,
  );
  $form['search']['box'][ADSENSE_SEARCH_DOMAIN . '_2'] = array(
    '#type' => 'textfield',
    '#field_prefix' => 'http://',
    '#default_value' => variable_get(str_replace('http://', '', ADSENSE_SEARCH_DOMAIN . '_2'), ''),
    '#size' => 32,
    '#maxlength' => 255,
  );
  $form['search']['box'][ADSENSE_SEARCH_LOGO] = array(
    '#type' => 'radios',
    '#title' => t('Logo Type'),
    '#default_value' => variable_get(ADSENSE_SEARCH_LOGO, ADSENSE_SEARCH_LOGO_GOOGLE),
    '#options' => array(
      ADSENSE_SEARCH_LOGO_GOOGLE => t('Google Logo'),
      ADSENSE_SEARCH_LOGO_ABOVE_TEXTBOX => t('Logo above text box'),
      ADSENSE_SEARCH_LOGO_ON_BUTTON => t('"Google Search" on button'),
    ),
  );
  $form['search']['box'][ADSENSE_SEARCH_BUTTON] = array(
    '#type' => 'checkbox',
    '#title' => t('Search button below text box'),
    '#return_value' => 1,
    '#default_value' => variable_get(ADSENSE_SEARCH_BUTTON, 0),
  );
  $box_background_color = variable_get(ADSENSE_SEARCH_COLOR_BOX_BACKGROUND, ADSENSE_SEARCH_COLOR_WHITE);
  $form['search']['box'][ADSENSE_SEARCH_COLOR_BOX_BACKGROUND] = array(
    '#type' => 'select',
    '#title' => t('Background Color'),
    '#default_value' => $box_background_color,
    '#options' => array(
      ADSENSE_SEARCH_COLOR_WHITE => t('White'),
      ADSENSE_SEARCH_COLOR_BLACK => t('Black'),
      ADSENSE_SEARCH_COLOR_GRAY => t('Gray'),
    ),
  );
  $box_text_color = variable_get(ADSENSE_SEARCH_COLOR_BOX_TEXT, ADSENSE_SEARCH_COLOR_BLACK);
  if ($box_background_color == ADSENSE_SEARCH_COLOR_BLACK) {
    $box_text_color = ADSENSE_SEARCH_COLOR_WHITE;
  }
  elseif ($box_background_color == ADSENSE_SEARCH_COLOR_WHITE) {
    $box_text_color = ADSENSE_SEARCH_COLOR_BLACK;
  }
  $form['search']['box'][ADSENSE_SEARCH_COLOR_BOX_TEXT] = array(
    '#type' => 'select',
    '#title' => t('Text Color'),
    '#default_value' => $box_text_color,
    '#options' => array(
      ADSENSE_SEARCH_COLOR_BLACK => t('Black'),
      ADSENSE_SEARCH_COLOR_WHITE => t('White'),
    ),
  );
  $form['search']['result'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t('Search Results Style'),
  );
  $form['search']['result'][ADSENSE_SEARCH_COUNTRY] = array(
    '#type' => 'select',
    '#title' => t('Country or territory for Google domain'),
    '#default_value' => variable_get(ADSENSE_SEARCH_COUNTRY, 'www.google.com'),
    '#options' => array(
      'www.google.co.uk' => t('United Kingdom'),
      'www.google.ca' => t('Canada'),
      'www.google.de' => t('Germany'),
      'www.google.co.jp' => t('Japan'),
      'www.google.fr' => t('France'),
      'www.google.com.au' => t('Australia'),
      'www.google.it' => t('Italy'),
      'www.google.at' => t('Austria'),
      'www.google.ch' => t('Switzerland'),
      'www.google.es' => t('Spain'),
      'www.google.nl' => t('Netherlands'),
      'www.google.be' => t('Belgium'),
      'www.google.dk' => t('Denmark'),
      'www.google.se' => t('Sweden'),
      'www.google.no' => t('Norway'),
      'www.google.com.br' => t('Brazil'),
      'www.google.pt' => t('Portugal'),
      'www.google.fi' => t('Finland'),
      'www.google.co.kr' => t('South Korea'),
      'www.google.cn' => t('China'),
      'www.google.com.hk' => t('Hong Kong'),
      'www.google.com.tw' => t('Taiwan'),
      'www.google.com.sg' => t('Singapore'),
      'www.google.com.af' => t('Afghanistan'),
      'www.google.com' => t('Albania'),
      'www.google.com' => t('Algeria'),
      'www.google.as' => t('American Samoa'),
      'www.google.com' => t('Andorra'),
      'www.google.com' => t('Angola'),
      'www.google.off.ai' => t('Anguilla'),
      'www.google.com' => t('Antarctica'),
      'www.google.com.ag' => t('Antigua and Barbuda'),
      'www.google.com.ar' => t('Argentina'),
      'www.google.am' => t('Armenia'),
      'www.google.com' => t('Aruba'),
      'www.google.az' => t('Azerbaijan'),
      'www.google.bs' => t('Bahamas'),
      'www.google.com.bh' => t('Bahrain'),
      'www.google.com.bd' => t('Bangladesh'),
      'www.google.com' => t('Barbados'),
      'www.google.com' => t('Belarus'),
      'www.google.com.bz' => t('Belize'),
      'www.google.com' => t('Benin'),
      'www.google.com' => t('Bermuda'),
      'www.google.com' => t('Bhutan'),
      'www.google.com.bo' => t('Bolivia'),
      'www.google.ba' => t('Bosnia and Herzegovina'),
      'www.google.co.bw' => t('Botswana'),
      'www.google.com' => t('Bouvet Island'),
      'www.google.com' => t('British Indian Ocean Territory'),
      'www.google.com.bn' => t('Brunei Darussalam'),
      'www.google.bg' => t('Bulgaria'),
      'www.google.com' => t('Burkina Faso'),
      'www.google.bi' => t('Burundi'),
      'www.google.com.kh' => t('Cambodia'),
      'www.google.com' => t('Cameroon'),
      'www.google.com' => t('Cape Verde'),
      'www.google.com' => t('Cayman Islands'),
      'www.google.com' => t('Central African Republic'),
      'www.google.com' => t('Chad'),
      'www.google.cl' => t('Chile'),
      'www.google.com' => t('Christmas Island'),
      'www.google.com' => t('Cocos (Keeling) Islands'),
      'www.google.com.co' => t('Colombia'),
      'www.google.com' => t('Comoros'),
      'www.google.cg' => t('Congo'),
      'www.google.cd' => t('Congo, Democratic Republic'),
      'www.google.co.ck' => t('Cook Islands'),
      'www.google.co.cr' => t('Costa Rica'),
      'www.google.ci' => t('Cote d&#39;Ivoire'),
      'www.google.hr' => t('Croatia'),
      'www.google.com.cu' => t('Cuba'),
      'www.google.com' => t('Cyprus'),
      'www.google.cz' => t('Czech Republic'),
      'www.google.dj' => t('Djibouti'),
      'www.google.dm' => t('Dominica'),
      'www.google.com.do' => t('Dominican Republic'),
      'www.google.tp' => t('East Timor'),
      'www.google.com.ec' => t('Ecuador'),
      'www.google.com.eg' => t('Egypt'),
      'www.google.com.sv' => t('El Salvador'),
      'www.google.com' => t('Equatorial Guinea'),
      'www.google.com' => t('Eritrea'),
      'www.google.ee' => t('Estonia'),
      'www.google.com.et' => t('Ethiopia'),
      'www.google.com' => t('Falkland Islands (Malvinas)'),
      'www.google.com' => t('Faroe Islands'),
      'www.google.com.fj' => t('Fiji'),
      'www.google.com' => t('French Guiana'),
      'www.google.com' => t('French Polynesia'),
      'www.google.com' => t('French Southern Territories'),
      'www.google.com' => t('Gabon'),
      'www.google.gm' => t('Gambia'),
      'www.google.ge' => t('Georgia'),
      'www.google.com' => t('Ghana'),
      'www.google.com.gi' => t('Gibraltar'),
      'www.google.gr' => t('Greece'),
      'www.google.gl' => t('Greenland'),
      'www.google.com' => t('Grenada'),
      'www.google.gp' => t('Guadeloupe'),
      'www.google.com' => t('Guam'),
      'www.google.com.gt' => t('Guatemala'),
      'www.google.com' => t('Guinea'),
      'www.google.com' => t('Guinea-Bissau'),
      'www.google.gy' => t('Guyana'),
      'www.google.ht' => t('Haiti'),
      'www.google.com' => t('Heard and McDonald Islands'),
      'www.google.hn' => t('Honduras'),
      'www.google.hu' => t('Hungary'),
      'www.google.is' => t('Iceland'),
      'www.google.co.in' => t('India'),
      'www.google.co.id' => t('Indonesia'),
      'www.google.com' => t('Iran'),
      'www.google.com' => t('Iraq'),
      'www.google.ie' => t('Ireland'),
      'www.google.co.il' => t('Israel'),
      'www.google.com.jm' => t('Jamaica'),
      'www.google.jo' => t('Jordan'),
      'www.google.kz' => t('Kazakhstan'),
      'www.google.co.ke' => t('Kenya'),
      'www.google.ki' => t('Kiribati'),
      'www.google.com' => t('Kuwait'),
      'www.google.kg' => t('Kyrgyzstan'),
      'www.google.la' => t('Lao People&#39;s Democratic Republic'),
      'www.google.lv' => t('Latvia'),
      'www.google.com' => t('Lebanon'),
      'www.google.co.ls' => t('Lesotho'),
      'www.google.com' => t('Liberia'),
      'www.google.com.ly' => t('Libya'),
      'www.google.li' => t('Liechtenstein'),
      'www.google.lt' => t('Lithuania'),
      'www.google.lu' => t('Luxembourg'),
      'www.google.com' => t('Macau'),
      'www.google.com' => t('Macedonia'),
      'www.google.com' => t('Madagascar'),
      'www.google.mw' => t('Malawi'),
      'www.google.com.my' => t('Malaysia'),
      'www.google.mv' => t('Maldives'),
      'www.google.com' => t('Mali'),
      'www.google.com.mt' => t('Malta'),
      'www.google.com' => t('Marshall Islands'),
      'www.google.com' => t('Martinique'),
      'www.google.com' => t('Mauritania'),
      'www.google.mu' => t('Mauritius'),
      'www.google.com' => t('Mayotte'),
      'www.google.com.mx' => t('Mexico'),
      'www.google.fm' => t('Micronesia'),
      'www.google.md' => t('Moldova'),
      'www.google.com' => t('Monaco'),
      'www.google.mn' => t('Mongolia'),
      'www.google.ms' => t('Montserrat'),
      'www.google.co.ma' => t('Morocco'),
      'www.google.com' => t('Mozambique'),
      'www.google.com' => t('Myanmar'),
      'www.google.com.na' => t('Namibia'),
      'www.google.nr' => t('Nauru'),
      'www.google.com.np' => t('Nepal'),
      'www.google.com' => t('Netherlands Antilles'),
      'www.google.com' => t('New Caledonia'),
      'www.google.co.nz' => t('New Zealand'),
      'www.google.com.ni' => t('Nicaragua'),
      'www.google.com' => t('Niger'),
      'www.google.com.ng' => t('Nigeria'),
      'www.google.nu' => t('Niue'),
      'www.google.com.nf' => t('Norfolk Island'),
      'www.google.com' => t('Northern Mariana Islands'),
      'www.google.com' => t('North Korea'),
      'www.google.com.om' => t('Oman'),
      'www.google.com.pk' => t('Pakistan'),
      'www.google.com' => t('Palau'),
      'www.google.com' => t('Palestinian Territory'),
      'www.google.com.pa' => t('Panama'),
      'www.google.com' => t('Papua New Guinea'),
      'www.google.com.py' => t('Paraguay'),
      'www.google.com.pe' => t('Peru'),
      'www.google.com.ph' => t('Philippines'),
      'www.google.pn' => t('Pitcairn'),
      'www.google.pl' => t('Poland'),
      'www.google.com.pr' => t('Puerto Rico'),
      'www.google.com.qa' => t('Qatar'),
      'www.google.com' => t('Reunion'),
      'www.google.ro' => t('Romania'),
      'www.google.ru' => t('Russian Federation'),
      'www.google.rw' => t('Rwanda'),
      'www.google.com' => t('Saint Kitts and Nevis'),
      'www.google.com' => t('Saint Lucia'),
      'www.google.com.vc' => t('Saint Vincent and the Grenadines'),
      'www.google.ws' => t('Samoa'),
      'www.google.sm' => t('San Marino'),
      'www.google.st' => t('Sao Tome and Principe'),
      'www.google.com.sa' => t('Saudi Arabia'),
      'www.google.sn' => t('Senegal'),
      'www.google.com' => t('Serbia and Montenegro'),
      'www.google.sc' => t('Seychelles'),
      'www.google.com' => t('Sierra Leone'),
      'www.google.sk' => t('Slovakia'),
      'www.google.si' => t('Slovenia'),
      'www.google.com.sb' => t('Solomon Islands'),
      'www.google.com' => t('Somalia'),
      'www.google.co.za' => t('South Africa'),
      'www.google.com' => t('South Georgia and The South Sandwich Islands'),
      'www.google.lk' => t('Sri Lanka'),
      'www.google.sh' => t('St. Helena'),
      'www.google.com' => t('St. Pierre and Miquelon'),
      'www.google.com' => t('Sudan'),
      'www.google.com' => t('Suriname'),
      'www.google.com' => t('Svalbard and Jan Mayen Islands'),
      'www.google.com' => t('Swaziland'),
      'www.google.com' => t('Syria'),
      'www.google.com.tj' => t('Tajikistan'),
      'www.google.com' => t('Tanzania'),
      'www.google.co.th' => t('Thailand'),
      'www.google.com' => t('Togo'),
      'www.google.tk' => t('Tokelau'),
      'www.google.to' => t('Tonga'),
      'www.google.tt' => t('Trinidad and Tobago'),
      'www.google.com' => t('Tunisia'),
      'www.google.com.tr' => t('Turkey'),
      'www.google.tm' => t('Turkmenistan'),
      'www.google.com' => t('Turks and Caicos Islands'),
      'www.google.com' => t('Tuvalu'),
      'www.google.co.ug' => t('Uganda'),
      'www.google.com.ua' => t('Ukraine'),
      'www.google.ae' => t('United Arab Emirates'),
      'www.google.com' => t('United States Minor Outlying Islands'),
      'www.google.com.uy' => t('Uruguay'),
      'www.google.co.uz' => t('Uzbekistan'),
      'www.google.vu' => t('Vanuatu'),
      'www.google.com' => t('Vatican'),
      'www.google.co.ve' => t('Venezuela'),
      'www.google.com.vn' => t('Viet Nam'),
      'www.google.vg' => t('Virgin Islands (British)'),
      'www.google.co.vi' => t('Virgin Islands (U.S.)'),
      'www.google.com' => t('Wallis and Futuna Islands'),
      'www.google.com' => t('Western Sahara'),
      'www.google.com' => t('Yemen'),
      'www.google.co.zm' => t('Zambia'),
      'www.google.co.zw' => t('Zimbabwe'),
      'www.google.com' => t('United States'),
    ),
  );
  $form['search']['box'][ADSENSE_SEARCH_LANGUAGE] = array(
    '#type' => 'select',
    '#title' => t('Site Language'),
    '#default_value' => variable_get(ADSENSE_SEARCH_LANGUAGE, 'en'),
    '#options' => array(
      'ar' => t('Arabic'),
      'bg' => t('Bulgarian'),
      'zh-CN' => t('Chinese (simplified)'),
      'zh-TW' => t('Chinese (traditional)'),
      'hr' => t('Croatian'),
      'cs' => t('Czech'),
      'da' => t('Danish'),
      'nl' => t('Dutch'),
      'en' => t('English'),
      'fi' => t('Finnish'),
      'fr' => t('French'),
      'de' => t('German'),
      'el' => t('Greek'),
      'iw' => t('Hebrew'),
      'hu' => t('Hungarian'),
      'in' => t('Indonesian'),
      'it' => t('Italian'),
      'ja' => t('Japanese'),
      'ko' => t('Korean'),
      'no' => t('Norwegian'),
      'pl' => t('Polish'),
      'pt' => t('Portuguese'),
      'ro' => t('Romanian'),
      'ru' => t('Russian'),
      'sk' => t('Slovak'),
      'es' => t('Spanish'),
      'sv' => t('Swedish'),
      'tr' => t('Turkish'),
    ),
  );
  $form['search']['box'][ADSENSE_SEARCH_ENCODING] = array(
    '#type' => 'select',
    '#title' => t('Site Encoding'),
    '#default_value' => variable_get(ADSENSE_SEARCH_ENCODING, 'UTF-8'),
    '#options' => array(
      'ISO-8859-1' => t('West European Latin-1 (ISO-8859-1)'),
      'ISO-8859-15' => t('West European Latin-9 (ISO-8859-15)'),
      'windows-1252' => t('Western (Windows-1252)'),
      'ISO-8859-10' => t('Nordic Latin-6 (ISO-8859-10)'),
      'ISO-8859-7' => t('Greek (ISO-8859-7)'),
      'Shift_JIS' => t('Japanese (Shift_JIS)'),
      'EUC-JP' => t('Japanese (EUC-JP)'),
      'ISO-2022-JP' => t('Japanese (ISO-2022-JP)'),
      'GB2312' => t('Chinese Simplified (GB2312)'),
      'GB18030' => t('Chinese Simplified (GB18030)'),
      'big5' => t('Chinese Traditional (Big5)'),
      'EUC-KR' => t('Korean (EUC-KR)'),
      'windows-874' => t('Thai (Windows-874)'),
      'windows-1258' => t('Vietnamese (Windows-1258)'),
      'ISO-8859-2' => t('Central European Latin-2 (ISO-8859-2)'),
      'windows-1250' => t('Central European (Windows-1250)'),
      'cp852' => t('Central European (CP852)'),
      'ISO-8859-9' => t('Turkish Latin-5 (ISO-8859-9)'),
      'windows-1254' => t('Turkish (Windows-1254)'),
      'ISO-8859-3' => t('South European Latin-3 (ISO-8859-3)'),
      'ISO-8859-8-I' => t('Hebrew (ISO-8859-8-I)'),
      'windows-1255' => t('Hebrew (Windows-1255)'),
      'windows-1256' => t('Arabic (Windows-1256)'),
      'ISO-8859-5' => t('Cyrillic (ISO-8859-5)'),
      'KOI8-R' => t('Cyrillic (KOI8-R)'),
      'windows-1251' => t('Cyrillic (Windows-1251)'),
      'cp-866' => t('Cyrillic/Russian (CP-866)'),
      'UTF-8' => t('Unicode (UTF-8)'),
    ),
  );
  $textbox_length = $textbox_length > 64 ? 64 : variable_get(ADSENSE_SEARCH_TEXTBOX_LENGTH, 15);
  $form['search']['box'][ADSENSE_SEARCH_TEXTBOX_LENGTH] = array(
    '#type' => 'textfield',
    '#title' => t('Length of text box (Max 64): '),
    '#default_value' => $textbox_length,
    '#size' => 2,
    '#maxlength' => 2,
  );
  $form['search']['result'][ADSENSE_SEARCH_FRAME_WIDTH] = array(
    '#type' => 'textfield',
    '#title' => t('Width of results area'),
    '#default_value' => variable_get(ADSENSE_SEARCH_FRAME_WIDTH, 500),
    '#size' => 3,
    '#maxlength' => 3,
  );
  $form['advanced'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#collapsed' => true,
    '#title' => t('Advanced options'),
  );
  $form['advanced'][ADSENSE_TEST_MODE] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable test mode?'),
    '#return_value' => 1,
    '#default_value' => variable_get(ADSENSE_TEST_MODE, 0),
    '#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.'),
  );
  $form['advanced'][ADSENSE_DISABLE] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable Google AdSense ads?'),
    '#return_value' => 1,
    '#default_value' => variable_get(ADSENSE_DISABLE, 0),
    '#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.'),
  );
  $form['advanced'][ADSENSE_PLACEHOLDER] = array(
    '#type' => 'checkbox',
    '#title' => t('Placeholder when ads are disabled?'),
    '#return_value' => 1,
    '#default_value' => variable_get(ADSENSE_PLACEHOLDER, 1),
    '#description' => t('This causes an empty box to be displayed in place of the ads when they are disabled.'),
  );
  $form['advanced'][ADSENSE_PLACEHOLDER_TEXT] = array(
    '#type' => 'textarea',
    '#title' => t('Placeholder text to display'),
    '#default_value' => variable_get(ADSENSE_PLACEHOLDER_TEXT, t('Google AdSense')),
    '#cols' => 70,
    '#rows' => 3,
    '#description' => t('Enter any text to display as a placeholder when ads are disabled.'),
  );
  $form['advanced'][ADSENSE_SECTION_TARGETING] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable AdSense section targeting?'),
    '#return_value' => 1,
    '#default_value' => variable_get(ADSENSE_SECTION_TARGETING, 1),
    '#description' => t('This better targets Google ads to the teaser and body of nodes.'),
  );
  return system_settings_form($form);
}