Skip to content

Commit

Permalink
Improvement: Add the option to suppress the footer button, solves #444.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Nov 12, 2023
1 parent 8807241 commit 2afb4ba
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 0 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-r2

* 2023-11-12 - Improvement: Option to suppress footer button, solves #444.
* 2023-11-11 - Bugfix: Bulk actions widget overlaid course header image, solves #469.
* 2023-11-09 - Bugfix: Hide back to top button on small screens as soon as the right hand drawer is opened, solves #379.
* 2023-11-09 - Bugfix: Styles of styled e-mail previews leaked into the rest of the admin UI, solves #413.
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ In this tab there are the following settings:

Whatever you add to this textarea will be displayed at the end of a page, in the footer. Refer to the setting description on the settings page for further instructions.

###### Footer

With these settings, you can show where to show or whether to suppress the footer (circle containing the question mark) button.

#### Tab "Static pages"

In this tab there are the following settings:
Expand Down
10 changes: 10 additions & 0 deletions lang/en/theme_boost_union.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,16 @@
// ... ... Setting: Footnote.
$string['footnotesetting'] = 'Footnote';
$string['footnotesetting_desc'] = 'Whatever you add to this textarea will be displayed at the end of a page, in the footer (not the floating footer) on every page which uses the layouts "drawers", "columns2" or "login". Content in this area could be for example the copyright, the terms of use or the name of your organisation. <br/> If you want to remove the footnote again, just empty the text area.';
// ... Section: Footer.
$string['footerheading'] = 'Footer';
// ... ... Setting: Footer.
$string['enablefooterbutton'] = 'Enable footer';
$string['enablefooterbutton_desc'] = 'With "footer", the circle containing the question mark at the bottom of the page is meant.<br />Upon click, the user is presented with an overlay. Depending on the site configuration the links
Help and documentation, Services and support, Contact site support, Login information, Reset user tour on this page, Data retention summary, Get the mobile app, Policies and Powered by Moodle could be shown.<br />With this setting it is possible to choose on which device to show or entirely suppress this footer button.';
$string['enablefooterbuttonboth'] = 'Desktop and mobile';
$string['enablefooterbuttondesktop'] = 'Desktop only';
$string['enablefooterbuttonmobile'] = 'Mobile only';
$string['enablefooterbuttonhidden'] = 'Hidden';

// Settings: Static pages tab.
$string['staticpagestab'] = 'Static pages';
Expand Down
3 changes: 3 additions & 0 deletions layout/columns2.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
// Include the template content for the static pages.
require_once(__DIR__ . '/includes/staticpages.php');

// Include the template content for the footer button.
require_once(__DIR__ . '/includes/footer.php');

// Include the template content for the JavaScript disabled hint.
require_once(__DIR__ . '/includes/javascriptdisabledhint.php');

Expand Down
3 changes: 3 additions & 0 deletions layout/drawers.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@
// Include the template content for the static pages.
require_once(__DIR__ . '/includes/staticpages.php');

// Include the template content for the footer button.
require_once(__DIR__ . '/includes/footer.php');

// Include the template content for the JavaScript disabled hint.
require_once(__DIR__ . '/includes/javascriptdisabledhint.php');

Expand Down
38 changes: 38 additions & 0 deletions layout/includes/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Theme Boost Union - Footer question mark button layout include.
*
* @package theme_boost_union
* @copyright 2023 Luca Bösch <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

// Require the necessary libraries.
require_once($CFG->dirroot.'/theme/boost_union/locallib.php');

$config = get_config('theme_boost_union');

// If the footerbutton is enabled.
$footerquestionmark = isset($config->enablefooterbutton) ? $config->enablefooterbutton :
THEME_BOOST_UNION_SETTING_ENABLEFOOTER_BOTH;

if ($footerquestionmark != THEME_BOOST_UNION_SETTING_ENABLEFOOTER_HIDDEN) {
$templatecontext['footerbutton'] = true;
}
3 changes: 3 additions & 0 deletions layout/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
// Include the template content for the static pages.
require_once(__DIR__ . '/includes/staticpages.php');

// Include the template content for the footer button.
require_once(__DIR__ . '/includes/footer.php');

// Include the template content for the info banners.
require_once(__DIR__ . '/includes/infobanners.php');

Expand Down
33 changes: 33 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
define('THEME_BOOST_UNION_SETTING_OUTSIDEREGIONSWITH_COURSECONTENTWIDTH', 'coursecontentwidth');
define('THEME_BOOST_UNION_SETTING_OUTSIDEREGIONSWITH_HEROWIDTH', 'herowidth');

define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_BOTH', 'enablefooterbuttonall');
define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_DESKTOP', 'enablefooterbuttondesktop');
define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_MOBILE', 'enablefooterbuttonmobile');
define('THEME_BOOST_UNION_SETTING_ENABLEFOOTER_HIDDEN', 'enablefooterbuttonhidden');

