| 1 |
<?php
|
| 2 |
// $Id: switchtheme.admin.inc,v 1.1 2008/09/18 23:16:50 sun Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Switchtheme administration functions.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Form builder function for theme settings; menu callback.
|
| 11 |
*/
|
| 12 |
function switchtheme_admin_settings() {
|
| 13 |
$options = switchtheme_options();
|
| 14 |
foreach ($options as $option) {
|
| 15 |
$form['switchtheme']['switchtheme_'. $option] = array(
|
| 16 |
'#type' => 'textfield',
|
| 17 |
'#title' => $option,
|
| 18 |
'#default_value' => variable_get('switchtheme_'. $option, drupal_ucfirst($option)),
|
| 19 |
);
|
| 20 |
}
|
| 21 |
return system_settings_form($form);
|
| 22 |
}
|
| 23 |
|
| 24 |
/**
|
| 25 |
* Form builder function for browser settings; menu callback.
|
| 26 |
*/
|
| 27 |
function switchtheme_admin_browser_settings() {
|
| 28 |
$form = array();
|
| 29 |
$form['switchtheme_browser_enabled'] = array(
|
| 30 |
'#type' => 'checkbox',
|
| 31 |
'#title' => t('Browser-based theme switching'),
|
| 32 |
'#description' => t('If enabled, the theme will be switched based on the browser of a visitor.'),
|
| 33 |
'#default_value' => variable_get('switchtheme_browser_enabled', FALSE),
|
| 34 |
);
|
| 35 |
|
| 36 |
$themes = switchtheme_select();
|
| 37 |
$themes['default'] = 'Default';
|
| 38 |
$useragents = array();
|
| 39 |
$result = db_query('SELECT data FROM {browscap}');
|
| 40 |
while ($row = db_fetch_object($result)) {
|
| 41 |
$data = $row->data;
|
| 42 |
$data = unserialize($data);
|
| 43 |
if (isset($data['parent'])) {
|
| 44 |
$useragents[trim($data['parent'])][] = isset($data['platform']) ? $data['platform'] : '';
|
| 45 |
}
|
| 46 |
}
|
| 47 |
$form['switchtheme_browser'] = array(
|
| 48 |
'#type' => 'fieldset',
|
| 49 |
'#title' => t('Browsers'),
|
| 50 |
'#collapsible' => FALSE,
|
| 51 |
'#collapsed' => FALSE,
|
| 52 |
);
|
| 53 |
foreach ($useragents as $parent => $platforms) {
|
| 54 |
$form['switchtheme_browser']['switchtheme_browser_'. md5($parent)] = array(
|
| 55 |
'#type' => 'select',
|
| 56 |
'#title' => $parent,
|
| 57 |
'#options' => $themes,
|
| 58 |
'#default_value' => variable_get('switchtheme_browser_'. md5($parent), 'default'),
|
| 59 |
);
|
| 60 |
}
|
| 61 |
return system_settings_form($form);
|
| 62 |
}
|
| 63 |
|