From 40172a867ddbdf686d4ed5b71302fd65fa71cb48 Mon Sep 17 00:00:00 2001 From: Kathrin Osswald <kathrin.osswald@uni-ulm.de> Date: Tue, 25 Aug 2020 12:26:00 +0200 Subject: [PATCH] Changed calling of footer and footnote layouts to fix behat issues. --- CHANGES.md | 1 + layout/columns2.php | 34 +++++---------------------- layout/includes/footer.php | 44 +++++++---------------------------- layout/includes/footnote.php | 2 -- layout/includes/imagearea.php | 1 - layout/login.php | 23 +++--------------- templates/columns2.mustache | 10 ++++---- templates/footer.mustache | 6 ++--- templates/footnote.mustache | 3 ++- templates/imagearea.mustache | 3 ++- templates/login.mustache | 2 +- 11 files changed, 31 insertions(+), 98 deletions(-) mode change 100644 => 100755 layout/includes/footer.php mode change 100644 => 100755 layout/includes/footnote.php mode change 100644 => 100755 layout/includes/imagearea.php diff --git a/CHANGES.md b/CHANGES.md index e512a1b..2083427 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2020-08-25 - Changed calling of footer and footnote layouts to fix behat issues. * 2020-08-25 - Fixed favicon 404 Error when no individual favicon is uploaded in Boost Campus. * 2020-08-19 - Added capability theme/boost_campus:viewhintinhiddencourse for setting showhintcoursehidden. * 2020-08-14 - Reduced inflationary call to reset theme caches for the settings. diff --git a/layout/columns2.php b/layout/columns2.php index 49743f7..16aa21c 100644 --- a/layout/columns2.php +++ b/layout/columns2.php @@ -169,36 +169,14 @@ ORIGINAL END. */ $templatecontext['firstcollectionlabel'] = $nav->get_collectionlabel(); -// MODIFICATION START: Handle additional layout elements. -// The output buffer is needed to render the additional layout elements now without outputting them to the page directly. -ob_start(); - -// Require additional layout files. -// Add footer blocks and standard footer. +// MODIFICATION START. +// Set the template context for the footer and additional layouts. require_once(__DIR__ . '/includes/footer.php'); -// Get imageareaitems config. -$imageareaitems = get_config('theme_boost_campus', 'imageareaitems'); -if (!empty($imageareaitems)) { - // Add imagearea layout file. - require_once(__DIR__ . '/includes/imagearea.php'); -} -// Get footnote config. -$footnote = get_config('theme_boost_campus', 'footnote'); -if (!empty($footnote)) { - // Add footnote layout file. - require_once(__DIR__ . '/includes/footnote.php'); -} - -// Get output buffer. -$pagebottomelements = ob_get_clean(); - -// If there isn't anything in the buffer, set the additional layouts string to an empty string to avoid problems later on. -if ($pagebottomelements == false) { - $pagebottomelements = ''; -} -// Add the additional layouts to the template context. -$templatecontext['pagebottomelements'] = $pagebottomelements; +require_once(__DIR__ . '/includes/imagearea.php'); +require_once(__DIR__ . '/includes/footnote.php'); +// MODIFICATION END. +// MODIFICATION START. // Render columns2.mustache from boost_campus. echo $OUTPUT->render_from_template('theme_boost_campus/columns2', $templatecontext); // MODIFICATION END. diff --git a/layout/includes/footer.php b/layout/includes/footer.php old mode 100644 new mode 100755 index c7f0085..be7da0d --- a/layout/includes/footer.php +++ b/layout/includes/footer.php @@ -27,49 +27,23 @@ defined('MOODLE_INTERNAL') || die(); $footerblocksetting = get_config('theme_boost_campus', 'footerblocks'); -// Setting is set to no footer blocks layout. -if ($footerblocksetting === '0columns') { - echo $OUTPUT->render_from_template('theme_boost_campus/footer', $templatecontext); -} - // Setting is set to one columns layout. if ($footerblocksetting === '1columns') { - $footerblock1columns = true; - - $footerleftblockshtml = $OUTPUT->blocks('footer-left'); - - $templatecontext['footerleftblocks'] = $footerleftblockshtml; - $templatecontext['footerblock1columns'] = $footerblock1columns; - - echo $OUTPUT->render_from_template('theme_boost_campus/footer', $templatecontext); + $templatecontext['footerleftblocks'] = $OUTPUT->blocks('footer-left'); + $templatecontext['footerblock1columns'] = true; } // Setting is set to two columns layout. if ($footerblocksetting === '2columns') { - $footerblock2columns = true; - - $footerleftblockshtml = $OUTPUT->blocks('footer-left'); - $footerrightblockshtml = $OUTPUT->blocks('footer-right'); - - $templatecontext['footerleftblocks'] = $footerleftblockshtml; - $templatecontext['footerrightblocks'] = $footerrightblockshtml; - $templatecontext['footerblock2columns'] = $footerblock2columns; - - echo $OUTPUT->render_from_template('theme_boost_campus/footer', $templatecontext); + $templatecontext['footerleftblocks'] = $OUTPUT->blocks('footer-left'); + $templatecontext['footerrightblocks'] = $OUTPUT->blocks('footer-right'); + $templatecontext['footerblock2columns'] = true; } // Setting is set to three columns layout. if ($footerblocksetting === '3columns') { - $footerblock3columns = true; - - $footerleftblockshtml = $OUTPUT->blocks('footer-left'); - $footermiddleblockshtml = $OUTPUT->blocks('footer-middle'); - $footerrightblockshtml = $OUTPUT->blocks('footer-right'); - - $templatecontext['footerleftblocks'] = $footerleftblockshtml; - $templatecontext['footermiddleblocks'] = $footermiddleblockshtml; - $templatecontext['footerrightblocks'] = $footerrightblockshtml; - $templatecontext['footerblock3columns'] = $footerblock3columns; - - echo $OUTPUT->render_from_template('theme_boost_campus/footer', $templatecontext); + $templatecontext['footerleftblocks'] = $OUTPUT->blocks('footer-left'); + $templatecontext['footermiddleblocks'] = $OUTPUT->blocks('footer-middle'); + $templatecontext['footerrightblocks'] = $OUTPUT->blocks('footer-right'); + $templatecontext['footerblock3columns'] = true; } diff --git a/layout/includes/footnote.php b/layout/includes/footnote.php old mode 100644 new mode 100755 index 99aca1e..3a27a45 --- a/layout/includes/footnote.php +++ b/layout/includes/footnote.php @@ -33,6 +33,4 @@ if (!html_is_blank($footnotesetting)) { $footnotesetting = format_text($footnotesetting); $templatecontext['footnotesetting'] = $footnotesetting; - - echo $OUTPUT->render_from_template('theme_boost_campus/footnote', $templatecontext); } diff --git a/layout/includes/imagearea.php b/layout/includes/imagearea.php old mode 100644 new mode 100755 index 7e2925b..2478973 --- a/layout/includes/imagearea.php +++ b/layout/includes/imagearea.php @@ -31,5 +31,4 @@ $imageareafiles = theme_boost_campus_get_imageareacontent(); // Only proceed if received array is not empty. if (!empty($imageareafiles)) { $templatecontext['imageareafiles'] = $imageareafiles; - echo $OUTPUT->render_from_template('theme_boost_campus/imagearea', $templatecontext); } diff --git a/layout/login.php b/layout/login.php index 7989066..2d4c3f8 100644 --- a/layout/login.php +++ b/layout/login.php @@ -87,30 +87,13 @@ if ($timedibenable) { // MODIFICATION END. // MODIFICATION START: Handle additional layout elements. -// The output buffer is needed to render the additional layout elements now without outputting them to the page directly. -ob_start(); - -// Include own layout file for the footnote region. // The theme_boost/login template already renders the standard footer. // The footer blocks and the image area are currently not shown on the login page. // Here, we will add the footnote only. -// Get footnote config. -$footnote = get_config('theme_boost_campus', 'footnote'); -if (!empty($footnote)) { - // Add footnote layout file. - require_once(__DIR__ . '/includes/footnote.php'); -} - -// Get output buffer. -$pagebottomelements = ob_get_clean(); - -// If there isn't anything in the buffer, set the additional layouts string to an empty string to avoid problems later on. -if ($pagebottomelements == false) { - $pagebottomelements = ''; -} -// Add the additional layouts to the template context. -$templatecontext['pagebottomelements'] = $pagebottomelements; +require_once(__DIR__ . '/includes/footnote.php'); +// MODIFICATION END. +// MODIFICATION START. // Render own template. echo $OUTPUT->render_from_template('theme_boost_campus/login', $templatecontext); // MODIFICATION END. diff --git a/templates/columns2.mustache b/templates/columns2.mustache index f1a8aab..d9d56bb 100644 --- a/templates/columns2.mustache +++ b/templates/columns2.mustache @@ -71,8 +71,8 @@ * If setting "showsettingsincourse" is enabled, then render course context menu from theme_boost_campus/settings_link_page template and use the equivalent own javascript "incoursesettings". * Call to own navbar mustache template instead of boost/navbar. - * Add own additional layout elements: the footer, footnote or image area. - * Moved the variable output.standard_end_of_body_html from footer.mustache to solve Javascript issues with behat tests. + * Use own footer instead of the theme_boost footer. + * Add own additional layout elements: footnote or image area. * Added the possibility to show information banners. }} {{> theme_boost/head }} @@ -141,10 +141,10 @@ </div> </div> {{{ output.standard_after_main_region_html }}} - {{{ pagebottomelements }}} + {{> theme_boost_campus/footer }} + {{> theme_boost_campus/imagearea }} + {{> theme_boost_campus/footnote }} </div> -{{! Moved the variable here from footer.mustache to solve Javascript issues with behat tests. }} -{{{ output.standard_end_of_body_html }}} </body> </html> diff --git a/templates/footer.mustache b/templates/footer.mustache index ba4a231..e6f1ddc 100644 --- a/templates/footer.mustache +++ b/templates/footer.mustache @@ -34,7 +34,7 @@ } }} {{! MODIFICATION: - * Moved the variable output.standard_end_of_body_html to the end of the columns2.mustache template to solve Javascript issues with behat tests. + * Add footer blocks. }} <footer id="page-footer" class="py-3 bg-dark text-light"> <div class="container-fluid"> @@ -106,9 +106,7 @@ {{/ output.custom_menu_flat }} </nav> {{{ output.standard_footer_html }}} - {{! Moved the variable - output.standard_end_of_body_html - to the end of the columns2.mustache template to solve Javascript issues with behat tests. }} + {{{ output.standard_end_of_body_html }}} </div> </div> </div> diff --git a/templates/footnote.mustache b/templates/footnote.mustache index 17354d1..56c1a2f 100644 --- a/templates/footnote.mustache +++ b/templates/footnote.mustache @@ -28,6 +28,7 @@ } }} +{{# footnotesetting }} <div class="footnote p-3 bg-dark text-light"> <div class="container-fluid"> <div class="row-fluid"> @@ -35,4 +36,4 @@ </div> </div> </div> - +{{/ footnotesetting }} diff --git a/templates/imagearea.mustache b/templates/imagearea.mustache index e02ad2d..4d8ad44 100644 --- a/templates/imagearea.mustache +++ b/templates/imagearea.mustache @@ -36,9 +36,10 @@ }} +{{# imageareafiles }} <div class="imagearea d-flex justify-content-center flex-wrap pb-3 bg-dark"> {{#imageareafiles}} {{#linkpath}}<a href="{{linkpath}}">{{/linkpath}}<img src="{{filepath}}" class="mt-3" {{#alttext}} alt="{{alttext}}"{{/alttext}}>{{#linkpath}}</a>{{/linkpath}} {{/imageareafiles}} </div> - +{{/ imageareafiles }} diff --git a/templates/login.mustache b/templates/login.mustache index 7fa605e..7f09db4 100644 --- a/templates/login.mustache +++ b/templates/login.mustache @@ -100,7 +100,7 @@ {{{ output.standard_end_of_body_html }}} </div> </footer> - {{{ pagebottomelements }}} + {{> theme_boost_campus/footnote }} </div> -- GitLab