diff --git a/core/includes/module.inc b/core/includes/module.inc index b5c0240..935a003 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -177,7 +177,7 @@ function system_list($type) { // Drupal installations, which might have modules installed in different // locations in the file system. The ordering here must also be // consistent with the one used in module_implements(). - $result = db_query("SELECT * FROM {system} WHERE (type = 'theme' OR type = 'module') AND status = 1 ORDER BY weight ASC, name ASC"); + $result = db_query("SELECT * FROM {system} WHERE type IN ('module', 'theme') AND status = 1 ORDER BY weight ASC, name ASC"); foreach ($result as $record) { // Build a list of all enabled modules. if ($record->type == 'module') { diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 652fab9..fba800a 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -60,6 +60,9 @@ function theme_load($name) { * * @param $theme * The theme object to return the title for. + * + * This needs to be a private function to avoid clashing with a possible + * theme_menu_title() theme function by Menu or a potential Menu Title module. */ function _theme_menu_title($theme) { return check_plain($theme->info['name']); @@ -72,14 +75,9 @@ function _theme_menu_title($theme) { * Either the name of a theme or a full theme object. * * @return - * Boolean TRUE if the theme is enabled or is the site administration theme; - * FALSE otherwise. + * Boolean TRUE if the theme is enabled; FALSE otherwise. */ function drupal_theme_access($theme) { - // Early-return for potentially bogus '0', FALSE, or NULL values. - if (empty($theme)) { - return FALSE; - } if (is_object($theme)) { return !empty($theme->status); } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 4f5f0aa..7c60387 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -199,9 +199,14 @@ function block_menu_local_tasks_alter(&$data, $router_item, $root_path) { // default theme. $themes = list_themes(); $default_theme = variable_get('theme_default', 'stark'); - foreach ($data['tabs'][0] as &$tab) { - if (isset($tab['#link']['path']) && $tab['#link']['path'] == 'admin/structure/block/list/default') { - $tab['#link']['title'] = $themes[$default_theme]->info['name']; + foreach ($data['tabs'][0] as $i => &$tab) { + if (isset($tab['#link']['path'])) { + if ($tab['#link']['path'] == 'admin/structure/block/list/default') { + $tab['#link']['title'] = $themes[$default_theme]->info['name']; + } + elseif ($tab['#link']['path'] == 'admin/structure/block/list/%') { + $selected_theme_index = $i; + } } } @@ -214,8 +219,11 @@ function block_menu_local_tasks_alter(&$data, $router_item, $root_path) { } // If the current page shows the interface for a selected theme, then the // menu router item with the %theme argument will expose the selected - // theme already; do not duplicate that tab. + // theme already; do not duplicate that tab, but ensure it appears in a + // consistent order when switching between tabs. if ($theme->name === $selected_theme) { + $data['tabs'][0][] = $data['tabs'][0][$selected_theme_index]; + unset($data['tabs'][0][$selected_theme_index]); continue; } $data['tabs'][0][] = array( diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 0fa4062..c10566d 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -363,14 +363,17 @@ function system_theme_default() { /** * Form builder; display theme configuration for entire site and individual themes. * - * @param $key - * A theme name. + * @param $theme + * (optional) A theme object. + * * @return * The form structure. + * * @ingroup forms * @see system_theme_settings_submit() */ -function system_theme_settings($form, &$form_state, $key = '') { +function system_theme_settings($form, &$form_state, $theme = NULL) { + $key = !empty($theme) ? $theme->name : ''; // Default settings are defined in theme_get_setting() in includes/theme.inc if ($key) { $var = 'theme_' . $key . '_settings'; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index b6d4608..8c1c5f0 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -693,23 +693,21 @@ function system_menu() { 'file' => 'system.admin.inc', 'weight' => 20, ); - // Theme configuration subtabs. $items['admin/appearance/settings/global'] = array( 'title' => 'Global settings', 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -1, + 'weight' => -10, + ); + $items['admin/appearance/settings/%theme'] = array( + 'title' => 'Theme settings', + 'title callback' => '_theme_menu_title', + 'title arguments' => array(3), + 'page arguments' => array('system_theme_settings', 3), + 'access callback' => '_system_themes_access', + 'access arguments' => array(3), + 'type' => MENU_LOCAL_TASK, + 'file' => 'system.admin.inc', ); - - foreach (list_themes() as $key => $theme) { - $items['admin/appearance/settings/' . $theme->name] = array( - 'title' => $theme->info['name'], - 'page arguments' => array('system_theme_settings', $theme->name), - 'type' => MENU_LOCAL_TASK, - 'access callback' => '_system_themes_access', - 'access arguments' => array($key), - 'file' => 'system.admin.inc', - ); - } // Modules. $items['admin/modules'] = array( @@ -1120,6 +1118,41 @@ function system_menu() { } /** + * Implements hook_menu_local_tasks_alter(). + */ +function system_menu_local_tasks_alter(&$data, $router_item, $root_path) { + if ($root_path === 'admin/appearance/settings' || $root_path === 'admin/appearance/settings/%') { + // Expand the dynamic %theme argument into a tab for each theme. + foreach ($data['tabs'][1] as $i => $tab) { + if (isset($tab['#link']['path']) && $tab['#link']['path'] == 'admin/appearance/settings/%') { + $selected_theme_index = $i; + break; + } + } + $themes = list_themes(); + $selected_theme = isset($router_item['original_map'][3]) ? $router_item['original_map'][3] : NULL; + foreach ($themes as $theme) { + // If the current page shows the interface for a selected theme, then the + // menu router item with the %theme argument will expose the selected + // theme already; do not duplicate that tab, but ensure it appears in a + // consistent order when switching between tabs. + if ($theme->name === $selected_theme) { + $data['tabs'][1][] = $data['tabs'][1][$selected_theme_index]; + unset($data['tabs'][1][$selected_theme_index]); + continue; + } + $data['tabs'][1][] = array( + '#theme' => 'menu_local_task', + '#link' => array( + 'title' => $theme->info['name'], + 'href' => 'admin/appearance/settings/' . $theme->name, + ), + ); + } + } +} + +/** * Page callback; Execute cron tasks. * * @see system_cron_access().