=== modified file 'modules/system/system.admin.inc' --- modules/system/system.admin.inc 2009-11-03 05:27:18 +0000 +++ modules/system/system.admin.inc 2009-11-04 09:17:34 +0000 @@ -193,11 +193,8 @@ function system_settings_overview() { /** * Menu callback; displays a listing of all themes. - * - * @ingroup forms - * @see system_themes_form_submit() */ -function system_themes_form() { +function system_themes_page() { // Get current list of themes. $themes = system_rebuild_theme_data(); @@ -210,12 +207,16 @@ function system_themes_form() { uasort($themes, 'system_sort_modules_by_info_name'); - $status = array(); - $incompatible_core = array(); - $incompatible_php = array(); + $theme_default = variable_get('theme_default', 'garland'); + $theme_groups = array(); + + foreach ($themes as $key => $theme) { + + $admin_theme_options[$key] = $theme->name; + $theme->is_default = ($theme->name == $theme_default); - foreach ($themes as $theme) { - $screenshot = NULL; + // Identify theme screenshot. + $theme->screenshot = NULL; // Create a list which includes the current theme and all its base themes. if (isset($themes[$theme->name]->base_themes)) { $theme_keys = array_keys($themes[$theme->name]->base_themes); @@ -227,50 +228,56 @@ function system_themes_form() { // Look for a screenshot in the current theme or in its closest ancestor. foreach (array_reverse($theme_keys) as $theme_key) { if (isset($themes[$theme_key]) && file_exists($themes[$theme_key]->info['screenshot'])) { - $screenshot = $themes[$theme_key]->info['screenshot']; + $theme->screenshot = $themes[$theme_key]->info['screenshot']; break; } } - $screenshot = $screenshot ? theme('image', array('path' => $screenshot, 'alt' => t('Screenshot for %theme theme', array('%theme' => $theme->info['name'])), 'title' => '', 'attributes' => array('class' => array('screenshot')), 'getsize' => FALSE)) : t('no screenshot'); - - $form[$theme->name]['screenshot'] = array('#markup' => $screenshot); - $form[$theme->name]['info'] = array( - '#type' => 'value', - '#value' => $theme->info, - ); - $options[$theme->name] = $theme->info['name']; - $form[$theme->name]['operations'] = drupal_theme_access($theme) ? array('#type' => 'link', '#title' => t('configure'), '#href' => 'admin/appearance/settings/' . $theme->name) : array(); - - if (!empty($theme->status)) { - $status[] = $theme->name; + if (drupal_theme_access($theme)) { + $theme->operations = array( + l(t('Configure'), 'admin/appearance/settings/' . $theme->name), + l(t('Disable'), 'admin/appearance/disable/' . $theme->name), + ); + if (!$theme->is_default) { + $theme->operations[] = l(t('Set default'), 'admin/appearance/default/' . $theme->name); + } } else { - // Ensure this theme is compatible with this version of core. - // Require the 'content' region to make sure the main page - // content has a common place in all themes. - if (!isset($theme->info['core']) || ($theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) || (!isset($theme->info['regions']['content']))) { - $incompatible_core[] = $theme->name; - } - if (version_compare(phpversion(), $theme->info['php']) < 0) { - $incompatible_php[$theme->name] = $theme->info['php']; - } + $theme->operations = array( + l(t('Enable'), 'admin/appearance/enable/' . $theme->name), + l(t('Set default'), 'admin/appearance/default/' . $theme->name), + ); } + + if (empty($theme->status)) { + // Ensure this theme is compatible with this version of core. + // Require the 'content' region to make sure the main page + // content has a common place in all themes. + $theme->incompatible_core = !isset($theme->info['core']) || ($theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) || (!isset($theme->info['regions']['content'])); + $theme->incompatible_php = version_compare(phpversion(), $theme->info['php']) < 0; + } + + // Add notes to default and administration theme. + $theme->notes = array(); + $theme->classes = array(); + if ($theme->is_default) { + $theme->classes[] = 'theme-default'; + $theme->notes[] = t('default theme'); + } + + // Sort enabled and disabled themes into their own groups. + $theme_groups[$theme->status ? 'enabled' : 'disabled'][] = $theme; } - $form['status'] = array( - '#type' => 'checkboxes', - '#options' => array_fill_keys(array_keys($options), ''), - '#default_value' => $status, - '#incompatible_themes_core' => drupal_map_assoc($incompatible_core), - '#incompatible_themes_php' => $incompatible_php, - ); - $form['theme_default'] = array( - '#type' => 'radios', - '#options' => array_fill_keys(array_keys($options), ''), - '#default_value' => variable_get('theme_default', 'garland'), - ); + uasort($theme_groups['enabled'], 'system_sort_themes'); + $admin_form = drupal_get_form('system_themes_admin_form', $admin_theme_options); + return theme('system_themes_page', array('theme_groups' => $theme_groups)) . drupal_render($admin_form); +} +/** + * Form to select the administration theme. + */ +function system_themes_admin_form($form_state, $theme_options) { // Administration theme settings. $form['admin_theme'] = array( '#type' => 'fieldset', @@ -280,7 +287,7 @@ function system_themes_form() { ); $form['admin_theme']['admin_theme'] = array( '#type' => 'select', - '#options' => array(0 => t('Default theme')) + $options, + '#options' => array(0 => t('Default theme')) + $theme_options, '#title' => t('Administration theme'), '#description' => t('Choose "Default theme" to always use the same theme as the rest of the site.'), '#default_value' => variable_get('admin_theme', 0), @@ -290,12 +297,10 @@ function system_themes_form() { '#title' => t('Use the administration theme when editing or creating content'), '#default_value' => variable_get('node_admin_theme', '0'), ); - - $form['buttons']['submit'] = array( + $form['admin_theme']['submit'] = array( '#type' => 'submit', '#value' => t('Save configuration'), ); - return $form; } @@ -776,6 +781,19 @@ function system_sort_modules_by_info_nam } /** + * Array sorting callback; sorts modules or themes by their name. + */ +function system_sort_themes($a, $b) { + if ($a->is_default) { + return -1; + } + if ($b->is_default) { + return 1; + } + return strcasecmp($a->info['name'], $b->info['name']); +} + +/** * Build a table row for the system modules page. */ function _system_modules_build_row($info, $extra) { @@ -2395,61 +2413,57 @@ function theme_system_modules_uninstall( * * @param $variables * An associative array containing: - * - form: An associative array containing the structure of the form. + * - theme_groups: An associative array containing groups of themes. * * @ingroup themeable */ -function theme_system_themes_form($variables) { - $form = $variables['form']; +function theme_system_themes_page($variables) { + $theme_groups = $variables['theme_groups']; - foreach (element_children($form) as $key) { - // Only look for themes - if (!isset($form[$key]['info'])) { + $output = '