function system_theme_select_form in Drupal 6
Same name and namespace in other branches
- 4 modules/system.module \system_theme_select_form()
- 5 modules/system/system.module \system_theme_select_form()
Returns a fieldset containing the theme select form.
Parameters
$description: description of the fieldset
$default_value: default value of theme radios
$weight: weight of the fieldset
Return value
a form array
1 call to system_theme_select_form()
- system_user in modules/
system/ system.module - Implementation of hook_user().
1 string reference to 'system_theme_select_form'
- color_form_alter in modules/
color/ color.module - Implementation of hook_form_alter().
File
- modules/
system/ system.module, line 676 - Configuration system that lets administrators modify the workings of the site.
Code
function system_theme_select_form($description = '', $default_value = '', $weight = 0) {
if (user_access('select different theme')) {
$enabled = array();
$themes = list_themes();
foreach ($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', 'garland') ? '' : $info->name;
$screenshot = NULL;
$theme_key = $info->name;
while ($theme_key) {
if (file_exists($themes[$theme_key]->info['screenshot'])) {
$screenshot = $themes[$theme_key]->info['screenshot'];
break;
}
$theme_key = isset($themes[$theme_key]->info['base theme']) ? $themes[$theme_key]->info['base theme'] : NULL;
}
$screenshot = $screenshot ? theme('image', $screenshot, t('Screenshot for %theme theme', array(
'%theme' => $info->name,
)), '', array(
'class' => 'screenshot',
), FALSE) : t('no screenshot');
$form['themes'][$info->key]['screenshot'] = array(
'#value' => $screenshot,
);
$form['themes'][$info->key]['description'] = array(
'#type' => 'item',
'#title' => $info->name,
'#value' => dirname($info->filename) . ($info->name == variable_get('theme_default', 'garland') ? '<br /> <em>' . t('(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;
}
}
}