diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be44c41..a36b3b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,8 @@ jobs: env: MYSQL_USER: 'root' MYSQL_ALLOW_EMPTY_PASSWORD: "true" + MYSQL_CHARACTER_SET_SERVER: "utf8mb4" + MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" ports: - 3306:3306 options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 @@ -19,16 +21,9 @@ jobs: strategy: fail-fast: false matrix: - include: - - php: 7.4 - moodle-branch: 'MOODLE_401_STABLE' - database: mariadb - - php: 8.0 - # The following line is only needed if you're going to run php8 jobs and your - # plugin needs xmlrpc services. - extensions: xmlrpc-beta - moodle-branch: 'MOODLE_401_STABLE' - database: mariadb + php: ['8.0', '8.1'] + moodle-branch: ['MOODLE_402_STABLE'] + database: [mariadb] steps: - name: Check out repository code @@ -46,7 +41,7 @@ jobs: - name: Initialise moodle-plugin-ci run: | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 echo $(cd ci/bin; pwd) >> $GITHUB_PATH echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH sudo locale-gen en_AU.UTF-8 diff --git a/CONTRIBUTING.txt b/CONTRIBUTING.txt deleted file mode 100644 index c2742ed..0000000 --- a/CONTRIBUTING.txt +++ /dev/null @@ -1,28 +0,0 @@ -Contributing to Adaptable -========================= - -Adaptable is open to your contributions. Feel free to fork it. - -You can contribute to Adaptable in several ways: fixing bugs, adding new features or translating the theme to your language. - -To approve and merge your Pull Request (PR) for bugs and improvements you must follow this requirements: - -Open an issue first and link it to the PR - -ALL the code must follow the Moodle code guideline (https://docs.moodle.org/dev/Coding_style) and pass Moodle Code Checker -without errors or warnings. This is mandatory to approve the PR. - -Add your code attribution as a single line comment before the code modified. - -Comment your code as much as you can. This will help other developers to understand your code and will help also in -the approval. - -Use space instead tab for indentation. Tab is not allowed. Use four spaces for indentation. - -Use only the default Bootstrap 2 media queries are: 1200px, 979px, 767px and 480px. Other values are not valid - -The PR must include only the issue related. If you want to submit a PR with several fixes then you must create an issue for -each one and submit a different PR for each one. - -Add the needed strings ONLY in English (British). DO NOT translate to other languages. The strings added will be translated -later to the rest of languages available by the translators. - - -If you want to submit a translation file then follow these rules: - -Follow the Moodle Coding Style (https://docs.moodle.org/dev/Coding_style) - -Use Unicode and UNIX format for files (Windows format is not allowed) - -Or you can use Moodle AMOS to add your translation. Note that translations submitted through AMOS are not official and will not -recognized as an Adaptable translation because we can't verify it. diff --git a/Changes.md b/Changes.md index 7737c8f..92b2867 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,43 @@ +Change Log in version 402.0.1 (2023092500) +=========================================== +1. Removed social wall format (https://moodle.org/plugins/format_socialwall/versions) as last known version was for Moodle 3.3. +2. Add theme version of FontAwesome 6.4.2 from Foundation theme. +3. Fix 'Dragging a block results in an unknown block region error'. +4. Fix bars icon on navbar. +5. Improved alert dismissal functionality. The alert key only needs to change when the content does not. +6. Corrected alert information that incorrectly stated that it was possible to restrict alerts to the front page. +7. Move the 'Alerts', 'Category Headers', 'Login', 'My courses', 'News ticker', 'Tools menu', 'Tracking' and 'User profile' + functionality to a separate 'Local Adaptable' plugin that will be available to sponsors only. This has been an + extremely difficult decision to make, however with the continued lack of support I consider that I have been + left with no choice and thus have targetted functionality unlikely to be used by small installations. + +Change Log in version 401.1.7 (2022112308) +=========================================== +1. Add 'courseactivitynavigationenabled' setting in 'Courses' tab (changed from 'Course Formats') to turn on / off activity + navigation. Disabled by default. +2. Fix "Spelling mistakes in 'theme_adaptable | responsivesectionnav'" - #14. +3. Fix 'Front Page Course Limited to 20' - ref: https://moodle.org/mod/forum/discuss.php?d=450609. +4. Fix 'Option to default right drawer to open for guests' - #16. +5. Removed social wall format (https://moodle.org/plugins/format_socialwall/versions) as last known version was for Moodle 3.3. +6. Add theme version of FontAwesome 6.4.2 from Foundation theme. +7. Fix 'Dragging a block results in an unknown block region error'. +8. Fix 'Grader report headings not sticky' - ref: https://moodle.org/mod/forum/discuss.php?d=451315S. + +Change Log in version 401.1.6 (2022112307) +=========================================== +1. Fix as much as possible URL's in strings - ref: https://moodle.org/mod/forum/discuss.php?d=446353. +2. Fix long student names in the grade book - ref: https://moodle.org/mod/forum/discuss.php?d=447234. +3. Fix 'Sidebars cannot be closed with sticky navbar' - ref: https://github.com/gjb2048/moodle-theme_adaptable/issues/8. +4. Fix 'columns1 layout issue' - ref: https://moodle.org/mod/forum/discuss.php?d=446487#p1800161. +5. Fix 'Block marketing - images' - #12. +6. Fix 'Missing content region on dashboard'. +7. Add link in the navbar to the 'My courses' page, with setting 'enablemycourses', not to be confused with the 'My courses' menu 'enablemysites'. +8. Fix margin on 'Course overview' block has header buttons not lining up, fix is good but may impact on other unknown elements as removed style is too global in effect. +9. Put back activity navigation. +10. Add new setting 'slidervisible' to state when the slider should be shown, being one of 'Logged out', 'Logged in' or 'Logged in or out'. +11. Re-fix use of $CFG->themedir for when it exists but Adaptable is still in the basedir - #273. +12. Fix header search area too large. + Change Log in version 401.1.5 (2022112306) =========================================== 1. Fix zoom after header move in markup. diff --git a/DidntReadme.md b/DidntReadme.md deleted file mode 100644 index 9000a02..0000000 --- a/DidntReadme.md +++ /dev/null @@ -1 +0,0 @@ -Please see [Readme.md](./Readme.md) \ No newline at end of file diff --git a/Readme.md b/Readme.md index 1694591..63ed306 100644 --- a/Readme.md +++ b/Readme.md @@ -50,11 +50,10 @@ This theme has been developed by the following: Required release of Moodle ========================== -This release works with Moodle 4.1 version 2022112800.00 (Build: 20221128) and above within the MOODLE_401_STABLE branch until the +This version works with Moodle 4.2 version 2023042400.00 (Build: 20230424) and above within the MOODLE_402_STABLE branch until the next release. -Please ensure that your hardware and software complies with 'Requirements' in 'Installing Moodle' on -'https://docs.moodle.org/401/en/Installing_Moodle'. +Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/402/en/Installing_Moodle)'. Installation ============ @@ -131,13 +130,6 @@ Translation: - Germán Valero (Español - México) - Jordi Rodilla (Català - Andorra) - -Contributions -============= -You are welcome to collaborate in the project. You can fix bugs, add new features or help in the translation to your language. -See CONTRIBUTING.txt for more information - - Licenses ======== Adaptable is licensed under: diff --git a/Support.md b/Support.md index 2abf044..164e66a 100644 --- a/Support.md +++ b/Support.md @@ -10,8 +10,8 @@ If you would like to sponsor me, get support or fund improvements, then please d - gMail eMail | gjbarnard at gMail dt com. - My website eMail | contact at gjbarnard dt co dt uk. -- GitLab | Please outline your issue / improvement on '[Adaptable issues](https://gitlab.com/jezhops/moodle-theme_adaptable/-/issues)'. -- @gjbarnard | '[Twitter](https://twitter.com/gjbarnard)'. +- GitHub | Please outline your issue / improvement on '[Adaptable issues](https://github.com/gjbarnard/moodle-theme_adaptable/issues'. +- @gjbarnard | [X](https://x.com/gjbarnard). Bespoke work ------------ @@ -29,7 +29,7 @@ below). Otherwise, the Moodle '[Themes](https://moodle.org/mod/forum/view.php?i Adaptable can be obtained from: * [Moodle.org](https://moodle.org/plugins/theme_adaptable). -* [GitLab](https://gitlab.com/jezhops/moodle-theme_adaptable/-/releases). +* [GitHub](https://github.com/gjbarnard/moodle-theme_adaptable/releases). You have all the rights granted to you by the GPLv3 license. If you are unsure about anything, then the FAQ - [GPL FAQ](https://www.gnu.org/licenses/gpl-faq.html) - is a good place to look. @@ -37,15 +37,15 @@ FAQ - [GPL FAQ](https://www.gnu.org/licenses/gpl-faq.html) - is a good place to If you reuse any of the code then I kindly ask that you make reference to the theme. If you make improvements or bug fixes then I would appreciate if you would send them back to me by forking from -[GitLab](https://gitlab.com/jezhops/moodle-theme_adaptable) and doing a 'Pull Request' so that the rest of the Moodle community +[GitHub](https://github.com/gjbarnard/moodle-theme_adaptable/) and doing a 'Pull Request' so that the rest of the Moodle community benefits. Required version of Moodle ========================== -This version works with Moodle 4.1 version 2022112800.00 (Build: 20221128) and above within the MOODLE_401_STABLE branch until the +This version works with Moodle 4.2 version 2023042400.00 (Build: 20230424) and above within the MOODLE_402_STABLE branch until the next release. -Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/401/en/Installing_Moodle)'. +Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/402/en/Installing_Moodle)'. Known issues ================ @@ -58,7 +58,7 @@ the major release of Moodle you are using. It is essential that you are operati this is because the theme relies on core functionality that is out of its control. If you think you've discovered a genuine bug with the theme then please look at the Moodle Themes forum first to see if it -has already been repoted. Secondly, look at [GitLab](https://gitlab.com/jezhops/moodle-theme_adaptable/-/issues). +has already been repoted. Secondly, look at [GitHub](https://github.com/gjbarnard/moodle-theme_adaptable/issues). I operate a policy that I will fix all genuine issues in 'my' (not other developers of the theme) code, when fully described and replicatable. @@ -68,12 +68,12 @@ version.php file / or the top of the 'Information' settings tab. Other version theme name and version also helps. A screen shot can be really useful in visualising the issue along with any files you consider to be relevant. -You can use either the '[Themes forum](https://moodle.org/mod/forum/view.php?id=46)' or '[GitLab](https://gitlab.com/jezhops/moodle-theme_adaptable/-/issues)'. +You can use either the '[Themes forum](https://moodle.org/mod/forum/view.php?id=46)' or '[GitHub](https://github.com/gjbarnard/moodle-theme_adaptable/issues)'. Currently developed and maintained by ===================================== G J Barnard MSc. BSc(Hons)(Sndw). MBCS. CEng. CITP. PGCE. - Moodle profile | [Moodle.org](http://moodle.org/user/profile.php?id=442195) -- @gjbarnard | [Twitter](https://twitter.com/gjbarnard). -- Web profile | [About.me](http://about.me/gjbarnard) +- @gjbarnard | [X](https://twitter.com/gjbarnard). +- Web profile | [gjbarnard.co.uk](https://gjbarnard.co.uk) diff --git a/amd/build/adaptable.min.js b/amd/build/adaptable.min.js index 513d3f5..c4a3a88 100644 --- a/amd/build/adaptable.min.js +++ b/amd/build/adaptable.min.js @@ -1,4 +1,4 @@ // @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. -define("theme_adaptable/adaptable",["jquery","core/log"],(function($,log){return log.debug("Adaptable AMD"),{init:function(){$(document).ready((function($){log.debug("Adaptable AMD init"),$(".close").click((function(){var alertindex=$(this).data("alertindex"),alertkey=$(this).data("alertkey");"undismissable"!=alertkey&&"undefined"!=alertkey&&alertkey&&M.util.set_user_preference("theme_adaptable_alertkey"+alertindex,alertkey)})),$(".breadcrumb li:not(:last-child) span").not(".separator").addClass(""),$(".breadcrumb li:last-child").addClass("lastli");try{$('.context-header-settings-menu .dropdown-menu .dropdown-item a[href*="edit"], #editingbutton a').click((function(event){event.preventDefault();var to=$(window).scrollTop();sessionStorage.setItem("scrollTo",to);var url=$(this).prop("href");return window.location.replace(url),!1}));var scrollTo=sessionStorage.getItem("scrollTo");null!==scrollTo&&(window.scrollTo(0,scrollTo),sessionStorage.removeItem("scrollTo"))}catch(e){log.debug("Adaptable: Session storage exception: "+e.name)}var bttOn;bttOn=!($(window).scrollTop()>50);var scrollCheck=function(){$(window).scrollTop()>50?0==bttOn&&(bttOn=!0,$("#back-to-top").fadeIn(500)):1==bttOn&&(bttOn=!1,$("#back-to-top").fadeOut(500))};if(scrollCheck(),$(window).scroll((function(){scrollCheck()})),$("#back-to-top").click((function(event){return event.preventDefault(),$("html, body").animate({scrollTop:0},500),!1})),window.location.hash&&$("body").hasClass("pagelayout-course")){var anchorTop=$(window.location.hash).offset().top;$("html, body").animate({scrollTop:anchorTop-102},500)}}))}}})); +define("theme_adaptable/adaptable",["jquery","core/log"],(function($,log){return log.debug("Adaptable AMD"),{init:function(){$(document).ready((function($){log.debug("Adaptable AMD init"),$(".breadcrumb li:not(:last-child) span").not(".separator").addClass(""),$(".breadcrumb li:last-child").addClass("lastli");try{$('.context-header-settings-menu .dropdown-menu .dropdown-item a[href*="edit"], #editingbutton a').click((function(event){event.preventDefault();var to=$(window).scrollTop();sessionStorage.setItem("scrollTo",to);var url=$(this).prop("href");return window.location.replace(url),!1}));var scrollTo=sessionStorage.getItem("scrollTo");null!==scrollTo&&(window.scrollTo(0,scrollTo),sessionStorage.removeItem("scrollTo"))}catch(e){log.debug("Adaptable: Session storage exception: "+e.name)}var bttOn;bttOn=!($(window).scrollTop()>50);var scrollCheck=function(){$(window).scrollTop()>50?0==bttOn&&(bttOn=!0,$("#back-to-top").fadeIn(500)):1==bttOn&&(bttOn=!1,$("#back-to-top").fadeOut(500))};if(scrollCheck(),$(window).scroll((function(){scrollCheck()})),$("#back-to-top").click((function(event){return event.preventDefault(),$("html, body").animate({scrollTop:0},500),!1})),window.location.hash&&$("body").hasClass("pagelayout-course")){var anchorTop=$(window.location.hash).offset().top;$("html, body").animate({scrollTop:anchorTop-102},500)}}))}}})); //# sourceMappingURL=adaptable.min.js.map \ No newline at end of file diff --git a/amd/build/bsoptions.min.js b/amd/build/bsoptions.min.js index 9222c27..aff584a 100644 --- a/amd/build/bsoptions.min.js +++ b/amd/build/bsoptions.min.js @@ -1,3 +1,3 @@ -define("theme_adaptable/bsoptions",["jquery","core/log"],(function($,log){return log.debug("Adaptable Bootstrap AMD opt in functions"),{init:function(data){if($(document).ready((function($){var body=$("body"),navbar=document.getElementById("main-navbar");if(data.stickynavbar&&null!==navbar){const screenmd=992,screensm=768;var currentWindowSize,windowWidth=$(window).width();currentWindowSize=windowWidth0&&void 0!==arguments[0]&&arguments[0];if(pageScrollTop=page.scrollTop,windowWidth=aboveHeaderHeight)return;pageScrollTop=aboveHeaderHeight,newHeaderTop=0,newPageMarginTop=0}else{if(!update&¤tPageScrollTop==headerNoNavbar&&pageScrollTop>=headerNoNavbar)return;update&&(headerHeight=header.getBoundingClientRect().height,navbarHeight=navbar.getBoundingClientRect().height,headerNoNavbar=headerHeight-navbarHeight),pageScrollTop>headerNoNavbar&&(pageScrollTop=headerNoNavbar),newHeaderTop=-pageScrollTop,newPageMarginTop=headerHeight-pageScrollTop}if(currentPageScrollTop=pageScrollTop,(update||newHeaderTop!=headerTop)&&(header.style.top=newHeaderTop+"px",headerTop=newHeaderTop),(update||newPageMarginTop!=pageMarginTop)&&(page.style.marginTop=newPageMarginTop+"px",pageMarginTop=newPageMarginTop),(courseIndex||sidePost)&&(newDrawerPaddingTop=windowWidth0&&void 0!==arguments[0]&&arguments[0];if(pageScrollTop=page.scrollTop,windowWidth=aboveHeaderHeight)return;pageScrollTop=aboveHeaderHeight,newHeaderTop=0,newPageMarginTop=0}else{if(!update&¤tPageScrollTop==headerNoNavbar&&pageScrollTop>=headerNoNavbar)return;update&&(headerHeight=header.getBoundingClientRect().height,null!==navbar&&(navbarHeight=navbar.getBoundingClientRect().height),headerNoNavbar=headerHeight-navbarHeight),pageScrollTop>headerNoNavbar&&(pageScrollTop=headerNoNavbar),newHeaderTop=-pageScrollTop,newPageMarginTop=headerHeight-pageScrollTop}if(currentPageScrollTop=pageScrollTop,(update||newHeaderTop!=headerTop)&&(header.style.top=newHeaderTop+"px",headerTop=newHeaderTop),(update||newPageMarginTop!=pageMarginTop)&&(page.style.marginTop=newPageMarginTop+"px",pageMarginTop=newPageMarginTop),(courseIndex||sidePost)&&(newDrawerPaddingTop=windowWidth. +// +// +// Adaptable Bootstrap opt in functions JS file +// +// @package theme_adaptable +// @copyright 2015-2019 Jeremy Hopkins (Coventry University) +// @copyright 2015-2019 Fernando Acedo (3-bits.com) +// @copyright 2018-2019 Manoj Solanki (Coventry University) +// @copyright 2019 G J Barnard +// {@link https://moodle.org/user/profile.php?id=442195} +// {@link https://gjbarnard.co.uk} +// @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. + /* jshint ignore:start */ define(['jquery', 'core/log'], function($, log) { "use strict"; // ...jshint ;_; !!! @@ -12,7 +40,7 @@ define(['jquery', 'core/log'], function($, log) { // Get the navbar, if present. var navbar = document.getElementById("main-navbar"); - if (data.stickynavbar && navbar !== null) { + if (data.stickynavbar) { /* New way to handle sticky navbar requirement. Simply taken from https://www.w3schools.com/howto/howto_js_navbar_sticky.asp. */ @@ -48,7 +76,10 @@ define(['jquery', 'core/log'], function($, log) { var currentPageScrollTop = pageScrollTop; var headerHeight = 0; var headerNoNavbar = 0; - var navbarHeight = navbar.getBoundingClientRect().height; + var navbarHeight = 0; + if (navbar !== null) { + navbarHeight = navbar.getBoundingClientRect().height; + } var aboveHeaderHeight = aboveHeader.getBoundingClientRect().height; var drawerPaddingTop = 0; @@ -129,7 +160,9 @@ define(['jquery', 'core/log'], function($, log) { if (update) { // Just changed from <= screenmd. headerHeight = header.getBoundingClientRect().height; - navbarHeight = navbar.getBoundingClientRect().height; + if (navbar !== null) { + navbarHeight = navbar.getBoundingClientRect().height; + } // Else will never change from 0 at init! headerNoNavbar = headerHeight - navbarHeight; } if (pageScrollTop > headerNoNavbar) { diff --git a/amd/src/icon_system_fontawesome.js b/amd/src/icon_system_fontawesome.js new file mode 100644 index 0000000..37a7549 --- /dev/null +++ b/amd/src/icon_system_fontawesome.js @@ -0,0 +1,125 @@ +// 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 . + +/** + * Adaptable theme. + * + * @module theme_adaptable/icon_system_fontawesome + * @copyright 2023 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. + */ + +define(['core/icon_system', 'jquery', 'core/ajax', 'core/mustache', 'core/localstorage', 'core/url'], +function(IconSystem, $, Ajax, Mustache, LocalStorage, Url) { + + var staticMap = null; + var fetchMap = null; + + /** + * IconSystemFontawesome + */ + var IconSystemFontawesome = function() { + IconSystem.apply(this, arguments); + }; + IconSystemFontawesome.prototype = Object.create(IconSystem.prototype); + + /** + * Prefetch resources so later calls to renderIcon can be resolved synchronously. + * + * @method init + * @return {Promise} + */ + IconSystemFontawesome.prototype.init = function() { + if (staticMap) { + return $.when(this); + } + + var map = LocalStorage.get('theme_adaptable/iconmap-fontawesome'); + if (map) { + map = JSON.parse(map); + } + + if (map) { + staticMap = map; + return $.when(this); + } + + if (fetchMap === null) { + fetchMap = Ajax.call([{ + methodname: 'theme_adaptable_output_load_fontawesome_icon_map', + args: [] + }], true, false)[0]; + } + + return fetchMap.then(function(map) { + staticMap = {}; + $.each(map, function(index, value) { + staticMap[value.component + '/' + value.pix] = value.to; + }); + LocalStorage.set('theme_adaptable/iconmap-fontawesome', JSON.stringify(staticMap)); + return this; + }.bind(this)); + }; + + /** + * Render an icon. + * + * @param {String} key + * @param {String} component + * @param {String} title + * @param {String} template + * @return {String} + * @method renderIcon + */ + IconSystemFontawesome.prototype.renderIcon = function(key, component, title, template) { + var mappedIcon = staticMap[component + '/' + key]; + var unmappedIcon = false; + if (typeof mappedIcon === "undefined") { + var url = Url.imageUrl(key, component); + + unmappedIcon = { + attributes: [ + {name: 'src', value: url}, + {name: 'alt', value: title}, + {name: 'title', value: title} + ] + }; + } + + var context = { + key: mappedIcon, + title: title, + alt: title, + unmappedIcon: unmappedIcon + }; + + return Mustache.render(template, context); + }; + + /** + * Get the name of the template to pre-cache for this icon system. + * + * @return {String} + * @method getTemplateName + */ + IconSystemFontawesome.prototype.getTemplateName = function() { + return 'theme_adaptable/pix_icon_fontawesome'; + }; + + return IconSystemFontawesome; // @alias module:theme_adaptable/icon_system_fontawesome + +}); diff --git a/amd/src/savebutton.js b/amd/src/savebutton.js index cb0d813..064fd25 100644 --- a/amd/src/savebutton.js +++ b/amd/src/savebutton.js @@ -1,3 +1,31 @@ +// +// This file is part of Adaptable theme for moodle +// +// 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 . +// +// +// Adaptable save button JS file +// +// @package theme_adaptable +// @copyright 2015-2019 Jeremy Hopkins (Coventry University) +// @copyright 2015-2019 Fernando Acedo (3-bits.com) +// @copyright 2018-2019 Manoj Solanki (Coventry University) +// @copyright 2019 G J Barnard +// {@link https://moodle.org/user/profile.php?id=442195} +// {@link https://gjbarnard.co.uk} +// @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. + /* jshint ignore:start */ define(['jquery', 'core/log'], function($, log) { diff --git a/amd/src/templatepreview.js b/amd/src/templatepreview.js index 7def066..82168a3 100644 --- a/amd/src/templatepreview.js +++ b/amd/src/templatepreview.js @@ -1,3 +1,28 @@ +// +// This file is part of Adaptable theme for moodle +// +// 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 . +// +// +// Adaptable Template Preview JS file +// +// @package theme_adaptable +// @copyright 2020 G J Barnard +// {@link https://moodle.org/user/profile.php?id=442195} +// {@link https://gjbarnard.co.uk} +// @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. + /* jshint ignore:start */ define(['jquery', 'core/log'], function($, log) { diff --git a/amd/src/utils.js b/amd/src/utils.js index 75ba912..3a7dee1 100644 --- a/amd/src/utils.js +++ b/amd/src/utils.js @@ -1,3 +1,30 @@ +// +// This file is part of Adaptable theme for moodle +// +// 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 . +// +// +// Adaptable main JS file +// +// @package theme_adaptable +// @copyright 2015-2019 Jeremy Hopkins (Coventry University) +// @copyright 2018-2019 Manoj Solanki (Coventry University) +// @copyright 2019 G J Barnard +// {@link https://moodle.org/user/profile.php?id=442195} +// {@link https://gjbarnard.co.uk} +// @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. + /* jshint ignore:start */ define(["jquery", "core/log"], function($, log) { diff --git a/classes/admin_setting_markdown.php b/classes/admin_setting_markdown.php index 9bada66..e9a1164 100644 --- a/classes/admin_setting_markdown.php +++ b/classes/admin_setting_markdown.php @@ -17,21 +17,18 @@ /** * Adaptable theme. * @package theme_adaptable - * @copyright © 2021-onwards G J Barnard. - * @author G J Barnard - {@link http://moodle.org/user/profile.php?id=442195} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2021 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later, */ namespace theme_adaptable; /** * Setting that displays markdown files. Based on admin_setting_description in adminlib.php. - * - * @copyright © 2021-onwards G J Barnard. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class admin_setting_markdown extends \admin_setting { - /** @var string Filename */ private $filename; @@ -85,7 +82,7 @@ public function write_setting($data) { * @param string $query * @return string Returns an HTML string */ - public function output_html($data, $query='') { + public function output_html($data, $query = '') { global $CFG, $OUTPUT; $context = new \stdClass(); @@ -93,11 +90,11 @@ public function output_html($data, $query='') { $context->description = $this->description; if (file_exists("{$CFG->dirroot}/theme/adaptable/{$this->filename}")) { - $filecontents = file_get_contents($CFG->dirroot.'/theme/adaptable/'.$this->filename); + $filecontents = file_get_contents($CFG->dirroot . '/theme/adaptable/' . $this->filename); } else if (!empty($CFG->themedir) && file_exists("{$CFG->themedir}/adaptable/{$this->filename}")) { - $filecontents = file_get_contents($CFG->themedir.'/adaptable/'.$this->filename); + $filecontents = file_get_contents($CFG->themedir . '/adaptable/' . $this->filename); } else { - $filecontents = 'admin_setting_markdown -> file not found: '.$this->filename; + $filecontents = 'admin_setting_markdown -> file not found: ' . $this->filename; } $context->markdown = format_text($filecontents, FORMAT_MARKDOWN); diff --git a/classes/admin_settingspage.php b/classes/admin_settingspage.php new file mode 100644 index 0000000..25a865a --- /dev/null +++ b/classes/admin_settingspage.php @@ -0,0 +1,65 @@ +. + +/** + * @package theme_adaptable + * @copyright 2023 G J Barnard + * @author G J Barnard - + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Adaptable admin_settingpage + */ +class theme_adaptable_admin_settingspage extends admin_settingpage { + /** @var boolean disabled. */ + private $disabled = false; + + /** + * see admin_settingpage for details of this mathod. + * + * @param string $name The internal name for this external page. Must be unique am ongst ALL part_of_admin_tree objects. + * @param string $visiblename The displayed name for this external page. Usually obtained through get_string(). + * @param int $local If the settings on the page require local_adaptable. + * @param mixed $req_capability The role capability/permission a user must have to access this external page. Defaults to 'moodle/site:config'. + * @param boolean $hidden Is this external page hidden in admin tree block? Default false. + * @param stdClass $context The context the page relates to. + */ + public function __construct($name, $visiblename, $local = false, $reqcapability = 'moodle/site:config', + $hidden = false, $context = null) { + parent::__construct($name, $visiblename, $reqcapability, $hidden, $context); + if (($local) && (\theme_adaptable\toolbox::get_local_toolbox() === false)) { + $localadaptableheading = 'Sponsors only'; + $localadaptableheadingdesc = 'These settings and functionlity require the \'local_adaptable\' plugin'. + ', which is available to sponsors only. Please consider sponsoring, see the \'Information\' tab.'; + + $this->disabled = true; + $this->add(new admin_setting_heading( + 'theme_adaptable_sponsor'.$name, + $localadaptableheading, + format_text($localadaptableheadingdesc, FORMAT_MARKDOWN) + )); + } + } + + public function get_disabled() { + return $this->disabled; + } +} diff --git a/classes/admin_settingspage_tabs.php b/classes/admin_settingspage_tabs.php index aa05c8d..820e5e1 100644 --- a/classes/admin_settingspage_tabs.php +++ b/classes/admin_settingspage_tabs.php @@ -15,21 +15,20 @@ // along with Moodle. If not, see . /** - * @package theme_adaptable - * @copyright © 2020 G J Barnard. - * @author G J Barnard - {@link http://moodle.org/user/profile.php?id=442195} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package theme_adaptable + * @copyright 2020 G J Barnard + * @author G J Barnard - + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ defined('MOODLE_INTERNAL') || die(); /** - * @package theme_adaptable - * @copyright © 2020 G J Barnard. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * Admin settings page tabs. */ class theme_adaptable_admin_settingspage_tabs extends theme_boost_admin_settingspage_tabs { - /** @var int The branch this Adaptable is for. */ protected $mbranch; @@ -38,16 +37,14 @@ class theme_adaptable_admin_settingspage_tabs extends theme_boost_admin_settings * * @param string $name The internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects. * @param string $visiblename The displayed name for this external page. Usually obtained through get_string(). - * @param string $version The version info. * @param int $mbranch The branch this Adaptable is for. - * @param int $aversion Adaptable version. * @param mixed $req_capability The role capability/permission a user must have to access this external page. Defaults to 'moodle/site:config'. * @param boolean $hidden Is this external page hidden in admin tree block? Default false. * @param stdClass $context The context the page relates to. */ - public function __construct($name, $visiblename, $mbranch, $req_capability = 'moodle/site:config', $hidden = false, $context = NULL) { + public function __construct($name, $visiblename, $mbranch, $reqcapability = 'moodle/site:config', $hidden = false, $context = null) { $this->mbranch = $mbranch; - return parent::__construct($name, $visiblename, $req_capability, $hidden, $context); + return parent::__construct($name, $visiblename, $reqcapability, $hidden, $context); } /** @@ -59,7 +56,7 @@ public function output_html() { global $CFG, $OUTPUT; $activetab = optional_param('activetab', '', PARAM_TEXT); - $context = array('tabs' => array()); + $context = ['tabs' => []]; $havesetactive = false; foreach ($this->get_tabs() as $tab) { @@ -73,12 +70,17 @@ public function output_html() { $active = true; } - $context['tabs'][] = array( + $disabled = false; + if ($tab instanceof theme_adaptable_admin_settingspage) { + $disabled = $tab->get_disabled(); + } + $context['tabs'][] = [ 'name' => $tab->name, 'displayname' => $tab->visiblename, 'html' => $tab->output_html(), 'active' => $active, - ); + 'disabled' => $disabled, + ]; } if (empty($context['tabs'])) { @@ -93,12 +95,14 @@ public function output_html() { $plugininfo->version = $plugininfo->versiondisk; } - $context['versioninfo'] = get_string('versioninfo', 'theme_adaptable', - array( + $context['versioninfo'] = get_string( + 'versioninfo', + 'theme_adaptable', + [ 'moodle' => $CFG->release, 'release' => $plugininfo->release, - 'version' => $plugininfo->version - ) + 'version' => $plugininfo->version, + ] ); if (!empty($plugininfo->maturity)) { @@ -106,35 +110,34 @@ public function output_html() { case MATURITY_ALPHA: $context['maturity'] = get_string('versionalpha', 'theme_adaptable'); $context['maturityalert'] = 'danger'; - break; + break; case MATURITY_BETA: $context['maturity'] = get_string('versionbeta', 'theme_adaptable'); $context['maturityalert'] = 'danger'; - break; + break; case MATURITY_RC: $context['maturity'] = get_string('versionrc', 'theme_adaptable'); $context['maturityalert'] = 'warning'; - break; + break; case MATURITY_STABLE: $context['maturity'] = get_string('versionstable', 'theme_adaptable'); $context['maturityalert'] = 'info'; - break; + break; } } - $context['privacynote'] = format_text(get_string('privacynote', 'theme_adaptable'), FORMAT_MARKDOWN); + $context['privacynote'] = format_text(get_string('privacy:note', 'theme_adaptable'), FORMAT_MARKDOWN); if ($CFG->branch != $this->mbranch) { - $context['versioncheck'] = 'Release '.$plugininfo->release.', version '.$plugininfo->version.' is incompatible with Moodle '.$CFG->release; + $context['versioncheck'] = 'Release ' . $plugininfo->release . ', version ' . $plugininfo->version . ' is incompatible with Moodle ' . $CFG->release; $context['versioncheck'] .= ', please get the correct version from '; $context['versioncheck'] .= 'Moodle.org. '; $context['versioncheck'] .= 'If none is available, then please consider supporting the theme by funding it. '; $context['versioncheck'] .= 'Please contact me via \'gjbarnard at gmail dot com\' or my '; - $context['versioncheck'] .= 'Moodle dot org profile. '; - $context['versioncheck'] .= 'This is my \'Web profile\' if you want '; + $context['versioncheck'] .= 'Moodle dot org profile. '; + $context['versioncheck'] .= 'This is my \'Web profile\' if you want '; $context['versioncheck'] .= 'to know more about me.'; } return $OUTPUT->render_from_template('theme_adaptable/adaptable_admin_setting_tabs', $context); } - } diff --git a/classes/core_h5p_renderer.php b/classes/core_h5p_renderer.php index 6e5c2c0..7d1ba07 100644 --- a/classes/core_h5p_renderer.php +++ b/classes/core_h5p_renderer.php @@ -17,14 +17,16 @@ /** * Adaptable theme. * - * @package theme_adaptable - * @copyright 2023 Gareth J Barnard - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package theme_adaptable + * @copyright 2023 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ defined('MOODLE_INTERNAL') || die; global $CFG; -if (file_exists($CFG->dirroot.'/h5p/classes/output/renderer.php')) { +if (file_exists($CFG->dirroot . '/h5p/classes/output/renderer.php')) { if (method_exists(\core_h5p\output\renderer::class, 'h5p_alter_styles')) { /** * Class theme_adaptable_core_h5p_renderer. @@ -33,8 +35,8 @@ * https://github.com/sarjona/h5pmods-moodle-plugin. * * @package theme_adaptable - * @copyright 2023 Gareth J Barnard - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2023 G J Barnard + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class theme_adaptable_core_h5p_renderer extends \core_h5p\output\renderer { use \theme_adaptable\hvp_toolbox; diff --git a/classes/hvp_toolbox.php b/classes/hvp_toolbox.php index 55ad7a2..dc7c158 100644 --- a/classes/hvp_toolbox.php +++ b/classes/hvp_toolbox.php @@ -17,9 +17,11 @@ /** * Adaptable theme. * - * @package theme_adaptable - * @copyright 2023 Gareth J Barnard - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package theme_adaptable + * @copyright 2023 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ namespace theme_adaptable; @@ -28,10 +30,6 @@ * * See: https://tracker.moodle.org/browse/MDL-69087 and * https://github.com/sarjona/h5pmods-moodle-plugin. - * - * @package theme_adaptable - * @copyright 2023 Gareth J Barnard - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ trait hvp_toolbox { /** @@ -42,12 +40,12 @@ trait hvp_toolbox { * @param string $embedtype How the H5P is displayed. */ protected function ahvp_alter_styles(&$styles, $libraries, $embedtype) { - $content = theme_adaptable_get_setting('hvpcustomcss'); + $content = \theme_adaptable\toolbox::get_setting('hvpcustomcss'); if (!empty($content)) { - $styles[] = (object) array( + $styles[] = (object) [ 'path' => $this->get_style_url($content), - 'version' => '' - ); + 'version' => '', + ]; } } @@ -63,7 +61,9 @@ protected function get_style_url($content) { $syscontext = \context_system::instance(); $itemid = md5($content); - return \moodle_url::make_file_url("$CFG->wwwroot/pluginfile.php", - "/$syscontext->id/theme_adaptable/hvp/$itemid/themehvp.css"); + return \moodle_url::make_file_url( + "$CFG->wwwroot/pluginfile.php", + "/$syscontext->id/theme_adaptable/hvp/$itemid/themehvp.css" + ); } } diff --git a/classes/icon_system_fontawesome.php b/classes/icon_system_fontawesome.php new file mode 100644 index 0000000..db12d50 --- /dev/null +++ b/classes/icon_system_fontawesome.php @@ -0,0 +1,544 @@ +. + +/** + * Adaptable theme. + * + * @package theme_adaptable + * @copyright 2023 G J Barnard + * @author G J Barnard - + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. + */ +namespace theme_adaptable\output; + +/** + * Font Awesome icon system. + */ +class icon_system_fontawesome extends \core\output\icon_system_fontawesome { + /** + * @var array $map Cached map of Moodle icon names to Font Awesome icon names. + */ + private $map = []; + + /** + * @var int $fav Using FontAwesome from core or our version of 6 - 0 or 2 values. + */ + private $fav; + + /** + * Constructor + */ + protected function __construct() { + // Has to be this for the external AJAX calls that don't know what theme is set. + $this->fav = \theme_adaptable\toolbox::get_config_setting('fav'); + } + + /** + * Return the icon map. + * + * @return array the map. + */ + public function get_core_icon_map() { + if (empty($this->fav)) { + $map = parent::get_core_icon_map(); + $map['core:i/navigationitem'] = 'fa-compass'; // Core has 'fa-fw'! + return $map; + } + + return [ + 'core:book' => 'fas fa-book', + 'core:docs' => 'fas fa-info-circle', + 'core:help' => 'fas fa-question-circle text-info', + 'core:req' => 'fas fa-exclamation-circle text-danger', + 'core:a/add_file' => 'far fa-file', + 'core:a/create_folder' => 'far fa-folder', + 'core:a/download_all' => 'fas fa-download', + 'core:a/help' => 'fas fa-question-circle text-info', + 'core:a/logout' => 'fas fa-sign-out-alt', + 'core:a/refresh' => 'fas fa-sync', + 'core:a/search' => 'fas fa-search', + 'core:a/setting' => 'fas fa-cog', + 'core:a/view_icon_active' => 'fas fa-th', + 'core:a/view_list_active' => 'fas fa-list', + 'core:a/view_tree_active' => 'fas fa-folder', + 'core:b/bookmark-new' => 'fas fa-bookmark', + 'core:b/document-edit' => 'fas fa-pencil-alt', + 'core:b/document-new' => 'far fa-file', + 'core:b/document-properties' => 'fas fa-info', + 'core:b/edit-copy' => 'far fa-file', + 'core:b/edit-delete' => 'fas fa-trash', + 'core:e/abbr' => 'fas fa-comment', + 'core:e/absolute' => 'fas fa-crosshairs', + 'core:e/accessibility_checker' => 'fas fa-universal-access', + 'core:e/acronym' => 'fas fa-comment', + 'core:e/advance_hr' => 'fas fa-arrows-alt-h', + 'core:e/align_center' => 'fas fa-align-center', + 'core:e/align_left' => 'fas fa-align-left', + 'core:e/align_right' => 'fas fa-align-right', + 'core:e/anchor' => 'fas fa-link', + 'core:e/backward' => 'fas fa-undo', + 'core:e/bold' => 'fas fa-bold', + 'core:e/bullet_list' => 'fas fa-list-ul', + 'core:e/cancel' => 'fas fa-times', + 'core:e/cancel_solid_circle' => 'fas fa-times-circle', + 'core:e/cell_props' => 'fas fa-info', + 'core:e/cite' => 'fas fa-quote-right', + 'core:e/cleanup_messy_code' => 'fas fa-eraser', + 'core:e/clear_formatting' => 'fas fa-i-cursor', + 'core:e/copy' => 'fas fa-clone', + 'core:e/cut' => 'fas fa-cut', + 'core:e/decrease_indent' => 'fas fa-outdent', + 'core:e/delete_col' => 'fas fa-minus', + 'core:e/delete_row' => 'fas fa-minus', + 'core:e/delete' => 'fas fa-minus', + 'core:e/delete_table' => 'fas fa-minus', + 'core:e/document_properties' => 'fas fa-info', + 'core:e/emoticons' => 'far fa-smile', + 'core:e/find_replace' => 'fas fa-search-plus', + 'core:e/file-text' => 'fas fa-file-alt', + 'core:e/forward' => 'fas fa-arrow-right', + 'core:e/fullpage' => 'fas fa-expand-arrows-alt', + 'core:e/fullscreen' => 'fas fa-expand-arrows-alt', + 'core:e/help' => 'fas fa-question-circle', + 'core:e/increase_indent' => 'fas fa-indent', + 'core:e/insert_col_after' => 'fas fa-columns', + 'core:e/insert_col_before' => 'fas fa-columns', + 'core:e/insert_date' => 'fas fa-calendar-alt', + 'core:e/insert_edit_image' => 'fas fa-image', + 'core:e/insert_edit_link' => 'fas fa-link', + 'core:e/insert_edit_video' => 'fas fa-video', + 'core:e/insert_file' => 'fas fa-file', + 'core:e/insert_horizontal_ruler' => 'fas fa-arrows-alt-h', + 'core:e/insert_nonbreaking_space' => 'far fa-square', + 'core:e/insert_page_break' => 'fas fa-level-down-alt', + 'core:e/insert_row_after' => 'fas fa-plus', + 'core:e/insert_row_before' => 'fas fa-plus', + 'core:e/insert' => 'fas fa-plus', + 'core:e/insert_time' => 'far fa-clock', + 'core:e/italic' => 'fas fa-italic', + 'core:e/justify' => 'fas fa-align-justify', + 'core:e/layers_over' => 'fas fa-level-up-alt', + 'core:e/layers' => 'fas fa-window-restore', + 'core:e/layers_under' => 'fas fa-level-down-alt', + 'core:e/left_to_right' => 'fas fa-chevron-right', + 'core:e/manage_files' => 'far fa-copy', + 'core:e/math' => 'fas fa-calculator', + 'core:e/merge_cells' => 'fas fa-compress', + 'core:e/new_document' => 'far fa-file', + 'core:e/numbered_list' => 'fas fa-list-ol', + 'core:e/page_break' => 'fas fa-level-down-alt', + 'core:e/paste' => 'far fa-clipboard', + 'core:e/paste_text' => 'far fa-clipboard', + 'core:e/paste_word' => 'far fa-clipboard', + 'core:e/prevent_autolink' => 'fas fa-exclamation', + 'core:e/preview' => 'fas fa-search-plus', + 'core:e/print' => 'fas fa-print', + 'core:e/question' => 'fas fa-question', + 'core:e/redo' => 'fas fa-redo', + 'core:e/remove_link' => 'fas fa-unlink', + 'core:e/remove_page_break' => 'fas fa-times', + 'core:e/resize' => 'fas fa-expand', + 'core:e/restore_draft' => 'fas fa-undo', + 'core:e/restore_last_draft' => 'fas fa-undo', + 'core:e/right_to_left' => 'fas fa-chevron-left', + 'core:e/row_props' => 'fas fa-info', + 'core:e/save' => 'far fa-save', + 'core:e/screenreader_helper' => 'fas fa-braille', + 'core:e/search' => 'fas fa-search', + 'core:e/select_all' => 'fas fa-arrows-alt-h', + 'core:e/show_invisible_characters' => 'fas fa-eye-slash', + 'core:e/source_code' => 'fas fa-code', + 'core:e/special_character' => 'fas fa-pen-square', + 'core:e/spellcheck' => 'fas fa-check', + 'core:e/split_cells' => 'fas fa-columns', + 'core:e/strikethrough' => 'fas fa-strikethrough', + 'core:e/styleparagraph' => 'fas fa-font', + 'core:e/subscript' => 'fas fa-subscript', + 'core:e/superscript' => 'fas fa-superscript', + 'core:e/table_props' => 'fas fa-table', + 'core:e/table' => 'fas fa-table', + 'core:e/template' => 'fas fa-sticky-note', + 'core:e/text_color_picker' => 'fas fa-paint-brush', + 'core:e/text_color' => 'fas fa-paint-brush', + 'core:e/text_highlight_picker' => 'far fa-lightbulb', + 'core:e/text_highlight' => 'far fa-lightbulb', + 'core:e/tick' => 'fas fa-check', + 'core:e/toggle_blockquote' => 'fas fa-quote-left', + 'core:e/underline' => 'fas fa-underline', + 'core:e/undo' => 'fas fa-undo', + 'core:e/visual_aid' => 'fas fa-universal-access', + 'core:e/visual_blocks' => 'fas fa-audio-description', + 'theme:fp/add_file' => 'far fa-file', + 'theme:fp/alias' => 'fas fa-share', + 'theme:fp/alias_sm' => 'fas fa-share', + 'theme:fp/check' => 'fas fa-check', + 'theme:fp/create_folder' => 'far fa-folder', + 'theme:fp/cross' => 'fas fa-times', + 'theme:fp/download_all' => 'fas fa-download', + 'theme:fp/help' => 'fas fa-question-circle', + 'theme:fp/link' => 'fas fa-link', + 'theme:fp/link_sm' => 'fas fa-link', + 'theme:fp/logout' => 'fas fa-sign-out-alt', + 'theme:fp/path_folder' => 'fas fa-folder', + 'theme:fp/path_folder_rtl' => 'fas fa-folder', + 'theme:fp/refresh' => 'fas fa-sync', + 'theme:fp/search' => 'fas fa-search', + 'theme:fp/setting' => 'fas fa-cog', + 'theme:fp/view_icon_active' => 'fas fa-th', + 'theme:fp/view_list_active' => 'fas fa-list', + 'theme:fp/view_tree_active' => 'fas fa-folder', + 'core:i/addblock' => 'fas fa-plus-square', + 'core:i/assignroles' => 'fas fa-user-plus', + 'core:i/asterisk' => 'fas fa-asterisk', + 'core:i/backup' => 'fas fa-file-archive', + 'core:i/badge' => 'fas fa-shield-alt', + 'core:i/breadcrumbdivider' => 'fa-angle-right', + 'core:i/bullhorn' => 'fas fa-bullhorn', + 'core:i/calc' => 'fas fa-calculator', + 'core:i/calendar' => 'fas fa-calendar-alt', + 'core:i/calendareventdescription' => 'fas fa-align-left', + 'core:i/calendareventtime' => 'far fa-clock', + 'core:i/caution' => 'fas fa-exclamation text-warning', + 'core:i/checked' => 'fas fa-check', + 'core:i/checkedcircle' => 'fas fa-check-circle', + 'core:i/checkpermissions' => 'fas fa-unlock-alt', + 'core:i/cohort' => 'fas fa-users', + 'core:i/competencies' => 'far fa-check-square', + 'core:i/completion_self' => 'far fa-user', + 'core:i/categoryevent' => 'fas fa-cubes', + 'core:i/contentbank' => 'fas fa-paint-brush', + 'core:i/course' => 'fas fa-graduation-cap', + 'core:i/courseevent' => 'fas fa-university', + 'core:i/customfield' => 'far fa-hand-point-right', + 'core:i/dashboard' => 'fas fa-tachometer-alt', + 'core:i/db' => 'fas fa-database', + 'core:i/delete' => 'fas fa-trash', + 'core:i/down' => 'fas fa-arrow-down', + 'core:i/dragdrop' => 'fas fa-arrows-alt', + 'core:i/duration' => 'far fa-clock', + 'core:i/emojicategoryactivities' => 'far fa-futbol', + 'core:i/emojicategoryanimalsnature' => 'fas fa-leaf', + 'core:i/emojicategoryflags' => 'fas fa-flag', + 'core:i/emojicategoryfooddrink' => 'fas fa-utensils', + 'core:i/emojicategoryobjects' => 'far fa-lightbulb', + 'core:i/emojicategorypeoplebody' => 'fas fa-restroom', + 'core:i/emojicategoryrecent' => 'far fa-clock', + 'core:i/emojicategorysmileysemotion' => 'far fa-smile', + 'core:i/emojicategorysymbols' => 'fas fa-heart', + 'core:i/emojicategorytravelplaces' => 'fas fa-plane', + 'core:i/edit' => 'fas fa-pencil-alt', + 'core:i/email' => 'fas fa-envelope', + 'core:i/empty' => 'fa-fw', + 'core:i/enrolmentsuspended' => 'fas fa-pause', + 'core:i/enrolusers' => 'fas fa-user-plus', + 'core:i/excluded' => 'fas fa-circle-minus', + 'core:i/expired' => 'fas fa-exclamation text-warning', + 'core:i/export' => 'fas fa-download', + 'core:i/externallink' => 'fas fa-external-link', + 'core:i/files' => 'far fa-copy', + 'core:i/filter' => 'fas fa-filter', + 'core:i/flagged' => 'fas fa-flag', + 'core:i/folder' => 'fas fa-folder', + 'core:i/grade_correct' => 'fas fa-check text-success', + 'core:i/grade_incorrect' => 'fas fa-times text-danger', + 'core:i/grade_partiallycorrect' => 'fas fa-check-square', + 'core:i/grades' => 'fas fa-table', + 'core:i/grading' => 'fas fa-wand-magic-sparkles', + 'core:i/gradingnotifications' => 'far fa-bell', + 'core:i/groupevent' => 'fas fa-users', + 'core:i/groupn' => 'fas fa-user', + 'core:i/group' => 'fas fa-users', + 'core:i/groups' => 'fas fa-user-circle', + 'core:i/groupv' => 'far fa-user-circle', + 'core:i/home' => 'fas fa-home', + 'core:i/hide' => 'fas fa-eye', + 'core:i/hierarchylock' => 'fas fa-lock', + 'core:i/import' => 'fas fa-level-up-alt', + 'core:i/incorrect' => 'fas fa-exclamation', + 'core:i/info' => 'fas fa-info', + 'core:i/invalid' => 'fas fa-times text-danger', + 'core:i/item' => 'fas fa-circle', + 'core:i/language' => 'fas fa-language', + 'core:i/link' => 'fas fa-link', + 'core:i/loading' => 'fas fa-circle-notch fa-spin', + 'core:i/loading_small' => 'fas fa-circle-notch fa-spin', + 'core:i/location' => 'fas fa-map-marker-alt', + 'core:i/lock' => 'fas fa-lock', + 'core:i/log' => 'fas fa-list-alt', + 'core:i/mahara_host' => 'fas fa-id-badge', + 'core:i/manual_item' => 'far fa-square', + 'core:i/marked' => 'fas fa-circle', + 'core:i/marker' => 'far fa-circle', + 'core:i/mean' => 'fas fa-calculator', + 'core:i/menu' => 'fas fa-ellipsis-v', + 'core:i/menubars' => 'fas fa-bars', + 'core:i/messagecontentaudio' => 'fas fa-headphones', + 'core:i/messagecontentimage' => 'far fa-image', + 'core:i/messagecontentmultimediageneral' => 'fas fa-video', + 'core:i/messagecontentvideo' => 'fas fa-film', + 'core:i/mnethost' => 'fas fa-external-link-alt', + 'core:i/moodle_host' => 'fas fa-graduation-cap', + 'core:i/moremenu' => 'fas fa-ellipsis-h', + 'core:i/move_2d' => 'fas fa-arrows-alt', + 'core:i/muted' => 'fas fa-microphone-slash', + 'core:i/navigationitem' => 'far fa-compass', + 'core:i/ne_red_mark' => 'fas fa-times', + 'core:i/new' => 'fas fa-bolt', + 'core:i/news' => 'far fa-newspaper', + 'core:i/next' => 'fas fa-chevron-right', + 'core:i/nosubcat' => 'far fa-plus-square', + 'core:i/notifications' => 'fas fa-bell', + 'core:i/open' => 'fas fa-folder-open', + 'core:i/otherevent' => 'fas fa-calendar-days', + 'core:i/outcomes' => 'fas fa-tasks', + 'core:i/overriden_grade' => 'fas fa-pencil', + 'core:i/payment' => 'far fa-money-bill-alt', + 'core:i/permissionlock' => 'fas fa-lock', + 'core:i/permissions' => 'fas fa-pen-square', + 'core:i/persona_sign_in_black' => 'fas fa-male', + 'core:i/portfolio' => 'fas fa-id-badge', + 'core:i/preview' => 'fas fa-search-plus', + 'core:i/previous' => 'fas fa-chevron-left', + 'core:i/privatefiles' => 'far fa-file', + 'core:i/progressbar' => 'fas fa-spinner fa-spin', + 'core:i/publish' => 'fas fa-share', + 'core:i/questions' => 'fas fa-question', + 'core:i/reload' => 'fas fa-sync', + 'core:i/report' => 'fas fa-chart-area', + 'core:i/repository' => 'far fa-hdd', + 'core:i/restore' => 'fas fa-level-up-alt', + 'core:i/return' => 'fas fa-arrow-left', + 'core:i/risk_config' => 'fas fa-exclamation text-muted', + 'core:i/risk_managetrust' => 'fas fa-exclamation-triangle text-warning', + 'core:i/risk_personal' => 'fas fa-exclamation-circle text-info', + 'core:i/risk_spam' => 'fas fa-exclamation text-primary', + 'core:i/risk_xss' => 'fas fa-exclamation-triangle text-danger', + 'core:i/role' => 'fas fa-user-md', + 'core:i/rss' => 'fas fa-rss', + 'core:i/rsssitelogo' => 'fas fa-graduation-cap', + 'core:i/scales' => 'fas fa-balance-scale', + 'core:i/scheduled' => 'far fa-calendar-check', + 'core:i/search' => 'fas fa-search', + 'core:i/section' => 'far fa-folder-open', + 'core:i/sendmessage' => 'fas fa-paper-plane', + 'core:i/settings' => 'fas fa-cog', + 'core:i/show' => 'fas fa-eye-slash', + 'core:i/siteevent' => 'fas fa-globe', + 'core:i/star' => 'fas fa-star', + 'core:i/star-o' => 'far fa-star', + 'core:i/star-rating' => 'fas fa-star', + 'core:i/stats' => 'fas fa-chart-line', + 'core:i/switch' => 'fas fa-exchange-alt', + 'core:i/switchrole' => 'fas fa-user-secret', + 'core:i/trash' => 'fas fa-trash-alt', + 'core:i/twoway' => 'fas fa-arrows-alt-h', + 'core:i/unchecked' => 'far fa-square', + 'core:i/uncheckedcircle' => 'far fa-circle', + 'core:i/unflagged' => 'far fa-flag', + 'core:i/unlock' => 'fas fa-unlock', + 'core:i/up' => 'fas fa-arrow-up', + 'core:i/userevent' => 'fas fa-user', + 'core:i/upload' => 'fas fa-upload', + 'core:i/user' => 'fas fa-user', + 'core:i/users' => 'fas fa-users', + 'core:i/valid' => 'fas fa-check text-success', + 'core:i/warning' => 'fas fa-exclamation text-warning', + 'core:i/window_close' => 'fas fa-window-close', + 'core:i/withsubcat' => 'fas fa-plus-square', + 'core:m/USD' => 'fas fa-usd', + 'core:t/addcontact' => 'fas fa-address-card', + 'core:t/add' => 'fas fa-plus', + 'core:t/approve' => 'fas fa-thumbs-up', + 'core:t/assignroles' => 'fas fa-user-circle', + 'core:t/award' => 'fas fa-trophy', + 'core:t/backpack' => 'fas fa-shopping-bag', + 'core:t/backup' => 'fas fa-arrow-circle-down', + 'core:t/block' => 'fas fa-ban', + 'core:t/block_to_dock_rtl' => 'fas fa-chevron-right', + 'core:t/block_to_dock' => 'fas fa-chevron-left', + 'core:t/blocks_drawer_rtl' => 'fas fa-chevron-right', + 'core:t/blocks_drawer' => 'fas fa-chevron-left', + 'core:t/calc_off' => 'fas fa-calculator', // TODO: Change to better icon once we have stacked icon support or more icons. + 'core:t/calc' => 'fas fa-calculator', + 'core:t/check' => 'fas fa-check', + 'core:t/clipboard' => 'fas fa-clipboard', + 'core:t/cohort' => 'fas fa-users', + 'core:t/collapsed_empty_rtl' => 'far fa-plus-square', + 'core:t/collapsed_empty' => 'far fa-plus-square', + 'core:t/collapsed_rtl' => 'fas fa-plus-square', + 'core:t/collapsed' => 'fas fa-plus-square', + 'core:t/collapsedcaret' => 'fas fa-caret-right', + 'core:t/collapsedchevron' => 'fas fa-chevron-right', + 'core:t/collapsedchevron_rtl' => 'fas fa-chevron-left', + 'core:t/completion_complete' => 'fas fa-circle', + 'core:t/completion_fail' => 'fas fa-xmark', + 'core:t/completion_incomplete' => 'fas fa-circle-dot', + 'core:t/contextmenu' => 'fas fa-cog', + 'core:t/copy' => 'fas fa-copy', + 'core:t/delete' => 'fas fa-trash', + 'core:t/dockclose' => 'fas fa-window-close', + 'core:t/dock_to_block_rtl' => 'fas fa-chevron-right', + 'core:t/dock_to_block' => 'fas fa-chevron-left', + 'core:t/download' => 'fas fa-download', + 'core:t/down' => 'fas fa-arrow-down', + 'core:t/downlong' => 'fas fa-long-arrow-alt-down', + 'core:t/dropdown' => 'fas fa-cog', + 'core:t/editinline' => 'fas fa-pencil-alt', + 'core:t/edit_menu' => 'fas fa-cog', + 'core:t/editstring' => 'fas fa-pencil-alt', + 'core:t/edit' => 'fas fa-cog', + 'core:t/emailno' => 'fas fa-ban', + 'core:t/email' => 'far fa-envelope', + 'core:t/emptystar' => 'far fa-star', + 'core:t/enrolusers' => 'fas fa-user-plus', + 'core:t/expanded' => 'fas fa-caret-down', + 'core:t/expandedchevron' => 'fas fa-chevron-down', + 'core:t/go' => 'fas fa-play', + 'core:t/grades' => 'fas fa-table', + 'core:t/groupn' => 'fas fa-user', + 'core:t/groups' => 'fas fa-user-circle', + 'core:t/groupv' => 'far fa-user-circle', + 'core:t/hide' => 'fas fa-eye', + 'core:t/index_drawer' => 'fas fa-list', + 'core:t/left' => 'fas fa-arrow-left', + 'core:t/less' => 'fas fa-caret-up', + 'core:t/life-ring' => 'far fa-life-ring', + 'core:t/locked' => 'fas fa-lock', + 'core:t/lock' => 'fas fa-unlock', + 'core:t/locktime' => 'fas fa-lock', + 'core:t/markasread' => 'fas fa-check', + 'core:t/messages' => 'fas fa-comments', + 'core:t/message' => 'fas fa-comment', + 'core:t/more' => 'fas fa-caret-down', + 'core:t/move' => 'fas fa-arrows-alt-v', + 'core:t/online' => 'fas fa-circle', + 'core:t/passwordunmask-edit' => 'fas fa-pencil-alt', + 'core:t/passwordunmask-reveal' => 'fas fa-eye', + 'core:t/play' => 'fas fa-play', + 'core:t/portfolioadd' => 'fas fa-plus', + 'core:t/preferences' => 'fas fa-wrench', + 'core:t/preview' => 'fas fa-search-plus', + 'core:t/print' => 'fas fa-print', + 'core:t/removecontact' => 'fas fa-user-times', + 'core:t/reload' => 'fas fa-sync-alt', + 'core:t/reset' => 'fas fa-redo', + 'core:t/restore' => 'fas fa-arrow-circle-up', + 'core:t/right' => 'fas fa-arrow-right', + 'core:t/sendmessage' => 'fas fa-paper-plane', + 'core:t/show' => 'fas fa-eye-slash', + 'core:t/sort_by' => 'fas fa-sort-amount-down-alt', + 'core:t/sort_asc' => 'fas fa-sort-up', + 'core:t/sort_desc' => 'fas fa-sort-down', + 'core:t/sort' => 'fas fa-sort', + 'core:t/stealth' => 'fas fa-eye-low-vision', + 'core:t/stop' => 'fas fa-stop', + // Note: Does not work with blocks due to M.util.init_block_hider using M.util.image_url. See: MDL-58848. + 'core:t/switch_minus' => 'fas fa-minus', + 'core:t/switch_plus' => 'fas fa-plus', + 'core:t/switch_whole' => 'far fa-square', + 'core:t/tags' => 'fas fa-tags', + 'core:t/unblock' => 'fas fa-commenting-alt', + 'core:t/unlocked' => 'fas fa-unlock-alt', + 'core:t/unlock' => 'fas fa-lock', + 'core:t/up' => 'fas fa-arrow-up', + 'core:t/uplong' => 'fas fa-long-arrow-alt-up', + 'core:t/user' => 'fas fa-user', + 'core:t/viewdetails' => 'fas fa-list', + ]; + } + + /** + * Overridable function to get a mapping of all icons. + * Default is to do no mapping. + * + * @return array the map. + */ + public function get_icon_name_map() { + if (empty($this->fav)) { + return parent::get_icon_name_map(); + } else { + if ($this->map === []) { + $cache = \cache::make('theme_adaptable', 'adaptablefontawesomeiconmapping'); + + $this->map = $cache->get('mapping' . $this->fav); + $getmethod = 'get_fa6_from_fa4'; // Only v6 now. + + if (empty($this->map)) { + $this->map = $this->get_core_icon_map(); + $callback = 'get_fontawesome_icon_map'; + + if ($pluginsfunction = get_plugins_with_function($callback)) { + $toolbox = \theme_adaptable\toolbox::get_instance(); + foreach ($pluginsfunction as $plugintype => $plugins) { + foreach ($plugins as $pluginsubtype => $pluginfunction) { + $pluginmap = $pluginfunction(); + // Convert map from FA 4 to 6. + foreach ($pluginmap as $micon => $faicon) { + $pluginmap[$micon] = $toolbox->{$getmethod}($faicon, true); + } + $this->map += $pluginmap; + } + } + } + $cache->set('mapping' . $this->fav, $this->map); + } + } + } + + return $this->map; + } + + /** + * Get the AMD JS code name. + * + * @return string the name. + */ + public function get_amd_name() { + if (empty($this->fav)) { + return parent::get_amd_name(); + } + return 'theme_adaptable/icon_system_fontawesome'; + } + + /** + * Get the AMD JS code name. + * + * @param renderer_base $output The output object. + * @param pix_icon $icon The pix_icon object. + * + * @return string the rendered icon markup. + */ + public function render_pix_icon(\renderer_base $output, \pix_icon $icon) { + $subtype = '\pix_icon_fontawesome'; + $subpix = new $subtype($icon); + $data = $subpix->export_for_template($output); + + if (!$subpix->is_mapped()) { + $data['unmappedIcon'] = $icon->export_for_template($output); + } else if (empty($this->fav)) { + $data['key'] = 'fa ' . $data['key']; + } + + // MDL-62680. + if (isset($icon->attributes['aria-hidden'])) { + $data['aria-hidden'] = $icon->attributes['aria-hidden']; + } + + return $output->render_from_template('theme_adaptable/pix_icon_fontawesome', $data); + } +} diff --git a/classes/mod_hvp_renderer.php b/classes/mod_hvp_renderer.php index 3d17223..ab967f2 100644 --- a/classes/mod_hvp_renderer.php +++ b/classes/mod_hvp_renderer.php @@ -17,14 +17,16 @@ /** * Adaptable theme. * - * @package theme_adaptable - * @copyright 2023 Gareth J Barnard - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package theme_adaptable + * @copyright 2023 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ defined('MOODLE_INTERNAL') || die; global $CFG; -$h5prenderer = $CFG->dirroot.'/mod/hvp/renderer.php'; +$h5prenderer = $CFG->dirroot . '/mod/hvp/renderer.php'; if (file_exists($h5prenderer)) { // Be sure to include the H5P renderer so it can be extended. require_once($h5prenderer); @@ -33,8 +35,8 @@ * Class theme_adaptable_mod_hvp_renderer * * @package theme_adaptable - * @copyright 2023 Gareth J Barnard - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2023 G J Barnard + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class theme_adaptable_mod_hvp_renderer extends mod_hvp_renderer { use \theme_adaptable\hvp_toolbox; diff --git a/classes/output/core/course_renderer.php b/classes/output/core/course_renderer.php index ca2c3cd..483a5ff 100644 --- a/classes/output/core/course_renderer.php +++ b/classes/output/core/course_renderer.php @@ -18,28 +18,18 @@ * Version details * * @package theme_adaptable + * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @copyright 2015-2019 Jeremy Hopkins (Coventry University) * @copyright 2015-2019 Fernando Acedo (3-bits.com) * @copyright 2017-2019 Manoj Solanki (Coventry University) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * + * @copyright 2023 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ namespace theme_adaptable\output\core; -/****************************************************************************************** - * - * Overridden Core Course Renderer for Adaptable theme - * - * @package theme_adaptable - * @copyright 2015 Jeremy Hopkins (Coventry University) - * @copyright 2015 Fernando Acedo (3-bits.com) - * @copyright 2015 Moodlerooms Inc. (http://www.moodlerooms.com) (activity further information functionality) - * @copyright 2017 Manoj Solanki (Coventry University) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - */ - use html_writer; use moodle_url; use coursecat_helper; @@ -48,17 +38,11 @@ use stdClass; /** - * Course renderer implementation. - * - * @package theme_adaptable - * @copyright 2017 Manoj Solanki (Coventry University) - * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * Overridden Core Course Renderer for Adaptable theme. */ class course_renderer extends \core_course_renderer { - /** - * Render course tiles in the fron page + * Render course tiles in the front page * * @param coursecat_helper $chelper * @param string $course @@ -66,7 +50,7 @@ class course_renderer extends \core_course_renderer { * @return string */ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '') { - $type = theme_adaptable_get_setting('frontpagerenderer'); + $type = \theme_adaptable\toolbox::get_setting('frontpagerenderer'); if ($type == 3 || $this->output->body_id() != 'page-site-index') { return parent::coursecat_coursebox($chelper, $course, $additionalclasses = ''); } @@ -106,23 +90,31 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi $spanclass = $this->page->theme->settings->frontpagenumbertiles; // Display course tiles depending the number per row. - $content .= html_writer::start_tag('div', - array('class' => 'col-xs-12 col-sm-'.$spanclass.' panel panel-default coursebox '.$additionalcss)); + $content .= html_writer::start_tag( + 'div', + ['class' => 'col-xs-12 col-sm-' . $spanclass . ' panel panel-default coursebox ' . $additionalcss] + ); // Add the course name. $coursename = $chelper->get_course_formatted_name($course); if (($type == 1) || ($showcourses < self::COURSECAT_SHOW_COURSES_EXPANDED)) { - $content .= html_writer::start_tag('div', array('class' => 'panel-heading')); - $content .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), - $coursename, array('class' => $course->visible ? '' : 'dimmed', 'title' => $coursename)); + $content .= html_writer::start_tag('div', ['class' => 'panel-heading']); + $content .= html_writer::link( + new moodle_url('/course/view.php', ['id' => $course->id]), + $coursename, + ['class' => $course->visible ? '' : 'dimmed', 'title' => $coursename] + ); } // If we display course in collapsed form but the course has summary or course contacts, display the link to the info page. if ($showcourses < self::COURSECAT_SHOW_COURSES_EXPANDED) { - $arrow = html_writer::tag('span', '', array('class' => 'fa fp-chevron ml-1')); - $content .= html_writer::link('#coursecollapse' . $course->id , '' . $arrow, - array('class' => 'fpcombocollapse collapsed', 'data-toggle' => 'collapse', - 'data-parent' => '#frontpage-category-combo')); + $arrow = html_writer::tag('span', '', ['class' => 'fa fp-chevron ml-1']); + $content .= html_writer::link( + '#coursecollapse' . $course->id, + '' . $arrow, + ['class' => 'fpcombocollapse collapsed', 'data-toggle' => 'collapse', + 'data-parent' => '#frontpage-category-combo', ] + ); } if ($type == 1) { @@ -134,11 +126,11 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi } if ($showcourses < self::COURSECAT_SHOW_COURSES_EXPANDED) { - $content .= html_writer::start_tag('div', array('id' => 'coursecollapse' . $course->id, - 'class' => 'panel-collapse collapse')); + $content .= html_writer::start_tag('div', ['id' => 'coursecollapse' . $course->id, + 'class' => 'panel-collapse collapse', ]); } - $content .= html_writer::start_tag('div', array('class' => 'panel-body clearfix')); + $content .= html_writer::start_tag('div', ['class' => 'panel-body clearfix']); // This gets the course image or files. $content .= $this->coursecat_coursebox_content($chelper, $course, $type); @@ -148,13 +140,15 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi if ('ltr' === get_string('thisdirection', 'langconfig')) { $icondirection = 'right'; } - $arrow = html_writer::tag('span', '', array('class' => 'fa fa-chevron-'.$icondirection)); + $arrow = html_writer::tag('span', '', ['class' => 'fa fa-chevron-' . $icondirection]); $btn = html_writer::tag('span', get_string('course', 'theme_adaptable') . ' ' . - $arrow, array('class' => 'get_stringlink')); + $arrow, ['class' => 'get_stringlink']); if (($type != 4) || (empty($this->page->theme->settings->covhidebutton))) { - $content .= html_writer::link(new moodle_url('/course/view.php', - array('id' => $course->id)), $btn, array('class' => " coursebtn submit btn btn-info btn-sm")); + $content .= html_writer::link(new moodle_url( + '/course/view.php', + ['id' => $course->id] + ), $btn, ['class' => " coursebtn submit btn btn-info btn-sm"]); } } @@ -178,7 +172,7 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi protected function coursecat_coursebox_enrolmenticons($course) { $content = ''; if ($icons = enrol_get_course_info_icons($course)) { - $content .= html_writer::start_tag('div', array('class' => 'enrolmenticons')); + $content .= html_writer::start_tag('div', ['class' => 'enrolmenticons']); foreach ($icons as $pixicon) { $content .= $this->render($pixicon); } @@ -216,23 +210,26 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours $contentfiles = ''; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); - $url = file_encode_url("$CFG->wwwroot/pluginfile.php", - '/'. $file->get_contextid(). '/'. $file->get_component(). '/'. - $file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage); + $url = file_encode_url( + "$CFG->wwwroot/pluginfile.php", + '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . + $file->get_filearea() . $file->get_filepath() . $file->get_filename(), + !$isimage + ); if ($isimage) { if ($type == 1) { - $contentimages .= html_writer::start_tag('div', array('class' => 'courseimage')); - $link = new moodle_url('/course/view.php', array('id' => $course->id)); - $contentimages .= html_writer::link($link, html_writer::empty_tag('img', array('src' => $url))); + $contentimages .= html_writer::start_tag('div', ['class' => 'courseimage']); + $link = new moodle_url('/course/view.php', ['id' => $course->id]); + $contentimages .= html_writer::link($link, html_writer::empty_tag('img', ['src' => $url])); $contentimages .= html_writer::end_tag('div'); } else { - $cimboxattr = array( + $cimboxattr = [ 'class' => 'cimbox', - 'style' => 'background-image: url(\''.$url.'\');' - ); + 'style' => 'background-image: url(\'' . $url . '\');', + ]; if ($type == 4) { $cimtag = 'a'; - $cimboxattr['href'] = new moodle_url('/course/view.php', array('id' => $course->id)); + $cimboxattr['href'] = new moodle_url('/course/view.php', ['id' => $course->id]); } else { $cimtag = 'div'; } @@ -240,62 +237,70 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours } } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); - $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). - html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename')); - $contentfiles .= html_writer::tag('span', - html_writer::link($url, $filename), - array('class' => 'coursefile fp-filename-icon')); + $filename = html_writer::tag('span', $image, ['class' => 'fp-icon']) . + html_writer::tag('span', $file->get_filename(), ['class' => 'fp-filename']); + $contentfiles .= html_writer::tag( + 'span', + html_writer::link($url, $filename), + ['class' => 'coursefile fp-filename-icon'] + ); } } if (strlen($contentimages) == 0 && (($type == 2) || ($type == 4))) { // Default image. - $cimboxattr = array('class' => 'cimbox'); + $cimboxattr = ['class' => 'cimbox']; $url = $this->page->theme->setting_file_url('frontpagerendererdefaultimage', 'frontpagerendererdefaultimage'); if (!empty($url)) { - $cimboxattr['style'] = 'background-image: url(\''.$url.'\');'; + $cimboxattr['style'] = 'background-image: url(\'' . $url . '\');'; } if ($type == 2) { $cimtag = 'div'; } else { // Type is 4. - $cimboxattr['href'] = new moodle_url('/course/view.php', array('id' => $course->id)); + $cimboxattr['href'] = new moodle_url('/course/view.php', ['id' => $course->id]); $cimtag = 'a'; } $contentimages .= html_writer::tag($cimtag, '', $cimboxattr); } - $content .= $contentimages.$contentfiles; + $content .= $contentimages . $contentfiles; if (($type == 2) || ($type == 4)) { $content .= $this->coursecat_coursebox_enrolmenticons($course); - $content .= html_writer::start_tag('div', array( - 'class' => 'coursebox-content' - ) - ); + $content .= html_writer::start_tag('div', [ + 'class' => 'coursebox-content', + ]); $coursename = $chelper->get_course_formatted_name($course); - $content .= html_writer::start_tag('a', array('href' => new moodle_url('/course/view.php', array('id' => $course->id)))); - $content .= html_writer::tag('h3', $coursename, array('class' => $course->visible ? '' : 'dimmed')); + $content .= html_writer::start_tag('a', ['href' => new moodle_url('/course/view.php', ['id' => $course->id])]); + $content .= html_writer::tag('h3', $coursename, ['class' => $course->visible ? '' : 'dimmed']); $content .= html_writer::end_tag('a'); } - $content .= html_writer::start_tag('div', array('class' => 'summary')); + $content .= html_writer::start_tag('div', ['class' => 'summary']); // Display course summary. if ($course->has_summary()) { - $summs = $chelper->get_course_formatted_summary($course, array('overflowdiv' => false, 'noclean' => true, - 'para' => false)); + $summs = $chelper->get_course_formatted_summary($course, ['overflowdiv' => false, 'noclean' => true, + 'para' => false, ]); $summs = strip_tags($summs); $truncsum = mb_strimwidth($summs, 0, 70, "...", 'utf-8'); - $content .= html_writer::tag('span', $truncsum, array('title' => $summs)); + $content .= html_writer::tag('span', $truncsum, ['title' => $summs]); } - $coursecontacts = theme_adaptable_get_setting('tilesshowcontacts'); + $coursecontacts = \theme_adaptable\toolbox::get_setting('tilesshowcontacts'); if ($coursecontacts) { - $coursecontacttitle = theme_adaptable_get_setting('tilescontactstitle'); + $coursecontacttitle = \theme_adaptable\toolbox::get_setting('tilescontactstitle'); // Display course contacts. See ::get_course_contacts(). if ($course->has_course_contacts()) { - $content .= html_writer::start_tag('ul', array('class' => 'teachers')); + $content .= html_writer::start_tag('ul', ['class' => 'teachers']); foreach ($course->get_course_contacts() as $userid => $coursecontact) { - $cct = ($coursecontacttitle ? $coursecontact['rolename'].': ' : html_writer::tag('i', ' ', - array('class' => 'fa fa-graduation-cap'))); - $name = html_writer::link(new moodle_url('/user/view.php', - array('id' => $userid, 'course' => $course->id)), - $cct.$coursecontact['username']); + $cct = ($coursecontacttitle ? $coursecontact['rolename'] . ': ' : html_writer::tag( + 'i', + ' ', + ['class' => 'fa fa-graduation-cap'] + )); + $name = html_writer::link( + new moodle_url( + '/user/view.php', + ['id' => $userid, 'course' => $course->id] + ), + $cct . $coursecontact['username'] + ); $content .= html_writer::tag('li', $name); } $content .= html_writer::end_tag('ul'); // Teachers. @@ -305,12 +310,15 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours // Display course category if necessary (for example in search results). if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) { - require_once($CFG->libdir. '/coursecatlib.php'); + require_once($CFG->libdir . '/coursecatlib.php'); if ($cat = core_course_category::get($course->category, IGNORE_MISSING)) { - $content .= html_writer::start_tag('div', array('class' => 'coursecat')); - $content .= get_string('category').': '. - html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), - $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed')); + $content .= html_writer::start_tag('div', ['class' => 'coursecat']); + $content .= get_string('category') . ': ' . + html_writer::link( + new moodle_url('/course/index.php', ['categoryid' => $cat->id]), + $cat->get_formatted_name(), + ['class' => $cat->visible ? '' : 'dimmed'] + ); $content .= html_writer::end_tag('div'); // Coursecat. } } @@ -319,64 +327,11 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours // End coursebox-content. } - $content .= html_writer::tag('div', '', array('class' => 'boxfooter')); // Coursecat. + $content .= html_writer::tag('div', '', ['class' => 'boxfooter']); // Coursecat. return $content; } - /** - * Frontpage course list - * - * @return string - */ - public function frontpage_my_courses() { - global $CFG, $DB; - $output = ''; - if (!isloggedin() || isguestuser()) { - return ''; - } - // Calls a core renderer method (render_mycourses) to get list of a user's current courses that they are enrolled on. - $sortedcourses = $this->render_mycourses(); - - if (!empty($sortedcourses) || !empty($rcourses) || !empty($rhosts)) { - $chelper = new coursecat_helper(); - if (count($sortedcourses) > $CFG->frontpagecourselimit) { - // There are more enrolled courses than we can display, display link to 'My courses'. - $totalcount = count($sortedcourses); - $courses = array_slice($sortedcourses, 0, $CFG->frontpagecourselimit, true); - $chelper->set_courses_display_options(array( - 'viewmoreurl' => new moodle_url('/my/'), - 'viewmoretext' => new lang_string('mycourses') - )); - } else { - // All enrolled courses are displayed, display link to 'All courses' if there are more courses in system. - $chelper->set_courses_display_options(array( - 'viewmoreurl' => new moodle_url('/course/index.php'), - 'viewmoretext' => new lang_string('fulllistofcourses') - )); - $totalcount = $DB->count_records('course') - 1; - } - $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_attributes( - array('class' => 'frontpage-course-list-enrolled')); - $output .= $this->coursecat_courses($chelper, $sortedcourses, $totalcount); - - if (!empty($rcourses)) { - $output .= html_writer::start_tag('div', array('class' => 'courses')); - foreach ($rcourses as $course) { - $output .= $this->frontpage_remote_course($course); - } - $output .= html_writer::end_tag('div'); - } else if (!empty($rhosts)) { - $output .= html_writer::start_tag('div', array('class' => 'courses')); - foreach ($rhosts as $host) { - $output .= $this->frontpage_remote_host($host); - } - $output .= html_writer::end_tag('div'); - } - } - return $output; - } - // New methods added for activity styling below. Adapted from snap theme by Moodleroooms. /** * Renders the activity navigation. @@ -394,24 +349,30 @@ public function render_activity_navigation(\core_course\output\activity_navigati if (!empty($data->prevlink)) { $data->prevlink->classes = 'previous_activity prevnext'; // Override the button! - $icon = html_writer::tag('i', '', array('class' => 'fa fa-angle-double-left')); - $previouslink = html_writer::tag('span', $icon, array('class' => 'nav_icon')); - $activityname = html_writer::tag('span', get_string('previousactivity', 'theme_adaptable'), - array('class' => 'nav_guide')).'
'; + $icon = html_writer::tag('i', '', ['class' => 'fa fa-angle-double-left']); + $previouslink = html_writer::tag('span', $icon, ['class' => 'nav_icon']); + $activityname = html_writer::tag( + 'span', + get_string('previousactivity', 'theme_adaptable'), + ['class' => 'nav_guide'] + ) . '
'; $activityname .= substr($data->prevlink->text, strpos($data->prevlink->text, ' ') + 1); - $previouslink .= html_writer::tag('span', $activityname, array('class' => 'text')); + $previouslink .= html_writer::tag('span', $activityname, ['class' => 'text']); $data->prevlink->text = $previouslink; } if (!empty($data->nextlink)) { $data->nextlink->classes = 'next_activity prevnext'; // Override the button! - $activityname = html_writer::tag('span', get_string('nextactivity', 'theme_adaptable'), - array('class' => 'nav_guide')).'
'; + $activityname = html_writer::tag( + 'span', + get_string('nextactivity', 'theme_adaptable'), + ['class' => 'nav_guide'] + ) . '
'; $activityname .= substr($data->nextlink->text, 0, strrpos($data->nextlink->text, ' ')); - $nextlink = html_writer::tag('span', $activityname, array('class' => 'text')); - $icon = html_writer::tag('i', '', array('class' => 'fa fa-angle-double-right')); - $nextlink .= html_writer::tag('span', $icon, array('class' => 'nav_icon')); + $nextlink = html_writer::tag('span', $activityname, ['class' => 'text']); + $icon = html_writer::tag('i', '', ['class' => 'fa fa-angle-double-right']); + $nextlink .= html_writer::tag('span', $icon, ['class' => 'nav_icon']); $data->nextlink->text = $nextlink; } diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index ce2a4c1..4319055 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -21,8 +21,10 @@ * @copyright 2015-2019 Jeremy Hopkins (Coventry University) * @copyright 2015-2019 Fernando Acedo (3-bits.com) * @copyright 2017-2019 Manoj Solanki (Coventry University) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * + * @copyright 2021 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ namespace theme_adaptable\output; @@ -30,12 +32,7 @@ use theme_boost\output\core_renderer as core_renderer_base; /** - * Renderers to align Moodle's HTML with that expected by Bootstrap - * - * Note: This class is required to avoid inheriting Boost's core_renderer - * - * @copyright Copyright (c) 2017 Manoj Solanki (Coventry University) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * Core Renderer */ class core_renderer extends core_renderer_base { use core_renderer_toolbox; diff --git a/classes/output/core_renderer_maintenance.php b/classes/output/core_renderer_maintenance.php index 85c7c4c..7b407f9 100644 --- a/classes/output/core_renderer_maintenance.php +++ b/classes/output/core_renderer_maintenance.php @@ -21,17 +21,16 @@ * @copyright 2015-2019 Jeremy Hopkins (Coventry University) * @copyright 2015-2019 Fernando Acedo (3-bits.com) * @copyright 2017-2019 Manoj Solanki (Coventry University) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * + * @copyright 2021 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ namespace theme_adaptable\output; /** * The core maintenance renderer. - * - * @copyright © 2021-onwards G J Barnard. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class core_renderer_maintenance extends \core_renderer_maintenance { use core_renderer_toolbox; diff --git a/classes/output/core_renderer_toolbox.php b/classes/output/core_renderer_toolbox.php index 44d870f..f3f65be 100644 --- a/classes/output/core_renderer_toolbox.php +++ b/classes/output/core_renderer_toolbox.php @@ -21,8 +21,10 @@ * @copyright 2015-2019 Jeremy Hopkins (Coventry University) * @copyright 2015-2019 Fernando Acedo (3-bits.com) * @copyright 2017-2019 Manoj Solanki (Coventry University) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * + * @copyright 2021 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ namespace theme_adaptable\output; @@ -36,21 +38,8 @@ use navigation_node; use stdClass; -define('ADAPTABLE_COURSE_STARRED', 'starred'); -define('ADAPTABLE_COURSE_IN_PROGRESS', 'inprogress'); -define('ADAPTABLE_COURSE_PAST', 'past'); -define('ADAPTABLE_COURSE_FUTURE', 'future'); -define('ADAPTABLE_COURSE_HIDDEN', 'hidden'); - /** * Trait for core and core maintenance renderers. - * - * @copyright 2015 Jeremy Hopkins (Coventry University) - * @copyright 2015 Fernando Acedo (3-bits.com) - * @copyright 2021 Gareth J Barnard - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * Core renderer for Adaptable theme */ trait core_renderer_toolbox { /** @var custom_menu_item language The language menu if created */ @@ -63,7 +52,7 @@ trait core_renderer_toolbox { * @param string|array $additionalclasses Any additional classes to give the body tag, * @return string */ - public function body_attributes($additionalclasses = array()) { + public function body_attributes($additionalclasses = []) { if (\core_useragent::is_safari()) { if (is_array($additionalclasses)) { $additionalclasses[] = 'safari'; @@ -83,138 +72,13 @@ public function body_attributes($additionalclasses = array()) { * attributes to give the box. * @return string the HTML to output. */ - public function box_start($classes = 'generalbox', $id = null, $attributes = array()) { + public function box_start($classes = 'generalbox', $id = null, $attributes = []) { $this->opencontainers->push('box', html_writer::end_tag('div')); $attributes['id'] = $id; $attributes['class'] = 'box ' . \renderer_base::prepare_classes($classes); return html_writer::start_tag('div', $attributes); } - /** - * Return list of the user's courses - * - * @param string $overridetype The override type, if null because being called from the course renderer, - * then will be retrieved. - * - * @return array list of courses - */ - public function render_mycourses($overridetype = null) { - if ((empty($overridetype)) && (!empty($this->page->theme->settings->mysitessortoverride))) { - $overridetype = $this->page->theme->settings->mysitessortoverride; - } - - // Set limit of courses to show in dropdown from setting. - $coursedisplaylimit = '20'; - if (isset($this->page->theme->settings->mycoursesmenulimit)) { - $coursedisplaylimit = $this->page->theme->settings->mycoursesmenulimit; - } - - $courses = enrol_get_my_courses( - join(',', array_keys(\core_course\external\course_summary_exporter::define_properties())) - ); - - /* Add timeaccess and timestart to the courses for all override types to use in some shape or form. - Get the last accessed information for the user and populate. */ - global $DB, $USER; - $lastaccess = $DB->get_records('user_lastaccess', array('userid' => $USER->id), '', 'courseid, timeaccess'); - if ($lastaccess) { - foreach ($courses as $course) { - if (!empty($lastaccess[$course->id])) { - $course->timeaccess = $lastaccess[$course->id]->timeaccess; - } - } - } - // Determine if we need to query the enrolment and user enrolment tables. - $enrolquery = false; - foreach ($courses as $course) { - if (empty($course->timeaccess)) { - $enrolquery = true; - break; - } - } - if ($enrolquery) { - // We do. - $params = array('userid' => $USER->id); - $sql = "SELECT ue.id, e.courseid, ue.timestart - FROM {enrol} e - JOIN {user_enrolments} ue ON (ue.enrolid = e.id AND ue.userid = :userid)"; - $enrolments = $DB->get_records_sql($sql, $params, 0, 0); - if ($enrolments) { - // Sort out any multiple enrolments on the same course. - $userenrolments = array(); - foreach ($enrolments as $enrolment) { - if (!empty($userenrolments[$enrolment->courseid])) { - if ($userenrolments[$enrolment->courseid] < $enrolment->timestart) { - // Replace. - $userenrolments[$enrolment->courseid] = $enrolment->timestart; - } - } else { - $userenrolments[$enrolment->courseid] = $enrolment->timestart; - } - } - // We don't need to worry about timeend etc. as our course list will be valid for the user from above. - foreach ($courses as $course) { - if (empty($course->timeaccess)) { - $course->timestart = $userenrolments[$course->id]; - } - } - } - } - - if ($overridetype == 'last') { - uasort($courses, array($this, 'timeaccesscompare')); - } - - // Get courses in sort order into list. - if ($coursedisplaylimit != 0) { - $sortedcourses = array(); - $counter = 0; - foreach ($courses as $course) { - if ($counter >= $coursedisplaylimit) { - break; - } - $sortedcourses[] = $course; - $counter++; - } - } else { - $sortedcourses = $courses; - } - - return $sortedcourses; - } - - /** - * Returns settings as formatted text - * - * @param string $setting - * @param string $format = false - * @param string $theme = null - * @return string - */ - public function get_setting($setting, $format = false, $theme = null) { - static $themeconfig = null; - if (empty($theme)) { - if (empty($themeconfig)) { - $themeconfig = \theme_config::load('adaptable'); - } - $theme = $themeconfig; - } - - if (empty($theme->settings->$setting)) { - return false; - } else if (!$format) { - return $theme->settings->$setting; - } else if ($format === 'format_text') { - return format_text($theme->settings->$setting, FORMAT_PLAIN); - } else if ($format === 'format_moodle') { - return format_text($theme->settings->$setting, FORMAT_MOODLE); - } else if ($format === 'format_html') { - return format_text($theme->settings->$setting, FORMAT_HTML); - } else { - return format_string($theme->settings->$setting); - } - } - /** * Returns user profile menu */ @@ -227,54 +91,54 @@ public function user_profile_menu() { URL for link in third param. Link text in fourth parameter. Icon in fifth param. */ - $usermenuitems = array(); - $usermenuitems[] = array('enablemy', false, $CFG->wwwroot.'/my', get_string('myhome'), - \theme_adaptable\toolbox::getfontawesomemarkup('dashboard')); - $usermenuitems[] = array('enableprofile', false, $CFG->wwwroot.'/user/profile.php', get_string('viewprofile'), - \theme_adaptable\toolbox::getfontawesomemarkup('user')); - $usermenuitems[] = array('enableeditprofile', false, $CFG->wwwroot.'/user/edit.php', get_string('editmyprofile'), - \theme_adaptable\toolbox::getfontawesomemarkup('cog')); - $usermenuitems[] = array('enableaccesstool', false, $CFG->wwwroot.'/local/accessibilitytool/manage.php', - get_string('enableaccesstool', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('low-vision')); - $usermenuitems[] = array('enableprivatefiles', false, $CFG->wwwroot.'/user/files.php', - get_string('privatefiles', 'block_private_files'), \theme_adaptable\toolbox::getfontawesomemarkup('file')); + $usermenuitems = []; + $usermenuitems[] = ['enablemy', false, $CFG->wwwroot . '/my', get_string('myhome'), + \theme_adaptable\toolbox::getfontawesomemarkup('dashboard', ['mr-1']), ]; + $usermenuitems[] = ['enableprofile', false, $CFG->wwwroot . '/user/profile.php', get_string('viewprofile'), + \theme_adaptable\toolbox::getfontawesomemarkup('user', ['mr-1']), ]; + $usermenuitems[] = ['enableeditprofile', false, $CFG->wwwroot . '/user/edit.php', get_string('editmyprofile'), + \theme_adaptable\toolbox::getfontawesomemarkup('cog', ['mr-1']), ]; + $usermenuitems[] = ['enableaccesstool', false, $CFG->wwwroot . '/local/accessibilitytool/manage.php', + get_string('enableaccesstool', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('low-vision', ['mr-1']), ]; + $usermenuitems[] = ['enableprivatefiles', false, $CFG->wwwroot . '/user/files.php', + get_string('privatefiles', 'block_private_files'), \theme_adaptable\toolbox::getfontawesomemarkup('file', ['mr-1']), ]; if (\theme_adaptable\toolbox::kalturaplugininstalled()) { - $usermenuitems[] = array(false, false, $CFG->wwwroot.'/local/mymedia/mymedia.php', - get_string('nav_mymedia', 'local_mymedia'), $this->pix_icon('my-media', '', 'local_mymedia')); - } - $usermenuitems[] = array('enablegrades', false, $CFG->wwwroot.'/grade/report/overview/index.php', get_string('grades'), - \theme_adaptable\toolbox::getfontawesomemarkup('list-alt')); - $usermenuitems[] = array('enablebadges', false, $CFG->wwwroot.'/badges/mybadges.php', get_string('badges'), - \theme_adaptable\toolbox::getfontawesomemarkup('certificate')); - $usermenuitems[] = array('enablepref', '2015051100', $CFG->wwwroot.'/user/preferences.php', get_string('preferences'), - \theme_adaptable\toolbox::getfontawesomemarkup('cog')); - $usermenuitems[] = array('enablenote', false, $CFG->wwwroot.'/message/edit.php', get_string('notifications'), - \theme_adaptable\toolbox::getfontawesomemarkup('paper-plane')); - $usermenuitems[] = array('enableblog', false, $CFG->wwwroot.'/blog/index.php', get_string('enableblog', 'theme_adaptable'), - \theme_adaptable\toolbox::getfontawesomemarkup('rss')); - $usermenuitems[] = array('enableposts', false, $CFG->wwwroot.'/mod/forum/user.php', - get_string('enableposts', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('commenting')); - $usermenuitems[] = array('enablefeed', false, $CFG->wwwroot.'/report/myfeedback/index.php', - get_string('enablefeed', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('bullhorn')); - $usermenuitems[] = array('enablecalendar', false, $CFG->wwwroot.'/calendar/view.php', - get_string('pluginname', 'block_calendar_month'), \theme_adaptable\toolbox::getfontawesomemarkup('calendar')); + $usermenuitems[] = [false, false, $CFG->wwwroot . '/local/mymedia/mymedia.php', + get_string('nav_mymedia', 'local_mymedia'), $this->pix_icon('my-media', '', 'local_mymedia'), ]; + } + $usermenuitems[] = ['enablegrades', false, $CFG->wwwroot . '/grade/report/overview/index.php', get_string('grades'), + \theme_adaptable\toolbox::getfontawesomemarkup('list-alt', ['mr-1']), ]; + $usermenuitems[] = ['enablebadges', false, $CFG->wwwroot . '/badges/mybadges.php', get_string('badges'), + \theme_adaptable\toolbox::getfontawesomemarkup('certificate', ['mr-1']), ]; + $usermenuitems[] = ['enablepref', '2015051100', $CFG->wwwroot . '/user/preferences.php', get_string('preferences'), + \theme_adaptable\toolbox::getfontawesomemarkup('cog', ['mr-1']), ]; + $usermenuitems[] = ['enablenote', false, $CFG->wwwroot . '/message/edit.php', get_string('notifications'), + \theme_adaptable\toolbox::getfontawesomemarkup('paper-plane', ['mr-1']), ]; + $usermenuitems[] = ['enableblog', false, $CFG->wwwroot . '/blog/index.php', get_string('enableblog', 'theme_adaptable'), + \theme_adaptable\toolbox::getfontawesomemarkup('rss', ['mr-1']), ]; + $usermenuitems[] = ['enableposts', false, $CFG->wwwroot . '/mod/forum/user.php', + get_string('enableposts', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('commenting', ['mr-1']), ]; + $usermenuitems[] = ['enablefeed', false, $CFG->wwwroot . '/report/myfeedback/index.php', + get_string('enablefeed', 'theme_adaptable'), \theme_adaptable\toolbox::getfontawesomemarkup('bullhorn', ['mr-1']), ]; + $usermenuitems[] = ['enablecalendar', false, $CFG->wwwroot . '/calendar/view.php', + get_string('pluginname', 'block_calendar_month'), \theme_adaptable\toolbox::getfontawesomemarkup('calendar', ['mr-1']), ]; $returnurl = $this->page->url->out_as_local_url(false); $context = context_course::instance($COURSE->id); if ((!is_role_switched($COURSE->id)) && (has_capability('moodle/role:switchroles', $context))) { - $url = $CFG->wwwroot.'/course/switchrole.php?id='.$COURSE->id.'&switchrole=-1&returnurl='.$returnurl; - $usermenuitems[] = array(false, false, $url, get_string('switchroleto'), - \theme_adaptable\toolbox::getfontawesomemarkup('user-o')); + $url = $CFG->wwwroot . '/course/switchrole.php?id=' . $COURSE->id . '&switchrole=-1&returnurl=' . $returnurl; + $usermenuitems[] = [false, false, $url, get_string('switchroleto'), + \theme_adaptable\toolbox::getfontawesomemarkup('user-o', ['mr-1']), ]; } if (is_role_switched($COURSE->id)) { - $url = $CFG->wwwroot.'/course/switchrole.php?id='.$COURSE->id.'&sesskey='.sesskey(). - '&switchrole=0&returnurl='.$returnurl; - $usermenuitems[] = array(false, false, $url, get_string('switchrolereturn'), - \theme_adaptable\toolbox::getfontawesomemarkup('user-o')); + $url = $CFG->wwwroot . '/course/switchrole.php?id=' . $COURSE->id . '&sesskey=' . sesskey() . + '&switchrole=0&returnurl=' . $returnurl; + $usermenuitems[] = [false, false, $url, get_string('switchrolereturn'), + \theme_adaptable\toolbox::getfontawesomemarkup('user-o', ['mr-1']), ]; } - $usermenuitems[] = array(false, false, $CFG->wwwroot.'/login/logout.php?sesskey='.sesskey(), get_string('logout'), - \theme_adaptable\toolbox::getfontawesomemarkup('sign-out')); + $usermenuitems[] = [false, false, $CFG->wwwroot . '/login/logout.php?sesskey=' . sesskey(), get_string('logout'), + \theme_adaptable\toolbox::getfontawesomemarkup('sign-out', ['mr-1']), ]; for ($i = 0; $i < count($usermenuitems); $i++) { $additem = true; @@ -292,7 +156,7 @@ public function user_profile_menu() { if ($additem) { $retval .= ''; - $retval .= $usermenuitems[$i][4].$usermenuitems[$i][3].''; + $retval .= $usermenuitems[$i][4] . $usermenuitems[$i][3] . ''; } } return $retval; @@ -328,7 +192,7 @@ public function block(block_contents $bc, $region) { } $skiptitle = strip_tags($bc->title); if ($bc->blockinstanceid && !empty($skiptitle)) { - $bc->attributes['aria-labelledby'] = 'instance-'.$bc->blockinstanceid.'-header'; + $bc->attributes['aria-labelledby'] = 'instance-' . $bc->blockinstanceid . '-header'; } else if (!empty($bc->arialabel)) { $bc->attributes['aria-label'] = $bc->arialabel; } @@ -347,10 +211,16 @@ public function block(block_contents $bc, $region) { $output = ''; $skipdest = ''; } else { - $output = html_writer::link('#sb-'.$bc->skipid, get_string('skipa', 'access', $skiptitle), - array('class' => 'skip skip-block', 'id' => 'fsb-' . $bc->skipid)); - $skipdest = html_writer::span('', 'skip-block-to', - array('id' => 'sb-' . $bc->skipid)); + $output = html_writer::link( + '#sb-' . $bc->skipid, + get_string('skipa', 'access', $skiptitle), + ['class' => 'skip skip-block', 'id' => 'fsb-' . $bc->skipid] + ); + $skipdest = html_writer::span( + '', + 'skip-block-to', + ['id' => 'sb-' . $bc->skipid] + ); } $output .= html_writer::start_tag('section', $bc->attributes); @@ -378,10 +248,10 @@ protected function block_header(block_contents $bc) { $title = ''; if ($bc->title) { - $attributes = array(); + $attributes = []; $attributes['class'] = 'd-inline'; if ($bc->blockinstanceid) { - $attributes['id'] = 'instance-'.$bc->blockinstanceid.'-header'; + $attributes['id'] = 'instance-' . $bc->blockinstanceid . '-header'; } $title = html_writer::tag('h2', $bc->title, $attributes); } @@ -395,12 +265,15 @@ protected function block_header(block_contents $bc) { $output = ''; if ($title || $controlshtml) { $output .= - html_writer::tag('div', - html_writer::tag('div', - html_writer::tag('div', '', array('class' => 'block_action')).$title. - html_writer::tag('div', $controlshtml, array('class' => 'block-controls float-right')), - array('class' => 'title')), - array('class' => 'header') + html_writer::tag( + 'div', + html_writer::tag( + 'div', + html_writer::tag('div', '', ['class' => 'block_action']) . $title . + html_writer::tag('div', $controlshtml, ['class' => 'block-controls float-right']), + ['class' => 'title'] + ), + ['class' => 'header'] ); } return $output; @@ -413,9 +286,9 @@ protected function block_header(block_contents $bc) { * @return string */ protected function block_content(block_contents $bc) { - $output = html_writer::start_tag('div', array('class' => 'content')); + $output = html_writer::start_tag('div', ['class' => 'content']); if (!$bc->title && !$this->block_controls($bc->controls)) { - $output .= html_writer::tag('div', '', array('class' => 'block_action notitle')); + $output .= html_writer::tag('div', '', ['class' => 'block_action notitle']); } $output .= $bc->content; $output .= $this->block_footer($bc); @@ -433,7 +306,7 @@ protected function block_content(block_contents $bc) { protected function block_footer(block_contents $bc) { $output = ''; if ($bc->footer) { - $output .= html_writer::tag('div', $bc->footer, array('class' => 'footer')); + $output .= html_writer::tag('div', $bc->footer, ['class' => 'footer']); } return $output; } @@ -447,7 +320,7 @@ protected function block_footer(block_contents $bc) { protected function block_annotation(block_contents $bc) { $output = ''; if ($bc->annotation) { - $output .= html_writer::tag('div', $bc->annotation, array('class' => 'blockannotation')); + $output .= html_writer::tag('div', $bc->annotation, ['class' => 'blockannotation']); } return $output; } @@ -459,351 +332,162 @@ protected function block_annotation(block_contents $bc) { */ public function init_block_hider_js(block_contents $bc) { if (!empty($bc->attributes['id']) && $bc->collapsible != block_contents::NOT_HIDEABLE) { - $config = new stdClass; + $config = new stdClass(); $config->id = $bc->attributes['id']; $config->title = strip_tags($bc->title); $config->preference = 'block' . $bc->blockinstanceid . 'hidden'; $config->tooltipVisible = get_string('hideblocka', 'access', $config->title); $config->tooltipHidden = get_string('showblocka', 'access', $config->title); - $this->page->requires->js_init_call('M.util.init_block_hider', array($config)); + $this->page->requires->js_init_call('M.util.init_block_hider', [$config]); user_preference_allow_ajax_update($config->preference, PARAM_BOOL); } } /** - * Renders preferences groups. - * - * @param preferences_groups $renderable The renderable - * @return string The output. - */ - public function render_preferences_groups(\preferences_groups $renderable) { - return $this->render_from_template('core/preferences_groups', $renderable); - } - - /** - * Returns list of alert messages for the user + * Returns standard navigation between activities in a course. * - * @return string + * @return string the navigation HTML. */ - public function get_alert_messages() { - global $CFG, $COURSE; - $alerts = ''; - - $alertcount = $this->page->theme->settings->alertcount; + public function activity_navigation() { + // First we should check if we want to add navigation. + if (!$this->page->theme->settings->courseactivitynavigationenabled) { + return ''; + } - if (\core\session\manager::is_loggedinas()) { - $alertindex = $alertcount + 1; - $alertkey = "undismissable"; - $logininfo = $this->login_info(); - $logininfo = str_replace('
', '', $logininfo); - $logininfo = str_replace('
', '', $logininfo); - $alerts = $this->get_alert_message($logininfo, 'warning', $alertindex, $alertkey) . $alerts; + $context = $this->page->context; + if ( + ($this->page->pagelayout !== 'incourse' && $this->page->pagelayout !== 'frametop') + || $context->contextlevel != CONTEXT_MODULE + ) { + return ''; } - if (empty($this->page->theme->settings->enablealerts)) { - return $alerts; + // If the activity is in stealth mode, show no links. + if ($this->page->cm->is_stealth()) { + return ''; } - for ($i = 1; $i <= $alertcount; $i++) { - $enablealert = 'enablealert' . $i; - $alerttext = 'alerttext' . $i; - $alertsession = 'alert' . $i; + // Get a list of all the activities in the course. + $course = $this->page->cm->get_course(); + $modules = get_fast_modinfo($course->id)->get_cms(); - if (isset($this->page->theme->settings->$enablealert)) { - $enablealert = $this->page->theme->settings->$enablealert; - } else { - $enablealert = false; + // Put the modules into an array in order by the position they are shown in the course. + $mods = []; + $activitylist = []; + foreach ($modules as $module) { + // Only add activities the user can access, aren't in stealth mode and have a url (eg. mod_label does not). + if (!$module->uservisible || $module->is_stealth() || empty($module->url)) { + continue; } + $mods[$module->id] = $module; - if (isset($this->page->theme->settings->$alerttext)) { - $alerttext = $this->page->theme->settings->$alerttext; - } else { - $alerttext = ''; + // No need to add the current module to the list for the activity dropdown menu. + if ($module->id == $this->page->cm->id) { + continue; } - - if ($enablealert && !empty($alerttext)) { - $alertprofilefield = 'alertprofilefield' . $i; - $profilevals = array('', ''); - - if (!empty($this->page->theme->settings->$alertprofilefield)) { - $profilevals = explode('=', $this->page->theme->settings->$alertprofilefield); - } - - if (!empty($this->page->theme->settings->enablealertstriptags)) { - $alerttext = strip_tags($alerttext); - } - - $alerttype = 'alerttype' . $i; - $alertaccess = 'alertaccess' . $i; - $alertkey = 'alertkey' . $i; - - $alerttype = $this->page->theme->settings->$alerttype; - $alertaccess = $this->page->theme->settings->$alertaccess; - $alertkey = $this->page->theme->settings->$alertkey; - - if ($this->get_alert_access($alertaccess, $profilevals[0], $profilevals[1], $alertsession)) { - $alerts .= $this->get_alert_message($alerttext, $alerttype, $i, $alertkey); - } + // Module name. + $modname = $module->get_formatted_name(); + // Display the hidden text if necessary. + if (!$module->visible) { + $modname .= ' ' . get_string('hiddenwithbrackets'); } + // Module URL. + $linkurl = new \moodle_url($module->url, ['forceview' => 1]); + // Add module URL (as key) and name (as value) to the activity list array. + $activitylist[$linkurl->out(false)] = $modname; } - if (is_role_switched($COURSE->id)) { - $alertindex = $alertcount + 1; - $alertkey = "undismissable"; - - $returnurl = $this->page->url->out_as_local_url(false); - $url = $CFG->wwwroot.'/course/switchrole.php?id='.$COURSE->id.'&sesskey='.sesskey(). - '&switchrole=0&returnurl='.$returnurl; - - $message = get_string('actingasrole', 'theme_adaptable') . '. '; - $message .= '' . get_string('switchrolereturn') . ''; - $alerts = $this->get_alert_message($message, 'warning', $alertindex, $alertkey) . $alerts; - } + $nummods = count($mods); - return $alerts; - } - - /** - * Returns formatted alert message - * - * @param string $text message text - * @param string $type alert type - * @param int $alertindex - * @param int $alertkey - */ - public function get_alert_message($text, $type, $alertindex, $alertkey) { - if ($alertkey == '' || theme_adaptable_get_alertkey($alertindex) == $alertkey) { + // If there is only one mod then do nothing. + if ($nummods == 1) { return ''; } - $retval = '
'; - $retval .= ''; - $retval .= ' '; - $retval .= $text; - $retval .= '
'; - return $retval; - } + // Get the position in the array of the course module we are viewing. + $position = array_search($this->page->cm->id, $modids); - /** - * Displays notices to alert teachers of problems with course such as being hidden. - */ - public function get_course_alerts() { - $retval = ''; - $alerttype = $this->page->theme->settings->alerthiddencourse; - if ($alerttype != 'disabled') { - if ($this->page->course->visible == 0) { - global $CFG, $COURSE; - $alerttext = get_string('alerthiddencoursetext-1', 'theme_adaptable'). - ''. - get_string('alerthiddencoursetext-2', 'theme_adaptable').''; + $prevmod = null; + $nextmod = null; - $alertindexkey = 'hiddencoursealert-'.$COURSE->id; + // Check if we have a previous mod to show. + if ($position > 0) { + $prevmod = $mods[$modids[$position - 1]]; + } - $retval = $this->get_alert_message($alerttext, $alerttype, $alertindexkey, $alertindexkey); - } + // Check if we have a next mod to show. + if ($position < ($nummods - 1)) { + $nextmod = $mods[$modids[$position + 1]]; } - return $retval; + $activitynav = new \core_course\output\activity_navigation($prevmod, $nextmod, $activitylist); + $renderer = $this->page->get_renderer('core', 'course'); + return $renderer->render($activitynav); } /** - * Checks the users access to alerts - * @param string $access the kind of access rule applied - * @param string $profilefield the custom profile filed to check - * @param string $profilevalue the expected value to be found in users profile - * @param string $alertsession a token to be used to store access in session - * @return boolean + * Renders preferences groups. + * + * @param preferences_groups $renderable The renderable + * @return string The output. */ - public function get_alert_access($access, $profilefield, $profilevalue, $alertsession) { - $retval = false; - switch ($access) { - case "global": - $retval = true; - break; - case "user": - if (isloggedin()) { - $retval = true; - } - break; - case "admin": - if (is_siteadmin()) { - $retval = true; - } - break; - case "profile": - /* Check if user is logged in and then check menu access for profile field. */ - if ( (isloggedin()) && ($this->check_menu_access($profilefield, $profilevalue, $alertsession)) ) { - $retval = true; - } - break; - } - return $retval; + public function render_preferences_groups(\preferences_groups $renderable) { + return $this->render_from_template('core/preferences_groups', $renderable); } /** - * Returns FA icon depending on the type of alert selected + * Returns list of alert messages for the user. * - * @param string $alertclassglobal * - * @return string + * @return string Markup if any. */ - public function alert_icon($alertclassglobal) { - switch ($alertclassglobal) { - case "success": - $alerticonglobal = $this->page->theme->settings->alerticonsuccess; - break; - case "info": - $alerticonglobal = $this->page->theme->settings->alerticoninfo; - break; - case "warning": - $alerticonglobal = $this->page->theme->settings->alerticonwarning; - break; + public function get_alert_messages() { + $markup = ''; + $localtoolbox = \theme_adaptable\toolbox::get_local_toolbox(); + + if (is_object($localtoolbox)) { + $themesettings = \theme_adaptable\toolbox::get_settings(); + $markup = $localtoolbox->get_alert_messages($themesettings, $this->page, $this); } - return $alerticonglobal; + + return $markup; } /** - * Returns Google Analytics code if analytics are enabled + * Displays notices to alert teachers of problems with course such as being hidden. * - * @return string + * @return string Markup if any. */ - public function get_analytics() { - $analytics = ''; - $analyticscount = $this->page->theme->settings->enableanalytics; - $anonymize = true; - - // Anonymize IP. - if (($this->page->theme->settings->anonymizega = 1) || (empty($this->page->theme->settings->anonymizega))) { - $anonymize = true; - } else { - $anonymize = false; - } - - // Load settings. - if (isset($this->page->theme->settings->enableanalytics)) { - for ($i = 1; $i <= $analyticscount; $i++) { - $analyticstext = 'analyticstext' . $i; - $analyticsprofilefield = 'analyticsprofilefield' . $i; - $analyticssession = 'analytics' . $i; - $access = true; - - if (!empty($this->page->theme->settings->$analyticsprofilefield)) { - $profilevals = explode('=', $this->page->theme->settings->$analyticsprofilefield); - $profilefield = $profilevals[0]; - $profilevalue = $profilevals[1]; - if (!$this->check_menu_access($profilefield, $profilevalue, $analyticssession)) { - $access = false; - } - } + public function get_course_alerts() { + $markup = ''; + $localtoolbox = \theme_adaptable\toolbox::get_local_toolbox(); - if (!empty($this->page->theme->settings->$analyticstext) && $access) { - // The closing tag of PHP heredoc doesn't like being indented so do not meddle with indentation of 'EOT;' below! - $analytics .= << - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', '$analyticstext', 'auto'); - ga('send', 'pageview'); - ga('set', 'anonymizeIp', $anonymize); - -EOT; - } - } + if (is_object($localtoolbox)) { + $themesettings = \theme_adaptable\toolbox::get_settings(); + $markup = $localtoolbox->get_course_alerts($themesettings, $this->page, $this); } - return $analytics; - } - /** - * Returns Piwik code if enabled. - * - * @copyright 2016 COMETE-UPO (Universit\E9 Paris Ouest) - * - * @return string - */ - public function get_piwik() { - $siteurl = $this->page->theme->settings->piwiksiteurl; - $siteid = $this->page->theme->settings->piwiksiteid; - - $analytics = ''; - if ($this->page->theme->settings->piwikenabled && - !empty($siteurl) && - !empty($siteid) && - ($this->page->theme->settings->piwiktrackadmin || !is_siteadmin())) { - // Cleanurl. - $pageinfo = get_context_info_array($this->page->context->id); - $trackurl = ''; - // Adds course category name. - if (isset($pageinfo[1]->category)) { - global $DB; - if ($category = $DB->get_record('course_categories', array('id' => $pageinfo[1]->category))) { - $cats = explode("/", $category->path); - foreach (array_filter($cats) as $cat) { - if ($categorydepth = $DB->get_record("course_categories", array("id" => $cat))) { - $trackurl .= $categorydepth->name.'/'; - } - } - } - } - // Adds course full name. - if (isset($pageinfo[1]->fullname)) { - $trackurl .= $pageinfo[1]->fullname.'/'; - if (!isset($pageinfo[2]->name)) { - if ($this->page->user_is_editing()) { - $trackurl .= get_string('edit'); - } else { - $trackurl .= get_string('view'); - } - } - } - // Adds module name. - if (isset($pageinfo[2]->name)) { - $trackurl .= get_string('pluginname', 'mod_'.$pageinfo[2]->modname).'/'.$pageinfo[2]->name; - } - $trackurl = mb_ereg_replace('"', '\"', $trackurl); - // Here we go. - $analytics .= ''.PHP_EOL. - ''.PHP_EOL; - if ($this->page->theme->settings->piwikimagetrack) { - $analytics .= ''.PHP_EOL; - } - $analytics .= ''; - } - return $analytics; + return $markup; } /** - * Returns all tracking methods (Analytics and Piwik) + * Returns all tracking methods. * - * @return string + * @return string Markup. */ public function get_all_tracking_methods() { - $analytics = ''; - $analytics .= $this->get_analytics(); - $analytics .= $this->get_piwik(); - return $analytics; + $markup = ''; + $localtoolbox = \theme_adaptable\toolbox::get_local_toolbox(); + + if (is_object($localtoolbox)) { + $themesettings = \theme_adaptable\toolbox::get_settings(); + $markup = $localtoolbox->get_all_tracking_methods($themesettings, $this->page, $this); + } + + return $markup; } /** @@ -830,15 +514,15 @@ public function edit_button(moodle_url $url, string $method = 'post') { $title = get_string('turneditingon'); $icon = 'fa-edit'; } - $editingtext = get_config('theme_adaptable', 'displayeditingbuttontext'); + $editingtext = \theme_adaptable\toolbox::get_setting('displayeditingbuttontext'); $buttontitle = ''; if ($editingtext) { $buttontitle = $title; } else { $icon .= ' only'; } - return html_writer::tag('a', html_writer::tag('i', '', array('class' => $icon.' fa fa-fw')). - $buttontitle, array('href' => $url, 'class' => 'btn '.$btn, 'title' => $title)); + return html_writer::tag('a', html_writer::tag('i', '', ['class' => $icon . ' fa fa-fw']) . + $buttontitle, ['href' => $url, 'class' => 'btn ' . $btn, 'title' => $title]); } /** @@ -856,12 +540,13 @@ protected function process_message($message) { $messagecontent->type = 'notification'; if (empty($message->contexturl)) { - $messagecontent->url = new moodle_url('/message/index.php', - array('user1' => $USER->id, 'viewing' => 'recentnotifications')); + $messagecontent->url = new moodle_url( + '/message/index.php', + ['user1' => $USER->id, 'viewing' => 'recentnotifications'] + ); } else { $messagecontent->url = new moodle_url($message->contexturl); } - } else { $messagecontent->type = 'message'; if ($message->fullmessageformat == FORMAT_HTML) { @@ -872,9 +557,11 @@ protected function process_message($message) { } else { $messagecontent->text = $message->smallmessage; } - $messagecontent->from = $DB->get_record('user', array('id' => $message->useridfrom)); - $messagecontent->url = new moodle_url('/message/index.php', - array('user1' => $USER->id, 'user2' => $message->useridfrom)); + $messagecontent->from = $DB->get_record('user', ['id' => $message->useridfrom]); + $messagecontent->url = new moodle_url( + '/message/index.php', + ['user1' => $USER->id, 'user2' => $message->useridfrom] + ); } $messagecontent->date = userdate($message->timecreated, get_string('strftimetime', 'langconfig')); $messagecontent->unread = empty($message->timeread); @@ -904,8 +591,8 @@ public function socialicons() { foreach ($lines as $line) { if (strstr($line, '|')) { $fields = explode('|', $line); - $retval .= ''; - $retval .= ''; + $retval .= ''; + $retval .= ''; $retval .= ''; } } @@ -914,55 +601,18 @@ public function socialicons() { } /** - * Returns html to render news ticker + * Returns html to render news ticker. + * Note: Requires local_adaptable plugin. * * @return string */ public function get_news_ticker() { $retval = ''; + $localtoolbox = \theme_adaptable\toolbox::get_local_toolbox(); - if (!isset($this->page->theme->settings->enabletickermy)) { - $this->page->theme->settings->enabletickermy = 0; - } - - // Display ticker if possible. - if ((!empty($this->page->theme->settings->enableticker) && - $this->page->theme->settings->enableticker && - $this->page->bodyid == "page-site-index") || - ($this->page->theme->settings->enabletickermy && $this->page->bodyid == "page-my-index")) { - $msg = ''; - $tickercount = $this->page->theme->settings->newstickercount; - - for ($i = 1; $i <= $tickercount; $i++) { - $textfield = 'tickertext' . $i; - $profilefield = 'tickertext' . $i . 'profilefield'; - - $access = true; - if (!empty($this->page->theme->settings->$profilefield)) { - $profilevals = explode('=', $this->page->theme->settings->$profilefield); - if (!$this->check_menu_access($profilevals[0], $profilevals[1], $textfield)) { - $access = false; - } - } - - if (($access) && (!empty($this->page->theme->settings->$textfield))) { - $msg .= format_text($this->page->theme->settings->$textfield, FORMAT_HTML, array('trusted' => true)); - } - } - - $msg = preg_replace('#\<[\/]{0,1}(li|ul|div|pre|blockquote)\>#', '', $msg); - if ($msg == '') { - $msg = '

' . get_string('tickerdefault', 'theme_adaptable') . '

'; - } - - $retval .= '
'; - $retval .= '
'; - $retval .= get_string('ticker', 'theme_adaptable'); - $retval .= '
'; - $retval .= '
    '; - $retval .= $msg; - $retval .= '
'; - $retval .= '
'; + if (is_object($localtoolbox)) { + $themesettings = \theme_adaptable\toolbox::get_settings(); + $retval = $localtoolbox->get_news_ticker($themesettings, $this->page, $this); } return $retval; @@ -982,14 +632,17 @@ public function get_news_ticker() { * 'my-block-a' and 'my-block-a' are expected to exist. * @return string HTML output */ - public function get_block_regions($settingsname = 'blocklayoutlayoutrow', $classnamebeginswith = 'frnt-market-', - $customrowsetting = null) { + public function get_block_regions( + $settingsname = 'blocklayoutlayoutrow', + $classnamebeginswith = 'frnt-market-', + $customrowsetting = null + ) { global $COURSE, $USER; $adminediting = false; $blockcount = 0; $classextra = ''; - $fields = array(); + $fields = []; $retval = ''; /* Check if user has capability to edit block on homepage. This is used as part of checking if @@ -999,13 +652,13 @@ public function get_block_regions($settingsname = 'blocklayoutlayoutrow', $class /* Check if front page and if has capability to edit blocks. The $pageallowed variable will store the correct state of whether user can edit that page. */ $caneditblock = has_capability('moodle/block:edit', $context); - if ( ($this->page->pagelayout == "frontpage") && ($caneditblock !== true) ) { + if (($this->page->pagelayout == "frontpage") && ($caneditblock !== true)) { $pageallowed = false; } else { $pageallowed = true; } - if ( (isset($USER->editing) && $USER->editing == 1) && ($pageallowed == true) ) { + if ((isset($USER->editing) && $USER->editing == 1) && ($pageallowed == true)) { $classextra = ' adaptable-block-area'; $adminediting = true; } @@ -1013,7 +666,7 @@ public function get_block_regions($settingsname = 'blocklayoutlayoutrow', $class if ($settingsname == 'customrowsetting') { $fields[] = $customrowsetting; } else { - for ($i = 1; $i <= 8; $i++) { + for ($i = 1; $i <= 5; $i++) { $marketrow = $settingsname . $i; /* Need to check if the setting exists as this function is now @@ -1036,14 +689,14 @@ public function get_block_regions($settingsname = 'blocklayoutlayoutrow', $class $vals = explode('-', $field); foreach ($vals as $val) { if ($val > 0) { - $retval .= '
'; + $retval .= '
'; // Moodle does not seem to like numbers in region names so using letter instead. - $blockcount ++; - $block = $classnamebeginswith. chr(96 + $blockcount); + $blockcount++; + $block = $classnamebeginswith . chr(96 + $blockcount); if ($adminediting) { - $retval .= ''.get_string('region-'.$block, 'theme_adaptable').''; + $retval .= '' . get_string('region-' . $block, 'theme_adaptable') . ''; } $retval .= $this->blocks($block, 'block-region-front'); @@ -1064,7 +717,7 @@ public function get_block_regions($settingsname = 'blocklayoutlayoutrow', $class * @param bool $displayall An override setting to simply display all blocks from the region * @return string HTML output */ - public function get_missing_block_regions($blocksarray, $classes = array(), $displayall = false) { + public function get_missing_block_regions($blocksarray, $classes = [], $displayall = false) { global $USER; $retval = ''; $adminediting = false; @@ -1074,16 +727,13 @@ public function get_missing_block_regions($blocksarray, $classes = array(), $dis } if (!empty($blocksarray)) { - $classes = (array)$classes; $missingblocks = ''; foreach ($blocksarray as $block) { - /* Do this for up to 8 rows (allows for expansion. Be careful of losing blocks if this value changes from a high to low number!). */ for ($i = 1; $i <= 8; $i++) { - /* For each block region in a row, analyse the current layout (e.g. 6-6-0-0, 3-3-3-3). Check if less than 4 blocks (meaning a change in settings from say 4-4-4-4 to 6-6. Meaning missing blocks, i.e. 6-6-0-0 means the two end ones may have content that is inadvertantly lost. */ @@ -1100,7 +750,6 @@ public function get_missing_block_regions($blocksarray, $classes = array(), $dis /* Here's the crucial bit. Check if span number is 0, or $displayall is true (override) and if so, print it out. */ if ($spannumber == 0 || $displayall) { - $blockclass = $block['classnamebeginswith'] . chr(96 + $y); $missingblock = $this->blocks($blockclass, 'block'); @@ -1108,7 +757,7 @@ public function get_missing_block_regions($blocksarray, $classes = array(), $dis if (strip_tags($missingblock)) { if ($adminediting) { $missingblocks .= 'ORPHANED BLOCK - Originally displays in: ' . - get_string('region-' . $blockclass, 'theme_adaptable') .''; + get_string('region-' . $blockclass, 'theme_adaptable') . ''; } $missingblocks .= $missingblock; } @@ -1136,12 +785,12 @@ public function get_missing_block_regions($blocksarray, $classes = array(), $dis * @return string Markup. */ public function get_marketing_blocks($layoutrow = 'marketlayoutrow', $settingname = 'market') { - $fields = array(); + $fields = []; $blockcount = 0; $extramarketclass = $this->page->theme->settings->frontpagemarketoption; - $retval = '
'; + $retval = '
'; for ($i = 1; $i <= 5; $i++) { $marketrow = $layoutrow . $i; @@ -1157,11 +806,11 @@ public function get_marketing_blocks($layoutrow = 'marketlayoutrow', $settingnam foreach ($vals as $val) { if ($val > 0) { $retval .= '
'; - $blockcount ++; + $blockcount++; $fieldname = $settingname . $blockcount; if (isset($this->page->theme->settings->$fieldname)) { // Add HTML format. - $retval .= $this->get_setting($fieldname, 'format_moodle'); + $retval .= \theme_adaptable\toolbox::get_setting($fieldname, 'format_moodle'); } $retval .= '
'; } @@ -1169,7 +818,7 @@ public function get_marketing_blocks($layoutrow = 'marketlayoutrow', $settingnam $retval .= '
'; } $retval .= '
'; - if ($blockcount == 0 ) { + if ($blockcount == 0) { $retval = ''; } return $retval; @@ -1205,7 +854,7 @@ public function get_footer_visibility() { * @return string HTML output. */ public function get_footer_blocks($layoutrow = 'footerlayoutrow') { - $fields = array(); + $fields = []; $blockcount = 0; if (!$this->get_footer_visibility()) { @@ -1227,17 +876,17 @@ public function get_footer_blocks($layoutrow = 'footerlayoutrow') { $vals = explode('-', $field); foreach ($vals as $val) { if ($val > 0) { - $blockcount ++; + $blockcount++; $footerheader = 'footer' . $blockcount . 'header'; $footercontent = 'footer' . $blockcount . 'content'; if (!empty($this->page->theme->settings->$footercontent)) { $output .= '
'; if (!empty($this->page->theme->settings->$footerheader)) { $output .= '

'; - $output .= $this->get_setting($footerheader, 'format_html'); + $output .= \theme_adaptable\toolbox::get_setting($footerheader, 'format_html'); $output .= '

'; } - $output .= $this->get_setting($footercontent, 'format_html'); + $output .= \theme_adaptable\toolbox::get_setting($footercontent, 'format_html'); $output .= '
'; } } @@ -1245,17 +894,33 @@ public function get_footer_blocks($layoutrow = 'footerlayoutrow') { $output .= '
'; } if (!empty($output)) { - $output = '
'.$output.'
'; + $output = '
' . $output . '
'; } return $output; } /** - * Renders frontpage slider - * + * Renders frontpage slider. + * @return string HTML output if any. */ public function get_frontpage_slider() { + if (empty($this->page->theme->settings->sliderenabled)) { + return ''; + } + + $visiblestate = 3; + if (!empty($this->page->theme->settings->slidervisible)) { + $visiblestate = $this->page->theme->settings->slidervisible; + } + + if ($visiblestate != 3) { + $loggedin = isloggedin(); + if ((($visiblestate == 1) && ($loggedin)) || (($visiblestate == 2) && (!$loggedin))) { + return ''; + } + } + $noslides = $this->page->theme->settings->slidercount; $responsiveslider = $this->page->theme->settings->responsiveslider; @@ -1294,7 +959,7 @@ public function get_frontpage_slider() { $sliderurl = 'p' . $i . 'url'; if (!empty($this->page->theme->settings->$sliderimage)) { - $slidercaption = 'p' . $i .'cap'; + $slidercaption = 'p' . $i . 'cap'; } $closelink = ''; @@ -1311,7 +976,7 @@ public function get_frontpage_slider() { if (!empty($this->page->theme->settings->$slidercaption)) { $retval .= '
'; - $retval .= $this->get_setting($slidercaption, 'format_html'); + $retval .= \theme_adaptable\toolbox::get_setting($slidercaption, 'format_html'); $retval .= '
'; } $retval .= $closelink . ''; @@ -1336,20 +1001,22 @@ public function page_navbar() { // Do not show navbar on dashboard / my home if news ticker is rendering. if (!($this->page->theme->settings->enabletickermy && $this->page->bodyid == "page-my-index")) { $retval = '
'; - if (($this->page->theme->settings->breadcrumbdisplay != 'breadcrumb') + if ( + ($this->page->theme->settings->breadcrumbdisplay != 'breadcrumb') && (($this->page->pagelayout == 'course') - || ($this->page->pagelayout == 'incourse'))) { + || ($this->page->pagelayout == 'incourse')) + ) { global $COURSE; $retval .= '
'; switch ($this->page->theme->settings->breadcrumbdisplay) { case 'fullname': // Full Course Name. $coursetitle = $COURSE->fullname; - break; + break; case 'shortname': // Short Course Name. $coursetitle = $COURSE->shortname; - break; + break; } $coursetitlemaxwidth = (!empty($this->page->theme->settings->coursetitlemaxwidth) @@ -1365,20 +1032,22 @@ public function page_navbar() { case 'fullname': case 'shortname': // Full / Short Course Name. - $courseurl = new moodle_url('/course/view.php', array('id' => $COURSE->id)); + $courseurl = new moodle_url('/course/view.php', ['id' => $COURSE->id]); $retval .= ''; - break; + . $courseurl->out(true) . '">' . format_string($coursetitle) . '
'; + break; } $retval .= '
'; } else { - if ($this->page->include_region_main_settings_in_header_actions() && - !$this->page->blocks->is_block_present('settings')) { + if ( + $this->page->include_region_main_settings_in_header_actions() && + !$this->page->blocks->is_block_present('settings') + ) { $this->page->add_header_action(html_writer::div( $this->region_main_settings_menu(), - 'd-print-none', - ['id' => 'region-main-settings-menu'] - )); + 'd-print-none', + ['id' => 'region-main-settings-menu'] + )); } $header = new stdClass(); @@ -1417,19 +1086,18 @@ public function navbar(): string { if ($start) { $breadcrumbs .= '
  • '; - if (get_config('theme_adaptable', 'enablehome') && get_config('theme_adaptable', 'enablemyhome')) { - $breadcrumbs = html_writer::tag('i', '', array( + if (\theme_adaptable\toolbox::get_setting('enablehome') && \theme_adaptable\toolbox::get_setting('enablemyhome')) { + $breadcrumbs = html_writer::tag('i', '', [ 'title' => get_string('home', 'theme_adaptable'), - 'class' => 'fa fa-folder-open fa-lg' - ) - ); - } else if (get_config('theme_adaptable', 'breadcrumbhome') == 'icon') { - $breadcrumbs .= html_writer::link(new moodle_url('/'), + 'class' => 'fa fa-folder-open fa-lg', + ]); + } else if (\theme_adaptable\toolbox::get_setting('breadcrumbhome') == 'icon') { + $breadcrumbs .= html_writer::link( + new moodle_url('/'), // Adds in a title for accessibility purposes. - html_writer::tag('i', '', array( + html_writer::tag('i', '', [ 'title' => get_string('home', 'theme_adaptable'), - 'class' => 'fa fa-home fa-lg') - ) + 'class' => 'fa fa-home fa-lg', ]) ); $breadcrumbs .= '
  • '; } else { @@ -1439,14 +1107,14 @@ public function navbar(): string { $start = false; continue; // This effectively removes the 'core' Home / Dashboard / User preference for such item. } - $breadcrumbs .= '
  • '. - $this->render($item).'
  • '; + $breadcrumbs .= '
  • ' . + $this->render($item) . '
  • '; } $classes = $this->page->theme->settings->responsivebreadcrumb; - return ' diff --git a/templates/headersearch.mustache b/templates/headersearch.mustache index c35f73c..5616177 100644 --- a/templates/headersearch.mustache +++ b/templates/headersearch.mustache @@ -25,6 +25,6 @@ "search": "The markup" } }} -
    +
    {{{search}}}
    diff --git a/templates/pix_icon_fontawesome.mustache b/templates/pix_icon_fontawesome.mustache new file mode 100644 index 0000000..fad44de --- /dev/null +++ b/templates/pix_icon_fontawesome.mustache @@ -0,0 +1,51 @@ +{{! + 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 . +}} +{{! + @template theme_adaptable/pix_icon_fontawesome + + Moodle pix_icon template. + + The purpose of this template is to render a pix_icon. If the icon was not mapped we fall back to normal pix_icon markup. + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * pix + * title + * extraclasses + + Example context (json): + { + "key": "fa-meh-o", + "title": "Meh", + "alt": "Meh Meh", + "extraclasses": "fa-spin", + "unmappedIcon": false + } + +}} +{{^unmappedIcon}} + +{{/unmappedIcon}} +{{#unmappedIcon}} +{{! We cannot include the pix_icon template directly here because we don't have all the mustache helpers loaded. }} + +{{/unmappedIcon}} diff --git a/tests/behat/behat_theme_adaptable_behat_admin.php b/tests/behat/behat_theme_adaptable_behat_admin.php index 91f9508..7f303b1 100644 --- a/tests/behat/behat_theme_adaptable_behat_admin.php +++ b/tests/behat/behat_theme_adaptable_behat_admin.php @@ -20,7 +20,7 @@ * @package theme_adaptable * @category test * @copyright 2019 Michael Hawkins (copied from theme_classic) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. @@ -28,8 +28,8 @@ require_once(__DIR__ . '/../../../../admin/tests/behat/behat_admin.php'); -use Behat\Gherkin\Node\TableNode as TableNode, - Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException; +use Behat\Gherkin\Node\TableNode, + Behat\Mink\Exception\ElementNotFoundException; /** * Site administration level steps definitions overrides for the Adaptable theme. @@ -37,10 +37,9 @@ * @package theme_adaptable * @category test * @copyright 2019 Michael Hawkins (copied from theme classic) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_admin extends behat_admin { - /** * Sets the specified site settings. A table with | Setting label | value | is expected. * @@ -53,7 +52,6 @@ public function i_set_the_following_administration_settings_values(TableNode $ta } foreach ($data as $label => $value) { - // We expect admin block to be visible, otherwise go to homepage. if (!$this->getSession()->getPage()->find('css', '.block_settings')) { $this->execute('behat_forms::i_am_on_homepage'); @@ -78,7 +76,6 @@ public function i_set_the_following_administration_settings_values(TableNode $ta "@id=//span[contains(normalize-space(.), $label)]/preceding-sibling::label[1]/@for]"; $fieldnode = $this->find('xpath', $fieldxpath, $exception); } catch (ElementNotFoundException $e) { - // Multi element settings, interacting only the first one. $fieldxpath = "//*[label[contains(., $label)]|span[contains(., $label)]]" . "/ancestor::div[contains(concat(' ', normalize-space(@class), ' '), ' form-item ')]" . diff --git a/tests/behat/behat_theme_adaptable_behat_auth.php b/tests/behat/behat_theme_adaptable_behat_auth.php index 43e0a1c..8a1bf10 100644 --- a/tests/behat/behat_theme_adaptable_behat_auth.php +++ b/tests/behat/behat_theme_adaptable_behat_auth.php @@ -18,7 +18,7 @@ * Overrides for behat authentication. * @author Marcus Green * @copyright Titus Learning - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. @@ -29,7 +29,7 @@ * Overrides for behat authentication. * @author Marcus Green * @copyright Titus Learning - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_auth extends behat_auth { public function i_log_out() { diff --git a/tests/behat/behat_theme_adaptable_behat_blocks.php b/tests/behat/behat_theme_adaptable_behat_blocks.php index dcb44af..bf0a49b 100644 --- a/tests/behat/behat_theme_adaptable_behat_blocks.php +++ b/tests/behat/behat_theme_adaptable_behat_blocks.php @@ -17,13 +17,13 @@ /** * Overrides for behat blocks. * @copyright Copyright (c) 2020 Titus - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. -use Behat\Mink\Exception\ExpectationException as ExpectationException, - Behat\Mink\Element\NodeElement as NodeElement; +use Behat\Mink\Exception\ExpectationException, + Behat\Mink\Element\NodeElement; require_once(__DIR__ . '/../../../../blocks/tests/behat/behat_blocks.php'); @@ -31,10 +31,9 @@ * Overrides to make behat block steps work with adaptable. * * @copyright Copyright (c) 2020 Titus. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_blocks extends behat_blocks { - /** * Adds the selected block. Editing mode must be previously enabled. * @@ -42,14 +41,16 @@ class behat_theme_adaptable_behat_blocks extends behat_blocks { * @return void */ public function i_add_the_block($blockname) { - $this->execute('behat_forms::i_set_the_field_to', - array("bui_addblock", $this->escape($blockname)) + $this->execute( + 'behat_forms::i_set_the_field_to', + ["bui_addblock", $this->escape($blockname)] ); // If we are running without javascript we need to submit the form. if (!$this->running_javascript()) { - $this->execute('behat_general::i_click_on_in_the', - array(get_string('go'), "button", "#add_block", "css_element") + $this->execute( + 'behat_general::i_click_on_in_the', + [get_string('go'), "button", "#add_block", "css_element"] ); } } diff --git a/tests/behat/behat_theme_adaptable_behat_grade.php b/tests/behat/behat_theme_adaptable_behat_grade.php index b3439f5..3a1d51e 100644 --- a/tests/behat/behat_theme_adaptable_behat_grade.php +++ b/tests/behat/behat_theme_adaptable_behat_grade.php @@ -20,14 +20,14 @@ * @package theme_classic * @category test * @copyright 2019 Michael Hawkins - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. require_once(__DIR__ . '/../../../../grade/tests/behat/behat_grade.php'); -use Behat\Gherkin\Node\TableNode as TableNode; +use Behat\Gherkin\Node\TableNode; /** * Behat grade overrides for the Adaptable theme. @@ -35,10 +35,9 @@ * @package theme_adaptable * @category test * @copyright 2019 Michael Hawkins (copied from theme_classic) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_grade extends behat_grade { - /** * Navigates to the course gradebook and selects a specified item from the grade navigation tabs. * @@ -48,8 +47,8 @@ public function i_navigate_to_in_the_course_gradebook($gradepath) { // If we are not on one of the gradebook pages already, follow "Grades" link in the navigation block. $xpath = '//div[contains(@class,\'grade-navigation\')]'; if (!$this->getSession()->getPage()->findAll('xpath', $xpath)) { - $this->execute("behat_general::i_click_on_in_the", array(get_string('grades'), 'link', - get_string('pluginname', 'block_navigation'), 'block')); + $this->execute("behat_general::i_click_on_in_the", [get_string('grades'), 'link', + get_string('pluginname', 'block_navigation'), 'block', ]); } $this->select_in_gradebook_tabs($gradepath); diff --git a/tests/behat/behat_theme_adaptable_behat_mod_quiz.php b/tests/behat/behat_theme_adaptable_behat_mod_quiz.php index 2ad47ca..61f7fcb 100644 --- a/tests/behat/behat_theme_adaptable_behat_mod_quiz.php +++ b/tests/behat/behat_theme_adaptable_behat_mod_quiz.php @@ -20,14 +20,14 @@ * @package theme_adaptable * @author Marcus Green * @copyright Titus 2020 - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. require_once(__DIR__ . '/../../../../mod/quiz/tests/behat/behat_mod_quiz.php'); -use Behat\Gherkin\Node\TableNode as TableNode; +use Behat\Gherkin\Node\TableNode; /** * Step definitions related to mod_quiz overrides for the adaptable theme. @@ -37,10 +37,9 @@ * @category test * @author Marcus Green * @copyright Titus 2020 - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_mod_quiz extends behat_mod_quiz { - /** * Adds a question to the existing quiz with filling the form. * The form for creating a question should be on one page. @@ -60,8 +59,8 @@ public function i_add_question_to_the_quiz_with($questiontype, $quizname, TableN $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", $editquiz); - $this->execute("behat_general::i_click_on", array($menuxpath, "xpath_element")); - $this->execute("behat_general::i_click_on", array($itemxpath, "xpath_element")); + $this->execute("behat_general::i_click_on", [$menuxpath, "xpath_element"]); + $this->execute("behat_general::i_click_on", [$itemxpath, "xpath_element"]); $this->finish_adding_question($questiontype, $questiondata); } diff --git a/tests/behat/behat_theme_adaptable_behat_navigation.php b/tests/behat/behat_theme_adaptable_behat_navigation.php index a0709fd..f48b172 100644 --- a/tests/behat/behat_theme_adaptable_behat_navigation.php +++ b/tests/behat/behat_theme_adaptable_behat_navigation.php @@ -18,24 +18,23 @@ * Overrides for behat navigation. * @author Marcus Green derived from code by Guy Thomas * @copyright Copyright (c) 2017 Blackboard Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. -use Behat\Mink\Exception\ExpectationException as ExpectationException; +use Behat\Mink\Exception\ExpectationException; -require_once (__DIR__ . '/../../../../lib/tests/behat/behat_navigation.php'); +require_once(__DIR__ . '/../../../../lib/tests/behat/behat_navigation.php'); /** * Overrides to make behat navigation work with adapt. * * @author Marcus Green derived from Snap theme * @copyright Titus Learning 2020 - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_navigation extends behat_navigation { - /** * Open an assignment or resource based on title. * @@ -152,7 +151,8 @@ public function i_follow_in_the_user_menu($nodetext) { // Now select the link. // The CSS path is always present, with or without JS. $xpath = "//div[@id='usermenu-dropdown']"; - $this->execute('behat_general::i_click_on_in_the', + $this->execute( + 'behat_general::i_click_on_in_the', [$nodetext, "link", $xpath, "xpath_element"] ); } diff --git a/tests/behat/behat_theme_adaptable_behat_permissions.php b/tests/behat/behat_theme_adaptable_behat_permissions.php index 3fbe7c9..e75621a 100644 --- a/tests/behat/behat_theme_adaptable_behat_permissions.php +++ b/tests/behat/behat_theme_adaptable_behat_permissions.php @@ -18,13 +18,13 @@ * Overrides for behat navigation. * @author Marcus Green * @copyright Titus Learning 2020 - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. -use Behat\Mink\Exception\ExpectationException as ExpectationException, - Behat\Mink\Element\NodeElement as NodeElement; +use Behat\Mink\Exception\ExpectationException, + Behat\Mink\Element\NodeElement; require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); require_once(__DIR__ . '/../../../../lib/tests/behat/behat_permissions.php'); @@ -34,7 +34,7 @@ * * @author Marcus Green * @copyright Titus Learning 2020 - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_permissions extends behat_permissions { public function i_set_the_following_system_permissions_of_role($rolename, $table) { @@ -44,7 +44,7 @@ public function i_set_the_following_system_permissions_of_role($rolename, $table $rolename = "editingteacher"; } // Find role by name. - $roleid = $DB->get_field('role', 'id', array('shortname' => strtolower($rolename)), MUST_EXIST); + $roleid = $DB->get_field('role', 'id', ['shortname' => strtolower($rolename)], MUST_EXIST); // Spawn a new system context instance. $systemcontext = context_system::instance(); /* Add capabilities to role given the table of capabilities. @@ -55,14 +55,14 @@ public function i_set_the_following_system_permissions_of_role($rolename, $table throw new ExpectationException($msg, $this->getSession()); } - list($capability, $permission) = $row; + [$capability, $permission] = $row; // Skip the headers row if it was provided. if (strtolower($capability) == 'capability' || strtolower($capability) == 'capabilities') { continue; } // Checking the permission value. - $permissionconstant = 'CAP_'. strtoupper($permission); + $permissionconstant = 'CAP_' . strtoupper($permission); if (!defined($permissionconstant)) { throw new ExpectationException( 'The provided permission value "' . $permission . '" is not valid. Use Inherit, Allow, Prevent or Prohibited', @@ -72,13 +72,16 @@ public function i_set_the_following_system_permissions_of_role($rolename, $table // Converting from permission to constant value. $permissionvalue = constant($permissionconstant); - \assign_capability($capability, $permissionvalue, - $roleid, $systemcontext->id, true); - + \assign_capability( + $capability, + $permissionvalue, + $roleid, + $systemcontext->id, + true + ); } $systemcontext->mark_dirty(); accesslib_clear_role_cache($roleid); - } /** * Overrides system capabilities at category, course and module levels. @@ -93,26 +96,25 @@ public function i_override_the_system_permissions_of_role_with($rolename, $table $rolename = "editingteacher"; } // Find role by name. - $roleid = $DB->get_field('role', 'id', array('shortname' => strtolower($rolename)), MUST_EXIST); + $roleid = $DB->get_field('role', 'id', ['shortname' => strtolower($rolename)], MUST_EXIST); // Spawn a new system context instance. $systemcontext = context_system::instance(); /* Add capabilities to role given the table of capabilities. Using getRows() as we are not sure if tests writers will add the header. */ foreach ($table->getRows() as $key => $row) { - if (count($row) !== 2) { $msg = 'You should specify a table with capability/permission columns'; throw new ExpectationException($msg, $this->getSession()); } - list($capability, $permission) = $row; + [$capability, $permission] = $row; // Skip the headers row if it was provided. if (strtolower($capability) == 'capability' || strtolower($capability) == 'capabilities') { continue; } // Checking the permission value. - $permissionconstant = 'CAP_'. strtoupper($permission); + $permissionconstant = 'CAP_' . strtoupper($permission); if (!defined($permissionconstant)) { throw new ExpectationException( 'The provided permission value "' . $permission . '" is not valid. Use Inherit, Allow, Prevent or Prohibited', @@ -123,12 +125,16 @@ public function i_override_the_system_permissions_of_role_with($rolename, $table // Converting from permission to constant value. $permissionvalue = constant($permissionconstant); - \assign_capability($capability, $permissionvalue, - $roleid, $systemcontext->id, true); + \assign_capability( + $capability, + $permissionvalue, + $roleid, + $systemcontext->id, + true + ); $systemcontext->mark_dirty(); accesslib_clear_role_cache($roleid); - } } } diff --git a/tests/behat/behat_theme_adaptable_behat_repository_upload.php b/tests/behat/behat_theme_adaptable_behat_repository_upload.php index 053e1a4..3b1e704 100644 --- a/tests/behat/behat_theme_adaptable_behat_repository_upload.php +++ b/tests/behat/behat_theme_adaptable_behat_repository_upload.php @@ -20,14 +20,14 @@ * @package theme_adaptable * @category test * @copyright 2019 Michael Hawkins (copied from theme_clasic) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. require_once(__DIR__ . '/../../../../repository/upload/tests/behat/behat_repository_upload.php'); -use Behat\Mink\Exception\ExpectationException as ExpectationException; +use Behat\Mink\Exception\ExpectationException; /** * Override definitions for the upload repository type for the Adaptable theme. @@ -35,10 +35,9 @@ * @package theme_adaptable * @category test * @copyright 2019 Michael Hawkins (copied from theme_clasic) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_repository_upload extends behat_repository_upload { - /** * Gets the NodeElement for filepicker of filemanager moodleform element. * diff --git a/tests/behat/core_auth/behat_theme_adaptable_behat_auth.php b/tests/behat/core_auth/behat_theme_adaptable_behat_auth.php index 8519dcc..302ec77 100644 --- a/tests/behat/core_auth/behat_theme_adaptable_behat_auth.php +++ b/tests/behat/core_auth/behat_theme_adaptable_behat_auth.php @@ -20,7 +20,7 @@ * @package theme_adaptable * @category test * @copyright © 2020 G J Barnard. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. @@ -32,7 +32,7 @@ * @package theme_adaptable * @category test * @copyright © 2020 G J Barnard. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class behat_theme_adaptable_behat_auth extends behat_auth { /** @@ -45,6 +45,6 @@ public function i_log_out() { // Click on logout link in user menu on the navbar. $this->execute('behat_general::i_click_on', ['#usermenu', 'css_element']); - $this->execute('behat_general::i_click_on_in_the', array(get_string('logout'), 'link', '#usermenu-dropdown', "css_element")); + $this->execute('behat_general::i_click_on_in_the', [get_string('logout'), 'link', '#usermenu-dropdown', "css_element"]); } } diff --git a/tests/theme_adaptable_toolbox_test.php b/tests/theme_adaptable_toolbox_test.php index 709b588..b57729b 100644 --- a/tests/theme_adaptable_toolbox_test.php +++ b/tests/theme_adaptable_toolbox_test.php @@ -20,17 +20,16 @@ * @package theme_adaptable * @copyright © 2018 G J Barnard. * @author G J Barnard - {@link http://moodle.org/user/profile.php?id=442195} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ /** * Toolbox unit tests for the Adaptable theme. * @group theme_adaptable * @copyright Copyright (c) 2017 Manoj Solanki (Coventry University) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ class theme_adaptable_toolbox_test extends advanced_testcase { - protected function setUp(): void { $this->resetAfterTest(true); diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml index 5232bc8..22df480 100644 --- a/thirdpartylibs.xml +++ b/thirdpartylibs.xml @@ -3,114 +3,219 @@ ../boost/scss/bootstrap Twitter Bootstrap + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 MIT - 4.6.0 - + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/alert.js bootstrap-alert - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/button.js - bootstrap-button - (MIT) - v4.6.0 + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/carousel.js bootstrap-carousel - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/collapse.js bootstrap-collapse - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/dropdown.js bootstrap-dropdown - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/modal.js bootstrap-modal - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/popover.js bootstrap-popover - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/tools/sanitizer.js bootstrap-sanitizer - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/scrollspy.js bootstrap-scrollspy - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/tab.js bootstrap-tab - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/toast.js bootstrap-toast - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/tooltip.js bootstrap-tooltip - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/bootstrap/util.js bootstrap-util - (MIT) - v4.6.0 - + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + ../boost/amd/src/index.js bootstrap-util + HTML, CSS, and JavaScript framework for developing responsive, mobile-first projects on the web. + 4.6.2 + MIT + https://github.com/twbs/bootstrap + + 2011-2021 Twitter, Inc + 2011-2021 The Bootstrap Authors + + + + + ../boost/scss/fontawesome + Font Awesome - http://fontawesome.com + Font Awesome CSS, LESS, and Sass files. Font Awesome is the Internet's icon library and toolkit, used by millions of designers, developers, and content creators. + 6.4.0 (MIT) - v4.6.0 - + https://github.com/FortAwesome/Font-Awesome + + 2023 Fonticons, Inc + - ../boost/scss/fontawesome/ - Font Awesome by Dave Gandy - http://fontawesome.io - Documentation: CC BY 3.0, Fonts: SIL OFL 1.1, Code: MIT License - 4.7.0 - + scss/fontawesome + Font Awesome - http://fontawesome.com + Font Awesome is the Internet's icon library and toolkit, used by millions of designers, developers, and content creators. + 6.4.2 + (MIT) + https://github.com/FortAwesome/Font-Awesome + + 2023 Fonticons, Inc + ./jquery/jquery-easing-min.js @@ -140,13 +245,6 @@ 1.0 - - ./pix_plugins/ - Font Awesome 6 - free - https://fontawesome.com - Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License - 6.2.1 - - diff --git a/version.php b/version.php index 1bd089f..16f06e5 100644 --- a/version.php +++ b/version.php @@ -17,13 +17,14 @@ /** * Version details * - * @package theme_adaptable - * @copyright 2015-2019 Jeremy Hopkins (Coventry University) - * @copyright 2015-2019 Fernando Acedo (3-bits.com) - * @copyright 2017-2019 Manoj Solanki (Coventry University) - * @copyright 2019-onwards G J Barnard - {@link http://moodle.org/user/profile.php?id=442195} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * + * @package theme_adaptable + * @copyright 2015-2019 Jeremy Hopkins (Coventry University) + * @copyright 2015-2019 Fernando Acedo (3-bits.com) + * @copyright 2017-2019 Manoj Solanki (Coventry University) + * @copyright 2019 G J Barnard + * {@link https://moodle.org/user/profile.php?id=442195} + * {@link https://gjbarnard.co.uk} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ defined('MOODLE_INTERNAL') || die; @@ -32,19 +33,19 @@ $plugin->component = 'theme_adaptable'; // Adaptable version date (YYYYMMDDrr where rr is the release number). -$plugin->version = 2022112306; +$plugin->version = 2023092500; -$plugin->requires = 2022112800.00; // 4.1 (Build: 20221128). +$plugin->requires = 2023042400.00; // 4.2 (Build: 20230424). -$plugin->supported = array(401, 401); +$plugin->supported = [402, 402]; // Adaptable version using SemVer (https://semver.org). -$plugin->release = '401.1.5'; +$plugin->release = '402.0.1'; // Adaptable maturity (do not use ALPHA or BETA versions in production sites). -$plugin->maturity = MATURITY_STABLE; +$plugin->maturity = MATURITY_RC; // Adaptable dependencies (Only Boost as it's the parent theme). -$plugin->dependencies = array( - 'theme_boost' => 2022112800 -); +$plugin->dependencies = [ + 'theme_boost' => 2023042400, +];