function themekey_ui_theme_select_form in ThemeKey 6.4
Same name and namespace in other branches
- 6.2 themekey_ui_admin.inc \themekey_ui_theme_select_form()
- 6.3 themekey_ui_admin.inc \themekey_ui_theme_select_form()
- 7.3 themekey_ui_admin.inc \themekey_ui_theme_select_form()
- 7 themekey_ui_admin.inc \themekey_ui_theme_select_form()
- 7.2 themekey_ui_admin.inc \themekey_ui_theme_select_form()
Adds theme selector to a form
Parameters
$form: form array
$title: title as string
$description: description as string
$weight: integer
$collapsed: boolean
See also
2 calls to themekey_ui_theme_select_form()
- themekey_ui_form_alter in ./
themekey_ui.module - Implements hook_form_alter().
- themekey_ui_pathalias in ./
themekey_ui_admin.inc - Adds theme select box to url alias form
File
- ./
themekey_ui_admin.inc, line 128
Code
function themekey_ui_theme_select_form(&$form, $title, $description, $default = 'default', $weight = NULL, $collapsed = TRUE) {
$themes = list_themes();
$theme_options = themekey_theme_options();
$form['themekey_ui_themes'] = array(
'#type' => 'fieldset',
'#title' => $title,
'#description' => $description,
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
'#theme' => 'themekey_ui_theme_select_form',
);
$form['themekey_ui_themes']['default']['screenshot'] = array();
$form['themekey_ui_themes']['default']['description'] = array(
'#type' => 'item',
'#value' => t("don't switch the theme"),
);
$options = array(
'default' => '',
);
foreach ($themes as $info) {
if (!array_key_exists($info->name, $theme_options)) {
continue;
}
$options[$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['themekey_ui_themes'][$info->name]['screenshot'] = array(
'#value' => $screenshot,
);
$form['themekey_ui_themes'][$info->name]['description'] = array(
'#type' => 'item',
'#title' => $info->info['name'],
'#value' => dirname($info->filename),
);
}
$form['themekey_ui_themes']['themekey_ui_theme'] = array(
'#type' => 'radios',
'#options' => $options,
'#default_value' => $default,
);
if (!is_null($weight)) {
$form['themekey_ui_themes']['#weight'] = $weight;
}
}