diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index 3c583443235cc..7804f64ebdb9a 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -8,60 +8,6 @@ ); if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // speedup for non-admins, add all caps used on this page - - $ADMIN->add('appearance', new admin_category('themes', new lang_string('themes'))); - // "themesettings" settingpage - $temp = new admin_settingpage('themesettings', new lang_string('themesettings', 'admin')); - $setting = new admin_setting_configtext('themelist', new lang_string('themelist', 'admin'), - new lang_string('configthemelist', 'admin'), '', PARAM_NOTAGS); - $setting->set_force_ltr(true); - $temp->add($setting); - $setting = new admin_setting_configcheckbox('themedesignermode', new lang_string('themedesignermode', 'admin'), new lang_string('configthemedesignermode', 'admin'), 0); - $setting->set_updatedcallback('theme_reset_all_caches'); - $temp->add($setting); - $temp->add(new admin_setting_configcheckbox('allowuserthemes', new lang_string('allowuserthemes', 'admin'), new lang_string('configallowuserthemes', 'admin'), 0)); - $temp->add(new admin_setting_configcheckbox('allowcoursethemes', new lang_string('allowcoursethemes', 'admin'), new lang_string('configallowcoursethemes', 'admin'), 0)); - $temp->add(new admin_setting_configcheckbox('allowcategorythemes', new lang_string('allowcategorythemes', 'admin'), new lang_string('configallowcategorythemes', 'admin'), 0)); - $temp->add(new admin_setting_configcheckbox('allowcohortthemes', new lang_string('allowcohortthemes', 'admin'), new lang_string('configallowcohortthemes', 'admin'), 0)); - $temp->add(new admin_setting_configcheckbox('allowthemechangeonurl', new lang_string('allowthemechangeonurl', 'admin'), new lang_string('configallowthemechangeonurl', 'admin'), 0)); - $temp->add(new admin_setting_configcheckbox('allowuserblockhiding', new lang_string('allowuserblockhiding', 'admin'), new lang_string('configallowuserblockhiding', 'admin'), 1)); - $temp->add(new admin_setting_configcheckbox('langmenuinsecurelayout', - new lang_string('langmenuinsecurelayout', 'admin'), - new lang_string('langmenuinsecurelayout_desc', 'admin'), 0)); - $temp->add(new admin_setting_configcheckbox('logininfoinsecurelayout', - new lang_string('logininfoinsecurelayout', 'admin'), - new lang_string('logininfoinsecurelayout_desc', 'admin'), 0)); - $temp->add(new admin_setting_configtextarea('custommenuitems', new lang_string('custommenuitems', 'admin'), - new lang_string('configcustommenuitems', 'admin'), '', PARAM_RAW, '50', '10')); - $temp->add(new admin_setting_configtextarea( - 'customusermenuitems', - new lang_string('customusermenuitems', 'admin'), - new lang_string('configcustomusermenuitems', 'admin'), - 'profile,moodle|/user/profile.php -grades,grades|/grade/report/mygrades.php -calendar,core_calendar|/calendar/view.php?view=month -privatefiles,moodle|/user/files.php -reports,core_reportbuilder|/reportbuilder/index.php', - PARAM_RAW, - '50', - '10' - )); - $ADMIN->add('themes', $temp); - $ADMIN->add('themes', new admin_externalpage('themeselector', - new lang_string('themeselector', 'admin'), $CFG->wwwroot . '/admin/themeselector.php')); - - // settings for each theme - foreach (core_component::get_plugin_list('theme') as $theme => $themedir) { - $settings_path = "$themedir/settings.php"; - if (file_exists($settings_path)) { - $settings = new admin_settingpage('themesetting'.$theme, new lang_string('pluginname', 'theme_'.$theme)); - include($settings_path); - if ($settings) { - $ADMIN->add('themes', $settings); - } - } - } - // Logos section. $temp = new admin_settingpage('logos', new lang_string('logossettings', 'admin')); @@ -337,4 +283,69 @@ $temp = new admin_settingpage('templates', new lang_string('templates', 'admin')); $temp->add($setting); $ADMIN->add('appearance', $temp); + + // Advanced theme settings page. + $temp = new admin_settingpage('themesettingsadvanced', new lang_string('themesettingsadvanced', 'admin')); + $setting = new admin_setting_configtext('themelist', new lang_string('themelist', 'admin'), + new lang_string('configthemelist', 'admin'), '', PARAM_NOTAGS); + $setting->set_force_ltr(true); + $temp->add($setting); + $setting = new admin_setting_configcheckbox('themedesignermode', new lang_string('themedesignermode', 'admin'), + new lang_string('configthemedesignermode', 'admin'), 0); + $setting->set_updatedcallback('theme_reset_all_caches'); + $temp->add($setting); + $temp->add(new admin_setting_configcheckbox('allowuserthemes', new lang_string('allowuserthemes', 'admin'), + new lang_string('configallowuserthemes', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('allowcoursethemes', new lang_string('allowcoursethemes', 'admin'), + new lang_string('configallowcoursethemes', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('allowcategorythemes', new lang_string('allowcategorythemes', 'admin'), + new lang_string('configallowcategorythemes', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('allowcohortthemes', new lang_string('allowcohortthemes', 'admin'), + new lang_string('configallowcohortthemes', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('allowthemechangeonurl', new lang_string('allowthemechangeonurl', 'admin'), + new lang_string('configallowthemechangeonurl', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('allowuserblockhiding', new lang_string('allowuserblockhiding', 'admin'), + new lang_string('configallowuserblockhiding', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('langmenuinsecurelayout', + new lang_string('langmenuinsecurelayout', 'admin'), + new lang_string('langmenuinsecurelayout_desc', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('logininfoinsecurelayout', + new lang_string('logininfoinsecurelayout', 'admin'), + new lang_string('logininfoinsecurelayout_desc', 'admin'), 0)); + $temp->add(new admin_setting_configtextarea('custommenuitems', new lang_string('custommenuitems', 'admin'), + new lang_string('configcustommenuitems', 'admin'), '', PARAM_RAW, '50', '10')); + $defaultsettingcustomusermenuitems = [ + 'profile,moodle|/user/profile.php', + 'grades,grades|/grade/report/mygrades.php', + 'calendar,core_calendar|/calendar/view.php?view=month', + 'privatefiles,moodle|/user/files.php', + 'reports,core_reportbuilder|/reportbuilder/index.php', + ]; + $temp->add(new admin_setting_configtextarea( + 'customusermenuitems', + new lang_string('customusermenuitems', 'admin'), + new lang_string('configcustomusermenuitems', 'admin'), + implode("\n", $defaultsettingcustomusermenuitems), + PARAM_RAW, + '50', + '10' + )); + $ADMIN->add('appearance', $temp); + + // Theme selector page. + $ADMIN->add('appearance', new admin_externalpage('themeselector', + new lang_string('themeselector', 'admin'), $CFG->wwwroot . '/admin/themeselector.php')); + + // Settings page for each theme. + foreach (core_component::get_plugin_list('theme') as $theme => $themedir) { + $settingspath = "$themedir/settings.php"; + if (file_exists($settingspath)) { + $settings = new admin_externalpage('themesetting' . $theme, new lang_string('pluginname', 'theme_'.$theme), + new moodle_url($settingspath), 'moodle/site:config', true); + include($settingspath); + if ($settings) { + $ADMIN->add('appearance', $settings); + } + } + } } // end of speedup diff --git a/admin/templates/themeselector/theme_card.mustache b/admin/templates/themeselector/theme_card.mustache index 9cb3bb6fea7a4..2e302adef54a3 100644 --- a/admin/templates/themeselector/theme_card.mustache +++ b/admin/templates/themeselector/theme_card.mustache @@ -26,7 +26,8 @@ "image": "http://moodlesite/theme/image.php?theme=boost&image=screenshot&component=theme", "current": true, "actionurl": "http://moodlesite/admin/themeselector.php", - "sesskey": "123XYZ" + "sesskey": "123XYZ", + "settingsurl": "http://moodlesite/admin/settings.php?section=themesettingboost" } }}
@@ -52,6 +53,16 @@ {{#str}}previewthemename, moodle, {{name}}{{/str}} + {{#settingsurl}} + + + {{#str}}themeeditsettingsname, admin, {{name}}{{/str}} + + {{/settingsurl}}
diff --git a/admin/themeselector.php b/admin/themeselector.php index d83959b0d759e..c3155ebc96fc0 100644 --- a/admin/themeselector.php +++ b/admin/themeselector.php @@ -112,6 +112,14 @@ $themedata['sesskey'] = sesskey(); } + // Settings url. + $settingspath = "$themedir/settings.php"; + if (file_exists($settingspath)) { + $section = "themesetting{$themename}"; + $settingsurl = new moodle_url('/admin/settings.php', ['section' => $section]); + $themedata['settingsurl'] = $settingsurl; + } + $data[$index] = $themedata; $index++; } diff --git a/admin/tool/mobile/classes/api.php b/admin/tool/mobile/classes/api.php index 1a502a847da5d..f2cda5e74323d 100644 --- a/admin/tool/mobile/classes/api.php +++ b/admin/tool/mobile/classes/api.php @@ -368,7 +368,7 @@ public static function get_config($section) { $settings->enabledashboard = $CFG->enabledashboard; } - if (empty($section) || $section === 'themesettings') { + if (empty($section) || ($section === 'themesettings' || $section === 'themesettingsadvanced')) { $settings->customusermenuitems = $CFG->customusermenuitems; } diff --git a/admin/tool/uploaduser/tests/behat/upload_users.feature b/admin/tool/uploaduser/tests/behat/upload_users.feature index d8d187c2a6ec7..d2ab0cf73d785 100644 --- a/admin/tool/uploaduser/tests/behat/upload_users.feature +++ b/admin/tool/uploaduser/tests/behat/upload_users.feature @@ -109,7 +109,7 @@ Feature: Upload users And I navigate to "Security > Site security settings" in site administration And I click on "Password policy" "checkbox" And I click on "Save changes" "button" - And I navigate to "Appearance > Themes > Theme settings" in site administration + And I navigate to "Appearance > Advanced theme settings" in site administration And I click on "Allow user themes" "checkbox" And I click on "Save changes" "button" # Upload the users. diff --git a/lang/en/admin.php b/lang/en/admin.php index 05e794078326e..981d67d092eea 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1457,8 +1457,9 @@ $string['themelist'] = 'Theme list'; $string['themeresetcaches'] = 'Clear theme caches'; $string['themeselect'] = 'Change theme'; -$string['themeselector'] = 'Theme selector'; -$string['themesettings'] = 'Theme settings'; +$string['themeselector'] = 'Themes'; +$string['themesettingsadvanced'] = 'Advanced theme settings'; +$string['themeeditsettingsname'] = 'Edit theme settings \'{$a}\''; $string['therewereerrors'] = 'There were errors in your data'; $string['thirdpartylibrary'] = 'Library'; $string['thirdpartylibrarylocation'] = 'Location'; @@ -1637,3 +1638,4 @@ // Deprecated since Moodle 4.4. $string['taskdeletecachetext'] = 'Delete old text cache records'; +$string['themesettings'] = 'Theme settings'; diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index b48331e0e8381..10801b8dd3186 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -112,3 +112,4 @@ passwordconfirmchange,core passwordnohelp,core grade,core_grades taskdeletecachetext,core_admin +themesettings,core_admin diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 2db2a8cf5a747..de04e4f66676b 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -3808,7 +3808,7 @@ public function export_for_template(renderer_base $output) { * of custom_menu_item nodes that can be rendered by the core renderer. * * To configure the custom menu: - * Settings: Administration > Appearance > Themes > Theme settings + * Settings: Administration > Appearance > Advanced theme settings * * @copyright 2010 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 392ea45ecd585..fc86b36df845c 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -3851,8 +3851,7 @@ public function darrow() { /** * Returns the custom menu if one has been set * - * A custom menu can be configured by browsing to - * Settings: Administration > Appearance > Themes > Theme settings + * A custom menu can be configured by browsing to a theme's settings page * and then configuring the custommenu config setting as described. * * Theme developers: DO NOT OVERRIDE! Please override function diff --git a/theme/boost/tests/behat/theme_selector.feature b/theme/boost/tests/behat/theme_selector.feature index f7ffc0d17ae59..dccb2721035b3 100644 --- a/theme/boost/tests/behat/theme_selector.feature +++ b/theme/boost/tests/behat/theme_selector.feature @@ -6,7 +6,7 @@ Feature: Select a theme in Boost theme Background: Given I log in as "admin" - And I navigate to "Appearance > Themes > Theme selector" in site administration + And I navigate to "Appearance > Themes" in site administration @javascript Scenario: I am able to preview a theme using a modal window @@ -26,3 +26,7 @@ Feature: Select a theme in Boost theme Given I should see "Current theme" in the "#theme-card-boost" "css_element" When I click on "Select theme 'Classic'" "button" Then I should see "Current theme" in the "#theme-card-classic" "css_element" + + Scenario: I am able to view a theme's settings page + Given I click on "Edit theme settings 'Boost'" "link" + Then I should see "Boost" diff --git a/theme/classic/tests/behat/theme_selector.feature b/theme/classic/tests/behat/theme_selector.feature index 75c8ac3774dd4..3553c189a0946 100644 --- a/theme/classic/tests/behat/theme_selector.feature +++ b/theme/classic/tests/behat/theme_selector.feature @@ -6,7 +6,7 @@ Feature: Select a theme in Classic theme Background: Given I log in as "admin" - And I navigate to "Appearance > Themes > Theme selector" in site administration + And I navigate to "Appearance > Themes" in site administration @javascript Scenario: I am able to preview a theme using a modal window @@ -26,3 +26,7 @@ Feature: Select a theme in Classic theme Given I should see "Current theme" in the "#theme-card-classic" "css_element" When I click on "Select theme 'Boost'" "button" Then I should see "Current theme" in the "#theme-card-boost" "css_element" + + Scenario: I am able to view a theme's settings page + Given I click on "Edit theme settings 'Classic'" "link" + Then I should see "Classic"