From 9c20b9b2668d30ece39cf2269a8532ba805e15a0 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:36:12 +0100 Subject: [PATCH] V405.0.1 --- .github/workflows/ci.yml | 4 +- Changes.md | 7 + Readme.md | 4 +- classes/admin_setting_configstoredfiles.php | 5 +- classes/admin_setting_getprops.php | 16 +- classes/hvp_toolbox.php | 6 +- classes/output/core/course_renderer.php | 22 +- classes/output/core_renderer_layout.php | 15 +- classes/output/core_renderer_maintenance.php | 2 +- classes/output/core_renderer_toolbox.php | 262 ++++++++++-------- .../output/core_user/myprofile/renderer.php | 1 - classes/output/custom_menu.php | 9 +- classes/output/icon_system_fontawesome.php | 6 +- classes/output/mustache_renderer.php | 2 +- classes/output/navigation/primary.php | 6 +- classes/toolbox.php | 19 +- config.php | 1 + lang/en/theme_adaptable.php | 3 + lib.php | 7 +- libs/admin_confightmleditor.php | 4 +- settings.php | 2 +- settings/block_settings.php | 6 + templates/sidepost.mustache | 1 - tests/toolbox_test.php | 2 + thirdpartylibs.xml | 4 +- version.php | 12 +- 26 files changed, 240 insertions(+), 188 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 383085e..cb680eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,8 +21,8 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.1', '8.2'] - moodle-branch: ['MOODLE_404_STABLE'] + php: ['8.3'] + moodle-branch: ['MOODLE_405_STABLE'] database: [mariadb] steps: diff --git a/Changes.md b/Changes.md index 1867738..047eb9f 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,10 @@ +Change Log in version 405.0.1 (2024100500) +========================================== +1. Block region tidy when editing, 'Add block' button for each region and added 'blockregioneditingtitleshown' setting + under 'Block' with a default of true. +2. Impact of MDL-81920 and MDL-81960. +3. Release candidate initial release. + Change Log in version 404.1.1 (2024032803) ========================================== 1. Fix missing 'recaptcha' on login form. diff --git a/Readme.md b/Readme.md index 537364a..163b3b8 100644 --- a/Readme.md +++ b/Readme.md @@ -49,10 +49,10 @@ This theme has been developed by the following: Required release of Moodle ========================== -This version works with Moodle 4.4 version 2024042200.00 (Build: 20231009) and above within the MOODLE_404_STABLE branch until the +This version works with Moodle 4.5 version 2024100700.00 (Build: 20241007) and above within the MOODLE_405_STABLE branch until the next release. -Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/404/en/Installing_Moodle)'. +Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/405/en/Installing_Moodle)'. Installation ============ diff --git a/classes/admin_setting_configstoredfiles.php b/classes/admin_setting_configstoredfiles.php index c1a14b2..335cdb0 100644 --- a/classes/admin_setting_configstoredfiles.php +++ b/classes/admin_setting_configstoredfiles.php @@ -29,6 +29,7 @@ use context_system; use context_user; +use core\url; defined('MOODLE_INTERNAL') || die; @@ -395,10 +396,10 @@ public static function setting_file_urls($setting, $filearea, $theme) { $syscontext->id, $component, $filearea, 0, 'sortorder,filepath,filename', false); // Item id could not be 0! foreach ($files as $file) { $filepath = $file->get_filepath().$file->get_filename(); - $url = \moodle_url::make_file_url( + $url = url::make_file_url( "$CFG->wwwroot/pluginfile.php", "/$syscontext->id/$component/$filearea/$itemid".$filepath); // Now this is tricky because the we can not hardcode http or https here, lets use the relative link. - // Note: unfortunately moodle_url does not support //urls yet. + // Note: unfortunately url does not support //urls yet. $url = preg_replace('|^https?://|i', '//', $url->out(false)); $urls[] = $url; } diff --git a/classes/admin_setting_getprops.php b/classes/admin_setting_getprops.php index 76450a9..e436374 100644 --- a/classes/admin_setting_getprops.php +++ b/classes/admin_setting_getprops.php @@ -28,9 +28,9 @@ use context_system; use context_user; -use html_table; -use html_writer; -use moodle_url; +use core_table\output\html_table; +use core\output\html_writer; +use core\url; /** * Get properties class. @@ -133,7 +133,7 @@ public function output_html($data, $query = '') { if ($saveprops) { $props = \theme_adaptable\toolbox::get_properties($this->pluginfrankenstyle); - $returnurl = new moodle_url('/admin/settings.php', ['section' => $this->settingsectionname]); + $returnurl = new url('/admin/settings.php', ['section' => $this->settingsectionname]); $returnbutton = '
' . $this->returnbuttonname . '
'; $return .= $returnbutton; @@ -205,7 +205,7 @@ public function output_html($data, $query = '') { } } - $returnurl = new moodle_url('/admin/settings.php', ['section' => $this->settingsectionname]); + $returnurl = new url('/admin/settings.php', ['section' => $this->settingsectionname]); $returnbutton = '
' . $this->returnbuttonname . '
'; $return .= $returnbutton; @@ -223,21 +223,21 @@ public function output_html($data, $query = '') { } else { $props = \theme_adaptable\toolbox::get_properties($this->pluginfrankenstyle); - $propsexporturl = new moodle_url('/admin/settings.php', ['section' => $this->settingsectionname, + $propsexporturl = new url('/admin/settings.php', ['section' => $this->settingsectionname, $this->pluginfrankenstyle . '_getprops_saveprops' => 1, ]); $propsexportbutton = '
' . $this->savepropsbuttonname . '
'; - $propsexportfilestoourl = new moodle_url('/admin/settings.php', ['section' => $this->settingsectionname, + $propsexportfilestoourl = new url('/admin/settings.php', ['section' => $this->settingsectionname, $this->pluginfrankenstyle . '_getprops_saveprops_filestoo' => 1, ]); $propsexportfilestoobutton = '
' . $this->savepropsfilestoobuttonname . '
'; - $propsexportfilestoofilesurl = new moodle_url('/admin/settings.php', ['section' => $this->settingsectionname, + $propsexportfilestoofilesurl = new url('/admin/settings.php', ['section' => $this->settingsectionname, $this->pluginfrankenstyle . '_getprops_saveprops_filestoofile' => 1, ]); $propsexportfilestoofilebutton = '
wwwroot/pluginfile.php", "/$syscontext->id/theme_adaptable/hvp/$itemid/themehvp.css" ); diff --git a/classes/output/core/course_renderer.php b/classes/output/core/course_renderer.php index 483a5ff..8cdf54e 100644 --- a/classes/output/core/course_renderer.php +++ b/classes/output/core/course_renderer.php @@ -30,11 +30,11 @@ namespace theme_adaptable\output\core; -use html_writer; -use moodle_url; +use core\output\html_writer; +use core\url; +use core_course_list_element; use coursecat_helper; use lang_string; -use core_course_list_element; use stdClass; /** @@ -100,7 +100,7 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi if (($type == 1) || ($showcourses < self::COURSECAT_SHOW_COURSES_EXPANDED)) { $content .= html_writer::start_tag('div', ['class' => 'panel-heading']); $content .= html_writer::link( - new moodle_url('/course/view.php', ['id' => $course->id]), + new url('/course/view.php', ['id' => $course->id]), $coursename, ['class' => $course->visible ? '' : 'dimmed', 'title' => $coursename] ); @@ -145,7 +145,7 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi $arrow, ['class' => 'get_stringlink']); if (($type != 4) || (empty($this->page->theme->settings->covhidebutton))) { - $content .= html_writer::link(new moodle_url( + $content .= html_writer::link(new url( '/course/view.php', ['id' => $course->id] ), $btn, ['class' => " coursebtn submit btn btn-info btn-sm"]); @@ -219,7 +219,7 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours if ($isimage) { if ($type == 1) { $contentimages .= html_writer::start_tag('div', ['class' => 'courseimage']); - $link = new moodle_url('/course/view.php', ['id' => $course->id]); + $link = new url('/course/view.php', ['id' => $course->id]); $contentimages .= html_writer::link($link, html_writer::empty_tag('img', ['src' => $url])); $contentimages .= html_writer::end_tag('div'); } else { @@ -229,7 +229,7 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours ]; if ($type == 4) { $cimtag = 'a'; - $cimboxattr['href'] = new moodle_url('/course/view.php', ['id' => $course->id]); + $cimboxattr['href'] = new url('/course/view.php', ['id' => $course->id]); } else { $cimtag = 'div'; } @@ -256,7 +256,7 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours if ($type == 2) { $cimtag = 'div'; } else { // Type is 4. - $cimboxattr['href'] = new moodle_url('/course/view.php', ['id' => $course->id]); + $cimboxattr['href'] = new url('/course/view.php', ['id' => $course->id]); $cimtag = 'a'; } $contentimages .= html_writer::tag($cimtag, '', $cimboxattr); @@ -269,7 +269,7 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours 'class' => 'coursebox-content', ]); $coursename = $chelper->get_course_formatted_name($course); - $content .= html_writer::start_tag('a', ['href' => new moodle_url('/course/view.php', ['id' => $course->id])]); + $content .= html_writer::start_tag('a', ['href' => new url('/course/view.php', ['id' => $course->id])]); $content .= html_writer::tag('h3', $coursename, ['class' => $course->visible ? '' : 'dimmed']); $content .= html_writer::end_tag('a'); } @@ -295,7 +295,7 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours ['class' => 'fa fa-graduation-cap'] )); $name = html_writer::link( - new moodle_url( + new url( '/user/view.php', ['id' => $userid, 'course' => $course->id] ), @@ -315,7 +315,7 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours $content .= html_writer::start_tag('div', ['class' => 'coursecat']); $content .= get_string('category') . ': ' . html_writer::link( - new moodle_url('/course/index.php', ['categoryid' => $cat->id]), + new url('/course/index.php', ['categoryid' => $cat->id]), $cat->get_formatted_name(), ['class' => $cat->visible ? '' : 'dimmed'] ); diff --git a/classes/output/core_renderer_layout.php b/classes/output/core_renderer_layout.php index ccfc29e..9fe4eb0 100644 --- a/classes/output/core_renderer_layout.php +++ b/classes/output/core_renderer_layout.php @@ -26,7 +26,7 @@ namespace theme_adaptable\output; -use moodle_url; +use core\url; use stdClass; /** @@ -195,7 +195,7 @@ public function yesheader($sidepostdrawer) { 'displayloginbox' => ($themesettings->displaylogin == 'box') ? true : false, 'output' => $this, 'token' => s(\core\session\manager::get_login_token()), - 'url' => new moodle_url('/login/index.php'), + 'url' => new url('/login/index.php'), ]; if (!$loginformcontext['displayloginbox']) { $authsequence = get_enabled_auth_plugins(); // Get all auths. @@ -415,7 +415,7 @@ protected function head($bodyclasses) { $headcontext->output = $this; $headcontext->sitefullname = $SITE->fullname; $headcontext->pagetitle = $this->page_title(); - $siteurl = new moodle_url(''); + $siteurl = new url(''); $headcontext->siteurl = $siteurl->out(); $headcontext->maincolor = $themesettings->maincolor; @@ -535,11 +535,9 @@ protected function sidepostheader() { $sidepostopen = false; } - // Add block button in editing mode. - $addblockbutton = $this->addblockbutton(); - $sideposthtml = $this->blocks('side-post'); - $hassidepost = (strpos($sideposthtml, 'data-block=') !== false || !empty($addblockbutton)); + // Blocks or add block button. + $hassidepost = ((strpos($sideposthtml, 'data-block=') !== false) || (strpos($sideposthtml, 'data-key="addblock"') !== false)); if (!$hassidepost) { $sidepostopen = false; } @@ -549,7 +547,6 @@ protected function sidepostheader() { } $sidepostcontext = [ - 'addblockbutton' => $addblockbutton, 'hassidepost' => $hassidepost, 'left' => $left, 'sidepostopen' => $sidepostopen, @@ -815,7 +812,7 @@ public function course_layout() { $section = optional_param('section', 0, PARAM_INT); if ((!empty($themesettings->tabbedlayoutcoursepagelink)) && (($sectionid) || ($section))) { - $courseurl = new moodle_url('/course/view.php', ['id' => $COURSE->id]); + $courseurl = new url('/course/view.php', ['id' => $COURSE->id]); echo '
'; } diff --git a/classes/output/core_renderer_maintenance.php b/classes/output/core_renderer_maintenance.php index 7e8b75e..dfac45b 100644 --- a/classes/output/core_renderer_maintenance.php +++ b/classes/output/core_renderer_maintenance.php @@ -32,6 +32,6 @@ /** * The core maintenance renderer. */ -class core_renderer_maintenance extends \core_renderer_maintenance { +class core_renderer_maintenance extends \core\output\core_renderer_maintenance { use core_renderer_toolbox, core_renderer_layout; } diff --git a/classes/output/core_renderer_toolbox.php b/classes/output/core_renderer_toolbox.php index e2bcace..4808740 100644 --- a/classes/output/core_renderer_toolbox.php +++ b/classes/output/core_renderer_toolbox.php @@ -29,11 +29,13 @@ namespace theme_adaptable\output; -use block_contents; use context_course; -use custom_menu_item; -use html_writer; -use moodle_url; +use core\output\action_link; +use core\output\custom_menu_item; +use core\output\html_writer; +use core\output\pix_icon; +use core\url; +use core_block\output\block_contents; use navigation_node; use stdClass; @@ -112,37 +114,37 @@ protected function user_profile_menu_items() { Link text in fourth parameter. Icon in fifth param. */ $usermenuitems = []; - $usermenuitems[] = ['enablemy', 'link', false, new moodle_url('/my'), get_string('myhome'), + $usermenuitems[] = ['enablemy', 'link', false, new url('/my'), get_string('myhome'), \theme_adaptable\toolbox::getfontawesomemarkup('dashboard', ['mr-1']), ]; - $usermenuitems[] = ['enableprofile', 'link', false, new moodle_url('/user/profile.php'), get_string('viewprofile'), + $usermenuitems[] = ['enableprofile', 'link', false, new url('/user/profile.php'), get_string('viewprofile'), \theme_adaptable\toolbox::getfontawesomemarkup('user', ['mr-1']), ]; - $usermenuitems[] = ['enableeditprofile', 'link', false, new moodle_url('/user/edit.php'), get_string('editmyprofile'), + $usermenuitems[] = ['enableeditprofile', 'link', false, new url('/user/edit.php'), get_string('editmyprofile'), \theme_adaptable\toolbox::getfontawesomemarkup('cog', ['mr-1']), ]; - $usermenuitems[] = ['enableaccesstool', 'link', false, new moodle_url('/local/accessibilitytool/manage.php'), + $usermenuitems[] = ['enableaccesstool', 'link', false, new url('/local/accessibilitytool/manage.php'), get_string('enableaccesstool', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('low-vision', ['mr-1']), ]; - $usermenuitems[] = ['enableprivatefiles', 'link', false, new moodle_url('/user/files.php'), + $usermenuitems[] = ['enableprivatefiles', 'link', false, new url('/user/files.php'), get_string('privatefiles', 'block_private_files'), \theme_adaptable\toolbox::getfontawesomemarkup('file', ['mr-1']), ]; if (\theme_adaptable\toolbox::kalturaplugininstalled()) { - $usermenuitems[] = [false, 'link', false, new moodle_url('/local/mymedia/mymedia.php'), + $usermenuitems[] = [false, 'link', false, new url('/local/mymedia/mymedia.php'), get_string('nav_mymedia', 'local_mymedia'), $this->pix_icon('my-media', '', 'local_mymedia'), ]; } - $usermenuitems[] = ['enablegrades', 'link', false, new moodle_url('/grade/report/overview/index.php'), get_string('grades'), + $usermenuitems[] = ['enablegrades', 'link', false, new url('/grade/report/overview/index.php'), get_string('grades'), \theme_adaptable\toolbox::getfontawesomemarkup('list-alt', ['mr-1']), ]; - $usermenuitems[] = ['enablebadges', 'link', false, new moodle_url('/badges/mybadges.php'), get_string('badges'), + $usermenuitems[] = ['enablebadges', 'link', false, new url('/badges/mybadges.php'), get_string('badges'), \theme_adaptable\toolbox::getfontawesomemarkup('certificate', ['mr-1']), ]; - $usermenuitems[] = ['enablepref', 'link', '2015051100', new moodle_url('/user/preferences.php'), get_string('preferences'), + $usermenuitems[] = ['enablepref', 'link', '2015051100', new url('/user/preferences.php'), get_string('preferences'), \theme_adaptable\toolbox::getfontawesomemarkup('cog', ['mr-1']), ]; - $usermenuitems[] = ['enablenote', 'link', false, new moodle_url('/message/edit.php'), get_string('notifications'), + $usermenuitems[] = ['enablenote', 'link', false, new url('/message/edit.php'), get_string('notifications'), \theme_adaptable\toolbox::getfontawesomemarkup('paper-plane', ['mr-1']), ]; $usermenuitems[] = [false, 'divider']; - $usermenuitems[] = ['enableblog', 'link', false, new moodle_url('/blog/index.php'), get_string('enableblog', 'theme_adaptable'), + $usermenuitems[] = ['enableblog', 'link', false, new url('/blog/index.php'), get_string('enableblog', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('rss', ['mr-1']), ]; - $usermenuitems[] = ['enableposts', 'link', false, new moodle_url('/mod/forum/user.php'), + $usermenuitems[] = ['enableposts', 'link', false, new url('/mod/forum/user.php'), get_string('enableposts', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('commenting', ['mr-1']), ]; - $usermenuitems[] = ['enablefeed', 'link', false, new moodle_url('/report/myfeedback/index.php'), + $usermenuitems[] = ['enablefeed', 'link', false, new url('/report/myfeedback/index.php'), get_string('enablefeed', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('bullhorn', ['mr-1']), ]; - $usermenuitems[] = ['enablecalendar', 'link', false, new moodle_url('/calendar/view.php'), + $usermenuitems[] = ['enablecalendar', 'link', false, new url('/calendar/view.php'), get_string('pluginname', 'block_calendar_month'), \theme_adaptable\toolbox::getfontawesomemarkup('calendar', ['mr-1']), ]; @@ -152,7 +154,7 @@ protected function user_profile_menu_items() { // Return. if (is_role_switched($COURSE->id)) { $returnurl = $this->page->url->out_as_local_url(false); - $url = new moodle_url('/course/switchrole.php', ['id' => $COURSE->id, 'sesskey' => sesskey(), + $url = new url('/course/switchrole.php', ['id' => $COURSE->id, 'sesskey' => sesskey(), 'switchrole' => '0', 'returnurl' => $returnurl]); $usermenuitems[] = [false, 'link', false, $url, get_string('switchrolereturn'), \theme_adaptable\toolbox::getfontawesomemarkup('user-o', ['mr-1']), ]; @@ -160,13 +162,13 @@ protected function user_profile_menu_items() { $context = context_course::instance($COURSE->id); if (has_capability('moodle/role:switchroles', $context)) { $returnurl = $this->page->url->out_as_local_url(false); - $url = new moodle_url('/course/switchrole.php', ['id' => $COURSE->id, 'switchrole' => '-1', 'returnurl' => $returnurl]); + $url = new url('/course/switchrole.php', ['id' => $COURSE->id, 'switchrole' => '-1', 'returnurl' => $returnurl]); $usermenuitems[] = [false, 'link', false, $url, get_string('switchroleto'), \theme_adaptable\toolbox::getfontawesomemarkup('user-o', ['mr-1']), ]; } } - $usermenuitems[] = [false, 'link', false, new moodle_url('/login/logout.php', ['sesskey' => sesskey()]), get_string('logout'), + $usermenuitems[] = [false, 'link', false, new url('/login/logout.php', ['sesskey' => sesskey()]), get_string('logout'), \theme_adaptable\toolbox::getfontawesomemarkup('sign-out', ['mr-1']), ]; foreach ($usermenuitems as $usermenuitem) { @@ -279,7 +281,7 @@ protected function user_convert_text_to_menu_items($text) { } // Make sure the url is a moodle url. - $bits[1] = new moodle_url(trim($bits[1])); + $bits[1] = new url(trim($bits[1])); } $child->url = $bits[1]; @@ -667,7 +669,7 @@ public function activity_navigation() { $modname .= ' ' . get_string('hiddenwithbrackets'); } // Module URL. - $linkurl = new \moodle_url($module->url, ['forceview' => 1]); + $linkurl = new url($module->url, ['forceview' => 1]); // Add module URL (as key) and name (as value) to the activity list array. $activitylist[$linkurl->out(false)] = $modname; } @@ -709,7 +711,7 @@ public function activity_navigation() { * @param preferences_groups $renderable The renderable * @return string The output. */ - public function render_preferences_groups(\preferences_groups $renderable) { + public function render_preferences_groups(\core\output\preferences_groups $renderable) { return $this->render_from_template('core/preferences_groups', $renderable); } @@ -770,11 +772,11 @@ public function get_all_tracking_methods() { * Note: Not called directly by theme but by core in its way of setting the 'page button' * attribute. This version needed for 'Edit button keep position' in adaptable.js. * - * @param moodle_url $url The URL + params to send through when clicking the button. + * @param url $url The URL + params to send through when clicking the button. * @param string $method Not used. * @return string HTML the button */ - public function edit_button(moodle_url $url, string $method = 'post') { + public function edit_button(url $url, string $method = 'post') { $url->param('sesskey', sesskey()); if ($this->page->user_is_editing()) { $url->param('edit', 'off'); @@ -813,12 +815,12 @@ protected function process_message($message) { $messagecontent->type = 'notification'; if (empty($message->contexturl)) { - $messagecontent->url = new moodle_url( + $messagecontent->url = new url( '/message/index.php', ['user1' => $USER->id, 'viewing' => 'recentnotifications'] ); } else { - $messagecontent->url = new moodle_url($message->contexturl); + $messagecontent->url = new url($message->contexturl); } } else { $messagecontent->type = 'message'; @@ -831,7 +833,7 @@ protected function process_message($message) { $messagecontent->text = $message->smallmessage; } $messagecontent->from = $DB->get_record('user', ['id' => $message->useridfrom]); - $messagecontent->url = new moodle_url( + $messagecontent->url = new url( '/message/index.php', ['user1' => $USER->id, 'user2' => $message->useridfrom] ); @@ -906,32 +908,10 @@ public function get_block_regions( $classnamebeginswith, $customrowsetting = null ) { - global $COURSE, $USER; - - $adminediting = false; $blockcount = 0; - $classextra = ''; $fields = []; $retval = ''; - /* Check if user has capability to edit block on homepage. This is used as part of checking if - blocks should display the dotted borders and labels for editing. (Issue #809). */ - $context = context_course::instance($COURSE->id); - - /* Check if front page and if has capability to edit blocks. The $pageallowed variable will store - the correct state of whether user can edit that page. */ - $caneditblock = has_capability('moodle/block:edit', $context); - if (($this->page->pagelayout == "frontpage") && ($caneditblock !== true)) { - $pageallowed = false; - } else { - $pageallowed = true; - } - - if ((isset($USER->editing) && $USER->editing == 1) && ($pageallowed == true)) { - $classextra = ' adaptable-block-area'; - $adminediting = true; - } - if ($settingsname == 'customrowsetting') { $fields[] = $customrowsetting; } else { @@ -958,16 +938,12 @@ public function get_block_regions( $vals = explode('-', $field); foreach ($vals as $val) { if ($val > 0) { - $retval .= '
'; + $retval .= '
'; // Moodle does not seem to like numbers in region names so using letter instead. $blockcount++; $block = $classnamebeginswith . chr(96 + $blockcount); - if ($adminediting) { - $retval .= '' . get_string('region-' . $block, 'theme_adaptable') . ''; - } - $retval .= $this->blocks($block, 'block-region-front'); $retval .= '
'; } @@ -987,13 +963,8 @@ public function get_block_regions( * @return string HTML output */ public function get_missing_block_regions($blocksarray, $classes = [], $displayall = false) { - global $USER; $retval = ''; - $adminediting = false; - - if (isset($USER->editing) && $USER->editing == 1) { - $adminediting = true; - } + $editing = $this->page->user_is_editing(); if (!empty($blocksarray)) { $classes = (array)$classes; @@ -1024,7 +995,7 @@ public function get_missing_block_regions($blocksarray, $classes = [], $displaya // Check if the block actually has content to display before displaying. if ($this->page->blocks->region_has_content($displayregion, $this)) { - if ($adminediting) { + if ($editing) { $missingblocks .= get_string( 'orphanedblock', 'theme_adaptable', @@ -1053,15 +1024,23 @@ public function get_missing_block_regions($blocksarray, $classes = [], $displaya * Get the HTML for block title in the given region. * * @param string $region The region to get HTML for. + * @param boolean $editing We are editing. * * @return string HTML. */ - protected function block_region_title($region) { - return html_writer::tag( - 'p', - get_string('region-' . $region, 'theme_adaptable'), - ['class' => 'block-region-title col-12 text-center font-italic font-weight-bold'] - ); + protected function block_region_title($region, $editing = true) { + $title = ''; + + $shown = (($editing && \theme_adaptable\toolbox::get_setting('blockregioneditingtitleshown')) || (!$editing)); + if ($shown) { + $title = html_writer::tag( + 'p', + get_string('region-' . $region, 'theme_adaptable'), + ['class' => 'block-region-title col-12 text-center font-italic font-weight-bold'] + ); + } + + return $title; } /** @@ -1096,13 +1075,15 @@ public function get_flexible_blocks( } } - $content = ''; + $blockcontent = ''; $classes = (array)$classes; $classes[] = 'block-region'; if ($editing) { - $content .= $this->block_region_title($region); $classes[] = 'editing-flexible-blocks'; + $classes[] = 'pl-2'; + $classes[] = 'pr-2'; + $classes[] = 'pt-2'; } $attributes = [ @@ -1113,7 +1094,7 @@ public function get_flexible_blocks( ]; if ($this->page->blocks->region_has_content($region, $this)) { - $content .= html_writer::tag('h2', get_string('blocks'), ['class' => 'sr-only']); + $blockcontent .= html_writer::tag('h2', get_string('blocks'), ['class' => 'sr-only']); $blockcontents = $this->page->blocks->get_content_for_region($region, $this); $lastblock = null; @@ -1130,7 +1111,7 @@ public function get_flexible_blocks( $blocksequencecount = 0; $blockspacescount = 0; - $content .= '
'; + $blockcontent .= '
'; for ($i = 1; $i <= 5; $i++) { $blockrowsetting = $layoutrow . $i; @@ -1160,7 +1141,7 @@ public function get_flexible_blocks( if (!$editing) { if (!empty($blocksequence[$blocksequencecount])) { if ($blocksequence[$blocksequencecount] == '+') { - $content .= '
'; + $blockcontent .= '
'; $blocksequencecount++; } $bc->attributes['class'] .= ' col-12 col-sm-'.$blocksequence[$blocksequencecount]; // Will be a number. @@ -1172,9 +1153,9 @@ public function get_flexible_blocks( get_string('flexibleblocksoverflow', 'theme_adaptable'), ['class' => 'block-region-overflow col-12 text-center font-italic font-weight-bold'] ); - $content .= '
'; + $blockcontent .= '
'; if (is_siteadmin()) { - $content .= html_writer::tag( + $blockcontent .= html_writer::tag( 'p', get_string('flexibleblocksoverflow', 'theme_adaptable'), ['class' => 'block-region-overflow col-12 text-center font-italic font-weight-bold'] @@ -1185,19 +1166,19 @@ public function get_flexible_blocks( } $bc->attributes['notitle'] = true; } - $content .= $this->block($bc, $region); + $blockcontent .= $this->block($bc, $region); $lastblock = $bc->title; $blockcount++; if ((!$editing) && (!$blockspacesexceeded)) { $blocksequencecount++; // Could be a end of row next. if ($blocksequence[$blocksequencecount] == '-') { - $content .= '
'; + $blockcontent .= '
'; $blocksequencecount++; } } } else if ($bc instanceof block_move_target) { - $content .= $this->block_move_target($bc, $zones, $lastblock, $region); + $blockcontent .= $this->block_move_target($bc, $zones, $lastblock, $region); } else { throw new coding_exception( 'Unexpected type of thing (' . get_class($bc) . ') found in list of block contents.'); @@ -1206,15 +1187,27 @@ public function get_flexible_blocks( if (!$editing) { if ($blockspacesexceeded) { - $content .= '
'; // End of flexible-blocks-overflow. + $blockcontent .= '
'; // End of flexible-blocks-overflow. } - $content .= '
'; // End of container. + $blockcontent .= '
'; // End of container. } } else { - $content .= html_writer::tag('h2', get_string('blocks'), ['class' => 'sr-only']); + $blockcontent .= html_writer::tag('h2', get_string('blocks'), ['class' => 'sr-only']); } + $blockcontent = html_writer::tag($tag, $blockcontent, $attributes); + + $content = ''; + if ($editing) { + $title = $this->block_region_title($region); + // Add block button in editing mode. + $addblockbutton = $this->addblockbutton($region); - return html_writer::tag($tag, $content, $attributes); + $content = html_writer::tag('div', $title.$blockcontent.$addblockbutton, ['class' => 'my-1 adaptable-block-area']); + } else { + $content = $blockcontent; + } + + return $content; } /** @@ -1492,7 +1485,7 @@ public function page_navbar() { case 'fullname': case 'shortname': // Full / Short Course Name. - $courseurl = new moodle_url('/course/view.php', ['id' => $COURSE->id]); + $courseurl = new url('/course/view.php', ['id' => $COURSE->id]); $retval .= ''; break; @@ -1553,7 +1546,7 @@ public function navbar(): string { ]); } else if (\theme_adaptable\toolbox::get_setting('breadcrumbhome') == 'icon') { $breadcrumbs .= html_writer::link( - new moodle_url('/'), + new url('/'), // Adds in a title for accessibility purposes. html_writer::tag('i', '', [ 'title' => get_string('home', 'theme_adaptable'), @@ -1561,7 +1554,7 @@ public function navbar(): string { ); $breadcrumbs .= ''; } else { - $breadcrumbs .= html_writer::link(new moodle_url('/'), get_string('home', 'theme_adaptable')); + $breadcrumbs .= html_writer::link(new url('/'), get_string('home', 'theme_adaptable')); $breadcrumbs .= ''; } $start = false; @@ -1664,9 +1657,9 @@ public function navigation_menu_content() { $branchlabel .= $branchtitle; if (!empty($this->page->theme->settings->enablehomeredirect)) { - $branchurl = new moodle_url('/?redirect=0'); + $branchurl = new url('/?redirect=0'); } else { - $branchurl = new moodle_url('/'); + $branchurl = new url('/'); } $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } @@ -1678,7 +1671,7 @@ public function navigation_menu_content() { $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('dashboard', ['fa-lg', 'mr-1']); } $branchlabel .= $branchtitle; - $branchurl = new moodle_url('/my/index.php'); + $branchurl = new url('/my/index.php'); $branchsort++; $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } @@ -1690,7 +1683,7 @@ public function navigation_menu_content() { $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('th', ['fa-lg', 'mr-1']); } $branchlabel .= $branchtitle; - $branchurl = new moodle_url('/my/courses.php'); + $branchurl = new url('/my/courses.php'); $branchsort++; $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } @@ -1703,7 +1696,7 @@ public function navigation_menu_content() { } $branchlabel .= $branchtitle; - $branchurl = new moodle_url('/calendar/view.php'); + $branchurl = new url('/calendar/view.php'); $branchsort++; $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } @@ -1786,7 +1779,7 @@ public function navigation_menu_content() { '', $branchtitle ) . $branchtitle; - $branchurl = new moodle_url('/user/index.php', ['id' => $this->page->course->id]); + $branchurl = new url('/user/index.php', ['id' => $this->page->course->id]); $branch->add($branchlabel, $branchurl, $branchtitle, $branchmenusort); } @@ -1794,7 +1787,7 @@ public function navigation_menu_content() { if ($this->page->theme->settings->displaygrades) { $branchtitle = get_string('grades'); $branchlabel = $this->pix_icon('i/grades', $branchtitle, '') . $branchtitle; - $branchurl = new moodle_url('/grade/report/index.php', ['id' => $this->page->course->id]); + $branchurl = new url('/grade/report/index.php', ['id' => $this->page->course->id]); $branchmenusort++; $branch->add($branchlabel, $branchurl, $branchtitle, $branchmenusort); } @@ -1803,7 +1796,7 @@ public function navigation_menu_content() { if (\theme_adaptable\toolbox::kalturaplugininstalled()) { $branchtitle = get_string('nav_mediagallery', 'local_kalturamediagallery'); $branchlabel = $this->pix_icon('media-gallery', $branchtitle, 'local_kalturamediagallery') . $branchtitle; - $branchurl = new moodle_url( + $branchurl = new url( '/local/kalturamediagallery/index.php', ['courseid' => $this->page->course->id] ); @@ -1816,7 +1809,7 @@ public function navigation_menu_content() { if ($this->page->theme->settings->enablecompetencieslink) { $branchtitle = get_string('competencies', 'competency'); $branchlabel = $this->pix_icon('i/competencies', $branchtitle, '') . $branchtitle; - $branchurl = new moodle_url( + $branchurl = new url( '/admin/tool/lp/coursecompetencies.php', ['courseid' => $this->page->course->id] ); @@ -1833,7 +1826,7 @@ public function navigation_menu_content() { $branchmenusort++; $branch->add( $icon . $modfullname, - new moodle_url('/course/resources.php', ['id' => $this->page->course->id]), + new url('/course/resources.php', ['id' => $this->page->course->id]), $modfullname, $branchmenusort ); @@ -1842,7 +1835,7 @@ public function navigation_menu_content() { $branchmenusort++; $branch->add( $icon . $modfullname, - new moodle_url('/mod/' . $modname . '/index.php', ['id' => $this->page->course->id]), + new url('/mod/' . $modname . '/index.php', ['id' => $this->page->course->id]), $modfullname, $branchmenusort ); @@ -1881,7 +1874,7 @@ public function navigation_menu_content() { $branchtitle = $this->page->theme->settings->$helplinktitlesetting; } $branchlabel = $helpicon . $branchtitle; - $branchurl = new moodle_url( + $branchurl = new url( $this->page->theme->settings->$enablehelpsetting, ['helptarget' => $this->page->theme->settings->helptarget] ); @@ -2614,13 +2607,13 @@ public function lang_menu($showtext = true) { $this->language = $langmenu->add( '' . $currentlang . '', - new moodle_url($this->page->url), + new url($this->page->url), $strlang, 10000 ); foreach ($langs as $langtype => $langname) { - $this->language->add($langname, new moodle_url($this->page->url, ['lang' => $langtype]), $langname); + $this->language->add($langname, new url($this->page->url, ['lang' => $langtype]), $langname); } } return $this->render_custom_menu($langmenu, '', '', 'langmenu'); @@ -2726,7 +2719,7 @@ protected function render_custom_menu_item(custom_menu_item $menunode, $level = $linkclass = 'dropdown-item'; } - /* This is a bit of a cludge, but allows us to pass url, of type moodle_url with a param of + /* This is a bit of a cludge, but allows us to pass url, of type url with a param of * "helptarget", which when equal to "_blank", will create a link with target="_blank" to allow the link to open * in a new window. This param is removed once checked. */ @@ -2734,7 +2727,7 @@ protected function render_custom_menu_item(custom_menu_item $menunode, $level = 'title' => $menunode->get_title(), 'class' => $linkclass, ]; - if (is_object($url) && (get_class($url) == 'moodle_url')) { + if (is_object($url) && (get_class($url) == 'core\url')) { $helptarget = $url->get_param('helptarget'); if ($helptarget != null) { $url->remove_params('helptarget'); @@ -2908,7 +2901,7 @@ protected function render_tabobject(\tabobject $tab) { ['class' => 'nav-link disabled'] ), ['class' => 'nav-item']); } else { - if (!($tab->link instanceof moodle_url)) { + if (!($tab->link instanceof url)) { // Backward compatibility when link was passed as quoted string. $link = "link\" title=\"$tab->title\">$tab->text"; } else { @@ -2943,6 +2936,11 @@ public function blocks($region, $classes = [], $tag = 'aside', $fakeblocksonly = $editing = $this->page->user_is_editing(); $classes = (array)$classes; $classes[] = 'block-region'; + if ($editing) { + $classes[] = 'pl-2'; + $classes[] = 'pr-2'; + $classes[] = 'pt-2'; + } $attributes = [ 'id' => 'block-region-'.preg_replace('#[^a-zA-Z0-9_\-]+#', '-', $displayregion), 'class' => join(' ', $classes), @@ -2950,18 +2948,27 @@ public function blocks($region, $classes = [], $tag = 'aside', $fakeblocksonly = 'data-droptarget' => '1', ]; + $blockcontent = ''; + if ($this->page->blocks->region_has_content($displayregion, $this)) { + $blockcontent .= html_writer::tag('h2', get_string('blocks'), ['class' => 'sr-only']) . + $this->blocks_for_region($displayregion, $fakeblocksonly); + } else { + $blockcontent .= html_writer::tag('h2', get_string('blocks'), ['class' => 'sr-only']); + } + $blockcontent = html_writer::tag($tag, $blockcontent, $attributes); + $content = ''; if ($editing) { - $content = $this->block_region_title($region); - } + $title = $this->block_region_title($region); + // Add block button in editing mode. + $addblockbutton = $this->addblockbutton($region); - if ($this->page->blocks->region_has_content($displayregion, $this)) { - $content .= html_writer::tag('h2', get_string('blocks'), ['class' => 'sr-only']) . - $this->blocks_for_region($displayregion, $fakeblocksonly); + $content = html_writer::tag('div', $title.$blockcontent.$addblockbutton, ['class' => 'my-1 adaptable-block-area']); } else { - $content .= html_writer::tag('h2', get_string('blocks'), ['class' => 'sr-only']); + $content = $blockcontent; } - return html_writer::tag($tag, $content, $attributes); + + return $content; } /** @@ -3015,6 +3022,23 @@ public function blocks_for_region($region, $fakeblocksonly = false) { return $output; } + /** + * Generate the add block button when editing mode is turned on and the user can edit blocks. + * + * @param string $region where new blocks should be added. + * @return string html for the add block button. + */ + public function addblockbutton($region = ''): string { + $content = parent::addblockbutton($region); + + if (!empty($content)) { + // Wrapper. + $content = html_writer::tag('div', $content, ['class' => 'd-flex justify-content-center']); + } + + return $content; + } + /** * This is an optional menu that can be added to a layout by a theme. It contains the * menu for the course administration, only on the course main page. Lifted from Boost theme @@ -3102,8 +3126,8 @@ public function context_header_settings_menu() { // We only add a list to the full settings menu if we didn't include every node in the short menu. if ($skipped) { $text = get_string('morenavigationlinks'); - $url = new moodle_url('/course/admin.php', ['courseid' => $this->page->course->id]); - $link = new \action_link($url, $text, null, null, new \pix_icon('t/edit', '')); + $url = new url('/course/admin.php', ['courseid' => $this->page->course->id]); + $link = new action_link($url, $text, null, null, new pix_icon('t/edit', '')); $menu->add_secondary_action($link); } } @@ -3117,8 +3141,8 @@ public function context_header_settings_menu() { // We only add a list to the full settings menu if we didn't include every node in the short menu. if ($skipped) { $text = get_string('morenavigationlinks'); - $url = new moodle_url('/course/admin.php', ['courseid' => $this->page->course->id]); - $link = new \action_link($url, $text, null, null, new \pix_icon('t/edit', '')); + $url = new url('/course/admin.php', ['courseid' => $this->page->course->id]); + $link = new action_link($url, $text, null, null, new pix_icon('t/edit', '')); $menu->add_secondary_action($link); } } @@ -3306,21 +3330,21 @@ protected function build_action_menu_from_navigation( continue; } if ($menuitem->action) { - if ($menuitem->action instanceof \action_link) { + if ($menuitem->action instanceof action_link) { $link = $menuitem->action; // Give preference to setting icon over action icon. if (!empty($menuitem->icon)) { $link->icon = $menuitem->icon; } } else { - $link = new \action_link($menuitem->action, $menuitem->text, null, null, $menuitem->icon); + $link = new action_link($menuitem->action, $menuitem->text, null, null, $menuitem->icon); } } else { if ($onlytopleafnodes) { $skipped = true; continue; } - $link = new \action_link(new moodle_url('#'), $menuitem->text, null, ['disabled' => true], $menuitem->icon); + $link = new action_link(new url('#'), $menuitem->text, null, ['disabled' => true], $menuitem->icon); } if ($indent) { $link->add_class('ml-4'); @@ -3369,10 +3393,10 @@ public function search_box($id = false) { result in an extra included file for each site, even the ones where global search is disabled. */ if (empty($CFG->enableglobalsearch) || !has_capability('moodle/search:query', \context_system::instance())) { - $action = new moodle_url('/course/search.php'); + $action = new url('/course/search.php'); $searchstring = get_string('coursesearch', 'theme_adaptable'); } else { - $action = new moodle_url('/search/index.php'); + $action = new url('/search/index.php'); $searchstring = get_string('globalsearch', 'core_admin'); } diff --git a/classes/output/core_user/myprofile/renderer.php b/classes/output/core_user/myprofile/renderer.php index 773a4c4..cfd9f31 100644 --- a/classes/output/core_user/myprofile/renderer.php +++ b/classes/output/core_user/myprofile/renderer.php @@ -34,7 +34,6 @@ use core_user\output\myprofile\category; use core_user\output\myprofile\node; use core_user\output\myprofile\tree; -use html_writer; require_once($CFG->dirroot . '/user/lib.php'); diff --git a/classes/output/custom_menu.php b/classes/output/custom_menu.php index f48c0f1..14f4f31 100644 --- a/classes/output/custom_menu.php +++ b/classes/output/custom_menu.php @@ -26,6 +26,9 @@ namespace theme_adaptable\output; +use core\output\custom_menu_item; +use core\url; + /** * Adaptable's custom menu. */ @@ -38,7 +41,7 @@ class custom_menu extends \custom_menu { */ public function __construct($definition = '', $currentlanguage = null) { $this->currentlanguage = $currentlanguage; - \custom_menu_item::__construct('root'); // create virtual root element of the menu + custom_menu_item::__construct('root'); // create virtual root element of the menu if (!empty($definition)) { $this->override_children(self::convert_text_to_menu_nodes($definition, $currentlanguage)); } @@ -51,7 +54,7 @@ public function __construct($definition = '', $currentlanguage = null) { * @param string $currentlanguage The current language code, null disables multilang support. * @param string $menu Other menu to add to (optional). */ - public function add_custom_menu_items($definition = '', $currentlanguage = null, \custom_menu_item $menu = null) { + public function add_custom_menu_items($definition = '', $currentlanguage = null, custom_menu_item $menu = null) { if (!empty($definition)) { $items = self::convert_text_to_menu_nodes($definition, $currentlanguage); if (empty($menu)) { @@ -122,7 +125,7 @@ public static function convert_text_to_menu_nodes($text, $language = null) { break; case 1: // URL. try { - $itemurl = new \moodle_url($setting); + $itemurl = new url($setting); } catch (\moodle_exception $exception) { // We're not actually worried about this, we don't want to mess up the display // just for a wrongly entered URL. diff --git a/classes/output/icon_system_fontawesome.php b/classes/output/icon_system_fontawesome.php index a764aba..2132d4d 100644 --- a/classes/output/icon_system_fontawesome.php +++ b/classes/output/icon_system_fontawesome.php @@ -26,6 +26,8 @@ */ namespace theme_adaptable\output; +use core\output\pix_icon; + /** * Font Awesome icon system. */ @@ -524,8 +526,8 @@ public function get_amd_name() { * * @return string the rendered icon markup. */ - public function render_pix_icon(\renderer_base $output, \pix_icon $icon) { - $subtype = '\pix_icon_fontawesome'; + public function render_pix_icon(\renderer_base $output, pix_icon $icon) { + $subtype = '\core\output\pix_icon_fontawesome'; $subpix = new $subtype($icon); $data = $subpix->export_for_template($output); diff --git a/classes/output/mustache_renderer.php b/classes/output/mustache_renderer.php index 8f220b2..7f896f8 100644 --- a/classes/output/mustache_renderer.php +++ b/classes/output/mustache_renderer.php @@ -29,7 +29,7 @@ /** * The mustache renderer. */ -class mustache_renderer extends \core_renderer { +class mustache_renderer extends \core\output\core_renderer { /** * @var Mustache_Loader $stringloader The mustache string loader. */ diff --git a/classes/output/navigation/primary.php b/classes/output/navigation/primary.php index 611f4ef..96b4593 100644 --- a/classes/output/navigation/primary.php +++ b/classes/output/navigation/primary.php @@ -16,8 +16,8 @@ namespace theme_adaptable\output\navigation; -use custom_menu; -use renderer_base; +use core\output\custom_menu; +use core\output\renderer_base; /** * Adaptable theme. @@ -60,7 +60,7 @@ public function export_for_template(?renderer_base $output = null): array { foreach ($menu->get_children() as $node) { $url = $node->get_url(); $target = ''; - if (is_object($url) && (get_class($url) == 'moodle_url')) { + if (is_object($url) && (get_class($url) == 'core\url')) { $target = $url->get_param('helptarget'); if ($target != null) { $url->remove_params('helptarget'); diff --git a/classes/toolbox.php b/classes/toolbox.php index fb1aae5..3488859 100644 --- a/classes/toolbox.php +++ b/classes/toolbox.php @@ -27,6 +27,9 @@ namespace theme_adaptable; +use core\output\html_writer; +use core\output\theme_config; + /** * Class definition for toolbox. */ @@ -75,7 +78,7 @@ public static function get_instance() { } /** - * Gets the setting moodle_url for the given setting if it exists and set. + * Gets the setting url for the given setting if it exists and set. * * See: https://moodle.org/mod/forum/discuss.php?d=371252#p1516474 and change if theme_config::setting_file_url * changes. @@ -86,11 +89,11 @@ public static function get_instance() { * * @return string Setting url */ - public static function get_setting_moodle_url($setting, $theconfig = null) { + public static function get_setting_url($setting, $theconfig = null) { $settingurl = null; if (empty($theconfig)) { - $theconfig = \theme_config::load('adaptable'); + $theconfig = theme_config::load('adaptable'); } if ($theconfig != null) { $thesetting = $theconfig->settings->$setting; @@ -99,7 +102,7 @@ public static function get_setting_moodle_url($setting, $theconfig = null) { $itemid = \theme_get_revision(); $syscontext = \context_system::instance(); - $settingurl = \moodle_url::make_file_url( + $settingurl = \core\url::make_file_url( "$CFG->wwwroot/pluginfile.php", "/$syscontext->id/theme_$theconfig->name/$setting/$itemid" . $thesetting ); @@ -142,7 +145,7 @@ public static function get_setting($settingname, $format = false, $themename = n $themename = 'adaptable'; } if (empty(self::$themeconfigs[$themename])) { - self::$themeconfigs[$themename] = \theme_config::load($themename); + self::$themeconfigs[$themename] = theme_config::load($themename); } $setting = (!empty(self::$themeconfigs[$themename]->settings->$settingname)) ? @@ -185,7 +188,7 @@ public static function get_theme($themename = null) { $themename = 'adaptable'; } if (empty(self::$themeconfigs[$themename])) { - self::$themeconfigs[$themename] = \theme_config::load($themename); + self::$themeconfigs[$themename] = theme_config::load($themename); } return self::$themeconfigs[$themename]; @@ -637,9 +640,9 @@ public static function getfontawesomemarkup($theicon, $classes = [], $attributes $attributes['class'] = implode(' ', $classes); if (!empty($title)) { $attributes['title'] = $title; - $content .= \html_writer::tag('span', $title, ['class' => 'sr-only']); + $content .= html_writer::tag('span', $title, ['class' => 'sr-only']); } - return \html_writer::tag('span', $content, $attributes); + return html_writer::tag('span', $content, $attributes); } /** diff --git a/config.php b/config.php index f850df5..fbf7c05 100644 --- a/config.php +++ b/config.php @@ -252,3 +252,4 @@ $THEME->haseditswitch = false; $THEME->usescourseindex = true; $THEME->iconsystem = '\\theme_adaptable\\output\\icon_system_fontawesome'; +$THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_FLATNAV; diff --git a/lang/en/theme_adaptable.php b/lang/en/theme_adaptable.php index c42e601..1796450 100644 --- a/lang/en/theme_adaptable.php +++ b/lang/en/theme_adaptable.php @@ -315,6 +315,9 @@ $string['blocklayoutlayoutrow'] = 'Block region row'; $string['blocklayoutlayoutrowdesc'] = 'Add / set layout for block region row on front page.'; +$string['blockregioneditingtitleshown'] = 'Show the block region title when editing'; +$string['blockregioneditingtitleshowndesc'] = 'You can show / hide the block region title when editing.'; + $string['dashblocklayoutlayoutrow'] = 'Dashboard block region row '; $string['dashblocklayoutlayoutrowdesc'] = 'Add / set layout for block region row on Dashboard page.'; diff --git a/lib.php b/lib.php index fd6a0e2..1a353e9 100644 --- a/lib.php +++ b/lib.php @@ -32,6 +32,9 @@ global $CFG; require_once($CFG->dirroot . '/theme/boost/lib.php'); +use core\output\theme_config; +use core\url; + define('THEME_ADAPTABLE_DEFAULT_ALERTCOUNT', '1'); define('THEME_ADAPTABLE_DEFAULT_ANALYTICSCOUNT', '1'); define('THEME_ADAPTABLE_DEFAULT_TOPMENUSCOUNT', '1'); @@ -804,12 +807,12 @@ function theme_adaptable_extend_navigation_course($coursenode, $course, $coursec $editstring = get_string('turngradereditingon', 'theme_adaptable'); } } else { - if ($PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) { + if ($PAGE->url->compare(new url('/course/view.php'), URL_MATCH_BASE)) { // We are on the course page, retain the current page params e.g. section. $editurl = clone($PAGE->url); } else { // Edit on the main course page. - $editurl = new moodle_url( + $editurl = new url( '/course/view.php', ['id' => $course->id, 'return' => $PAGE->url->out_as_local_url(false)] ); diff --git a/libs/admin_confightmleditor.php b/libs/admin_confightmleditor.php index 6de3f09..0b24bc0 100644 --- a/libs/admin_confightmleditor.php +++ b/libs/admin_confightmleditor.php @@ -26,6 +26,8 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ +use core\url; + /** * Class to configure html editor for admin settings allowing use of repositories. * @@ -261,7 +263,7 @@ public function write_setting($data) { ) { $filerec = $fs->create_file_from_storedfile($filerecord, $file); } - $url = moodle_url::make_pluginfile_url( + $url = url::make_pluginfile_url( $filerec->get_contextid(), $filerec->get_component(), $filerec->get_filearea(), diff --git a/settings.php b/settings.php index c627971..7cf195e 100644 --- a/settings.php +++ b/settings.php @@ -40,7 +40,7 @@ $asettings = new \theme_adaptable\admin_settingspage_tabs( 'themesettingadaptable', get_string('configtabtitle', 'theme_adaptable'), - 404 + 405 ); if ($ADMIN->fulltree) { include(dirname(__FILE__) . '/settings/array_definitions.php'); diff --git a/settings/block_settings.php b/settings/block_settings.php index 7543900..3844cfc 100644 --- a/settings/block_settings.php +++ b/settings/block_settings.php @@ -35,6 +35,12 @@ $setting = new admin_setting_heading($name, $heading, ''); $page->add($setting); + $name = 'theme_adaptable/blockregioneditingtitleshown'; + $title = get_string('blockregioneditingtitleshown', 'theme_adaptable'); + $description = get_string('blockregioneditingtitleshowndesc', 'theme_adaptable'); + $setting = new admin_setting_configcheckbox($name, $title, $description, true); + $page->add($setting); + $name = 'theme_adaptable/frontpageuserblocksenabled'; $title = get_string('frontpageuserblocksenabled', 'theme_adaptable'); $description = get_string('frontpageuserblocksenableddesc', 'theme_adaptable'); diff --git a/templates/sidepost.mustache b/templates/sidepost.mustache index 89fcce2..b231e83 100644 --- a/templates/sidepost.mustache +++ b/templates/sidepost.mustache @@ -35,7 +35,6 @@ {{$drawerclasses}}drawer drawer-{{#left}}left{{/left}}{{^left}}right{{/left}}{{#sidepostopen}} show{{/sidepostopen}}{{#stickynavbar}} d-none{{/stickynavbar}}{{/drawerclasses}} {{$drawercontent}}
- {{{ addblockbutton }}} {{{ sidepost }}}
{{/drawercontent}} diff --git a/tests/toolbox_test.php b/tests/toolbox_test.php index 61face9..5a89a96 100644 --- a/tests/toolbox_test.php +++ b/tests/toolbox_test.php @@ -36,6 +36,7 @@ final class toolbox_test extends \advanced_testcase { * Set up. */ protected function setUp(): void { + parent::setUp(); $this->resetAfterTest(true); set_config('theme', 'adaptable'); @@ -43,6 +44,7 @@ protected function setUp(): void { /** * Add property test. + * @covers \theme_adaptable\toolbox::to_add_property */ public function test_to_add_property(): void { // Ref: http://stackoverflow.com/questions/249664/best-practices-to-test-protected-methods-with-phpunit. diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml index 211333c..7c9fa2f 100644 --- a/thirdpartylibs.xml +++ b/thirdpartylibs.xml @@ -199,7 +199,7 @@ ../boost/scss/fontawesome Font Awesome - http://fontawesome.com Font Awesome CSS, LESS, and Sass files. Font Awesome is the Internet's icon library and toolkit, used by millions of designers, developers, and content creators. - 6.5.1 + 6.5.2 (MIT) https://github.com/FortAwesome/Font-Awesome @@ -239,5 +239,3 @@ - - diff --git a/version.php b/version.php index a2bd0d5..2367734 100644 --- a/version.php +++ b/version.php @@ -33,19 +33,19 @@ $plugin->component = 'theme_adaptable'; // Adaptable version date (YYYYMMDDrr where rr is the release number). -$plugin->version = 2024032803; +$plugin->version = 2024100500; -$plugin->requires = 2024042200.00; // 4.4 (Build: 20240422). +$plugin->requires = 2024100700.00; // 4.5 (Build: 20241007). -$plugin->supported = [404, 404]; +$plugin->supported = [405, 405]; // Adaptable version using SemVer (https://semver.org). -$plugin->release = '404.1.1'; +$plugin->release = '405.0.1'; // Adaptable maturity (do not use ALPHA or BETA versions in production sites). -$plugin->maturity = MATURITY_STABLE; +$plugin->maturity = MATURITY_RC; // Adaptable dependencies (Only Boost as it's the parent theme). $plugin->dependencies = [ - 'theme_boost' => 2024042200, + 'theme_boost' => 2024100700, ];