Skip to content

Commit

Permalink
Improvement: Add the option to suppress the icons in front of the foo…
Browse files Browse the repository at this point in the history
…ter links, resolves #649.
  • Loading branch information
lucaboesch committed May 9, 2024
1 parent f9b429c commit 5a98f77
Show file tree
Hide file tree
Showing 9 changed files with 243 additions and 10 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

### Unreleased

* 2024-05-09 - Improvement: Suppress icons in footer, resolves #649
* 2024-05-09 - Bugfix: Smart menu menubar overlaid course index, resolves #607
* 2024-04-27 - Improvement: Add navigation to policy overview page, resolves #633

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
109 changes: 109 additions & 0 deletions classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,4 +663,113 @@ 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.
*
* @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;

$footericonsetting = get_config('theme_boost_union', 'footersuppressicons');
$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('book', '', 'moodle', array('class' => 'iconhelp icon-pre'));
}

$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.
*
* @return string
*/
public function services_support_link(): string {
global $CFG;

if (during_initial_install() ||
(isset($CFG->showservicesandsupportcontent) && $CFG->showservicesandsupportcontent == false) ||
!is_siteadmin()) {
return '';
}

$footericonsetting = get_config('theme_boost_union', 'footersuppressicons');
$liferingicon = 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) {
$liferingicon = $this->pix_icon('t/life-ring', '', 'moodle', ['class' => 'fa fa-life-ring']);
}
$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
*
* @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');
$footericonsetting = get_config('theme_boost_union', 'footersuppressicons');
$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 before links in the footer.
$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
13 changes: 13 additions & 0 deletions layout/includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,17 @@
// 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
64 changes: 55 additions & 9 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": true,
}
}}
{{!
Expand Down Expand Up @@ -147,55 +148,100 @@
<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>
{{# suppressfooterlinkicons }}
<a href="{{ aboutuslink }}">{{ aboutuspagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ aboutuslink }}"><i class="icon fa fa-info-circle fa-fw " aria-hidden="true"></i>{{ aboutuspagetitle }}</a>
{{/ suppressfooterlinkicons }}
</div>
{{/ aboutuslinkpositionfooter }}

{{# offerslinkpositionfooter }}
<div class="footer-support-link theme_boost_union_footer_offerslink">
{{# suppressfooterlinkicons }}
<a href="{{ offerslink }}">{{ offerspagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ offerslink }}"><i class="icon fa fa-briefcase fa-fw " aria-hidden="true"></i>{{ offerspagetitle }}</a>
{{/ suppressfooterlinkicons }}
</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>
{{# suppressfooterlinkicons }}
<a href="{{ imprintlink }}">{{ imprintpagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ imprintlink }}"><i class="icon fa fa-building-o fa-fw " aria-hidden="true"></i>{{ imprintpagetitle }}</a>
{{/ suppressfooterlinkicons }}
</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>
{{# suppressfooterlinkicons }}
<a href="{{ contactlink }}">{{ contactpagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ contactlink }}"><i class="icon fa fa-address-card fa-fw " aria-hidden="true"></i>{{ contactpagetitle }}</a>
{{/ suppressfooterlinkicons }}
</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>
{{# suppressfooterlinkicons }}
<a href="{{ helplink }}">{{ helppagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ helplink }}"><i class="icon fa fa-question-circle-o fa-fw " aria-hidden="true"></i>{{ helppagetitle }}</a>
{{/ suppressfooterlinkicons }}
</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>
{{# suppressfooterlinkicons }}
<a href="{{ maintenancelink }}">{{ maintenancepagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ maintenancelink }}"><i class="icon fa fa-wrench fa-fw " aria-hidden="true"></i>{{ maintenancepagetitle }}</a>
{{/ suppressfooterlinkicons }}
</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>
{{# suppressfooterlinkicons }}
<a href="{{ page1link }}">{{ page1pagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ page1link }}"><i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{ page1pagetitle }}</a>
{{/ suppressfooterlinkicons }}
</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>
{{# suppressfooterlinkicons }}
<a href="{{ page2link }}">{{ page2pagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ page2link }}"><i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{ page2pagetitle }}</a>
{{/ suppressfooterlinkicons }}
</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>
{{# suppressfooterlinkicons }}
<a href="{{ page3link }}">{{ page3pagetitle }}</a>
{{/ suppressfooterlinkicons }}
{{^ suppressfooterlinkicons }}
<a href="{{ page3link }}"><i class="icon fa fa-arrow-circle-o-right fa-fw " aria-hidden="true"></i>{{ page3pagetitle }}</a>
{{/ suppressfooterlinkicons }}
</div>
{{/ page3linkpositionfooter }}
</div>
Expand Down
Loading

0 comments on commit 5a98f77

Please sign in to comment.