summaryrefslogtreecommitdiff
path: root/modules/system.module
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-04-14 20:30:08 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-04-14 20:30:08 +0000
commit2f927f14b76f4ba89a2743af6e9cebce43288437 (patch)
treeec4f9d7e50e2cee276597aebe823e0b64a961855 /modules/system.module
parentfb580ade439a1903f1355f447e5e3d167cfb1a65 (diff)
downloadbrdo-2f927f14b76f4ba89a2743af6e9cebce43288437.tar.gz
brdo-2f927f14b76f4ba89a2743af6e9cebce43288437.tar.bz2
#58330: Fix inconsistent theme selector code
Diffstat (limited to 'modules/system.module')
-rw-r--r--modules/system.module82
1 files changed, 55 insertions, 27 deletions
diff --git a/modules/system.module b/modules/system.module
index 0ea7f9c8c..662a6cd7f 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -167,32 +167,9 @@ function system_test_clean_url($form_id) {
* Allows users to individually set their theme and time zone.
*/
function system_user($type, $edit, &$user, $category = NULL) {
- if ($type == 'form' && $category == 'account') {
- if (user_access('select different theme')) {
- $themes = array_filter(list_themes(), create_function('$theme', 'return $theme->status;'));
-
- if (count($themes) > 1) {
- ksort($themes);
-
- $form['themes'] = array(
- '#type' => 'fieldset', '#title' => t('Theme configuration'), '#description' => t('Selecting a different theme will change the look and feel of the site.'), '#weight' => 2, '#collapsible' => TRUE, '#theme' => 'system_user');
-
- foreach ($themes 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' => $edit['theme'] ? $edit['theme'] : '');
- }
- }
-
+ if ($type == 'form' && $category == 'account') {
+ $form['theme_select'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the site.'), $edit['theme'], 2);
+
if (variable_get('configurable_timezones', 1)) {
$zones = _system_zonelist();
$form['timezone'] = array('#type'=>'fieldset', '#title' => t('Locale settings'), '#weight' => 6);
@@ -201,11 +178,62 @@ function system_user($type, $edit, &$user, $category = NULL) {
'#options' => $zones, '#description' => t('Select your current local time. Dates and times throughout this site will be displayed using this time zone.')
);
}
+
return $form;
}
}
-function theme_system_user($form) {
+/*
+ * Returns a fieldset containing the theme select form.
+ *
+ * @param $description
+ * description of the fieldset
+ * @param $default_value
+ * default value of theme radios
+ * @param $weight
+ * weight of the fieldset
+ * @return
+ * a form array
+ */
+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;
+ }
+ }
+}
+
+function theme_system_theme_select_form($form) {
foreach (element_children($form) as $key) {
$row = array();
if (is_array($form[$key]['description'])) {