function yr_verdata_settings in Yr Weatherdata 6.2
Same name and namespace in other branches
- 6 yr_verdata.module \yr_verdata_settings()
- 7.3 yr_verdata.admin.inc \yr_verdata_settings()
- 7 yr_verdata.admin.inc \yr_verdata_settings()
Administrative settings for yr_verdata.
Return value
Returns a form array to be processed by drupal_get_form().
1 string reference to 'yr_verdata_settings'
- yr_verdata_menu in ./
yr_verdata.module - Implementation of hook_menu()
File
- ./
yr_verdata.admin.inc, line 14 - This file contains the functions for the admin interface for yr_verdata.
Code
function yr_verdata_settings($form) {
$form = array();
$form['yc'] = array(
'#type' => 'fieldset',
'#title' => t('Forecast customization'),
'#description' => t('Choose the default formats and unit types you want to display the forecasts in.'),
'#collapsible' => TRUE,
);
// Set up dates. This is more awkward in D6 than D7, so w'ell have to make do with what we can.
/* $available_date_types = array('small', 'medium', 'large');
$date_options = array();
foreach ($available_date_types as $type) {
$date_options[$type] = format_date(time(), $type);
}
$form['yc']['yr_verdata_date_format'] = array(
'#type' => 'select',
'#title' => t('Date format'),
'#options' => $date_options,
'#default_value' => variable_get('yr_verdata_date_format', 'small'),
'#description' => t('These formats can be managed at !datetime.', array('!datetime' => l('admin/settings/date-time', 'admin/settings/date-time'))),
);*/
$form['yc']['yr_verdata_temp_unit'] = array(
'#type' => 'select',
'#title' => t('Temperature unit'),
'#options' => array(
'celsius' => t('Celsius'),
'fahrenheit' => t('Fahrenheit'),
'kelvin' => t('Kelvin'),
),
'#default_value' => variable_get('yr_verdata_temp_unit', 'celsius'),
);
$form['yc']['yr_verdata_press_unit'] = array(
'#type' => 'select',
'#title' => t('Pressure unit'),
'#options' => drupal_map_assoc(array(
'hPa',
'bar',
'psi',
'inHg',
'torr',
)),
'#default_value' => variable_get('yr_verdata_press_unit', 'hPa'),
);
$form['yc']['yr_verdata_precip_unit'] = array(
'#type' => 'select',
'#title' => t('Precipitation unit'),
'#options' => drupal_map_assoc(array(
'mm',
'in',
)),
'#default_value' => variable_get('yr_verdata_precip_unit', 'mm'),
);
$form['yc']['yr_verdata_windspeed_unit'] = array(
'#type' => 'select',
'#title' => t('Wind speed unit'),
'#options' => array(
'm/s' => t('Meters per second'),
'knots' => t('Knots'),
'km/h' => t('Kilometers per hour'),
'mph' => t('Miles per hour'),
),
'#default_value' => variable_get('yr_verdata_windspeed_unit', 'mps'),
);
$form['yd'] = array(
'#type' => 'fieldset',
'#title' => t('Display options'),
'#collapsible' => TRUE,
);
$locreg = t('Location, Region');
$loccoun = t('Location, Country');
$form['yd']['yr_verdata_name_display'] = array(
'#type' => 'select',
'#title' => t('Location name format'),
'#options' => array(
4 => t('Location'),
2 => $locreg,
1 => $loccoun,
),
'#default_value' => variable_get('yr_verdata_name_display', 1),
'#description' => t('How the location name should be output in page titles and listings. Note that if you set this to %locreg and the location name is the same as the region name, the output will use a fallback.', array(
'%locreg' => $locreg,
)),
);
$form['yd']['yr_verdata_name_fallback'] = array(
'#type' => 'select',
'#title' => t('Location name fallback'),
'#options' => array(
4 => t('Just the location name'),
1 => $loccoun,
),
'#default_value' => variable_get('yr_verdata_name_fallback', 4),
'#description' => t('How the location name fallback should work.'),
);
$form['yd']['yr_verdata_order'] = array(
'#type' => 'select',
'#title' => t('Sorting'),
'#options' => array(
'name' => t('Name'),
'weight' => t('Weight'),
),
'#default_value' => variable_get('yr_verdata_order', 'weight'),
'#description' => t('How to sort locations in the block and overview page.'),
);
$form['yd']['yr_verdata_group'] = array(
'#type' => 'select',
'#title' => t('Grouping'),
'#options' => array(
'off' => t('No grouping'),
'region' => t('Region'),
'country' => t('Country'),
'lang' => t('Language'),
),
'#default_value' => variable_get('yr_verdata_group', 'off'),
'#description' => t('Locations can be grouped according to region, country or the language the forecast is collected in.'),
);
$form['yd']['yr_verdata_npp'] = array(
'#type' => 'textfield',
'#size' => 3,
'#title' => t('Paging'),
'#default_value' => variable_get('yr_verdata_npp', 0),
'#description' => t('You can use a pager on the overview page if you have a lot of locations. Set the number for how many locations to display per page. Enter "0" for no pager.'),
);
$form['yd']['yr_verdata_multiblocks'] = array(
'#type' => 'radios',
'#title' => t('Multiple blocks'),
'#options' => array(
'on' => t('On'),
'off' => t('Off'),
),
'#default_value' => variable_get('yr_verdata_multiblocks', '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['yd']['yr_verdata_randomblock'] = array(
'#type' => 'radios',
'#title' => t('Random block'),
'#options' => array(
'on' => t('On'),
'off' => t('Off'),
),
'#default_value' => variable_get('yr_verdata_randomblock', 'off'),
'#description' => t('Yr verdata provides one block, listing all locations. If you want to, it can additionally provide a block that shows the forecast for a random location. Note that this will make a database query on each page load for the random select. This is a small request, but with VERY high traffic, it could be a potential performance issue. The generated output will be cached for each location. All the other blocks are cached before the database is queried, so they are not affected by this.'),
);
$form['yt'] = array(
'#type' => 'fieldset',
'#title' => t('Theming options'),
'#description' => t('A few options that can be used if you are making Yr weatherdata fit your theme. These values should only be altered if you know what you are doing and why you are doing them.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['yt']['yr_verdata_ui_css'] = array(
'#type' => 'radios',
'#title' => t('Yr CSS for jQuery UI'),
'#description' => t('Yr weatherdata comes with a little bit of CSS for the jQuery UI. If you have another jQuery UI theme for your entire site, you might want to disable this, to avoid conflicts and keep a consistent look.'),
'#default_value' => variable_get('yr_verdata_ui_css', 1),
'#options' => array(
1 => t('Enabled'),
0 => t('Disabled'),
),
);
$form['yt']['yr_verdata_symbol_url'] = array(
'#type' => 'textfield',
'#title' => t('Symbol image directory'),
'#description' => t("The absolute path to the directory where you keep your symbol images (including trailing slash). Note that they should be named according to yr.no's scheme, which is partially documented at !symdoc. You can also study the xml files to figure it out. Note that the implementation in this module is actually a theme function, so you could alter that one too, to entirely fit your own needs through a theme hook.", array(
'!symdoc' => l('api.yr.no', 'http://api.yr.no/weatherapi/weathericon/1.0/documentation'),
)),
'#default_value' => variable_get('yr_verdata_symbol_url', 'http://symbol.yr.no/grafikk/sym/b38/'),
);
$form['yt']['yr_verdata_wind_url'] = array(
'#type' => 'textfield',
'#title' => t('Wind arrow image directory'),
'#description' => t("The absolute path to the location where you keep or generate your wind arrow images (including trailing slash). Note that they should be named according to yr.no's scheme, which are auto-generated arrows based on speed and direction. This is not really documented, but you can check the source code in !module at around line 660 to see how I calculate it. Note that the implementation in this module is actually a theme function, so you could alter that one too, to entirely fit your own needs through a theme hook.", array(
'!module' => l('yr_verdata.module', 'http://drupalcode.org/viewvc/drupal/contributions/modules/yr_verdata/yr_verdata.module?view=markup&pathrev=DRUPAL-7--1'),
)),
'#default_value' => variable_get('yr_verdata_wind_url', 'http://fil.nrk.no/yr/grafikk/vindpiler/32/'),
);
$form['yr_verdata_maxage'] = array(
'#type' => 'select',
'#title' => t('Forecast maxage'),
'#options' => array(
0 => t('Always update (development only!)'),
3600 => t('One hour'),
10800 => t('Three hours'),
21600 => t('Six hours (recommended)'),
43200 => t('12 hours'),
86800 => t('24 hours'),
),
'#default_value' => variable_get('yr_verdata_maxage', 21600),
'#description' => t('The longest time that will pass before the module attempts to update the locally stored forecast with a new one from yr.no. Note that yr.no does not update most locations more often than every 5-6 hours. Yr.no will block ip-addresses that request forecasts too often.'),
);
$form['yr_verdata_debug'] = array(
'#type' => 'radios',
'#title' => t('Debug mode'),
'#options' => array(
0 => t('Off'),
1 => t('On'),
),
'#default_value' => variable_get('yr_verdata_debug', 0),
'#description' => t('Enabling debug mode will make this module write a <strong>lot</strong> of events to the log (watchdog). Only enable if you are in fact debugging.'),
);
return system_settings_form($form);
}