MDL-78426 core_theme: Move theme's settings to theme card

Theme selector and theme settings have been renamed. Theme admin
section has been removed and contents merged into Appearance category.
This commit is contained in:
David Woloszyn
2023-11-20 17:05:35 +11:00
parent b58d1fd4e2
commit cbbcacdd8f
11 changed files with 104 additions and 64 deletions
+65 -54
View File
@@ -8,60 +8,6 @@ $capabilities = array(
);
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 @@ reports,core_reportbuilder|/reportbuilder/index.php',
$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
@@ -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"
}
}}
<div class="card dashboard-card" role="listitem" id="theme-card-{{choose}}" aria-labelledby="theme-name-{{choose}} {{#current}}current-theme-{{choose}}{{/current}}">
@@ -52,6 +53,16 @@
<i class="icon fa fa-info-circle m-0" aria-hidden="true"></i>
<span class="sr-only">{{#str}}previewthemename, moodle, {{name}}{{/str}}</span>
</button>
{{#settingsurl}}
<a
href="{{settingsurl}}"
id="theme-settings-{{choose}}"
class="btn btn-link p-0 ml-2"
title="{{#str}}themeeditsettingsname, admin, {{name}}{{/str}}">
<i class="icon fa fa-cog m-0" aria-hidden="true"></i>
<span class="sr-only">{{#str}}themeeditsettingsname, admin, {{name}}{{/str}}</span>
</a>
{{/settingsurl}}
</div>
</div>
</div>
+8
View File
@@ -112,6 +112,14 @@ foreach ($themes as $themename => $themedir) {
$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++;
}
+1 -1
View File
@@ -368,7 +368,7 @@ class api {
$settings->enabledashboard = $CFG->enabledashboard;
}
if (empty($section) || $section === 'themesettings') {
if (empty($section) || ($section === 'themesettings' || $section === 'themesettingsadvanced')) {
$settings->customusermenuitems = $CFG->customusermenuitems;
}
@@ -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.
+4 -2
View File
@@ -1457,8 +1457,9 @@ $string['themedesignermodewarning'] = 'Theme designer mode is enabled. This shou
$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 @@ $string['unsettheme'] = 'Unset theme';
// Deprecated since Moodle 4.4.
$string['taskdeletecachetext'] = 'Delete old text cache records';
$string['themesettings'] = 'Theme settings';
+1
View File
@@ -112,3 +112,4 @@ passwordconfirmchange,core
passwordnohelp,core
grade,core_grades
taskdeletecachetext,core_admin
themesettings,core_admin
+1 -1
View File
@@ -3808,7 +3808,7 @@ class custom_menu_item implements renderable, templatable {
* 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
+1 -2
View File
@@ -3851,8 +3851,7 @@ EOD;
/**
* 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
@@ -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"
@@ -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"