From a9dca1ca7a20e7855278a63789df8acb7d1259a7 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:21:28 +0000 Subject: [PATCH] V405.1.1 --- Changes.md | 15 + classes/admin_setting_getprops.php | 6 +- classes/output/core_renderer_layout.php | 7 +- classes/output/core_renderer_toolbox.php | 345 +++++++----------- classes/output/custom_menu.php | 7 +- classes/output/external.php | 2 +- db/upgrade.php | 11 + lang/en/theme_adaptable.php | 33 +- lib.php | 12 +- scss/main.scss | 1 + scss/nosettings/_menu.scss | 30 ++ scss/nosettings/_modal.scss | 8 + scss/settings/adaptable.scss | 7 +- scss/settings/menu.scss | 30 +- scss/settings/search.scss | 59 ++- settings.php | 2 +- settings/dash_block_regions.php | 5 +- settings/header.php | 2 +- settings/navbar_mycourses.php | 10 + settings/navbar_styles.php | 17 +- ...menu.php => navbar_userfav_tools_menu.php} | 33 +- templates/headernavbar.mustache | 2 + templates/headerstyleone.mustache | 2 +- version.php | 4 +- 24 files changed, 355 insertions(+), 295 deletions(-) create mode 100644 scss/nosettings/_menu.scss rename settings/{navbar_tools_menu.php => navbar_userfav_tools_menu.php} (77%) diff --git a/Changes.md b/Changes.md index 40a603c..6eded3b 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,18 @@ +Change Log in version 405.1.1 (2024100502) +========================================== +1. Fix 'Class "core\external\output\icon_system" not found' - #35. +2. Add theme user settings, initially 'My courses custom sort' - Sponsors only functionality. +3. Larger tools menu title and field setting boxes. The former to help with multilang support. +4. Fix navbar search magnifying glass position. +5. Add user favourites menu - Sponsors only functionality. +6. Tools menu settings should be 'PARAM_TEXT'. +7. Allow sub-sub menus. +8. Add 'navbardisplaytitles' setting to show / hide the navbar titles, disabled when 'navbardisplayicons' is unset. +9. Rename 'navbardisplaysubmenuarrow' to 'navbardisplaymenuarrow' and fix places where this didn't apply. +10. Fix original header search icon colour when open. +11. Fix header search position and default setting value. +12. Tidy header search. + Change Log in version 405.1.0 (2024100501) ========================================== 1. Stable release for Moodle 4.5. diff --git a/classes/admin_setting_getprops.php b/classes/admin_setting_getprops.php index e436374..d58473a 100644 --- a/classes/admin_setting_getprops.php +++ b/classes/admin_setting_getprops.php @@ -198,7 +198,11 @@ public function output_html($data, $query = '') { $draftjson->delete(); // Finished with draft. - $savepropsfilestoofileresult = get_string('propertiesexportfilestoofilesuccess', $this->pluginfrankenstyle, $settingfile->get_filename()); + $savepropsfilestoofileresult = get_string( + 'propertiesexportfilestoofilesuccess', + $this->pluginfrankenstyle, + $settingfile->get_filename() + ); } else { $savepropsfilestoofileresult = get_string('propertiesexportfilestoofilefail', $this->pluginfrankenstyle); $alertstate = 'warning'; diff --git a/classes/output/core_renderer_layout.php b/classes/output/core_renderer_layout.php index 3e6b726..fe8dda8 100644 --- a/classes/output/core_renderer_layout.php +++ b/classes/output/core_renderer_layout.php @@ -220,7 +220,8 @@ public function yesheader($sidepostdrawer) { // Display user profile menu. // Only used when user is logged in and not on the secure layout. if ((isloggedin()) && ($this->page->pagelayout != 'secure')) { - $headercontext['loginoruser'] = ''; + $headercontext['loginoruser'] = + ''; } else { $headercontext['loginoruser'] = ''; } @@ -247,6 +248,7 @@ public function yesheader($sidepostdrawer) { $headercontext['shownavbar'] = [ 'navigationmenu' => $this->navigation_menu('main-navigation'), 'output' => $this, + 'userfavmenu' => $this->userfav_menu(), 'toolsmenu' => $this->tools_menu(), ]; @@ -544,7 +546,8 @@ protected function sidepostheader() { $sideposthtml = $this->blocks('side-post'); // Blocks or add block button. - $hassidepost = ((strpos($sideposthtml, 'data-block=') !== false) || (strpos($sideposthtml, 'data-key="addblock"') !== false)); + $hassidepost = + ((strpos($sideposthtml, 'data-block=') !== false) || (strpos($sideposthtml, 'data-key="addblock"') !== false)); if (!$hassidepost) { $sidepostopen = false; } diff --git a/classes/output/core_renderer_toolbox.php b/classes/output/core_renderer_toolbox.php index 4808740..bc3fe33 100644 --- a/classes/output/core_renderer_toolbox.php +++ b/classes/output/core_renderer_toolbox.php @@ -36,6 +36,7 @@ use core\output\pix_icon; use core\url; use core_block\output\block_contents; +use custom_menu as core_custom_menu; use navigation_node; use stdClass; @@ -1586,37 +1587,19 @@ protected function render_navigation_node(navigation_node $item) { } /** - * Compares two course entries against their access time for a user to see which is first. + * Returns the page heading menu. * - * @param stdClass $a A course. - * @param stdClass $b A course. - * - * @return int -1 'a' is first, 1 'b' is first or 0 they are equal. + * @return string Markup. */ - protected static function timeaccesscompare($a, $b) { - // The timeaccess is lastaccess entry and timestart an enrol entry. - if ((!empty($a->timeaccess)) && (!empty($b->timeaccess))) { - // Both last access. - if ($a->timeaccess == $b->timeaccess) { - return 0; - } - return ($a->timeaccess > $b->timeaccess) ? -1 : 1; - } else if ((!empty($a->timestart)) && (!empty($b->timestart))) { - // Both enrol. - if ($a->timestart == $b->timestart) { - return 0; - } - return ($a->timestart > $b->timestart) ? -1 : 1; - } + public function page_heading_menu() { + $retr = parent::page_heading_menu(); - /* Must be comparing an enrol with a last access. - -1 is to say that 'a' comes before 'b'. */ - if (!empty($a->timestart)) { - // If 'a' is the enrol entry. - return -1; + $localtoolbox = \theme_adaptable\toolbox::get_local_toolbox(); + if (is_object($localtoolbox)) { + $themesettings = \theme_adaptable\toolbox::get_settings(); + $retr = $localtoolbox->get_user_settings($themesettings, $this->page, $this).$retr; } - // Then 'b' must be the enrol entry. - return 1; + return $retr; } /** @@ -1632,31 +1615,28 @@ public function navigation_menu_content() { $overridelist = false; $overridetype = 'off'; - if (!empty($this->page->theme->settings->navbardisplayicons)) { - $navbardisplayicons = true; - } else { - $navbardisplayicons = false; - } - - $mysitesmaxlength = '30'; - if (!empty($this->page->theme->settings->mysitesmaxlength)) { - $mysitesmaxlength = $this->page->theme->settings->mysitesmaxlength; + $themesettings = \theme_adaptable\toolbox::get_settings(); + $navbardisplayicons = (!empty($themesettings->navbardisplayicons)); + $navbardisplaytitles = (!empty($themesettings->navbardisplaytitles)); + if (!$navbardisplaytitles && !$navbardisplayicons) { + // Can't have nothing! + $navbardisplaytitles = true; } - $mysitesmaxlengthhidden = $mysitesmaxlength - 3; - $branchsort = 9998; if (isloggedin() && !isguestuser()) { - if (!empty($this->page->theme->settings->enablehome)) { + if (!empty($themesettings->enablehome)) { $branchlabel = ''; $branchtitle = get_string('home', 'theme_adaptable'); if ($navbardisplayicons) { $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('home', ['fa-lg', 'mr-1']); } - $branchlabel .= $branchtitle; + if ($navbardisplaytitles) { + $branchlabel .= '' . $branchtitle . ''; + } - if (!empty($this->page->theme->settings->enablehomeredirect)) { + if (!empty($themesettings->enablehomeredirect)) { $branchurl = new url('/?redirect=0'); } else { $branchurl = new url('/'); @@ -1664,99 +1644,70 @@ public function navigation_menu_content() { $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } - if (!empty($this->page->theme->settings->enablemyhome)) { + if (!empty($themesettings->enablemyhome)) { $branchlabel = ''; $branchtitle = get_string('myhome'); if ($navbardisplayicons) { $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('dashboard', ['fa-lg', 'mr-1']); } - $branchlabel .= $branchtitle; + if ($navbardisplaytitles) { + $branchlabel .= '' . $branchtitle . ''; + } $branchurl = new url('/my/index.php'); $branchsort++; $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } - if (!empty($this->page->theme->settings->enablemycourses)) { + if (!empty($themesettings->enablemycourses)) { $branchlabel = ''; $branchtitle = get_string('courses'); if ($navbardisplayicons) { $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('th', ['fa-lg', 'mr-1']); } - $branchlabel .= $branchtitle; + if ($navbardisplaytitles) { + $branchlabel .= '' . $branchtitle . ''; + } $branchurl = new url('/my/courses.php'); $branchsort++; $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } - if (!empty($this->page->theme->settings->enableevents)) { + if (!empty($themesettings->enableevents)) { $branchlabel = ''; $branchtitle = get_string('events', 'theme_adaptable'); if ($navbardisplayicons) { $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('calendar', ['fa-lg', 'mr-1']); } - $branchlabel .= $branchtitle; + if ($navbardisplaytitles) { + $branchlabel .= '' . $branchtitle . ''; + } $branchurl = new url('/calendar/view.php'); $branchsort++; $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } - $overridetype = null; - $overridelist = null; - - if (!empty($this->page->theme->settings->mysitessortoverride)) { - $overridetype = $this->page->theme->settings->mysitessortoverride; - } - - if (!empty($this->page->theme->settings->mysitessortoverridefield)) { - $overridelist = $this->page->theme->settings->mysitessortoverridefield; - } - - if (($overridetype == 'profilefields' || $overridetype == 'profilefieldscohort') && (isset($overridelist))) { - $overridelist = $this->get_profile_field_contents($overridelist); - - if ($overridetype == 'profilefieldscohort') { - $overridelist = array_merge($this->get_cohort_enrollments(), $overridelist); - } - } - - if ($overridetype == 'strings' && isset($overridelist)) { - $overridelist = explode(',', $overridelist); - } - $localtoolbox = \theme_adaptable\toolbox::get_local_toolbox(); if (is_object($localtoolbox)) { - $themesettings = \theme_adaptable\toolbox::get_settings(); $localtoolbox->get_mycourses( $menu, $branchsort, - $navbardisplayicons, - $overridelist, - $overridetype, - $mysitesmaxlength, - $mysitesmaxlengthhidden, - $this->page->theme->settings, + $themesettings, $this->page, $this ); } - if (!empty($this->page->theme->settings->enablethiscourse)) { + if (!empty($themesettings->enablethiscourse)) { if (isset($COURSE->id) && $COURSE->id != SITEID) { - $branchlabel = ''; $branchtitle = get_string('thiscourse', 'theme_adaptable'); + $branchlabel = ''; if ($navbardisplayicons) { $branchlabel .= - \theme_adaptable\toolbox::getfontawesomemarkup('sitemap', ['mr-1', 'fa-lg']) . ''; + \theme_adaptable\toolbox::getfontawesomemarkup('sitemap', ['mr-1', 'fa-lg']); } - $branchlabel .= $branchtitle; - if ($navbardisplayicons) { - $branchlabel .= ''; - } - - // Check the option of displaying a sub-menu arrow symbol. - if (!empty($this->page->theme->settings->navbardisplaysubmenuarrow)) { - $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('caret-down', ['ml-1']); + if ($navbardisplaytitles) { + $branchlabel .= '' . $branchtitle . ''; } $branchurl = $this->page->url; @@ -1764,13 +1715,13 @@ public function navigation_menu_content() { $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); // Course sections. - if ($this->page->theme->settings->enablecoursesections) { + if ($themesettings->enablecoursesections) { $this->create_course_sections_menu($branch); } // Display Participants. $branchmenusort = 10000; - if ($this->page->theme->settings->displayparticipants) { + if ($themesettings->displayparticipants) { $branchtitle = get_string('people', 'theme_adaptable'); $branchlabel = \theme_adaptable\toolbox::getfontawesomemarkup( 'users', @@ -1778,15 +1729,17 @@ public function navigation_menu_content() { [], '', $branchtitle - ) . $branchtitle; + ); + $branchlabel .= '' . $branchtitle . ''; $branchurl = new url('/user/index.php', ['id' => $this->page->course->id]); $branch->add($branchlabel, $branchurl, $branchtitle, $branchmenusort); } // Display Grades. - if ($this->page->theme->settings->displaygrades) { + if ($themesettings->displaygrades) { $branchtitle = get_string('grades'); - $branchlabel = $this->pix_icon('i/grades', $branchtitle, '') . $branchtitle; + $branchlabel = $this->pix_icon('i/grades', $branchtitle, ''); + $branchlabel .= '' . $branchtitle . ''; $branchurl = new url('/grade/report/index.php', ['id' => $this->page->course->id]); $branchmenusort++; $branch->add($branchlabel, $branchurl, $branchtitle, $branchmenusort); @@ -1795,7 +1748,8 @@ public function navigation_menu_content() { // Kaltura video gallery. if (\theme_adaptable\toolbox::kalturaplugininstalled()) { $branchtitle = get_string('nav_mediagallery', 'local_kalturamediagallery'); - $branchlabel = $this->pix_icon('media-gallery', $branchtitle, 'local_kalturamediagallery') . $branchtitle; + $branchlabel = $this->pix_icon('media-gallery', $branchtitle, 'local_kalturamediagallery'); + $branchlabel .= '' . $branchtitle . ''; $branchurl = new url( '/local/kalturamediagallery/index.php', ['courseid' => $this->page->course->id] @@ -1806,9 +1760,10 @@ public function navigation_menu_content() { // Display Competencies. if (get_config('core_competency', 'enabled')) { - if ($this->page->theme->settings->enablecompetencieslink) { + if ($themesettings->enablecompetencieslink) { $branchtitle = get_string('competencies', 'competency'); - $branchlabel = $this->pix_icon('i/competencies', $branchtitle, '') . $branchtitle; + $branchlabel = $this->pix_icon('i/competencies', $branchtitle, ''); + $branchlabel .= '' . $branchtitle . ''; $branchurl = new url( '/admin/tool/lp/coursecompetencies.php', ['courseid' => $this->page->course->id] @@ -1821,20 +1776,22 @@ public function navigation_menu_content() { // Display activities. $data = theme_adaptable_get_course_activities(); foreach ($data as $modname => $modfullname) { + $branchmenusort++; + $branchlabel = ''; if ($modname === 'resources') { - $icon = $this->pix_icon('monologo', get_string('pluginname', 'mod_page'), 'mod_page'); - $branchmenusort++; + $branchlabel .= $this->pix_icon('monologo', get_string('pluginname', 'mod_page'), 'mod_page'); + $branchlabel .= '' . $modfullname . ''; $branch->add( - $icon . $modfullname, + $branchlabel, new url('/course/resources.php', ['id' => $this->page->course->id]), $modfullname, $branchmenusort ); } else { - $icon = $this->pix_icon('monologo', get_string('pluginname', 'mod_' . $modname), $modname); - $branchmenusort++; + $branchlabel .= $this->pix_icon('monologo', get_string('pluginname', 'mod_' . $modname), $modname); + $branchlabel .= '' . $modfullname . ''; $branch->add( - $icon . $modfullname, + $branchlabel, new url('/mod/' . $modname . '/index.php', ['id' => $this->page->course->id]), $modfullname, $branchmenusort @@ -1851,14 +1808,14 @@ public function navigation_menu_content() { $helpicon = ''; } - if (!empty($this->page->theme->settings->helplinkscount)) { - for ($helpcount = 1; $helpcount <= $this->page->theme->settings->helplinkscount; $helpcount++) { + if (!empty($themesettings->helplinkscount)) { + for ($helpcount = 1; $helpcount <= $themesettings->helplinkscount; $helpcount++) { $enablehelpsetting = 'enablehelp' . $helpcount; - if (!empty($this->page->theme->settings->$enablehelpsetting)) { + if (!empty($themesettings->$enablehelpsetting)) { $access = true; $helpprofilefieldsetting = 'helpprofilefield' . $helpcount; - if (!empty($this->page->theme->settings->$helpprofilefieldsetting)) { - $fields = explode('=', $this->page->theme->settings->$helpprofilefieldsetting); + if (!empty($themesettings->$helpprofilefieldsetting)) { + $fields = explode('=', $themesettings->$helpprofilefieldsetting); $ftype = $fields[0]; $setvalue = $fields[1]; if (!$this->check_menu_access($ftype, $setvalue, 'help' . $helpcount)) { @@ -1868,15 +1825,18 @@ public function navigation_menu_content() { if ($access && !$this->hideinforum()) { $helplinktitlesetting = 'helplinktitle' . $helpcount; - if (empty($this->page->theme->settings->$helplinktitlesetting)) { + if (empty($themesettings->$helplinktitlesetting)) { $branchtitle = get_string('helptitle', 'theme_adaptable', ['number' => $helpcount]); } else { - $branchtitle = $this->page->theme->settings->$helplinktitlesetting; + $branchtitle = $themesettings->$helplinktitlesetting; + } + $branchlabel = $helpicon; + if ($navbardisplaytitles) { + $branchlabel .= '' . $branchtitle . ''; } - $branchlabel = $helpicon . $branchtitle; $branchurl = new url( - $this->page->theme->settings->$enablehelpsetting, - ['helptarget' => $this->page->theme->settings->helptarget] + $themesettings->$enablehelpsetting, + ['helptarget' => $themesettings->helptarget] ); $branchsort++; @@ -1888,24 +1848,17 @@ public function navigation_menu_content() { // Custom menu. if ((!empty($CFG->custommenuitems)) && - (empty($this->page->theme->settings->disablecustommenu))) { + (empty($themesettings->disablecustommenu))) { $custommenutitle = \theme_adaptable\toolbox::get_setting('custommenutitle', 'format_plain'); $branch = null; if (!empty($custommenutitle)) { $branchlabel = ''; $branchtitle = $custommenutitle; if ($navbardisplayicons) { - $branchlabel .= - \theme_adaptable\toolbox::getfontawesomemarkup('bars', ['mr-1', 'fa-lg']) . ''; - } - $branchlabel .= $branchtitle; - if ($navbardisplayicons) { - $branchlabel .= ''; + $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('ellipsis', ['mr-1', 'fa-lg']); } - - // Check the option of displaying a sub-menu arrow symbol. - if (!empty($this->page->theme->settings->navbardisplaysubmenuarrow)) { - $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup('caret-down', ['ml-1']); + if ($navbardisplaytitles) { + $branchlabel .= '' . $branchtitle . ''; } $branchurl = $this->page->url; @@ -1951,13 +1904,15 @@ protected function create_course_sections_menu($menu) { if (!empty($sectionsformnenu)) { // Rare but possible! $branchtitle = get_string('sections', 'theme_adaptable'); - $branchlabel = \theme_adaptable\toolbox::getfontawesomemarkup( + $branchlabel = ''; + $branchlabel .= \theme_adaptable\toolbox::getfontawesomemarkup( 'list-ol', ['icon', 'fa-lg'], [], '', $branchtitle - ) . $branchtitle; + ); + $branchlabel .= '' . $branchtitle . ''; $branch = $menu->add($branchlabel, null, $branchtitle, 100003); foreach ($sectionsformnenu as $sectionformenu) { @@ -1986,7 +1941,27 @@ public function navigation_menu($menuid) { } /** - * Returns html to render tools menu in main navigation bar + * Returns html to render user favourites menu on the main navigation bar. + * + * @param string $menuid The id to use when creating menu. Used so this could be called for a nav drawer style display. + * + * + * @return string + */ + public function userfav_menu() { + $retval = ''; + $localtoolbox = \theme_adaptable\toolbox::get_local_toolbox(); + + if (is_object($localtoolbox)) { + $themesettings = \theme_adaptable\toolbox::get_settings(); + $retval = $localtoolbox->userfav_menu($themesettings, $this->page, $this); + } + + return $retval; + } + + /** + * Returns html to render tools menu on the main navigation bar. * * @param string $menuid The id to use when creating menu. Used so this could be called for a nav drawer style display. * @@ -2209,28 +2184,22 @@ public function get_top_menus($showlinktext = false) { $menus = []; $visibility = true; $nummenus = 0; + $themesettings = \theme_adaptable\toolbox::get_settings(); - if (!empty($this->page->theme->settings->menuuseroverride)) { + if (!empty($themesettings->menuuseroverride)) { $visibility = $this->check_menu_user_visibility(); } - $template->showright = false; - if (!empty($this->page->theme->settings->menuslinkright)) { - $template->showright = true; - } + $template->showright = (!empty($themesettings->menuslinkright)); - if (!empty($this->page->theme->settings->menuslinkicon)) { - $template->menuslinkicon = $this->page->theme->settings->menuslinkicon; - } else { - $template->menuslinkicon = 'fa-link'; - } + $template->menuslinkicon = (!empty($themesettings->menuslinkicon)) ? $themesettings->menuslinkicon : 'fa-link'; if ($visibility) { if ( - !empty($this->page->theme->settings->topmenuscount) && !empty($this->page->theme->settings->enablemenus) - && (!$this->page->theme->settings->disablemenuscoursepages || $COURSE->id == 1) + !empty($themesettings->topmenuscount) && !empty($themesettings->enablemenus) + && (!$themesettings->disablemenuscoursepages || $COURSE->id == 1) ) { - $topmenuscount = $this->page->theme->settings->topmenuscount; + $topmenuscount = $themesettings->topmenuscount; for ($i = 1; $i <= $topmenuscount; $i++) { $menunumber = 'menu' . $i; @@ -2241,9 +2210,9 @@ public function get_top_menus($showlinktext = false) { $custommenuitems = ''; $access = true; - if (empty($this->page->theme->settings->$requirelogin) || isloggedin()) { - if (!empty($this->page->theme->settings->$fieldsetting)) { - $fields = explode('=', $this->page->theme->settings->$fieldsetting); + if (empty($themesettings->$requirelogin) || isloggedin()) { + if (!empty($themesettings->$fieldsetting)) { + $fields = explode('=', $themesettings->$fieldsetting); $ftype = $fields[0]; $setvalue = $fields[1]; if (!$this->check_menu_access($ftype, $setvalue, $menunumber)) { @@ -2251,11 +2220,11 @@ public function get_top_menus($showlinktext = false) { } } - if (!empty($this->page->theme->settings->$newmenu) && $access == true) { + if (!empty($themesettings->$newmenu) && $access == true) { $nummenus++; - $menu = ($this->page->theme->settings->$newmenu); - $title = ($this->page->theme->settings->$newmenutitle); - $custommenuitems = $this->parse_custom_menu($menu, format_string($title)); + $menu = $themesettings->$newmenu; + $title = format_string($themesettings->$newmenutitle); + $custommenuitems = $this->parse_custom_menu($menu, $title, $title); $custommenu = new custom_menu($custommenuitems, current_language()); $menus[] = $this->render_overlay_menu($custommenu); } @@ -2300,11 +2269,7 @@ public function get_top_menus($showlinktext = false) { } } - if ($showlinktext == false) { - $template->showlinktext = false; - } else { - $template->showlinktext = true; - } + $template->showlinktext = $showlinktext; return $this->render_from_template('theme_adaptable/overlaymenu', $template); } @@ -2465,89 +2430,23 @@ public function check_menu_access($ftype, $setvalue, $menu) { return $USER->theme_adaptable_menus[$menu]; } - /** - * Returns list of cohort enrollments - * - * @return array - */ - public function get_cohort_enrollments() { - global $DB, $USER; - $userscohorts = $DB->get_records('cohort_members', ['userid' => $USER->id]); - $courses = []; - if ($userscohorts) { - $cohortedcourseslist = $DB->get_records_sql('select ' - . 'courseid ' - . 'from {enrol} ' - . 'where enrol = "cohort" ' - . 'and customint1 in (?)', array_keys($userscohorts)); - $cohortedcourses = $DB->get_records_list('course', 'id', array_keys($cohortedcourseslist), null, 'shortname'); - foreach ($cohortedcourses as $course) { - $courses[] = $course->shortname; - } - } - return($courses); - } - - /** - * Returns contents of multiple comma delimited custom profile fields. - * - * @param string $profilefields delimited list of fields. - * @return array of multiple comma delimited custom profile fields. - */ - public function get_profile_field_contents($profilefields) { - global $CFG, $USER; - $timestamp = 'currentcoursestime'; - $list = 'currentcourseslist'; - $time = time(); - - if (isset($USER->theme_adaptable_menus[$timestamp])) { - if ($USER->theme_adaptable_menus[$timestamp] >= $time) { - if (isset($USER->theme_adaptable_menus[$list])) { - return $USER->theme_adaptable_menus[$list]; - } - } - } - - $retval = []; - - require_once($CFG->dirroot . '/user/profile/lib.php'); - require_once($CFG->dirroot . '/user/lib.php'); - profile_load_data($USER); - - $fields = explode(',', $profilefields); - foreach ($fields as $field) { - $field = trim($field); - $field = "profile_field_$field"; - if (isset($USER->$field)) { - $vals = explode(',', $USER->$field); - foreach ($vals as $value) { - $retval[] = trim($value); - } - } - } - - $USER->theme_adaptable_menus[$list] = $retval; - $USER->theme_adaptable_menus[$timestamp] = $time + 1000 * 60 * 3; // Sess TTL. - - return $retval; - } - /** * Parses / wraps custom menus in HTML. * * @param string $menu * @param string $label + * @param string $title * @param string $class * @param string $close * * @return string */ - public function parse_custom_menu($menu, $label, $class = '', $close = '') { + public function parse_custom_menu($menu, $label, $title, $class = '', $close = '') { /* Top level menu option. No URL added after $close (previously was #). Done to fix current jquery / Bootstrap version incompatibility with using # in target URLS. Ref: Issue 617 on Adaptable theme issues on Bitbucket. */ - $custommenuitems = $class . $label . $close . "||" . $label . "\n"; + $custommenuitems = $class . $label . $close . "||" . $title . "\n"; $arr = explode("\n", $menu); // We want to force everything inputted under this menu. @@ -2560,7 +2459,7 @@ public function parse_custom_menu($menu, $label, $class = '', $close = '') { } /** - * Hide tools menu in forum to make room for forum search optoin + * Hide help, user favourites and tools menu in a forum to make room for forum search option. * * @return boolean */ @@ -2649,14 +2548,14 @@ public function custom_menu_drawer() { * * @return string */ - public function render_custom_menu(\custom_menu $menu, $wrappre = '', $wrappost = '', $menuid = '') { + public function render_custom_menu(core_custom_menu $menu, $wrappre = '', $wrappost = '', $menuid = '') { if (!$menu->has_children()) { return ''; } $content = ''; foreach ($menu->get_children() as $item) { - if (stristr($menuid, 'drawer')) { + if ((!empty($menuid)) && (stristr($menuid, 'drawer'))) { $content .= $this->render_custom_menu_item_drawer($item, 0, $menuid, false); } else { $content .= $this->render_custom_menu_item($item, 0, $menuid); diff --git a/classes/output/custom_menu.php b/classes/output/custom_menu.php index 14f4f31..7f9e07c 100644 --- a/classes/output/custom_menu.php +++ b/classes/output/custom_menu.php @@ -28,11 +28,12 @@ use core\output\custom_menu_item; use core\url; +use custom_menu as core_custom_menu; /** * Adaptable's custom menu. */ -class custom_menu extends \custom_menu { +class custom_menu extends core_custom_menu { /** * Creates the custom menu * @@ -41,7 +42,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)); } @@ -54,7 +55,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 = '', ?string $currentlanguage = null, ?custom_menu_item $menu = null) { if (!empty($definition)) { $items = self::convert_text_to_menu_nodes($definition, $currentlanguage); if (empty($menu)) { diff --git a/classes/output/external.php b/classes/output/external.php index 3e2c953..05f4443 100644 --- a/classes/output/external.php +++ b/classes/output/external.php @@ -33,8 +33,8 @@ use core_external\external_single_structure; use core_external\external_value; use core_external\external_warnings; -use core\external\output\icon_system; use core\external\output\icon_system\load_fontawesome_map; +use core\output\icon_system; use core_user; /** diff --git a/db/upgrade.php b/db/upgrade.php index bff0de0..de405ec 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -102,6 +102,17 @@ function xmldb_theme_adaptable_upgrade($oldversion = 0) { upgrade_plugin_savepoint(true, 2024032803, 'theme', 'adaptable'); } + if ($oldversion < 2024100502) { + $value = get_config('theme_adaptable', 'navbardisplaysubmenuarrow'); + if (!empty($value)) { + set_config('navbardisplaymenuarrow', $value, 'theme_adaptable'); + // Prevent replacement when upgrade has already happened in a version for an older Moodle! + unset_config('navbardisplaysubmenuarrow', 'theme_adaptable'); + } + + upgrade_plugin_savepoint(true, 2024100502, 'theme', 'adaptable'); + } + // Automatic 'Purge all caches'.... purge_all_caches(); diff --git a/lang/en/theme_adaptable.php b/lang/en/theme_adaptable.php index 8fd52ea..c0d7b93 100644 --- a/lang/en/theme_adaptable.php +++ b/lang/en/theme_adaptable.php @@ -495,10 +495,13 @@ $string['navbarlinksettingsdesc'] = 'Allows you to control the links that appear on the navigation bar.'; $string['navbardisplayicons'] = 'Display icons'; -$string['navbardisplayiconsdesc'] = 'Display icons next to main menu headings'; +$string['navbardisplayiconsdesc'] = 'Display an icon next to the menu title. Note: This is ignored when \'custommenutitle\' isn\'t set for the custom menu.'; -$string['navbardisplaysubmenuarrow'] = 'Display sub-menu arrow'; -$string['navbardisplaysubmenuarrowdesc'] = 'Display sub-menu arrow (downward facing) when a menu heading has sub-menu options.'; +$string['navbardisplaytitles'] = 'Display titles'; +$string['navbardisplaytitlesdesc'] = 'Display the menu title. Notes: Ignored when \'navbardisplayicons\' is unset and also ignored when \'custommenutitle\' isn\'t set for the custom menu.'; + +$string['navbardisplaymenuarrow'] = 'Display menu arrow'; +$string['navbardisplaymenuarrowdesc'] = 'Display menu arrow (downward facing) for a menu title.'; $string['home'] = 'Home'; $string['enablemy'] = 'Dashboard'; @@ -588,11 +591,14 @@ $string['enablemysitesrestriction'] = 'Restrict user\'s courses dropdown to a custom profile field'; $string['enablemysitesrestrictiondesc'] = 'Restrict dropdown with a user\'s courses by custom profile field. E.g. usertype=staff.'; -$string['mysitessortoverride'] = 'Enable my courses custom sort'; +$string['mysitessortoverride'] = 'My courses custom sort'; $string['mysitessortoverridedesc'] = 'Use custom profile fields or generic strings (year etc) to collapse past courses in sub menu.'; $string['mysitessortoverridefield'] = 'My Courses Custom Profile Field(s) or Strings'; $string['mysitessortoverridefielddesc'] = 'Comma delimited list of profile fields or strings to check for in course short codes.'; +$string['enableusermysitessortoverride'] = 'Enable user my courses custom sort'; +$string['enableusermysitessortoverridedesc'] = 'Allow the user to set their own value for \'My courses custom sort\', including defaulting to the theme setting value set by \'mysitessortoverride\'.'; + $string['mysitessortoverrideoff'] = 'Display all enrolled courses in single flat list'; $string['mysitessortoverridestrings'] = 'Display enrolled containing strings in first list, others in sub menu'; $string['mysitessortoverrideprofilefields'] = 'Display courses found in profile fields in first list, others in sub menu'; @@ -1488,8 +1494,8 @@ $string['helptarget'] = 'Help target'; $string['helptargetdesc'] = 'Do you want the help link to open in a new window?'; -$string['hideinforum'] = 'Hide help and tools in forums'; -$string['hideinforumdesc'] = 'When using fixed width and all menu options the forum search box spills onto the line below. Turning this option on will hide tools and help menu items in forums allowing it to display properly.'; +$string['hideinforum'] = 'Hide help, user favourites and tools in forums'; +$string['hideinforumdesc'] = 'When using fixed width and all menu options the forum search box spills onto the line below. Turning this option on will hide help, user favourites and tools menu items in forums allowing it to display properly.'; $string['targetnewwindow'] = 'New window'; $string['targetsamewindow'] = 'Same window'; @@ -1599,6 +1605,21 @@ $string['newmenutitledesc'] = 'The title of the dropdown list that will appear in the header of your site.'; $string['newmenutitledefault'] = 'Menu'; +$string['navbaruserfavtoolsmenus'] = 'Navbar user favourites and tools menus'; + +$string['userfavmenu'] = 'User favourites menu'; +$string['userfavmenudesc'] = 'The user will be able to create their own favourites menu saved as a user preference. The format of each line is \'text|url|title|langs|fontawesome classes\'. Only enter what you require. If you don\'t need something but do need another thing further along then leave it blank but still use the \'|\' delimiter. For example: \'text|url|||fontawesome classes\'. To find the FontAwesome(Free) classes for the icon you wish to use, go to Font Awesome free and search for the icon. You can use the name, such as \'graduation-cap\' or the complete list of classes \'fa-solid fa-graduation-cap\'. For example:
+Courses
+-All courses|/course/|||graduation-cap
+-Course search|/course/search.php
+-###
+-FAQ|https://example.org/faq
+-Exam Clock|https://mysite.localhost|Exam Clock||clock
+
'; + +$string['enableuserfavmenu'] = 'Enable user favourites menu'; +$string['enableuserfavmenudesc'] = 'It is recommended you leave this off if the menu is not in use for preformance reasons.'; + $string['enabletoolsmenus'] = 'Enable tool menus'; $string['enabletoolsmenusdesc'] = 'It is recommended you leave this off if menus are not in use for preformance reasons.'; diff --git a/lib.php b/lib.php index 6f33340..47f6dec 100644 --- a/lib.php +++ b/lib.php @@ -54,9 +54,12 @@ function theme_adaptable_pre_scss($theme) { $fontcolorrgba = \theme_adaptable\toolbox::hex2rgba($fontcolor, 0.25); $prescss = '$body-bg: ' . $regionmaincolor . ';' . PHP_EOL; $prescss = '$body-color: ' . $fontcolor . ';' . PHP_EOL; - $prescss .= '$primary: ' . \theme_adaptable\toolbox::get_setting('primarycolour', false, $theme->name, '#00796b') . ';' . PHP_EOL; - $prescss .= '$secondary: ' . \theme_adaptable\toolbox::get_setting('secondarycolour', false, $theme->name, '#009688') . ';' . PHP_EOL; - $prescss .= '$loadingcolor: ' . \theme_adaptable\toolbox::get_setting('loadingcolor', false, $theme->name, '#00B3A1') . ';' . PHP_EOL; + $prescss .= '$primary: ' . + \theme_adaptable\toolbox::get_setting('primarycolour', false, $theme->name, '#00796b') . ';' . PHP_EOL; + $prescss .= '$secondary: ' . + \theme_adaptable\toolbox::get_setting('secondarycolour', false, $theme->name, '#009688') . ';' . PHP_EOL; + $prescss .= '$loadingcolor: ' . + \theme_adaptable\toolbox::get_setting('loadingcolor', false, $theme->name, '#00B3A1') . ';' . PHP_EOL; $loadingcolor = \theme_adaptable\toolbox::get_setting('loadingcolor', false, $theme->name, '#00B3A1'); $loadingcolorrgba = \theme_adaptable\toolbox::hex2rgba($loadingcolor, 0.2); $prescss .= '$loadingcolor: ' . $loadingcolor . ';' . PHP_EOL; @@ -440,6 +443,9 @@ function theme_adaptable_process_scss($scss, $theme) { $defaults['[[setting:linkcolorrgba]]'] = \theme_adaptable\toolbox::hex2rgba($defaults['[[setting:linkcolor]]'], 0.75); $defaults['[[setting:linkhoverrgba]]'] = \theme_adaptable\toolbox::hex2rgba($defaults['[[setting:linkhover]]'], 0.75); + // The navbardisplaymenuarrow setting. + $defaults['[[setting:navbardisplaymenuarrow]]'] = (empty($theme->settings->navbardisplaymenuarrow)) ? 'content: none;' : ''; + // Replace the CSS with values from the $defaults array. $scss = strtr($scss, $defaults); if (empty($theme->settings->tilesshowallcontacts) || $theme->settings->tilesshowallcontacts == false) { diff --git a/scss/main.scss b/scss/main.scss index 73a4a95..bee19c9 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -14,6 +14,7 @@ @import "nosettings/grade"; @import "nosettings/header"; @import "nosettings/layout"; +@import "nosettings/menu"; @import "nosettings/messages"; @import "nosettings/mod"; @import "nosettings/modal"; diff --git a/scss/nosettings/_menu.scss b/scss/nosettings/_menu.scss new file mode 100644 index 0000000..561a34c --- /dev/null +++ b/scss/nosettings/_menu.scss @@ -0,0 +1,30 @@ +// +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . +// +// +// Adaptable Menu style sheet +// +// @package theme_adaptable +// @copyright 2024 G J Barnard - {@link http://moodle.org/user/profile.php?id=442195} +// @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later +// + +.dropdown-toggle::after { + content: "\f0d7"; + font-size: 14px; + vertical-align: baseline; + width: 14px; +} diff --git a/scss/nosettings/_modal.scss b/scss/nosettings/_modal.scss index e1ed340..ae3c040 100644 --- a/scss/nosettings/_modal.scss +++ b/scss/nosettings/_modal.scss @@ -38,6 +38,10 @@ &.modal-in-page { z-index: 1; } + + ul { + list-style-type: none; + } } .modal-backdrop { @@ -78,6 +82,10 @@ .modal-body { overflow-y: auto; padding: 15px; + + li { + line-height: $line-height-base; + } } .modal-form { diff --git a/scss/settings/adaptable.scss b/scss/settings/adaptable.scss index 70b466d..ed49805 100644 --- a/scss/settings/adaptable.scss +++ b/scss/settings/adaptable.scss @@ -27,12 +27,17 @@ // Main elements selectors. html, -body { +body, +.body { background-color: [[setting:maincolor]]; color: [[setting:fontcolor]]; font-family: [[setting:fontname]], sans-serif; font-size: [[setting:fontsize]]; font-weight: [[setting:fontweight]] !important; +} + +html, +body { line-height: normal; margin: 0; padding: 0; diff --git a/scss/settings/menu.scss b/scss/settings/menu.scss index c5adb9a..d5a44d0 100644 --- a/scss/settings/menu.scss +++ b/scss/settings/menu.scss @@ -39,9 +39,14 @@ margin-right: -[[setting:menufontpadding]]; } -// Remove caret from main navbar menu. -#adaptable-page-header-wrapper #main-navbar .dropdown-toggle::after { - content: none; +// Remove caret from navbar menus. +#adaptable-page-header-wrapper { + .above-header, + #main-navbar { + .dropdown-toggle::after { + [[setting:navbardisplaymenuarrow]] + } + } } #adaptable-page-header-wrapper { @@ -162,11 +167,8 @@ color: inherit; } -#adaptable-page-header-wrapper #header2 a i { - padding-right: 4px; -} - #adaptable-page-header-wrapper .above-header a.dropdown-toggle { + margin-bottom: 2px; margin-top: 2px; } @@ -369,7 +371,6 @@ #adaptable-page-header-wrapper #main-navbar .navbar-nav .nav-item .dropdown-menu > .nav-item .dropdown-menu { max-height: 400px; - overflow-x: auto; top: -1px; } @@ -405,19 +406,6 @@ padding: 0; } -#adaptable-page-header-wrapper #main-navbar .action-menu .dropdown-toggle::after { - border-bottom: 0; - border-left: .5em solid transparent; - border-right: .5em solid transparent; - border-top: .5em solid; - content: ""; - display: inline-block; - height: 0; - margin-left: .255em; - vertical-align: .255em; - width: 0; -} - #adaptable-page-header-wrapper #main-navbar .action-menu a.dropdown-toggle i { padding: 0; } diff --git a/scss/settings/search.scss b/scss/settings/search.scss index 811f2a2..21c15a8 100644 --- a/scss/settings/search.scss +++ b/scss/settings/search.scss @@ -24,6 +24,13 @@ .headersearch { padding: [[setting:searchboxpadding]]; + + abbr[title] { + border-bottom: none; + cursor: pointer; + text-decoration: none; + } + .btn { color: [[setting:headertextcolor2]]; } @@ -34,19 +41,17 @@ .btn { box-shadow: none; } + .btn-close { border-width: 0; + .icon { + vertical-align: middle; + } } -} -#adaptable-page-header-wrapper #header2 a.btn-open i { - color: [[setting:headertextcolor]]; -} - -.headersearch abbr[title]{ - border-bottom: none; - cursor: pointer; - text-decoration: none; + input { + padding: 1.1rem; + } } .headersearch .form-inline, @@ -60,22 +65,40 @@ height: 35px; } -#adaptable-page-header-wrapper .navbarsearchsocial form .icon { - color: [[setting:fontcolor]]; +#adaptable-page-header-wrapper { + .navbarsearchsocial form, + .headersearch .show { + .icon { + color: [[setting:fontcolor]]; + font-size: 16px; + } + } } .headersearch .simplesearchform .btn-submit, #adaptable-page-header-wrapper .above-header .navbar .navbarsearchsocial button { border-radius: 0; } -.navbarsearchsocial .btn-open { - border-width: 0; - font-size: 1.2em; -} -#adaptable-page-header-wrapper .navbarsearchsocial .icon { - margin-right: 0; - padding-right: 0; +#adaptable-page-header-wrapper .navbarsearchsocial { + .btn-close { + padding-right: 0; + padding-top: 3px; + right: 2rem; + } + + .btn-open { + border-width: 0; + + .icon { + font-size: 16px; + } + } + + .icon { + padding-left: 4px; + padding-right: 4px; + } } .simplesearchform .collapse.show, diff --git a/settings.php b/settings.php index 000c0f3..02b5717 100644 --- a/settings.php +++ b/settings.php @@ -76,8 +76,8 @@ include(dirname(__FILE__) . '/settings/navbar_mycourses.php'); include(dirname(__FILE__) . '/settings/navbar_links.php'); include(dirname(__FILE__) . '/settings/navbar_styles.php'); + include(dirname(__FILE__) . '/settings/navbar_userfav_tools_menu.php'); include(dirname(__FILE__) . '/settings/news_ticker.php'); - include(dirname(__FILE__) . '/settings/navbar_tools_menu.php'); include(dirname(__FILE__) . '/settings/print.php'); include(dirname(__FILE__) . '/settings/templates.php'); include(dirname(__FILE__) . '/settings/user.php'); diff --git a/settings/dash_block_regions.php b/settings/dash_block_regions.php index f595ad8..46a44e5 100644 --- a/settings/dash_block_regions.php +++ b/settings/dash_block_regions.php @@ -21,6 +21,9 @@ * @copyright 2017 Manoj Solanki (Coventry University) * @copyright 2015 Jeremy Hopkins (Coventry University) * @copyright 2015 Fernando Acedo (3-bits.com) + * @copyright 2024 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ @@ -53,7 +56,7 @@ $page->add($setting); // Dashboard block region builder. - $noregions = 20; // // Number of block regions defined in config.php - frnt-market- etc. + $noregions = 20; // Number of block regions defined in config.php - frnt-market- etc. ['imgblder' => $imgblder, 'totalblocks' => $totalblocks] = \theme_adaptable\toolbox::admin_settings_layout_builder( $page, 'dashblocklayoutlayoutrow', diff --git a/settings/header.php b/settings/header.php index 5c0001b..5b378dc 100644 --- a/settings/header.php +++ b/settings/header.php @@ -232,7 +232,7 @@ $name = 'theme_adaptable/searchboxpadding'; $title = get_string('searchboxpadding', 'theme_adaptable'); $description = get_string('searchboxpaddingdesc', 'theme_adaptable'); - $setting = new admin_setting_configtext($name, $title, $description, '0 0 10px 0'); + $setting = new admin_setting_configtext($name, $title, $description, '0 0 0 0'); $setting->set_updatedcallback('theme_reset_all_caches'); $page->add($setting); diff --git a/settings/navbar_mycourses.php b/settings/navbar_mycourses.php index feaa8f9..ec7f462 100644 --- a/settings/navbar_mycourses.php +++ b/settings/navbar_mycourses.php @@ -20,6 +20,9 @@ * @package theme_adaptable * @copyright 2015 Jeremy Hopkins (Coventry University) * @copyright 2015 Fernando Acedo (3-bits.com) + * @copyright 2024 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ @@ -86,6 +89,13 @@ $setting = new admin_setting_configselect($name, $title, $description, 'myoverview', $choices); $page->add($setting); + $name = 'theme_adaptable/enableusermysitessortoverride'; + $title = get_string('enableusermysitessortoverride', 'theme_adaptable'); + $description = get_string('enableusermysitessortoverridedesc', 'theme_adaptable'); + $default = true; + $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false); + $page->add($setting); + $name = 'theme_adaptable/mysitessortoverridefield'; $title = get_string('mysitessortoverridefield', 'theme_adaptable'); $description = get_string('mysitessortoverridefielddesc', 'theme_adaptable'); diff --git a/settings/navbar_styles.php b/settings/navbar_styles.php index 501615b..6f8b496 100644 --- a/settings/navbar_styles.php +++ b/settings/navbar_styles.php @@ -20,6 +20,9 @@ * @package theme_adaptable * @copyright 2015 Jeremy Hopkins (Coventry University) * @copyright 2015 Fernando Acedo (3-bits.com) + * @copyright 2024 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ @@ -87,11 +90,19 @@ $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false); $page->add($setting); - $name = 'theme_adaptable/navbardisplaysubmenuarrow'; - $title = get_string('navbardisplaysubmenuarrow', 'theme_adaptable'); - $description = get_string('navbardisplaysubmenuarrowdesc', 'theme_adaptable'); + $name = 'theme_adaptable/navbardisplaytitles'; + $title = get_string('navbardisplaytitles', 'theme_adaptable'); + $description = get_string('navbardisplaytitlesdesc', 'theme_adaptable'); + $default = true; + $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false); + $page->add($setting); + + $name = 'theme_adaptable/navbardisplaymenuarrow'; + $title = get_string('navbardisplaymenuarrow', 'theme_adaptable'); + $description = get_string('navbardisplaymenuarrowdesc', 'theme_adaptable'); $default = false; $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false); + $setting->set_updatedcallback('theme_reset_all_caches'); $page->add($setting); // Dropdown border radius. diff --git a/settings/navbar_tools_menu.php b/settings/navbar_userfav_tools_menu.php similarity index 77% rename from settings/navbar_tools_menu.php rename to settings/navbar_userfav_tools_menu.php index f262074..7a014f8 100644 --- a/settings/navbar_tools_menu.php +++ b/settings/navbar_userfav_tools_menu.php @@ -15,19 +15,38 @@ // along with Moodle. If not, see . /** - * Navbar tools menu + * Navbar user favourites and tools menu. * * @package theme_adaptable * @copyright 2015 Jeremy Hopkins (Coventry University) * @copyright 2015 Fernando Acedo (3-bits.com) + * @copyright 2024 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ defined('MOODLE_INTERNAL') || die; -// Settings for tools menus. +// Settings for user favourites and tools menus. if ($ADMIN->fulltree) { - $page = new \theme_adaptable\admin_settingspage('theme_adaptable_navbar_tools_menu', - get_string('toolsmenu', 'theme_adaptable'), true); + $page = new \theme_adaptable\admin_settingspage('theme_adaptable_navbar_userfavtools_menu', + get_string('navbaruserfavtoolsmenus', 'theme_adaptable'), true); + + $page->add(new admin_setting_heading( + 'theme_adaptable_userfavmenu', + get_string('userfavmenu', 'theme_adaptable'), + format_text( + get_string('userfavmenudesc', 'theme_adaptable'), + FORMAT_MARKDOWN + ) + )); + + $name = 'theme_adaptable/enableuserfavmenu'; + $title = get_string('enableuserfavmenu', 'theme_adaptable'); + $description = get_string('enableuserfavmenudesc', 'theme_adaptable'); + $default = true; + $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false); + $page->add($setting); $page->add(new admin_setting_heading( 'theme_adaptable_toolsmenu', @@ -69,19 +88,19 @@ $title = get_string('toolsmenutitle', 'theme_adaptable') . ' ' . $toolsmenusindex; $description = get_string('toolsmenutitledesc', 'theme_adaptable'); $default = get_string('toolsmenutitledefault', 'theme_adaptable'); - $setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_RAW); + $setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_TEXT, '101'); $page->add($setting); $name = 'theme_adaptable/toolsmenu' . $toolsmenusindex; $title = get_string('toolsmenu', 'theme_adaptable') . ' ' . $toolsmenusindex; $description = get_string('toolsmenudesc', 'theme_adaptable'); - $setting = new admin_setting_configtextarea($name, $title, $description, '', PARAM_RAW, '50', '10'); + $setting = new admin_setting_configtextarea($name, $title, $description, '', PARAM_TEXT, '50', '10'); $page->add($setting); $name = 'theme_adaptable/toolsmenu' . $toolsmenusindex . 'field'; $title = get_string('toolsmenufield', 'theme_adaptable'); $description = get_string('toolsmenufielddesc', 'theme_adaptable'); - $setting = new admin_setting_configtext($name, $title, $description, '', PARAM_RAW); + $setting = new admin_setting_configtext($name, $title, $description, '', PARAM_TEXT, '101'); $page->add($setting); } diff --git a/templates/headernavbar.mustache b/templates/headernavbar.mustache index 448752d..00d3dcc 100644 --- a/templates/headernavbar.mustache +++ b/templates/headernavbar.mustache @@ -29,6 +29,7 @@ "pageheadingbutton": "", "responsiveheader": "d-none d-lg-block", "showcog": true, + "userfavmenu": "", "toolsmenu": "" } }} @@ -40,6 +41,7 @@ diff --git a/templates/headerstyleone.mustache b/templates/headerstyleone.mustache index c690e38..2ce0086 100644 --- a/templates/headerstyleone.mustache +++ b/templates/headerstyleone.mustache @@ -94,7 +94,7 @@ {{{output.course_header}}} -
+
{{#searchandsocialheader}} {{{searchandsocialheader}}} {{/searchandsocialheader}} diff --git a/version.php b/version.php index 4cdd63d..de97ff8 100644 --- a/version.php +++ b/version.php @@ -33,14 +33,14 @@ $plugin->component = 'theme_adaptable'; // Adaptable version date (YYYYMMDDrr where rr is the release number). -$plugin->version = 2024100501; +$plugin->version = 2024100502; $plugin->requires = 2024100700.00; // 4.5 (Build: 20241007). $plugin->supported = [405, 405]; // Adaptable version using SemVer (https://semver.org). -$plugin->release = '405.1.0'; +$plugin->release = '405.1.1'; // Adaptable maturity (do not use ALPHA or BETA versions in production sites). $plugin->maturity = MATURITY_STABLE;