From b46bb8a13b4e05a1dd32854802a97a91f259632f Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Tue, 11 Dec 2012 00:17:32 +0800 Subject: [PATCH] Issue #943212: Change THEME_form_system_theme_settings_alter() to THEME_theme_config() --- core/modules/color/color.module | 2 +- .../color/lib/Drupal/color/Tests/ColorTest.php | 4 +- .../system/Tests/System/PageTitleFilteringTest.php | 2 +- .../lib/Drupal/system/Tests/System/ThemeTest.php | 6 +-- core/modules/system/system.admin.inc | 43 ++++++++++++---------- core/modules/system/system.module | 14 +++---- core/modules/system/theme.api.php | 4 +- 7 files changed, 39 insertions(+), 36 deletions(-) diff --git a/core/modules/color/color.module b/core/modules/color/color.module index 53a7f39..6bbbc6a 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -36,7 +36,7 @@ function color_theme() { /** * Implements hook_form_FORM_ID_alter(). */ -function color_form_system_theme_settings_alter(&$form, &$form_state) { +function color_form_system_theme_config_alter(&$form, &$form_state) { if (isset($form_state['build_info']['args'][0]) && ($theme = $form_state['build_info']['args'][0]) && color_get_info($theme) && function_exists('gd_info')) { $form['color'] = array( '#type' => 'details', diff --git a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php index d1f3b1e..ada8960 100644 --- a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php +++ b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php @@ -77,7 +77,7 @@ function testColor() { */ function _testColor($theme, $test_values) { variable_set('theme_default', $theme); - $settings_path = 'admin/appearance/settings/' . $theme; + $settings_path = 'admin/appearance/config/' . $theme; $this->drupalLogin($this->big_user); $this->drupalGet($settings_path); @@ -123,7 +123,7 @@ function _testColor($theme, $test_values) { */ function testValidColor() { variable_set('theme_default', 'bartik'); - $settings_path = 'admin/appearance/settings/bartik'; + $settings_path = 'admin/appearance/config/bartik'; $this->drupalLogin($this->big_user); $edit['scheme'] = ''; diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php index 7e89cf7..9153e1c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php @@ -100,7 +100,7 @@ function testTitleXSS() { 'toggle_main_menu' => TRUE, 'toggle_secondary_menu' => TRUE, ); - $this->drupalPost('admin/appearance/settings', $edit, t('Save configuration')); + $this->drupalPost('admin/appearance/config', $edit, t('Save configuration')); // Set title and slogan. $edit = array( diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php index 111e6b7..671cd27 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php @@ -80,7 +80,7 @@ function testThemeSettings() { 'default_logo' => FALSE, 'logo_path' => $input, ); - $this->drupalPost('admin/appearance/settings', $edit, t('Save configuration')); + $this->drupalPost('admin/appearance/config', $edit, t('Save configuration')); $this->assertNoText('The custom logo path is invalid.'); $this->assertFieldByName('logo_path', $expected['form']); @@ -142,7 +142,7 @@ function testThemeSettings() { // Absolute paths to any local file (even if it exists). drupal_realpath($file->uri), ); - $this->drupalGet('admin/appearance/settings'); + $this->drupalGet('admin/appearance/config'); foreach ($unsupported_paths as $path) { $edit = array( 'default_logo' => FALSE, @@ -158,7 +158,7 @@ function testThemeSettings() { 'logo_path' => '', 'files[logo_upload]' => drupal_realpath($file->uri), ); - $this->drupalPost('admin/appearance/settings', $edit, t('Save configuration')); + $this->drupalPost('admin/appearance/config', $edit, t('Save configuration')); $fields = $this->xpath($this->constructFieldXpath('name', 'logo_path')); $uploaded_filename = 'public://' . $fields[0]['value']; diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 5d6a70f..8b8d776 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -122,6 +122,10 @@ function system_themes_page() { $theme_groups = array(); $admin_theme = config('system.site')->get('admin_theme'); + $query = array( + 'token' => drupal_get_token('system-theme-operation-link'), + ); + foreach ($themes as &$theme) { if (!empty($theme->info['hidden'])) { continue; @@ -162,16 +166,15 @@ function system_themes_page() { // Confirm that the theme engine is available. $theme->incompatible_engine = (isset($theme->info['engine']) && !isset($theme->owner)); } - $query['token'] = drupal_get_token('system-theme-operation-link'); $theme->operations = array(); if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) { // Create the operations links. $query['theme'] = $theme->name; if (drupal_theme_access($theme)) { $theme->operations[] = array( - 'title' => t('Settings'), - 'href' => 'admin/appearance/settings/' . $theme->name, - 'attributes' => array('title' => t('Settings for !theme theme', array('!theme' => $theme->info['name']))), + 'title' => t('Configure'), + 'href' => 'admin/appearance/config/' . $theme->name, + 'attributes' => array('title' => t('Configuration settings for !theme theme', array('!theme' => $theme->info['name']))), ); } if (!empty($theme->status)) { @@ -380,9 +383,9 @@ function system_theme_default() { * @return * The form structure. * @ingroup forms - * @see system_theme_settings_submit() + * @see system_theme_config_submit() */ -function system_theme_settings($form, &$form_state, $key = '') { +function system_theme_config($form, &$form_state, $key = '') { // Default settings are defined in theme_get_setting() in includes/theme.inc if ($key) { $var = 'theme_' . $key . '_settings'; @@ -543,7 +546,7 @@ function system_theme_settings($form, &$form_state, $key = '') { if ($key) { // Call engine-specific settings. - $function = $themes[$key]->prefix . '_engine_settings'; + $function = $themes[$key]->prefix . '_engine_config'; if (function_exists($function)) { $form['engine_specific'] = array( '#type' => 'details', @@ -577,7 +580,7 @@ function system_theme_settings($form, &$form_state, $key = '') { } // Call theme-specific settings. - $function = $theme . '_form_system_theme_settings_alter'; + $function = $theme . '_theme_config'; if (function_exists($function)) { $function($form, $form_state); } @@ -595,15 +598,15 @@ function system_theme_settings($form, &$form_state, $key = '') { $form = system_settings_form($form); // We don't want to call system_settings_form_submit(), so change #submit. array_pop($form['#submit']); - $form['#submit'][] = 'system_theme_settings_submit'; - $form['#validate'][] = 'system_theme_settings_validate'; + $form['#submit'][] = 'system_theme_config_submit'; + $form['#validate'][] = 'system_theme_config_validate'; return $form; } /** - * Validator for the system_theme_settings() form. + * Validator for the system_theme_config() form. */ -function system_theme_settings_validate($form, &$form_state) { +function system_theme_config_validate($form, &$form_state) { if (module_exists('file')) { // Handle file uploads. $validators = array('file_validate_is_image' => array()); @@ -641,13 +644,13 @@ function system_theme_settings_validate($form, &$form_state) { // If the user provided a path for a logo or favicon file, make sure a file // exists at that path. if ($form_state['values']['logo_path']) { - $path = _system_theme_settings_validate_path($form_state['values']['logo_path']); + $path = _system_theme_config_validate_path($form_state['values']['logo_path']); if (!$path) { form_set_error('logo_path', t('The custom logo path is invalid.')); } } if ($form_state['values']['favicon_path']) { - $path = _system_theme_settings_validate_path($form_state['values']['favicon_path']); + $path = _system_theme_config_validate_path($form_state['values']['favicon_path']); if (!$path) { form_set_error('favicon_path', t('The custom favicon path is invalid.')); } @@ -656,7 +659,7 @@ function system_theme_settings_validate($form, &$form_state) { } /** - * Helper function for the system_theme_settings form. + * Helper function for the system_theme_config form. * * Attempts to validate normal system paths, paths relative to the public files * directory, or stream wrapper URIs. If the given path is any of the above, @@ -669,7 +672,7 @@ function system_theme_settings_validate($form, &$form_state) { * A valid path that can be displayed through the theme system, or FALSE if * the path could not be validated. */ -function _system_theme_settings_validate_path($path) { +function _system_theme_config_validate_path($path) { // Absolute local file paths are invalid. if (drupal_realpath($path) == $path) { return FALSE; @@ -689,9 +692,9 @@ function _system_theme_settings_validate_path($path) { } /** - * Process system_theme_settings form submissions. + * Process system_theme_config form submissions. */ -function system_theme_settings_submit($form, &$form_state) { +function system_theme_config_submit($form, &$form_state) { // Exclude unnecessary elements before saving. form_state_values_clean($form_state); $values = $form_state['values']; @@ -722,10 +725,10 @@ function system_theme_settings_submit($form, &$form_state) { // If the user entered a path relative to the system files directory for // a logo or favicon, store a public:// URI so the theme system can handle it. if (!empty($values['logo_path'])) { - $values['logo_path'] = _system_theme_settings_validate_path($values['logo_path']); + $values['logo_path'] = _system_theme_config_validate_path($values['logo_path']); } if (!empty($values['favicon_path'])) { - $values['favicon_path'] = _system_theme_settings_validate_path($values['favicon_path']); + $values['favicon_path'] = _system_theme_config_validate_path($values['favicon_path']); } if (empty($values['default_favicon']) && !empty($values['favicon_path'])) { diff --git a/core/modules/system/system.module b/core/modules/system/system.module index c3df4c1..fc6517f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -90,11 +90,11 @@ function system_help($path, $arg) { case 'admin/appearance': $output = '

