diff --git a/CHANGES.md b/CHANGES.md index b1afb0af7a1..5aebdaceb7a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### v4.3-r13 +* 2024-05-13 - Improvement: Suppress icons in footer, resolves #649 * 2024-05-13 - Bugfix: Make the "More menu behavior" setting in smart menus more stable, resolves #461. * 2024-05-11 - Improvement: Enhance smart menu restrictions for authenticated user role, guest roles and visitor role, resolves #571 * 2024-05-11 - Improvement: Smart menu "locations" must be filled with a value, resolves #404 diff --git a/README.md b/README.md index e38b84f9c00..f4a7debaca8 100644 --- a/README.md +++ b/README.md @@ -477,6 +477,10 @@ Whatever you add to this textarea will be displayed at the end of a page, in the With this setting, you can control whether to show or to suppress the footer button at the bottom of the page. +###### Suppress icons in front of the footer links + +With this setting, you can entirely suppress the icons in front of the footer links. + ###### Suppress ... link With these settings, you can entirely suppress particular links in the footer. diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index 74fb2553279..bfe9da750cc 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -663,4 +663,130 @@ public function standard_end_of_body_html_additionalhtmlfooter() { } return $output; } + + /** + * Returns a string containing a link to the user documentation. + * Also contains an icon by default. Shown to teachers and admin only. + * + * This renderer function is copied and modified from /lib/outputrenderers.php + * + * @param string $path The page link after doc root and language, no leading slash. + * @param string $text The text to be displayed for the link + * @param boolean $forcepopup Whether to force a popup regardless of the value of $CFG->doctonewwindow + * @param array $attributes htm attributes + * @return string + */ + public function doc_link($path, $text = '', $forcepopup = false, array $attributes = []) { + global $CFG; + + // Set the icon only if the setting is not set to suppress the footer icons. + $footericonsetting = get_config('theme_boost_union', 'footersuppressicons'); + if (!isset($footericonsetting) || $footericonsetting == THEME_BOOST_UNION_SETTING_SELECT_NO) { + $icon = $this->pix_icon('book', '', 'moodle', ['class' => 'iconhelp icon-pre']); + + // Otherwise. + } else { + $icon = null; + } + + $attributes['href'] = new moodle_url(get_docs_url($path)); + $newwindowicon = ''; + if (!empty($CFG->doctonewwindow) || $forcepopup) { + $attributes['target'] = '_blank'; + $newwindowicon = $this->pix_icon('i/externallink', get_string('opensinnewwindow'), 'moodle', + ['class' => 'fa fa-externallink fa-fw']); + } + + return html_writer::tag('a', $icon . $text . $newwindowicon, $attributes); + } + + /** + * Returns the services and support link for the help pop-up. + * + * This renderer function is copied and modified from /lib/outputrenderers.php + * + * @return string + */ + public function services_support_link(): string { + global $CFG; + + if (during_initial_install() || + (isset($CFG->showservicesandsupportcontent) && $CFG->showservicesandsupportcontent == false) || + !is_siteadmin()) { + return ''; + } + + // Set the icon only if the setting is not set to suppress the footer icons. + $footericonsetting = get_config('theme_boost_union', 'footersuppressicons'); + if (!isset($footericonsetting) || $footericonsetting == THEME_BOOST_UNION_SETTING_SELECT_NO) { + $liferingicon = $this->pix_icon('t/life-ring', '', 'moodle', ['class' => 'fa fa-life-ring']); + + // Otherwise. + } else { + $liferingicon = null; + } + + $newwindowicon = $this->pix_icon('i/externallink', get_string('opensinnewwindow'), 'moodle', ['class' => 'ml-1']); + $link = !empty($CFG->servicespage) + ? $CFG->servicespage + : 'https://moodle.com/help/?utm_source=CTA-banner&utm_medium=platform&utm_campaign=name~Moodle4+cat~lms+mp~no'; + $content = $liferingicon . get_string('moodleservicesandsupport') . $newwindowicon; + + return html_writer::tag('a', $content, ['target' => '_blank', 'href' => $link]); + } + + /** + * Returns the HTML for the site support email link + * + * This renderer function is copied and modified from /lib/outputrenderers.php + * + * @param array $customattribs Array of custom attributes for the support email anchor tag. + * @param bool $embed Set to true if you want to embed the link in other inline content. + * @return string The html code for the support email link. + */ + public function supportemail(array $customattribs = [], bool $embed = false): string { + global $CFG; + + // Do not provide a link to contact site support if it is unavailable to this user. This would be where the site has + // disabled support, or limited it to authenticated users and the current user is a guest or not logged in. + if (!isset($CFG->supportavailability) || + $CFG->supportavailability == CONTACT_SUPPORT_DISABLED || + ($CFG->supportavailability == CONTACT_SUPPORT_AUTHENTICATED && (!isloggedin() || isguestuser()))) { + return ''; + } + + $label = get_string('contactsitesupport', 'admin'); + + // Set the icon only if the setting is not set to suppress the footer icons. + $footericonsetting = get_config('theme_boost_union', 'footersuppressicons'); + if (!isset($footericonsetting) || $footericonsetting == THEME_BOOST_UNION_SETTING_SELECT_NO) { + $icon = $this->pix_icon('book', '', 'moodle', ['class' => 'iconhelp icon-pre']); + + // Otherwise. + } else { + $icon = null; + } + + // Set the icon only if the setting is no set to suppress the footer icons. + if (isset($footericonsetting) && $footericonsetting != THEME_BOOST_UNION_SETTING_SELECT_YES) { + $icon = $this->pix_icon('t/email', ''); + } + + if (!$embed) { + $content = $icon . $label; + } else { + $content = $label; + } + + if (!empty($CFG->supportpage)) { + $attributes = ['href' => $CFG->supportpage, 'target' => 'blank']; + $content .= $this->pix_icon('i/externallink', '', 'moodle', ['class' => 'ml-1']); + } else { + $attributes = ['href' => $CFG->wwwroot . '/user/contactsitesupport.php']; + } + + $attributes += $customattribs; + + return html_writer::tag('a', $content, $attributes); + } } diff --git a/lang/en/theme_boost_union.php b/lang/en/theme_boost_union.php index 57ee7435e0f..415ee3accc4 100644 --- a/lang/en/theme_boost_union.php +++ b/lang/en/theme_boost_union.php @@ -571,6 +571,9 @@ $string['enablefooterbuttondesktop'] = 'Enable on desktop and tablet only, hide on mobile (unchanged as presented by Moodle core)'; $string['enablefooterbuttonmobile'] = 'Enable on mobile only, hide on desktop and tablet'; $string['enablefooterbuttonhidden'] = 'Hide on all devices'; +// ... ... Setting: Suppress icons in front of the footer links. +$string['footersuppressiconssetting'] = 'Suppress icons in front of the footer links'; +$string['footersuppressiconssetting_desc'] = 'With this setting, you can entirely suppress the icons in front of the footer links. \'Documentation for this page\' has a book icon, \'Services and support\' a life ring etc.'; // ... ... Setting: Suppress 'Chat to course participants' link. $string['footersuppresschatsetting'] = 'Suppress \'Chat to course participants\' link'; $string['footersuppresschatsetting_desc'] = 'With this setting, you can entirely suppress the \'Chat to course participants\' link in the footer. This link would otherwise appear within courses as soon as a communication room is added in a course\'s settings.'; diff --git a/layout/includes/footer.php b/layout/includes/footer.php index 74eb33ff4fe..c258efc014a 100644 --- a/layout/includes/footer.php +++ b/layout/includes/footer.php @@ -128,4 +128,18 @@ // Add marker to hide this link. $templatecontext['footershowpowered'] = false; } + + // If the "Suppress icons in front of the footer links" setting is not enabled. + $footersuppressfooterlinkiconssetting = get_config('theme_boost_union', 'footersuppressicons'); + if (!isset($footersuppressfooterlinkiconssetting) || + $footersuppressfooterlinkiconssetting != THEME_BOOST_UNION_SETTING_SELECT_YES) { + // Add marker to show the icons. + $templatecontext['suppressfooterlinkicons'] = false; + + // Otherwise. + } else { + // Add marker to hide the icons. + $templatecontext['suppressfooterlinkicons'] = true; + } + } diff --git a/settings.php b/settings.php index 5ad55d3780f..ab4f0d34de8 100644 --- a/settings.php +++ b/settings.php @@ -1714,6 +1714,13 @@ THEME_BOOST_UNION_SETTING_ENABLEFOOTER_DESKTOP, $enablefooterbuttonoptions); $tab->add($setting); + // Setting: Suppress icons in front of the footer links. + $name = 'theme_boost_union/footersuppressicons'; + $title = get_string('footersuppressiconssetting', 'theme_boost_union', null, true); + $description = get_string('footersuppressiconssetting_desc', 'theme_boost_union', null, true); + $setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption); + $tab->add($setting); + // Setting: Suppress 'Chat to course participants' link. $name = 'theme_boost_union/footersuppresschat'; $title = get_string('footersuppresschatsetting', 'theme_boost_union', null, true); diff --git a/templates/theme_boost/footer.mustache b/templates/theme_boost/footer.mustache index 7eed57f4979..26c52a4e24c 100644 --- a/templates/theme_boost/footer.mustache +++ b/templates/theme_boost/footer.mustache @@ -68,7 +68,8 @@ "page2pagetitle": "Generic page 2", "page3linkpositionfooter": true, "page3link": "https://localhost/theme/boost_union/pages/page3.php", - "page3pagetitle": "Generic page 3" + "page3pagetitle": "Generic page 3", + "suppressfooterlinkicons": false } }} {{! @@ -96,6 +97,7 @@ * The "Reset user tour on this page" link is added to the page by Moodle core with a quite aggressive JavaScript code. If this JS code does not find the placeholder div, it will add the link at another location on the page. That's why we keep the placeholder here and hide it with CSS if the link should be suppressed. + * Added the possibility to suppress the icons in front of the footer links. }}