You are here

function yr_verdata_settings in Yr Weatherdata 6

Same name and namespace in other branches
  1. 6.2 yr_verdata.admin.inc \yr_verdata_settings()
  2. 7.3 yr_verdata.admin.inc \yr_verdata_settings()
  3. 7 yr_verdata.admin.inc \yr_verdata_settings()

The administrative settings form.

Return value

Returns a form array, processed by system_settings_form().

1 string reference to 'yr_verdata_settings'
yr_verdata_menu in ./yr_verdata.module
Implementation of hook_menu().

File

./yr_verdata.module, line 444
yr_verdata.module This file provides the yr_verdata forecast module.

Code

function yr_verdata_settings() {

  // Make sure that the file directory exists.
  $local_dir = file_directory_path() . '/yr_verdata';
  file_check_directory($local_dir, 1);

  // Set up the form.
  $form['yr_verdata_settings'] = array(
    '#prefix' => '<div id="yr-admin-settings">',
    '#suffix' => '</div>',
  );
  $form['yr_verdata_settings']['yr_verdata_lang'] = array(
    '#type' => 'select',
    '#title' => t('Default language'),
    '#options' => array(
      'place' => t('English'),
      'sted' => t('Norwegian Bokmål'),
      'stad' => t('Norwegian Nynorsk'),
    ),
    '#default_value' => variable_get('yr_verdata_lang', 'place'),
    '#description' => t('Note that for locations in mainland Norway, a text forecast is included, and this is only supplied in Norwegian.'),
  );
  $form['yr_verdata_settings']['yr_verdata_maxage'] = array(
    '#type' => 'select',
    '#title' => t('Maximum age of XML files'),
    '#options' => array(
      1 => t('Always update (debugging only)'),
      900 => t('15 minutes'),
      3600 => t('One hour'),
      10800 => t('Three hours'),
      21600 => t('Six hours'),
      43200 => t('12 hours'),
      86400 => t('24 hours'),
    ),
    '#default_value' => variable_get('yr_verdata_maxage', 21600),
    '#description' => t('Setting a value less than 3 hours is probably useless, since the forecast is not updated that often at yr.no. 3 hours should be plenty to keep your site up to date while avoiding unneccessary server load.'),
  );
  $form['yr_verdata_settings']['yr_verdata_order'] = array(
    '#type' => 'select',
    '#title' => t('Default sort order'),
    '#options' => array(
      'location' => t('Location name'),
      'subregion' => t('Subregion/municipality'),
      'region' => t('Region/state/county'),
      'country' => t('Country/continent'),
    ),
    '#default_value' => variable_get('yr_verdata_order', 'subregion'),
  );
  $form['yr_verdata_settings']['yr_verdata_display_countryname'] = array(
    '#type' => 'radios',
    '#title' => t('Show the region and country name in listings'),
    '#options' => array(
      'on' => t('On'),
      'off' => t('Off'),
    ),
    '#default_value' => variable_get('yr_verdata_display_countryname', 'off'),
  );
  $form['yr_verdata_settings']['yr_verdata_multiblock'] = array(
    '#type' => 'radios',
    '#title' => t('Multiple blocks'),
    '#options' => array(
      'on' => t('On'),
      'off' => t('Off'),
    ),
    '#default_value' => variable_get('yr_verdata_multiblock', 'off'),
    '#description' => t('Yr verdata provides one block, listing all locations. If you want to, it can additionally provide one block for each location. Note that this may look cluttered, so it can be a good idea to use page-specific settings for these blocks.'),
  );
  $form['yr_verdata_settings']['yr_jquery_ui_version'] = array(
    '#type' => 'radios',
    '#title' => t('jQuery UI version'),
    '#options' => array(
      '16' => t('jQuery UI 1.6 and jQuery 1.2.x'),
      '17' => t('jQuery UI 1.7 and jQuery 1.3.x'),
    ),
    '#default_value' => variable_get('yr_jquery_ui_version', '17'),
    '#description' => t('If you are using !jquery_update with <em>jQuery 1.3.x</em>, you should use <em>jQuery UI 1.7</em>. Otherwise, use <em>jQuery UI 1.6</em> (this will work with the default jQuery version shipped with Drupal).', array(
      '!jquery_ui' => l('jQuery UI', 'http://drupal.org/project/jquery_ui'),
      '!jquery_update' => l('the jQuery update module', 'http://drupal.org/project/jquery_update'),
    )),
  );
  $form = system_settings_form($form);
  unset($form['#submit']);
  $form['#submit'][] = 'yr_verdata_settings_submit';
  return $form;
}