From 192a894801b168763cf7ede88b6d4fcc18a6d7d7 Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Sun, 31 Dec 2023 15:50:47 +0100 Subject: [PATCH] Improvement: Fix several edge-cases where the 'Mark external links' should not add its icons, solves #525 & #526 & #528. --- CHANGES.md | 1 + UPGRADE.md | 1 + locallib.php | 26 ++++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f042158af69..c935b635891 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2023-12-31 - Improvement: Fix several edge-cases where the "Mark external links" should not add its icons, solves #525 & #526 & #528. * 2023-12-28 - Feature: Add slider which can be displayed on site home, solves #162. * 2023-12-27 - Improvement: Add content style setting to the advertisement tiles, solves #519. * 2023-12-27 - Test: Always reactivate debugging during Behat tests, solves #521. diff --git a/UPGRADE.md b/UPGRADE.md index 870f80b46c5..50a67062847 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -15,6 +15,7 @@ Upstream changes * This theme is built on top of theme_boost from Moodle core. It inherits the codebase from theme_boost and overwrites and extends several behaviours and functions. Doing this, code duplication couldn't be avoided. If there are any upstream changes in theme_boost, you should check if they should be adopted to this theme as well. * In addition to that, you should check any upstream changes which happen in /lib/templates and /lib/outputrenderers.php as some of these templates and renderers are overwritten in this theme as well. +* In addition to that, you should check if any additions to theme_boost_union_get_scss_to_mark_external_links() should be made. This might be particularly necessary if any new links have been added to the footer questionmark icon in Moodle core (have a look at footer.mustache) or if any links have been added which have a hardcoded external-link icon (check for new occurrences of "i/externallink" in the Moodle codebase). Automated tests diff --git a/locallib.php b/locallib.php index 488217d5f1e..cda94e73801 100644 --- a/locallib.php +++ b/locallib.php @@ -1421,20 +1421,42 @@ function theme_boost_union_get_scss_to_mark_external_links($theme) { padding-right: 0.25rem; }'; + // While adding the external link icon to text links is perfectly fine and intended, the SCSS code also + // matches on image links. And this should be avoided for optical reasons. + // Unfortunately, we can't select _all_ images which are surrounded by links with pure CSS. + // But we can at least revert the external link icon in images and other assets which we know that should not + // get it: + // * Everything inside the frontpage slider. + $scss .= '#themeboostunionslider a::before, #themeboostunionslider a::after { + display: none; + }'; + // Moodle adds a hardcoded external-link icon to several links: // * The "services and support" link in the questionmark menu (which should point to moodle.com/help, but may also point to // the URL in the $CFG->servicespage setting). // * The "contact site support" link in the questionmark menu (as soon as the URL in the $CFG->supportpage setting is set). // * The links to the Moodle docs (which are created with the get_docs_url() helper function). + // * The "Chat to course participants" link in the questionmark menu (as soon as the communication setting is set within + // a course). + // * The "Give feedback about this software" link in the questionmark menu (if the $CFG->enableuserfeedback setting + // is enabled). + // * Anything else which is shown in the call-to-action notification banners on the Dashboard + // (Currently just the "Give feedback about this software" link as well). // These icons become obsolete now. We remove them with the sledgehammer. - $scss .= '.footer-support-link a[href^="https://moodle.com/help/"] .fa-external-link'; + $scss .= '.footer-support-link a[href^="https://moodle.com/help/"] .fa-external-link, + .footer-support-link a[target="_blank"] .fa-external-link'; if (!empty($CFG->servicespage)) { $scss .= ', .footer-support-link a[href="'.$CFG->servicespage.'"] .fa-external-link'; } if (!empty($CFG->supportpage)) { $scss .= ', a[href="'.$CFG->supportpage.'"] .fa-external-link'; } - $scss .= ', a[href^="'.get_docs_url().'"] .fa-external-link { + if (!empty($CFG->enableuserfeedback)) { + $scss .= ', a[href^="https://feedback.moodle.org"] .fa-external-link, + a[href^="https://feedback.moodle.org"] .ml-1'; + } + $scss .= ', a[href^="'.get_docs_url().'"] .fa-external-link, + div.cta a .fa-external-link { display: none; }'; }