| Versions | |
|---|---|
| 4.7 – 6 | system_theme_select_form($description = '', $default_value = '', $weight = 0) |
Returns a fieldset containing the theme select form.
$description description of the fieldset
$default_value default value of theme radios
$weight weight of the fieldset
a form array
modules/
<?php
function system_theme_select_form($description = '', $default_value = '', $weight = 0) {
if (user_access('select different theme')) {
foreach (list_themes() as $theme) {
if ($theme->status) {
$enabled[] = $theme;
}
}
if (count($enabled) > 1) {
ksort($enabled);
$form['themes'] = array(
'#type' => 'fieldset',
'#title' => t('Theme configuration'),
'#description' => $description,
'#collapsible' => TRUE,
'#theme' => 'system_theme_select_form',
);
foreach ($enabled as $info) {
// For the default theme, revert to an empty string so the user's theme updates when the site theme is changed.
$info->key = $info->name == variable_get('theme_default', 'bluemarine') ? '' : $info->name;
$info->screenshot = dirname($info->filename) . '/screenshot.png';
$screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot');
$form['themes'][$info->key]['screenshot'] = array(
'#type' => 'markup',
'#value' => $screenshot,
);
$form['themes'][$info->key]['description'] = array(
'#type' => 'item',
'#title' => $info->name,
'#value' => dirname($info->filename) . ($info->name == variable_get('theme_default', 'bluemarine') ? t('<br /> <em>(site default theme)</em>') : ''),
);
$options[$info->key] = '';
}
$form['themes']['theme'] = array(
'#type' => 'radios',
'#options' => $options,
'#default_value' => $default_value ? $default_value : '',
);
$form['#weight'] = $weight;
return $form;
}
}
}
?>