/**
* Returns the main SCSS content.
*
Expand Down Expand Up @@ -289,6 +294,34 @@ function theme_boost_union_get_extra_scss($theme) {
// Setting: Mark external links.
$content .= theme_boost_union_get_scss_to_mark_external_links($theme);

// If the footerbutton is enabled.
$footerquestionmark = get_config('theme_boost_union', 'enablefooterbutton');

switch ($footerquestionmark) {
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_BOTH:
$content .= '@media (max-width: 575px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: block !important; } }' . PHP_EOL;
break;
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_DESKTOP:
$content .= '@media (min-width: 576px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: block !important; } }' . PHP_EOL;
$content .= '#page-footer .footer-content-popover.container { display: none !important; }' . PHP_EOL;
break;
case THEME_BOOST_UNION_SETTING_ENABLEFOOTER_MOBILE:
$content .= '@media (min-width: 576px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: none !important; } }' . PHP_EOL;
$content .= '@media (max-width: 575px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: block !important; bottom: 5rem; } }' . PHP_EOL;
$content .= '#page-footer .footer-content-popover.container { display: none !important; }' . PHP_EOL;
break;
default:
$content .= '@media (max-width: 575px) { #page-footer [data-region="footer-container-popover"] .btn-footer-popover ' .
'{ display: none !important; } }' . PHP_EOL;
$content .= '@media (max-width: 575px) { #page-footer .footer-content-popover.container ' .
'{ display: none !important; } }' . PHP_EOL;
break;
}

return $content;
}

Expand Down
15 changes: 15 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,21 @@
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
$tab->add($setting);

// Setting: Footer.
$enablefooterbuttonoptions = [
'enablefooterbuttonboth' => get_string('enablefooterbuttonboth', 'theme_boost_union', null, true),
'enablefooterbuttondesktop' => get_string('enablefooterbuttondesktop', 'theme_boost_union', null, true),
'enablefooterbuttonmobile' => get_string('enablefooterbuttonmobile', 'theme_boost_union', null, true),
'enablefooterbuttonhidden' => get_string('enablefooterbuttonhidden', 'theme_boost_union', null, true),
];
$name = 'theme_boost_union/enablefooterbutton';
$title = get_string('enablefooterbutton', 'theme_boost_union', null, true);
$description = get_string('enablefooterbutton_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, 'enablefooterbuttonboth',
$enablefooterbuttonoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);

// Add tab to settings page.
$page->add($tab);

Expand Down
3 changes: 3 additions & 0 deletions templates/theme_boost/footer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
* Added the possibility to show the generic page 2 link.
* Added the possibility to show the generic page 3 link.
* Added the bottom menu bar to show menus in footer for mobile devices.
* Added the possibility to suppress the footer button (question mark in the circle).
}}

<footer id="page-footer" class="footer-popover bg-white">
Expand All @@ -84,9 +85,11 @@
{{#pix}}t/messages-o, core{{/pix}}
</button>
{{/output.has_communication_links}}
{{# footerbutton }}
<button class="btn btn-icon bg-secondary icon-no-margin btn-footer-popover" data-action="footer-popover" aria-label="{{#str}}showfooter, theme_boost{{/str}}">
{{#pix}}e/question, core{{/pix}}
</button>
{{/ footerbutton }}
</div>
<div class="footer-content-popover container" data-region="footer-content-popover">
{{#output.has_communication_links}}
Expand Down
72 changes: 72 additions & 0 deletions tests/behat/theme_boost_union_contentsettings_footer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,75 @@ Feature: Configuring the theme_boost_union plugin for the "Footer" tab on the "C
And I should see "Footnote" in the "#footnote" "css_element"
And I should not see "<span lang=\"en\" class=\"multilang\">Footnote</span>" in the "#footnote" "css_element"
And I should not see "FootnoteFussnote" in the "#footnote" "css_element"

@javascript
Scenario: Setting: Footer - Enable and disable the footer button
Given the following config values are set as admin:
| config | value | plugin |
| enablefooterbutton | enablefooterbuttonhidden | theme_boost_union |
When I log in as "teacher1"
And I change viewport size to "large"
And I follow "Dashboard"
Then ".btn-footer-popover" "css_element" should not exist
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should not exist
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I change viewport size to "large"
Then ".btn-footer-popover" "css_element" should not exist
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should not exist
And I log out
And I follow "Log in"
And I change viewport size to "large"
Then ".btn-footer-popover" "css_element" should not exist
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should not exist
And I log out
And the following config values are set as admin:
| config | value | plugin |
| enablefooterbutton | enablefooterbuttonboth | theme_boost_union |
When I log in as "teacher1"
And I change viewport size to "large"
And I follow "Dashboard"
Then ".btn-footer-popover" "css_element" should exist
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should exist
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I change viewport size to "large"
Then ".btn-footer-popover" "css_element" should exist
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should exist
And I log out
And I follow "Log in"
And I change viewport size to "large"
Then ".btn-footer-popover" "css_element" should exist
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should exist
And I log out
And the following config values are set as admin:
| config | value | plugin |
| enablefooterbutton | enablefooterbuttondesktop | theme_boost_union |
When I log in as "teacher1"
And I am on site homepage
And I change viewport size to "large"
And I follow "Dashboard"
Then ".btn-footer-popover" "css_element" should be visible
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should not be visible
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I change viewport size to "large"
Then ".btn-footer-popover" "css_element" should be visible
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should not be visible
And I log out
And I follow "Log in"
And I change viewport size to "large"
Then ".btn-footer-popover" "css_element" should be visible
And I change viewport size to "480x800"
Then ".btn-footer-popover" "css_element" should not be visible

0 comments on commit 2afb4ba

Please sign in to comment.