' . t('Set and configure the default theme for your website. Alternative themes are available.', array('@themes' => 'http://drupal.org/project/themes')) . '

'; return $output; - case 'admin/appearance/settings/' . $arg[3]: + case 'admin/appearance/config/' . $arg[3]: $theme_list = list_themes(); $theme = $theme_list[$arg[3]]; return '

' . t('These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.', array('%name' => $theme->info['name'])) . '

'; - case 'admin/appearance/settings': + case 'admin/appearance/config': return '

' . t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') . '

'; case 'admin/modules': $output = '

' . t('Download additional contributed modules to extend Drupal\'s functionality.', array('@modules' => 'http://drupal.org/project/modules')) . '

'; @@ -665,27 +665,27 @@ function system_menu() { 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); - $items['admin/appearance/settings'] = array( + $items['admin/appearance/config'] = array( 'title' => 'Settings', 'description' => 'Configure default and theme specific settings.', 'page callback' => 'drupal_get_form', - 'page arguments' => array('system_theme_settings'), + 'page arguments' => array('system_theme_config'), 'access arguments' => array('administer themes'), 'type' => MENU_LOCAL_TASK, 'file' => 'system.admin.inc', 'weight' => 20, ); // Theme configuration subtabs. - $items['admin/appearance/settings/global'] = array( + $items['admin/appearance/config/global'] = array( 'title' => 'Global settings', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1, ); foreach (list_themes() as $key => $theme) { - $items['admin/appearance/settings/' . $theme->name] = array( + $items['admin/appearance/config/' . $theme->name] = array( 'title' => $theme->info['name'], - 'page arguments' => array('system_theme_settings', $theme->name), + 'page arguments' => array('system_theme_config', $theme->name), 'type' => MENU_LOCAL_TASK, 'access callback' => '_system_themes_access', 'access arguments' => array($key), diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 0001cba..1c063ff 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -67,7 +67,7 @@ */ /** - * Allow themes to alter the theme-specific settings form. + * Allow themes to add to the theme-specific settings form. * * With this hook, themes can alter the theme-specific settings form in any way * allowable by Drupal's Form API, such as adding form elements, changing @@ -82,7 +82,7 @@ * @param $form_state * A keyed array containing the current state of the form. */ -function hook_form_system_theme_settings_alter(&$form, &$form_state) { +function hook_theme_config(&$form, &$form_state) { // Add a checkbox to toggle the breadcrumb trail. $form['toggle_breadcrumb'] = array( '#type' => 'checkbox', -- 1.8.0.1