Skip to content

Commit

Permalink
Improvement: Configurable "Documentation for this page" link in footer,
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch authored May 16, 2024
1 parent 087af02 commit d2de6b0
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
126 changes: 126 additions & 0 deletions classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
3 changes: 3 additions & 0 deletions lang/en/theme_boost_union.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
14 changes: 14 additions & 0 deletions layout/includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
7 changes: 7 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 12 additions & 10 deletions templates/theme_boost/footer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}}
{{!
Expand Down Expand Up @@ -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.
}}
<footer id="page-footer" class="footer-popover bg-white">
Expand Down Expand Up @@ -147,55 +149,55 @@
<div class="footer-section p-3 border-bottom">
{{# aboutuslinkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_aboutuslink">
<a href="{{ aboutuslink }}"><i class="icon fa fa-info-circle fa-fw " aria-hidden="true"></i>{{ aboutuspagetitle }}</a>
<a href="{{ aboutuslink }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-info-circle fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ aboutuspagetitle }}</a>
</div>
{{/ aboutuslinkpositionfooter }}

{{# offerslinkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_offerslink">
<a href="{{ offerslink }}"><i class="icon fa fa-briefcase fa-fw " aria-hidden="true"></i>{{ offerspagetitle }}</a>
<a href="{{ offerslink }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-briefcase fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ offerspagetitle }}</a>
</div>
{{/ offerslinkpositionfooter }}

{{# imprintlinkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_imprintlink">
<a href="{{ imprintlink }}"><i class="icon fa fa-building-o fa-fw " aria-hidden="true"></i>{{ imprintpagetitle }}</a>
<a href="{{ imprintlink }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-building-o fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ imprintpagetitle }}</a>
</div>
{{/ imprintlinkpositionfooter }}

{{# contactlinkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_contactlink">
<a href="{{ contactlink }}"><i class="icon fa fa-address-card fa-fw " aria-hidden="true"></i>{{ contactpagetitle }}</a>
<a href="{{ contactlink }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-address-card fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ contactpagetitle }}</a>
</div>
{{/ contactlinkpositionfooter }}

{{# helplinkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_helplink">
<a href="{{ helplink }}"><i class="icon fa fa-question-circle-o fa-fw " aria-hidden="true"></i>{{ helppagetitle }}</a>
<a href="{{ helplink }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-question-circle-o fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ helppagetitle }}</a>
</div>
{{/ helplinkpositionfooter }}

{{# maintenancelinkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_maintenancelink">
<a href="{{ maintenancelink }}"><i class="icon fa fa-wrench fa-fw " aria-hidden="true"></i>{{ maintenancepagetitle }}</a>
<a href="{{ maintenancelink }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-wrench fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ maintenancepagetitle }}</a>
</div>
{{/ maintenancelinkpositionfooter }}

{{# page1linkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_page1link">
<a href="{{ page1link }}"><i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{ page1pagetitle }}</a>
<a href="{{ page1link }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ page1pagetitle }}</a>
</div>
{{/ page1linkpositionfooter }}

{{# page2linkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_page2link">
<a href="{{ page2link }}"><i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{ page2pagetitle }}</a>
<a href="{{ page2link }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ page2pagetitle }}</a>
</div>
{{/ page2linkpositionfooter }}

{{# page3linkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_page3link">
<a href="{{ page3link }}"><i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{ page3pagetitle }}</a>
<a href="{{ page3link }}">{{^ suppressfooterlinkicons }}<i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{/ suppressfooterlinkicons }}{{ page3pagetitle }}</a>
</div>
{{/ page3linkpositionfooter }}
</div>
Expand Down
50 changes: 50 additions & 0 deletions tests/behat/theme_boost_union_contentsettings_footer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,53 @@ Feature: Configuring the theme_boost_union plugin for the "Footer" tab on the "C
| value | shouldornot |
| no | should |
| yes | should not |

@javascript
Scenario Outline: Setting: Footer - Suppress icons in front of the footer links
Given the following config values are set as admin:
| config | value | plugin |
| footersuppressicons | <value> | theme_boost_union |
| enableaboutus | yes | theme_boost_union |
| aboutuscontent | <p>Lorem ipsum</p> | theme_boost_union |
| aboutuslinkposition | footer | theme_boost_union |
| enableoffers | yes | theme_boost_union |
| offerscontent | <p>Lorem ipsum</p> | theme_boost_union |
| offerslinkposition | footer | theme_boost_union |
| enableimprint | yes | theme_boost_union |
| imprintcontent | <p>Lorem ipsum</p> | theme_boost_union |
| imprintlinkposition | footer | theme_boost_union |
| enablecontact | yes | theme_boost_union |
| contactcontent | <p>Lorem ipsum</p> | theme_boost_union |
| contactlinkposition | footer | theme_boost_union |
| enablehelp | yes | theme_boost_union |
| helpcontent | <p>Lorem ipsum</p> | theme_boost_union |
| helplinkposition | footer | theme_boost_union |
| enablemaintainance | yes | theme_boost_union |
| maintainancecontent | <p>Lorem ipsum</p> | theme_boost_union |
| maintainancelinkposition | footer | theme_boost_union |
| enablepage1 | yes | theme_boost_union |
| page1content | <p>Lorem ipsum</p> | theme_boost_union |
| page1linkposition | footer | theme_boost_union |
| enablepage2 | yes | theme_boost_union |
| page2content | <p>Lorem ipsum</p> | theme_boost_union |
| page2linkposition | footer | theme_boost_union |
| enablepage3 | yes | theme_boost_union |
| page3content | <p>Lorem ipsum</p> | theme_boost_union |
| page3linkposition | footer | theme_boost_union |
When I log in as "admin"
And I am on "Course 1" course homepage
And I click on ".btn-footer-popover" "css_element" in the "#page-footer" "css_element"
Then ".footer-support-link a i.icon.fa-book" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"
And ".footer-support-link a i.icon.fa-life-ring" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"
And ".footer-support-link a i.icon.fa-envelope-o" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"
And ".footer-support-link a i.icon.fa-info-circle" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"
And ".footer-support-link a i.icon.fa-briefcase" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"
And ".footer-support-link a i.icon.fa-building-o" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"
And ".footer-support-link a i.icon.fa-address-card" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"
And ".footer-support-link a i.icon.fa-question-circle-o" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"
And ".footer-support-link a i.icon.fa-arrow-circle-o-right" "css_element" <shouldornot> exist in the ".footer .popover-body" "css_element"

Examples:
| value | shouldornot |
| no | should |
| yes | should not |
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'theme_boost_union';
$plugin->version = 2023102038;
$plugin->version = 2023102039;
$plugin->release = 'v4.3-r13';
$plugin->requires = 2023100900;
$plugin->supported = [403, 403];
Expand Down

0 comments on commit d2de6b0

Please sign in to comment.