| 1456 | ariadna | 1 | <?php
 | 
        
           |  |  | 2 | // This file is part of Moodle - http://moodle.org/
 | 
        
           |  |  | 3 | //
 | 
        
           |  |  | 4 | // Moodle is free software: you can redistribute it and/or modify
 | 
        
           |  |  | 5 | // it under the terms of the GNU General Public License as published by
 | 
        
           |  |  | 6 | // the Free Software Foundation, either version 3 of the License, or
 | 
        
           |  |  | 7 | // (at your option) any later version.
 | 
        
           |  |  | 8 | //
 | 
        
           |  |  | 9 | // Moodle is distributed in the hope that it will be useful,
 | 
        
           |  |  | 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
        
           |  |  | 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
        
           |  |  | 12 | // GNU General Public License for more details.
 | 
        
           |  |  | 13 | //
 | 
        
           |  |  | 14 | // You should have received a copy of the GNU General Public License
 | 
        
           |  |  | 15 | // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 | 
        
           |  |  | 16 |   | 
        
           |  |  | 17 | /**
 | 
        
           |  |  | 18 |  *
 | 
        
           |  |  | 19 |  * @package   theme_universe
 | 
        
           |  |  | 20 |  * @copyright 2023 Marcin Czaja (https://rosea.io)
 | 
        
           |  |  | 21 |  * @license   Commercial https://themeforest.net/licenses
 | 
        
           |  |  | 22 |  *
 | 
        
           |  |  | 23 |  */
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 | defined('MOODLE_INTERNAL') || die();
 | 
        
           |  |  | 26 | global $PAGE, $OUTPUT;
 | 
        
           |  |  | 27 |   | 
        
           |  |  | 28 | // Variables - Settings.
 | 
        
           |  |  | 29 | $block4introsubtitle = format_text(theme_universe_get_setting('block4introsubtitle'), FORMAT_HTML, array('noclean' => true));
 | 
        
           |  |  | 30 | $block4wrapperalign = theme_universe_get_setting('block4wrapperalign');
 | 
        
           |  |  | 31 | $block4titlecolor = theme_universe_get_setting('block4herotitlecolor');
 | 
        
           |  |  | 32 | $block4herotitlesize = theme_universe_get_setting('block4herotitlesize');
 | 
        
           |  |  | 33 | $block4titleweight = theme_universe_get_setting('block4herotitleweight');
 | 
        
           |  |  | 34 | $block4count = theme_universe_get_setting('block4count');
 | 
        
           |  |  | 35 | $block4class = theme_universe_get_setting('block4class');
 | 
        
           |  |  | 36 |   | 
        
           |  |  | 37 | if (!empty(theme_universe_get_setting('block4sliderinterval'))) {
 | 
        
           |  |  | 38 |     $block4sliderinterval = theme_universe_get_setting('block4sliderinterval');
 | 
        
           |  |  | 39 | } else {
 | 
        
           |  |  | 40 |     $block4sliderinterval = '7000';
 | 
        
           |  |  | 41 | }
 | 
        
           |  |  | 42 |   | 
        
           |  |  | 43 | // Customm ID for the block.
 | 
        
           |  |  | 44 | $block4customid = theme_universe_get_setting('block4id');
 | 
        
           |  |  | 45 | $fpblockid4 = 'block4';
 | 
        
           |  |  | 46 | if (!empty($block4customid)) {
 | 
        
           |  |  | 47 |     $fpblockid5 = $block4customid;
 | 
        
           |  |  | 48 | }
 | 
        
           |  |  | 49 | // End.
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 | // Start Title - Alignment.
 | 
        
           |  |  | 52 | $block4wrapperalignclass = null;
 | 
        
           |  |  | 53 | if ($block4wrapperalign == 0) {
 | 
        
           |  |  | 54 |     $block4wrapperalignclass = 'rui-hero-content-left';
 | 
        
           |  |  | 55 | }
 | 
        
           |  |  | 56 |   | 
        
           |  |  | 57 | if ($block4wrapperalign == 1) {
 | 
        
           |  |  | 58 |     $block4wrapperalignclass = 'rui-hero-content-centered';
 | 
        
           |  |  | 59 | }
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 | if ($block4wrapperalign == 2) {
 | 
        
           |  |  | 62 |     $block4wrapperalignclass = 'rui-hero-content-right';
 | 
        
           |  |  | 63 | }
 | 
        
           |  |  | 64 | // End.
 | 
        
           |  |  | 65 |   | 
        
           |  |  | 66 | // Start Title - Color.
 | 
        
           |  |  | 67 | $block4titlecolorclass = null;
 | 
        
           |  |  | 68 | if ($block4titlecolor == 0) {
 | 
        
           |  |  | 69 |     $block4titlecolorclass = ' rui-text--white';
 | 
        
           |  |  | 70 | }
 | 
        
           |  |  | 71 |   | 
        
           |  |  | 72 | if ($block4titlecolor == 1) {
 | 
        
           |  |  | 73 |     $block4titlecolorclass = ' rui-text--black';
 | 
        
           |  |  | 74 | }
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 | if ($block4titlecolor == 2) {
 | 
        
           |  |  | 77 |     $block4titlecolorclass = ' rui-text--gradient';
 | 
        
           |  |  | 78 | }
 | 
        
           |  |  | 79 | // End.
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 | // Start Title - Weight.
 | 
        
           |  |  | 82 | $block4titleweightclass = null;
 | 
        
           |  |  | 83 | if ($block4titleweight == 0) {
 | 
        
           |  |  | 84 |     $block4titleweightclass = ' rui-text--weight-normal';
 | 
        
           |  |  | 85 | }
 | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 | if ($block4titleweight == 1) {
 | 
        
           |  |  | 88 |     $block4titleweightclass = ' rui-text--weight-medium';
 | 
        
           |  |  | 89 | }
 | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 | if ($block4titleweight == 2) {
 | 
        
           |  |  | 92 |     $block4titleweightclass = ' rui-text--weight-bold';
 | 
        
           |  |  | 93 | }
 | 
        
           |  |  | 94 | // End.
 | 
        
           |  |  | 95 |   | 
        
           |  |  | 96 | // Start Title - Size.
 | 
        
           |  |  | 97 | $block4herotitlesizeclass = null;
 | 
        
           |  |  | 98 | if ($block4herotitlesize == 0) {
 | 
        
           |  |  | 99 |     $block4herotitlesizeclass = '';
 | 
        
           |  |  | 100 | }
 | 
        
           |  |  | 101 |   | 
        
           |  |  | 102 | if ($block4herotitlesize == 1) {
 | 
        
           |  |  | 103 |     $block4herotitlesizeclass = ' rui-hero-title-lg';
 | 
        
           |  |  | 104 | }
 | 
        
           |  |  | 105 |   | 
        
           |  |  | 106 | if ($block4herotitlesize == 2) {
 | 
        
           |  |  | 107 |     $block4herotitlesizeclass = ' rui-hero-title-xl';
 | 
        
           |  |  | 108 | }
 | 
        
           |  |  | 109 | // End.
 | 
        
           |  |  | 110 |   | 
        
           |  |  | 111 | if (theme_universe_get_setting('showblock4sliderwrapper') == '1') {
 | 
        
           |  |  | 112 |     $class = 'rui-hero-content-backdrop rui-hero-content-backdrop--block4';
 | 
        
           |  |  | 113 | } else {
 | 
        
           |  |  | 114 |     $class = '';
 | 
        
           |  |  | 115 | }
 | 
        
           |  |  | 116 |   | 
        
           |  |  | 117 | echo '<!-- Start Block #1 -->';
 | 
        
           |  |  | 118 |   | 
        
           |  |  | 119 | if (theme_universe_get_setting('block4fw') == '1') {
 | 
        
           |  |  | 120 |     echo '<div id="' . $fpblockid4 . '" class="wrapper-fw rui-fp-block--4 rui-fp-margin-bottom ' . $block4class . '">';
 | 
        
           |  |  | 121 | } else {
 | 
        
           |  |  | 122 |     echo '<div id="' . $fpblockid4 . '" class="wrapper-lg rui-fp-block--4 rui-fp-margin-bottom mt-3 ' . $block4class . '">';
 | 
        
           |  |  | 123 | }
 | 
        
           |  |  | 124 |   | 
        
           |  |  | 125 |   | 
        
           |  |  | 126 | echo '<div class="swiper swiper-block--4 pb-0">';
 | 
        
           |  |  | 127 | echo '<div class="swiper-wrapper">';
 | 
        
           |  |  | 128 |   | 
        
           |  |  | 129 | for ($i = 1; $i <= $block4count; $i++) {
 | 
        
           |  |  | 130 |   | 
        
           |  |  | 131 |     $title = format_text(theme_universe_get_setting("block4slidetitle" . $i), FORMAT_HTML, array('noclean' => true));
 | 
        
           |  |  | 132 |     $caption = format_text(theme_universe_get_setting("block4slidecaption" . $i), FORMAT_HTML, array('noclean' => true));
 | 
        
           |  |  | 133 |     $css = theme_universe_get_setting("block4slidecss" . $i);
 | 
        
           |  |  | 134 |     $img = $PAGE->theme->setting_file_url("block4slideimg" . $i, "block4slideimg" . $i);
 | 
        
           |  |  | 135 |   | 
        
           |  |  | 136 |     if (!empty($css)) {
 | 
        
           |  |  | 137 |         echo '<div class="rui-hero-bg swiper-slide">';
 | 
        
           |  |  | 138 |     } else {
 | 
        
           |  |  | 139 |         echo '<div class="rui-hero-bg swiper-slide" style="' . $css . '">';
 | 
        
           |  |  | 140 |     }
 | 
        
           |  |  | 141 |   | 
        
           |  |  | 142 |     if (!empty($caption) || !empty($title)) {
 | 
        
           |  |  | 143 |         echo '<div class="rui-hero-content rui-hero--slide ' .
 | 
        
           |  |  | 144 |         $class .
 | 
        
           |  |  | 145 |         ' rui-hero-content-position ' .
 | 
        
           |  |  | 146 |         $block4wrapperalignclass .
 | 
        
           |  |  | 147 |         '">';
 | 
        
           |  |  | 148 |     }
 | 
        
           |  |  | 149 |   | 
        
           |  |  | 150 |     if (!empty($title)) {
 | 
        
           |  |  | 151 |         echo '<h3 class="rui-hero-title' .
 | 
        
           |  |  | 152 |             $block4titlecolorclass .
 | 
        
           |  |  | 153 |             $block4titleweightclass .
 | 
        
           |  |  | 154 |             $block4herotitlesizeclass .
 | 
        
           |  |  | 155 |             '">' . $title . '</h3>';
 | 
        
           |  |  | 156 |     }
 | 
        
           |  |  | 157 |   | 
        
           |  |  | 158 |     if (!empty($caption)) {
 | 
        
           |  |  | 159 |         echo '<div class="rui-hero-desc">' . $caption . '</div>';
 | 
        
           |  |  | 160 |     }
 | 
        
           |  |  | 161 |   | 
        
           |  |  | 162 |     if (!empty($caption) || !empty($title)) {
 | 
        
           |  |  | 163 |         echo '</div>';
 | 
        
           |  |  | 164 |     }
 | 
        
           |  |  | 165 |   | 
        
           |  |  | 166 |     echo '<img class="d-flex img-fluid w-100" src="' . $img . '" alt="' . $title . '" />';
 | 
        
           |  |  | 167 |     echo '</div>';
 | 
        
           |  |  | 168 | }
 | 
        
           |  |  | 169 |   | 
        
           |  |  | 170 | echo '</div>';
 | 
        
           |  |  | 171 | echo '<div class="d-none d-md-flex swiper-button-next"></div>';
 | 
        
           |  |  | 172 | echo '<div class="d-none d-md-flex swiper-button-prev"></div>';
 | 
        
           |  |  | 173 | echo '<div class="swiper-pagination"></div>';
 | 
        
           |  |  | 174 | echo '</div>';
 | 
        
           |  |  | 175 | echo '</div>';
 | 
        
           |  |  | 176 |   | 
        
           |  |  | 177 | /*
 | 
        
           |  |  | 178 |     function reportWindowSize() {
 | 
        
           |  |  | 179 |         // Align center content of the hero
 | 
        
           |  |  | 180 |         var el = document.getElementsByClassName("rui-hero-content");
 | 
        
           |  |  | 181 |         for (var i=0, len=el.length|0; i<len; i=i+1|0) {
 | 
        
           |  |  | 182 |             var sidebarContentHeight = el[i].offsetHeight;
 | 
        
           |  |  | 183 |             el[i].style.top = "calc(50% - " + sidebarContentHeight * 0.5+ "px)";
 | 
        
           |  |  | 184 |         }
 | 
        
           |  |  | 185 |     }
 | 
        
           |  |  | 186 |   | 
        
           |  |  | 187 |     window.addEventListener("resize", reportWindowSize);
 | 
        
           |  |  | 188 |     window.onload = reportWindowSize();
 | 
        
           |  |  | 189 | */
 | 
        
           |  |  | 190 | echo '<script>function reportWindowSize(){for(var e=document.getElementsByClassName("rui-hero--slide"),
 | 
        
           |  |  | 191 | o=0,t=0|e.length;o<t;o=o+1|0){var n=e[o].offsetHeight;e[o].style.top="calc(50% - "+n/2+"px)"}}
 | 
        
           |  |  | 192 | window.addEventListener("resize",reportWindowSize),
 | 
        
           |  |  | 193 | window.onload=reportWindowSize();</script>';
 | 
        
           |  |  | 194 | echo '<!-- End Block #1 -->';
 | 
        
           |  |  | 195 |   | 
        
           |  |  | 196 | echo '<script>var swiper=new Swiper(".swiper-block--4",{slidesPerView:1,
 | 
        
           |  |  | 197 | pagination:{el:".swiper-pagination",type:"progressbar"},
 | 
        
           |  |  | 198 | navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},
 | 
        
           |  |  | 199 | autoplay: {delay: ' . $block4sliderinterval . ',},
 | 
        
           |  |  | 200 | keyboard:{enabled:!0},mousewheel:{releaseOnEdges:!0},effect:"creative",
 | 
        
           |  |  | 201 | autoHeight:!0,creativeEffect:{prev:{shadow:!0,translate:["-20%",0,-1]},
 | 
        
           |  |  | 202 | next:{translate:["100%",0,0]}},breakpoints:{}});</script>';
 |