Skip to content

Commit

Permalink
Improvement: Add the option to oppress the footer button, solves mood…
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Nov 7, 2023
1 parent 4affa26 commit 8d3ed05
Show file tree
Hide file tree
Showing 12 changed files with 145 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

### Unreleased

* 2023-11-05 - Improvement: Option to suppress footer button, solves #444.
* 2023-10-09 - Improvement: Add a direct 'view course' icon on the course management pages, solves #129.
* 2023-10-05 - Improvement: Allow the admin to set the background-position of the background and login background images, solves #111.
* 2023-11-03 - Bugfix: Add missing cachedef strings to the language pack, solves #441.
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 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;
}
1 change: 1 addition & 0 deletions layout/includes/staticpages.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@
$templatecontext[$staticpage.'link'] = theme_boost_union_get_staticpage_link($staticpage);
$templatecontext[$staticpage.'pagetitle'] = theme_boost_union_get_staticpage_pagetitle($staticpage);
}
$templatecontext['footerbutton'] = false;
}
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
24 changes: 24 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,25 @@ 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');

if ($footerquestionmark == 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;
PHP_EOL;
} else if ($footerquestionmark == 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;
} else if ($footerquestionmark == 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;
} else {
$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;
}

return $content;
}

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

// Setting: Footer.
$enablefooterbuttonoptions = array(
'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
41 changes: 41 additions & 0 deletions tests/behat/theme_boost_union_contentsettings_footer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,44 @@ Feature: Configuring the theme_boost_union plugin for the "Footer" tab on the "C
And I follow "Log in"
Then "#footnote" "css_element" should exist
And I should see "Whatever footnote" in the "#footnote" "css_element"

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 "admin"
And I follow "Dashboard"
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
Then ".btn-footer-popover" "css_element" should not exist
And I log out
And I follow "Log in"
Then ".btn-footer-popover" "css_element" should not exist
And the following config values are set as admin:
| config | value | plugin |
| enablefooterbutton | enablefooterbuttonboth | theme_boost_union |
When I log in as "admin"
And I follow "Dashboard"
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
Then ".btn-footer-popover" "css_element" should exist
And I log out
And I follow "Log in"
Then ".btn-footer-popover" "css_element" should exist
And the following config values are set as admin:
| config | value | plugin |
| enablefooterbutton | enablefooterbuttondesktop | theme_boost_union |
When I log in as "admin"
And I follow "Dashboard"
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
Then ".btn-footer-popover" "css_element" should exist
And I log out
And I follow "Log in"
Then ".btn-footer-popover" "css_element" should exist

0 comments on commit 8d3ed05

Please sign in to comment.