Skip to content

Commit

Permalink
Merge branch 'MDL-78426-master' of https://github.com/davewoloszyn/mo…
Browse files Browse the repository at this point in the history
  • Loading branch information
HuongNV13 committed Nov 20, 2023
2 parents 6d0f351 + cbbcacd commit 9623c6b
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 64 deletions.
119 changes: 65 additions & 54 deletions admin/settings/appearance.php
Expand Up @@ -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'));

Expand Down Expand Up @@ -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
13 changes: 12 additions & 1 deletion admin/templates/themeselector/theme_card.mustache
Expand Up @@ -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}}">
Expand All @@ -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>
Expand Down
8 changes: 8 additions & 0 deletions admin/themeselector.php
Expand Up @@ -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++;
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/mobile/classes/api.php
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/uploaduser/tests/behat/upload_users.feature
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions lang/en/admin.php
Expand Up @@ -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';
Expand Down Expand Up @@ -1637,3 +1638,4 @@

// Deprecated since Moodle 4.4.
$string['taskdeletecachetext'] = 'Delete old text cache records';
$string['themesettings'] = 'Theme settings';
1 change: 1 addition & 0 deletions lang/en/deprecated.txt
Expand Up @@ -112,3 +112,4 @@ passwordconfirmchange,core
passwordnohelp,core
grade,core_grades
taskdeletecachetext,core_admin
themesettings,core_admin
2 changes: 1 addition & 1 deletion lib/outputcomponents.php
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions lib/outputrenderers.php
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion theme/boost/tests/behat/theme_selector.feature
Expand Up @@ -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
Expand All @@ -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 changes: 5 additions & 1 deletion theme/classic/tests/behat/theme_selector.feature
Expand Up @@ -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
Expand All @@ -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"

0 comments on commit 9623c6b

Please sign in to comment.