diff --git a/CHANGES.md b/CHANGES.md index 0518ec5ffc6..6bc3a321150 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,12 @@ moodle-theme_boost_union Changes ------- +### Unreleased + +* 2024-12-06 - Tests: Add several Behat optimisations to bring down the test suite run time, resolves #765. +* 2024-12-06 - Upstream change: Adopt changes from MDL-83759 ('System notification navbar popover is misplaced in Moodle 4.4 and 4.5') +* 2024-12-06 - Upstream change: Adopt changes from MDL-75610 ('Quiz activity name no longer being displayed in quiz landing page when using Safe Exam Browser'), resolves #766. + ### v4.5-r3 * 2024-11-19 - Bugfix: The starred courses popover showed a JavaScript error in the browser JS console, resolves #759. diff --git a/classes/form/smartmenu_edit_form.php b/classes/form/smartmenu_edit_form.php index c7ae6d4471e..d5432427a97 100644 --- a/classes/form/smartmenu_edit_form.php +++ b/classes/form/smartmenu_edit_form.php @@ -80,10 +80,7 @@ public function definition() { $mform->addRule('location', get_string('required'), 'required'); // Add mode as select element. - $modeoptions = [ - smartmenu::MODE_SUBMENU => get_string('smartmenusmodesubmenu', 'theme_boost_union'), - smartmenu::MODE_INLINE => get_string('smartmenusmodeinline', 'theme_boost_union'), - ]; + $modeoptions = smartmenu::get_mode_options(); $mform->addElement('select', 'mode', get_string('smartmenusmenumode', 'theme_boost_union'), $modeoptions); $mform->setDefault('mode', smartmenu::MODE_SUBMENU); $mform->setType('mode', PARAM_INT); @@ -102,12 +99,7 @@ public function definition() { $mform->addHelpButton('type', 'smartmenusmenutype', 'theme_boost_union'); // Add show description as select element. - $showdescriptionoptions = [ - smartmenu::DESC_NEVER => get_string('smartmenusmenushowdescriptionnever', 'theme_boost_union'), - smartmenu::DESC_ABOVE => get_string('smartmenusmenushowdescriptionabove', 'theme_boost_union'), - smartmenu::DESC_BELOW => get_string('smartmenusmenushowdescriptionbelow', 'theme_boost_union'), - smartmenu::DESC_HELP => get_string('smartmenusmenushowdescriptionhelp', 'theme_boost_union'), - ]; + $showdescriptionoptions = smartmenu::get_showdescription_options(); $mform->addElement('select', 'showdesc', get_string('smartmenusmenushowdescription', 'theme_boost_union'), $showdescriptionoptions); $mform->setDefault('showdesc', smartmenu::DESC_NEVER); @@ -115,11 +107,7 @@ public function definition() { $mform->addHelpButton('showdesc', 'smartmenusmenushowdescription', 'theme_boost_union'); // Add more menu behavior as select element. - $moremenuoptions = [ - smartmenu::MOREMENU_DONOTCHANGE => get_string('dontchange', 'theme_boost_union'), - smartmenu::MOREMENU_INTO => get_string('smartmenusmenumoremenubehaviorforceinto', 'theme_boost_union'), - smartmenu::MOREMENU_OUTSIDE => get_string('smartmenusmenumoremenubehaviorkeepoutside', 'theme_boost_union'), - ]; + $moremenuoptions = smartmenu::get_moremenu_options(); $mform->addElement('select', 'moremenubehavior', get_string('smartmenusmenumoremenubehavior', 'theme_boost_union'), $moremenuoptions); $mform->setDefault('moremenubehavior', smartmenu::MOREMENU_DONOTCHANGE); @@ -132,12 +120,7 @@ public function definition() { $mform->setType('cssclass', PARAM_TEXT); // Add card size as select element. - $cardsizeoptions = [ - smartmenu::CARDSIZE_TINY => get_string('smartmenusmenucardsizetiny', 'theme_boost_union').' (50px)', - smartmenu::CARDSIZE_SMALL => get_string('smartmenusmenucardsizesmall', 'theme_boost_union').' (100px)', - smartmenu::CARDSIZE_MEDIUM => get_string('smartmenusmenucardsizemedium', 'theme_boost_union').' (150px)', - smartmenu::CARDSIZE_LARGE => get_string('smartmenusmenucardsizelarge', 'theme_boost_union').' (200px)', - ]; + $cardsizeoptions = smartmenu::get_cardsize_options(); $mform->addElement('select', 'cardsize', get_string('smartmenusmenucardsize', 'theme_boost_union'), $cardsizeoptions); $mform->setDefault('cardsize', smartmenu::CARDSIZE_TINY); $mform->setType('cardsize', PARAM_INT); @@ -145,16 +128,7 @@ public function definition() { $mform->addHelpButton('cardsize', 'smartmenusmenucardsize', 'theme_boost_union'); // Add card form as select element. - $cardformoptions = [ - smartmenu::CARDFORM_SQUARE => - get_string('smartmenusmenucardformsquare', 'theme_boost_union').' (1/1)', - smartmenu::CARDFORM_PORTRAIT => - get_string('smartmenusmenucardformportrait', 'theme_boost_union').' (2/3)', - smartmenu::CARDFORM_LANDSCAPE => - get_string('smartmenusmenucardformlandscape', 'theme_boost_union').' (3/2)', - smartmenu::CARDFORM_FULLWIDTH => - get_string('smartmenusmenucardformfullwidth', 'theme_boost_union'), - ]; + $cardformoptions = smartmenu::get_cardform_options(); $mform->addElement('select', 'cardform', get_string('smartmenusmenucardform', 'theme_boost_union'), $cardformoptions); $mform->setDefault('cardform', smartmenu::CARDFORM_SQUARE); @@ -163,12 +137,7 @@ public function definition() { $mform->addHelpButton('cardform', 'smartmenusmenucardform', 'theme_boost_union'); // Add card overflow behaviour as select element. - $cardoverflowoptions = [ - smartmenu::CARDOVERFLOWBEHAVIOUR_NOWRAP => - get_string('smartmenusmenucardoverflowbehaviornowrap', 'theme_boost_union'), - smartmenu::CARDOVERFLOWBEHAVIOUR_WRAP => - get_string('smartmenusmenucardoverflowbehaviorwrap', 'theme_boost_union'), - ]; + $cardoverflowoptions = smartmenu::get_cardoverflowbehaviour_options(); $mform->addElement('select', 'cardoverflowbehavior', get_string('smartmenusmenucardoverflowbehavior', 'theme_boost_union'), $cardoverflowoptions); $mform->setDefault('cardoverflowbehaviour', smartmenu::CARDOVERFLOWBEHAVIOUR_NOWRAP); @@ -199,10 +168,7 @@ public function definition() { $mform->addHelpButton('roles', 'smartmenusbyrole', 'theme_boost_union'); // Add context as select element. - $rolecontext = [ - smartmenu::ANYCONTEXT => get_string('any'), - smartmenu::SYSTEMCONTEXT => get_string('coresystem'), - ]; + $rolecontext = smartmenu::get_rolecontext_options(); $mform->addElement('select', 'rolecontext', get_string('smartmenusrolecontext', 'theme_boost_union'), $rolecontext); $mform->setDefault('rolecontext', smartmenu::ANYCONTEXT); $mform->setType('rolecontext', PARAM_INT); @@ -216,12 +182,8 @@ public function definition() { } // Add restriction as select element. - $rolecontext = [ - smartmenu::BYADMIN_ALL => get_string('smartmenusbyadmin_all', 'theme_boost_union'), - smartmenu::BYADMIN_ADMINS => get_string('smartmenusbyadmin_admins', 'theme_boost_union'), - smartmenu::BYADMIN_NONADMINS => get_string('smartmenusbyadmin_nonadmins', 'theme_boost_union'), - ]; - $mform->addElement('select', 'byadmin', get_string('smartmenusbyadmin', 'theme_boost_union'), $rolecontext); + $byadminoptions = smartmenu::get_byadmin_options(); + $mform->addElement('select', 'byadmin', get_string('smartmenusbyadmin', 'theme_boost_union'), $byadminoptions); $mform->setDefault('byadmin', smartmenu::BYADMIN_ALL); $mform->setType('byadmin', PARAM_INT); $mform->addHelpButton('byadmin', 'smartmenusbyadmin', 'theme_boost_union'); @@ -249,10 +211,7 @@ public function definition() { $mform->addHelpButton('cohorts', 'smartmenusbycohort', 'theme_boost_union'); // Add operator as select element. - $operatoroptions = [ - smartmenu::ANY => get_string('any'), - smartmenu::ALL => get_string('all'), - ]; + $operatoroptions = smartmenu::get_operator_options(); $mform->addElement('select', 'operator', get_string('smartmenusoperator', 'theme_boost_union'), $operatoroptions); $mform->setDefault('operator', smartmenu::ANY); $mform->setType('operator', PARAM_INT); diff --git a/classes/form/smartmenu_item_edit_form.php b/classes/form/smartmenu_item_edit_form.php index 7ada173ec4b..c7547e890ed 100644 --- a/classes/form/smartmenu_item_edit_form.php +++ b/classes/form/smartmenu_item_edit_form.php @@ -98,10 +98,7 @@ public function definition() { $mform->addHelpButton('url', 'smartmenusmenuitemurl', 'theme_boost_union'); // Add mode as select element. - $modeoptions = [ - smartmenu_item::MODE_INLINE => get_string('smartmenusmodeinline', 'theme_boost_union'), - smartmenu_item::MODE_SUBMENU => get_string('smartmenusmodesubmenu', 'theme_boost_union'), - ]; + $modeoptions = smartmenu_item::get_mode_options(); $mform->addElement('select', 'mode', get_string('smartmenusmenuitemmode', 'theme_boost_union'), $modeoptions); $mform->setDefault('mode', smartmenu_item::MODE_INLINE); $mform->setType('mode', PARAM_INT); @@ -138,14 +135,7 @@ public function definition() { $mform->addHelpButton('enrolmentrole', 'smartmenusdynamiccoursesenrolmentrole', 'theme_boost_union'); // Add completion status (for the dynamic courses menu item type) as autocomplete element. - $completionstatusoptions = [ - smartmenu_item::COMPLETION_ENROLLED => - get_string('smartmenusdynamiccoursescompletionstatusenrolled', 'theme_boost_union'), - smartmenu_item::COMPLETION_INPROGRESS => - get_string('smartmenusdynamiccoursescompletionstatusinprogress', 'theme_boost_union'), - smartmenu_item::COMPLETION_COMPLETED => - get_string('smartmenusdynamiccoursescompletionstatuscompleted', 'theme_boost_union'), - ]; + $completionstatusoptions = smartmenu_item::get_completionstatus_options(); $completionstatuswidget = $mform->addElement('autocomplete', 'completionstatus', get_string('smartmenusmenuitemtypedynamiccourses', 'theme_boost_union').': '. get_string('smartmenusdynamiccoursescompletionstatus', 'theme_boost_union'), $completionstatusoptions); @@ -155,14 +145,7 @@ public function definition() { $mform->addHelpButton('completionstatus', 'smartmenusdynamiccoursescompletionstatus', 'theme_boost_union'); // Add date range (for the dynamic courses menu item type) as autocomplete element. - $daterangeoptions = [ - smartmenu_item::RANGE_PAST => - get_string('smartmenusdynamiccoursesdaterangepast', 'theme_boost_union'), - smartmenu_item::RANGE_PRESENT => - get_string('smartmenusdynamiccoursesdaterangepresent', 'theme_boost_union'), - smartmenu_item::RANGE_FUTURE => - get_string('smartmenusdynamiccoursesdaterangefuture', 'theme_boost_union'), - ]; + $daterangeoptions = smartmenu_item::get_daterange_options(); $daterangewidget = $mform->addElement('autocomplete', 'daterange', get_string('smartmenusmenuitemtypedynamiccourses', 'theme_boost_union').': '. get_string('smartmenusdynamiccoursesdaterange', 'theme_boost_union'), $daterangeoptions); @@ -196,13 +179,7 @@ public function definition() { $PAGE->requires->js_call_amd('theme_boost_union/fontawesome-popover', 'init', ['#id_menuicon', $systemcontextid]); // Add title presentation and select element. - $displayoptions = [ - smartmenu_item::DISPLAY_SHOWTITLEICON => - get_string('smartmenusmenuitemdisplayoptionsshowtitleicon', 'theme_boost_union'), - smartmenu_item::DISPLAY_HIDETITLE => get_string('smartmenusmenuitemdisplayoptionshidetitle', 'theme_boost_union'), - smartmenu_item::DISPLAY_HIDETITLEMOBILE => - get_string('smartmenusmenuitemdisplayoptionshidetitlemobile', 'theme_boost_union'), - ]; + $displayoptions = smartmenu_item::get_display_options(); $mform->addElement('select', 'display', get_string('smartmenusmenuitemdisplayoptions', 'theme_boost_union'), $displayoptions); $mform->setDefault('display', smartmenu_item::DISPLAY_SHOWTITLEICON); @@ -215,10 +192,7 @@ public function definition() { $mform->addHelpButton('tooltip', 'smartmenusmenuitemtooltip', 'theme_boost_union'); // Add link target as select element. - $targetoptions = [ - smartmenu_item::TARGET_SAME => get_string('smartmenusmenuitemlinktargetsamewindow', 'theme_boost_union'), - smartmenu_item::TARGET_NEW => get_string('smartmenusmenuitemlinktargetnewtab', 'theme_boost_union'), - ]; + $targetoptions = smartmenu_item::get_target_options(); $mform->addElement('select', 'target', get_string('smartmenusmenuitemlinktarget', 'theme_boost_union'), $targetoptions); $mform->setDefault('target', smartmenu_item::TARGET_SAME); @@ -256,24 +230,7 @@ public function definition() { $mform->addHelpButton('cssclass', 'smartmenusmenuitemcssclass', 'theme_boost_union'); // Add course list ordering (for the dynamic courses menu item type) as select element. - $listsortoptions = [ - smartmenu_item::LISTSORT_FULLNAME_ASC => - get_string('smartmenusmenuitemlistsortfullnameasc', 'theme_boost_union'), - smartmenu_item::LISTSORT_FULLNAME_DESC => - get_string('smartmenusmenuitemlistsortfullnamedesc', 'theme_boost_union'), - smartmenu_item::LISTSORT_SHORTNAME_ASC => - get_string('smartmenusmenuitemlistsortshortnameasc', 'theme_boost_union'), - smartmenu_item::LISTSORT_SHORTNAME_DESC => - get_string('smartmenusmenuitemlistsortshortnamedesc', 'theme_boost_union'), - smartmenu_item::LISTSORT_COURSEID_ASC => - get_string('smartmenusmenuitemlistsortcourseidasc', 'theme_boost_union'), - smartmenu_item::LISTSORT_COURSEID_DESC => - get_string('smartmenusmenuitemlistsortcourseiddesc', 'theme_boost_union'), - smartmenu_item::LISTSORT_COURSEIDNUMBER_ASC => - get_string('smartmenusmenuitemlistsortcourseidnumberasc', 'theme_boost_union'), - smartmenu_item::LISTSORT_COURSEIDNUMBER_DESC => - get_string('smartmenusmenuitemlistsortcourseidnumberdesc', 'theme_boost_union'), - ]; + $listsortoptions = smartmenu_item::get_listsort_options(); $mform->addElement('select', 'listsort', get_string('smartmenusmenuitemtypedynamiccourses', 'theme_boost_union').': '. get_string('smartmenusmenuitemlistsort', 'theme_boost_union'), $listsortoptions); @@ -283,10 +240,7 @@ public function definition() { $mform->addHelpButton('listsort', 'smartmenusmenuitemlistsort', 'theme_boost_union'); // Add course name presentation (for the dynamic courses menu item type) as select element. - $displayfieldoptions = [ - smartmenu_item::FIELD_FULLNAME => get_string('smartmenusmenuitemdisplayfieldcoursefullname', 'theme_boost_union'), - smartmenu_item::FIELD_SHORTNAME => get_string('smartmenusmenuitemdisplayfieldcourseshortname', 'theme_boost_union'), - ]; + $displayfieldoptions = smartmenu_item::get_displayfield_options(); $mform->addElement('select', 'displayfield', get_string('smartmenusmenuitemtypedynamiccourses', 'theme_boost_union').': '. get_string('smartmenusmenuitemdisplayfield', 'theme_boost_union'), $displayfieldoptions); @@ -318,14 +272,7 @@ public function definition() { $mform->addHelpButton('image', 'smartmenusmenuitemcardimage', 'theme_boost_union'); // Add card text position as select element. - $textpositionoptions = [ - smartmenu_item::POSITION_BELOW => - get_string('smartmenusmenuitemtextpositionbelowimage', 'theme_boost_union'), - smartmenu_item::POSITION_OVERLAYTOP => - get_string('smartmenusmenuitemtextpositionoverlaytop', 'theme_boost_union'), - smartmenu_item::POSITION_OVERLAYBOTTOM => - get_string('smartmenusmenuitemtextpositionoverlaybottom', 'theme_boost_union'), - ]; + $textpositionoptions = smartmenu_item::get_textposition_options(); $mform->addElement('select', 'textposition', get_string('smartmenusmenuitemtextposition', 'theme_boost_union'), $textpositionoptions); $mform->setDefault('textposition', smartmenu_item::POSITION_BELOW); @@ -368,10 +315,7 @@ public function definition() { $mform->addHelpButton('roles', 'smartmenusbyrole', 'theme_boost_union'); // Add context as select element. - $rolecontext = [ - smartmenu::ANYCONTEXT => get_string('any'), - smartmenu::SYSTEMCONTEXT => get_string('coresystem'), - ]; + $rolecontext = smartmenu::get_rolecontext_options(); $mform->addElement('select', 'rolecontext', get_string('smartmenusrolecontext', 'theme_boost_union'), $rolecontext); $mform->setDefault('rolecontext', smartmenu::ANYCONTEXT); $mform->setType('rolecontext', PARAM_INT); @@ -385,12 +329,8 @@ public function definition() { } // Add restriction as select element. - $rolecontext = [ - smartmenu::BYADMIN_ALL => get_string('smartmenusbyadmin_all', 'theme_boost_union'), - smartmenu::BYADMIN_ADMINS => get_string('smartmenusbyadmin_admins', 'theme_boost_union'), - smartmenu::BYADMIN_NONADMINS => get_string('smartmenusbyadmin_nonadmins', 'theme_boost_union'), - ]; - $mform->addElement('select', 'byadmin', get_string('smartmenusbyadmin', 'theme_boost_union'), $rolecontext); + $byadminoptions = smartmenu::get_byadmin_options(); + $mform->addElement('select', 'byadmin', get_string('smartmenusbyadmin', 'theme_boost_union'), $byadminoptions); $mform->setDefault('byadmin', smartmenu::BYADMIN_ALL); $mform->setType('byadmin', PARAM_INT); $mform->addHelpButton('byadmin', 'smartmenusbyadmin', 'theme_boost_union'); @@ -418,10 +358,7 @@ public function definition() { $mform->addHelpButton('cohorts', 'smartmenusbycohort', 'theme_boost_union'); // Add operator as select element. - $operatoroptions = [ - smartmenu::ANY => get_string('any'), - smartmenu::ALL => get_string('all'), - ]; + $operatoroptions = smartmenu::get_operator_options(); $mform->addElement('select', 'operator', get_string('smartmenusoperator', 'theme_boost_union'), $operatoroptions); $mform->setDefault('operator', smartmenu::ANY); $mform->setType('operator', PARAM_INT); diff --git a/classes/smartmenu.php b/classes/smartmenu.php index 6c6f1be27f0..e33264efb2b 100644 --- a/classes/smartmenu.php +++ b/classes/smartmenu.php @@ -592,10 +592,18 @@ public function build($resetcache=false) { return false; } + // Add marker class to make clear that this is a Boost Union smart menu. + $this->menu->classes[] = 'boost-union-smartmenu'; + + // Add custom CSS class. + $this->menu->classes[] = $this->menu->cssclass; + + // Add CSS classes for card menus. $this->menu->classes[] = $this->get_cardform(); // Html class for the card form size, Potrait, Square, landscape. $this->menu->classes[] = $this->get_cardsize(); // HTML class for the card Size, tiny, small, medium, large. $this->menu->classes[] = $this->get_cardwrap(); // HtML class for the card overflow behaviour. - $this->menu->classes[] = $this->menu->cssclass;// Custom class selector for menu. + + // Add CSS classes for more behaviour. $this->menu->classes[] = ($this->menu->moremenubehavior == self::MOREMENU_OUTSIDE) ? "force-menu-out" : ''; // Card type menus doesn't supports inline menus. @@ -885,6 +893,136 @@ public static function get_type($type) { return $types[$type] ?? false; } + /** + * Return options for the mode setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_mode_options(): array { + return [ + self::MODE_SUBMENU => get_string('smartmenusmodesubmenu', 'theme_boost_union'), + self::MODE_INLINE => get_string('smartmenusmodeinline', 'theme_boost_union'), + ]; + } + + /** + * Return options for the showdescription setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_showdescription_options(): array { + return [ + self::DESC_NEVER => get_string('smartmenusmenushowdescriptionnever', 'theme_boost_union'), + self::DESC_ABOVE => get_string('smartmenusmenushowdescriptionabove', 'theme_boost_union'), + self::DESC_BELOW => get_string('smartmenusmenushowdescriptionbelow', 'theme_boost_union'), + self::DESC_HELP => get_string('smartmenusmenushowdescriptionhelp', 'theme_boost_union'), + ]; + } + + /** + * Return options for the moremenu setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_moremenu_options(): array { + return [ + self::MOREMENU_DONOTCHANGE => get_string('dontchange', 'theme_boost_union'), + self::MOREMENU_INTO => get_string('smartmenusmenumoremenubehaviorforceinto', 'theme_boost_union'), + self::MOREMENU_OUTSIDE => get_string('smartmenusmenumoremenubehaviorkeepoutside', 'theme_boost_union'), + ]; + } + + /** + * Return options for the cardsize setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_cardsize_options(): array { + return [ + self::CARDSIZE_TINY => get_string('smartmenusmenucardsizetiny', 'theme_boost_union').' (50px)', + self::CARDSIZE_SMALL => get_string('smartmenusmenucardsizesmall', 'theme_boost_union').' (100px)', + self::CARDSIZE_MEDIUM => get_string('smartmenusmenucardsizemedium', 'theme_boost_union').' (150px)', + self::CARDSIZE_LARGE => get_string('smartmenusmenucardsizelarge', 'theme_boost_union').' (200px)', + ]; + } + + /** + * Return options for the cardform setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_cardform_options(): array { + return[ + self::CARDFORM_SQUARE => + get_string('smartmenusmenucardformsquare', 'theme_boost_union').' (1/1)', + self::CARDFORM_PORTRAIT => + get_string('smartmenusmenucardformportrait', 'theme_boost_union').' (2/3)', + self::CARDFORM_LANDSCAPE => + get_string('smartmenusmenucardformlandscape', 'theme_boost_union').' (3/2)', + self::CARDFORM_FULLWIDTH => + get_string('smartmenusmenucardformfullwidth', 'theme_boost_union'), + ]; + } + + /** + * Return options for the cardoverflowbehaviour setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_cardoverflowbehaviour_options(): array { + return [ + self::CARDOVERFLOWBEHAVIOUR_NOWRAP => + get_string('smartmenusmenucardoverflowbehaviornowrap', 'theme_boost_union'), + self::CARDOVERFLOWBEHAVIOUR_WRAP => + get_string('smartmenusmenucardoverflowbehaviorwrap', 'theme_boost_union'), + ]; + } + + /** + * Return options for the rolecontext setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_rolecontext_options(): array { + return [ + self::ANYCONTEXT => get_string('any'), + self::SYSTEMCONTEXT => get_string('coresystem'), + ]; + } + + /** + * Return options for the byadmin setting. + * + * @return array + */ + public static function get_byadmin_options(): array { + return [ + self::BYADMIN_ALL => get_string('smartmenusbyadmin_all', 'theme_boost_union'), + self::BYADMIN_ADMINS => get_string('smartmenusbyadmin_admins', 'theme_boost_union'), + self::BYADMIN_NONADMINS => get_string('smartmenusbyadmin_nonadmins', 'theme_boost_union'), + ]; + } + + /** + * Return options for the operator setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_operator_options(): array { + return [ + self::ANY => get_string('any'), + self::ALL => get_string('all'), + ]; + } + /** * Insert or update the menu instance to DB. Convert the multiple options select elements to json. * setup menu order after insert. diff --git a/classes/smartmenu_item.php b/classes/smartmenu_item.php index c40d37e28d5..39d50dcb82d 100644 --- a/classes/smartmenu_item.php +++ b/classes/smartmenu_item.php @@ -1042,8 +1042,12 @@ public function build() { return false; } - // Add custom css class. + // Add marker class to make clear that this is a Boost Union smart menu item. + $class[] = 'boost-union-smartmenuitem'; + + // Add custom CSS class. $class[] = $this->item->cssclass; + // Add classes for hide items in specific viewport. $class[] = $this->item->desktop ? 'd-lg-none' : 'd-lg-inline-flex'; $class[] = $this->item->tablet ? 'd-md-none' : 'd-md-inline-flex'; @@ -1051,11 +1055,14 @@ public function build() { // Add classes for item title placement on card. $class[] = $this->get_textposition_class(); - // Menu item class. + + // Add menu item class. $types = [self::TYPESTATIC => 'static', self::TYPEDYNAMIC => 'dynamic', self::TYPEHEADING => 'heading']; $class[] = 'menu-item-'.($types[$this->item->type] ?? ''); + // Add classes to item data. $this->item->classes = $class; + // Load the location of menu, used to collect menus for locations in menu inline mode. $this->item->location = $this->menu->location; @@ -1329,20 +1336,134 @@ public static function get_types(?int $type = null) { } /** - * Returns the display options for the menu items. + * Return the options for the display setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_display_options() { + return [ + self::DISPLAY_SHOWTITLEICON => get_string('smartmenusmenuitemdisplayoptionsshowtitleicon', 'theme_boost_union'), + self::DISPLAY_HIDETITLE => get_string('smartmenusmenuitemdisplayoptionshidetitle', 'theme_boost_union'), + self::DISPLAY_HIDETITLEMOBILE => get_string('smartmenusmenuitemdisplayoptionshidetitlemobile', 'theme_boost_union'), + ]; + } + + /** + * Return the options for the target setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_target_options(): array { + return [ + self::TARGET_SAME => get_string('smartmenusmenuitemlinktargetsamewindow', 'theme_boost_union'), + self::TARGET_NEW => get_string('smartmenusmenuitemlinktargetnewtab', 'theme_boost_union'), + ]; + } + + /** + * Return the options for the completionstatus setting. * - * @param int|null $option The display option to retrieve. If null, returns all display options. - * @return array|string The array of display options if $option is null, or the display option string if $option is set. - * @throws coding_exception if $option is set but invalid. - */ - public static function get_display_options(?int $option = null) { - $displayoptions = [ - self::DISPLAY_SHOWTITLEICON => get_string('smartmenusmenuitemdisplayoptionsshowtitleicon', 'theme_boost_union'), - self::DISPLAY_HIDETITLE => get_string('smartmenushidetitle', 'theme_boost_union'), - self::DISPLAY_HIDETITLEMOBILE => get_string('smartmenushidetitlemobile', 'theme_boost_union'), + * @return array + * @throws \coding_exception + */ + public static function get_completionstatus_options(): array { + return [ + self::COMPLETION_ENROLLED => + get_string('smartmenusdynamiccoursescompletionstatusenrolled', 'theme_boost_union'), + self::COMPLETION_INPROGRESS => + get_string('smartmenusdynamiccoursescompletionstatusinprogress', 'theme_boost_union'), + self::COMPLETION_COMPLETED => + get_string('smartmenusdynamiccoursescompletionstatuscompleted', 'theme_boost_union'), ]; + } - return ($option !== null && isset($displayoptions[$option])) ? $displayoptions[$option] : $displayoptions; + /** + * Return the options for the daterange setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_daterange_options(): array { + return [ + self::RANGE_PAST => + get_string('smartmenusdynamiccoursesdaterangepast', 'theme_boost_union'), + self::RANGE_PRESENT => + get_string('smartmenusdynamiccoursesdaterangepresent', 'theme_boost_union'), + self::RANGE_FUTURE => + get_string('smartmenusdynamiccoursesdaterangefuture', 'theme_boost_union'), + ]; + } + + /** + * Return the options for the listsort setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_listsort_options(): array { + return [ + self::LISTSORT_FULLNAME_ASC => + get_string('smartmenusmenuitemlistsortfullnameasc', 'theme_boost_union'), + self::LISTSORT_FULLNAME_DESC => + get_string('smartmenusmenuitemlistsortfullnamedesc', 'theme_boost_union'), + self::LISTSORT_SHORTNAME_ASC => + get_string('smartmenusmenuitemlistsortshortnameasc', 'theme_boost_union'), + self::LISTSORT_SHORTNAME_DESC => + get_string('smartmenusmenuitemlistsortshortnamedesc', 'theme_boost_union'), + self::LISTSORT_COURSEID_ASC => + get_string('smartmenusmenuitemlistsortcourseidasc', 'theme_boost_union'), + self::LISTSORT_COURSEID_DESC => + get_string('smartmenusmenuitemlistsortcourseiddesc', 'theme_boost_union'), + self::LISTSORT_COURSEIDNUMBER_ASC => + get_string('smartmenusmenuitemlistsortcourseidnumberasc', 'theme_boost_union'), + self::LISTSORT_COURSEIDNUMBER_DESC => + get_string('smartmenusmenuitemlistsortcourseidnumberdesc', 'theme_boost_union'), + ]; + } + + /** + * Return the options for the displayfield setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_displayfield_options(): array { + return [ + self::FIELD_FULLNAME => get_string('smartmenusmenuitemdisplayfieldcoursefullname', 'theme_boost_union'), + self::FIELD_SHORTNAME => get_string('smartmenusmenuitemdisplayfieldcourseshortname', 'theme_boost_union'), + ]; + } + + /** + * Return the options for the mode setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_mode_options(): array { + return [ + self::MODE_INLINE => get_string('smartmenusmodeinline', 'theme_boost_union'), + self::MODE_SUBMENU => get_string('smartmenusmodesubmenu', 'theme_boost_union'), + ]; + } + + /** + * Return the options for the testposition setting. + * + * @return array + * @throws \coding_exception + */ + public static function get_textposition_options(): array { + return [ + self::POSITION_BELOW => + get_string('smartmenusmenuitemtextpositionbelowimage', 'theme_boost_union'), + self::POSITION_OVERLAYTOP => + get_string('smartmenusmenuitemtextpositionoverlaytop', 'theme_boost_union'), + self::POSITION_OVERLAYBOTTOM => + get_string('smartmenusmenuitemtextpositionoverlaybottom', 'theme_boost_union'), + ]; } /** diff --git a/config.php b/config.php index a6503eadb11..f9e8abf1faa 100644 --- a/config.php +++ b/config.php @@ -168,7 +168,12 @@ 'secure' => [ 'file' => 'secure.php', 'regions' => ['side-pre'], - 'defaultregion' => 'side-pre' + 'defaultregion' => 'side-pre', + 'options' => [ + 'activityheader' => [ + 'notitle' => false, + ], + ], ] ]; diff --git a/smartmenus/edit.php b/smartmenus/edit.php index 7b203921ca8..14c99552be0 100644 --- a/smartmenus/edit.php +++ b/smartmenus/edit.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Theme boost union - Edit menu. + * Theme Boost Union - Edit menu. * * @package theme_boost_union * @copyright 2023 bdecent GmbH diff --git a/smartmenus/edit_items.php b/smartmenus/edit_items.php index a12aa8a1c4a..65a359f6ada 100644 --- a/smartmenus/edit_items.php +++ b/smartmenus/edit_items.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Theme boost union - Edit menu items. + * Theme Boost Union - Edit menu items. * * @package theme_boost_union * @copyright 2023 bdecent GmbH diff --git a/templates/theme_boost/navbar.mustache b/templates/theme_boost/navbar.mustache index 0ad983ef3d5..371edea1175 100644 --- a/templates/theme_boost/navbar.mustache +++ b/templates/theme_boost/navbar.mustache @@ -101,7 +101,7 @@ {{{ output.page_heading_menu }}} -