You are here

function system_theme_select_form in Drupal 4

Same name and namespace in other branches
  1. 5 modules/system/system.module \system_theme_select_form()
  2. 6 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.module
Implementation of hook_user().

File

modules/system.module, line 183
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')) {
    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;
    }
  }
}