function themekey_ui_theme_build_select_form in ThemeKey 7.3
Same name and namespace in other branches
- 7 themekey_ui_admin.inc \themekey_ui_theme_build_select_form()
- 7.2 themekey_ui_admin.inc \themekey_ui_theme_build_select_form()
Internal function to add a theme selector to a form.
The API for contrib modules is provided by
Parameters
$form: form array
$title: title as string
$description: description as string
$weight: integer
$collapsed: boolean
$element_key: the name of form element
$themes: array of theme names to be provided as options in the select form
$add_default: boolean, TRUE if 'System default' should be be provided as options in the select form
$multiple: boolean, TRUE if multiple themes should be selectable
See also
themekey_ui_theme_select_form()
3 calls to themekey_ui_theme_build_select_form()
- themekey_ajax_settings_form in ./
themekey_admin.inc - Form builder for the ThemeKey ajax settings form.
- themekey_ui_settings_form in ./
themekey_ui_admin.inc - ThemeKey UI settings form
- themekey_ui_theme_select_form in ./
themekey_ui_admin.inc - Adds theme selector to a form.
File
- ./
themekey_ui_admin.inc, line 223
Code
function themekey_ui_theme_build_select_form(&$form, $title, $description, $default, $weight, $collapsed, $element_key, $themes, $add_default, $multiple = FALSE) {
$theme_options = themekey_theme_options();
$form['themekey_ui_themes'] = array(
'#type' => 'fieldset',
'#title' => check_plain($title),
'#description' => filter_xss($description),
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
'#theme' => 'themekey_ui_theme_select_form',
'#themekey_ui_theme_select_form_element_key' => $element_key,
);
if ($add_default) {
$form['themekey_ui_themes']['default']['screenshot'] = array();
$form['themekey_ui_themes']['default']['description'] = array(
'#type' => 'item',
'#markup' => 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 && array_key_exists($theme_key, $themes)) {
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', array(
'path' => $screenshot,
'width' => t('Screenshot for %theme theme', array(
'%theme' => $info->name,
)),
'height' => '',
'alt' => array(
'class' => 'screenshot',
),
'title' => FALSE,
)) : t('no screenshot');
$form['themekey_ui_themes'][$info->name]['screenshot'] = array(
'#markup' => $screenshot,
);
$form['themekey_ui_themes'][$info->name]['description'] = array(
'#type' => 'item',
'#title' => check_plain($info->info['name']),
'#markup' => dirname($info->filename),
);
}
$form['themekey_ui_themes'][$element_key] = array(
'#type' => $multiple ? 'checkboxes' : 'radios',
'#options' => $options,
'#default_value' => $default,
);
if (!is_null($weight)) {
$form['themekey_ui_themes']['#weight'] = $weight;
}
// REVIEW should we hardcode this here?
// SET GROUP FOR VERTICAL TABS
$form['themekey_ui_themes']['#group'] = 'additional_settings';
}