| 1 | 
           efrain | 
           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 | 
            * A one column layout for the universe theme.
  | 
        
        
            | 
            | 
           19 | 
            *
  | 
        
        
            | 
            | 
           20 | 
            * @package   theme_universe
  | 
        
        
            | 
            | 
           21 | 
            * @copyright 2023 Marcin Czaja (https://rosea.io)
  | 
        
        
            | 
            | 
           22 | 
            * @license   Commercial https://themeforest.net/licenses
  | 
        
        
            | 
            | 
           23 | 
            */
  | 
        
        
            | 
            | 
           24 | 
              | 
        
        
            | 
            | 
           25 | 
           defined('MOODLE_INTERNAL') || die();
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           require_once($CFG->libdir . '/behat/lib.php');
  | 
        
        
            | 
            | 
           28 | 
           require_once($CFG->dirroot . '/course/lib.php');
  | 
        
        
            | 
            | 
           29 | 
              | 
        
        
            | 
            | 
           30 | 
           $draweropenright = false;
  | 
        
        
            | 
            | 
           31 | 
           $extraclasses = [];
  | 
        
        
            | 
            | 
           32 | 
              | 
        
        
            | 
            | 
           33 | 
           // Moodle 4. - Add block button in editing mode.
  | 
        
        
            | 
            | 
           34 | 
           $addblockbutton = $OUTPUT->addblockbutton();
  | 
        
        
            | 
            | 
           35 | 
           if (isloggedin()) {
  | 
        
        
            | 
            | 
           36 | 
               $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
  | 
        
        
            | 
            | 
           37 | 
               $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
  | 
        
        
            | 
            | 
           38 | 
           } else {
  | 
        
        
            | 
            | 
           39 | 
               $courseindexopen = false;
  | 
        
        
            | 
            | 
           40 | 
               $blockdraweropen = false;
  | 
        
        
            | 
            | 
           41 | 
           }
  | 
        
        
            | 
            | 
           42 | 
              | 
        
        
            | 
            | 
           43 | 
           if (defined('BEHAT_SITE_RUNNING')) {
  | 
        
        
            | 
            | 
           44 | 
               $blockdraweropen = true;
  | 
        
        
            | 
            | 
           45 | 
           }
  | 
        
        
            | 
            | 
           46 | 
              | 
        
        
            | 
            | 
           47 | 
           $extraclasses = ['uses-drawers'];
  | 
        
        
            | 
            | 
           48 | 
           if ($courseindexopen) {
  | 
        
        
            | 
            | 
           49 | 
               $extraclasses[] = 'drawer-open-index';
  | 
        
        
            | 
            | 
           50 | 
           }
  | 
        
        
            | 
            | 
           51 | 
           // End.
  | 
        
        
            | 
            | 
           52 | 
              | 
        
        
            | 
            | 
           53 | 
           // Dark mode.
  | 
        
        
            | 
            | 
           54 | 
           if (isloggedin()) {
  | 
        
        
            | 
            | 
           55 | 
               $navdraweropen = get_user_preferences('drawer-open-nav', true);
  | 
        
        
            | 
            | 
           56 | 
               $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
  | 
        
        
            | 
            | 
           57 | 
              | 
        
        
           | 1441 | 
           ariadna | 
           58 | 
               switch (theme_universe_get_setting('darkmodetheme')) {
  | 
        
        
            | 
            | 
           59 | 
                   case '1':
  | 
        
        
            | 
            | 
           60 | 
                       $darkmodeon = get_user_preferences('darkmode-on');
  | 
        
        
            | 
            | 
           61 | 
                       if ($darkmodeon) {
  | 
        
        
            | 
            | 
           62 | 
                           $extraclasses[] = 'theme-dark';
  | 
        
        
            | 
            | 
           63 | 
                       }
  | 
        
        
            | 
            | 
           64 | 
                       $darkmodetheme = true;
  | 
        
        
            | 
            | 
           65 | 
                       break;
  | 
        
        
            | 
            | 
           66 | 
                   default:
  | 
        
        
            | 
            | 
           67 | 
                       $darkmodeon = false;
  | 
        
        
            | 
            | 
           68 | 
                       break;
  | 
        
        
           | 1 | 
           efrain | 
           69 | 
               }
  | 
        
        
            | 
            | 
           70 | 
           } else {
  | 
        
        
            | 
            | 
           71 | 
               $navdraweropen = false;
  | 
        
        
            | 
            | 
           72 | 
           }
  | 
        
        
            | 
            | 
           73 | 
              | 
        
        
            | 
            | 
           74 | 
           if (theme_universe_get_setting('darkmodefirst') == '1') {
  | 
        
        
            | 
            | 
           75 | 
               $extraclasses[] = 'theme-dark';
  | 
        
        
            | 
            | 
           76 | 
               $darkmodetheme = false;
  | 
        
        
            | 
            | 
           77 | 
               $darkmodeon = true;
  | 
        
        
            | 
            | 
           78 | 
           }
  | 
        
        
            | 
            | 
           79 | 
              | 
        
        
            | 
            | 
           80 | 
           $siteurl = $CFG->wwwroot;
  | 
        
        
            | 
            | 
           81 | 
              | 
        
        
            | 
            | 
           82 | 
           $blockshtml = $OUTPUT->blocks('side-pre');
  | 
        
        
            | 
            | 
           83 | 
           $hasblocks = strpos($blockshtml, 'data-block=') !== false;
  | 
        
        
            | 
            | 
           84 | 
              | 
        
        
            | 
            | 
           85 | 
           $sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
  | 
        
        
            | 
            | 
           86 | 
           $hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
  | 
        
        
            | 
            | 
           87 | 
              | 
        
        
            | 
            | 
           88 | 
              | 
        
        
            | 
            | 
           89 | 
           $ctopbl = $OUTPUT->blocks('ctopbl');
  | 
        
        
            | 
            | 
           90 | 
           $cbottombl = $OUTPUT->blocks('cbottombl');
  | 
        
        
            | 
            | 
           91 | 
           $cstopbl = $OUTPUT->blocks('cstopbl');
  | 
        
        
            | 
            | 
           92 | 
           $csbottombl = $OUTPUT->blocks('csbottombl');
  | 
        
        
            | 
            | 
           93 | 
              | 
        
        
            | 
            | 
           94 | 
           if ($draweropenright && $hasblocks) {
  | 
        
        
            | 
            | 
           95 | 
               $extraclasses[] = 'drawer-open-right';
  | 
        
        
            | 
            | 
           96 | 
           }
  | 
        
        
            | 
            | 
           97 | 
              | 
        
        
            | 
            | 
           98 | 
           if ($PAGE->course->enablecompletion == '1') {
  | 
        
        
            | 
            | 
           99 | 
               $extraclasses[] = 'rui-course--enablecompletion';
  | 
        
        
            | 
            | 
           100 | 
           }
  | 
        
        
            | 
            | 
           101 | 
              | 
        
        
            | 
            | 
           102 | 
           if ($PAGE->course->showactivitydates == '1') {
  | 
        
        
            | 
            | 
           103 | 
               $extraclasses[] = 'rui-course--showactivitydates';
  | 
        
        
            | 
            | 
           104 | 
           }
  | 
        
        
            | 
            | 
           105 | 
              | 
        
        
            | 
            | 
           106 | 
           if ($PAGE->course->visible == '1') {
  | 
        
        
            | 
            | 
           107 | 
               $extraclasses[] = 'rui-course--visible';
  | 
        
        
            | 
            | 
           108 | 
           }
  | 
        
        
            | 
            | 
           109 | 
              | 
        
        
            | 
            | 
           110 | 
           $forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
  | 
        
        
            | 
            | 
           111 | 
              | 
        
        
            | 
            | 
           112 | 
              | 
        
        
            | 
            | 
           113 | 
           // Moodle 4.
  | 
        
        
           | 1441 | 
           ariadna | 
           114 | 
           switch (theme_universe_get_setting('hidecourseindexnav')) {
  | 
        
        
            | 
            | 
           115 | 
               case false:
  | 
        
        
            | 
            | 
           116 | 
                   $courseindex = core_course_drawer();
  | 
        
        
            | 
            | 
           117 | 
                   if (!$courseindex) {
  | 
        
        
            | 
            | 
           118 | 
                       $courseindexopen = false;
  | 
        
        
            | 
            | 
           119 | 
                   }
  | 
        
        
            | 
            | 
           120 | 
                   $extraclasses[] = ($courseindexopen == false) ? 'drawer-open-index--closed' : 'drawer-open-index--open';
  | 
        
        
            | 
            | 
           121 | 
                   break;
  | 
        
        
            | 
            | 
           122 | 
               default:
  | 
        
        
            | 
            | 
           123 | 
                   $courseindex = false;
  | 
        
        
           | 1 | 
           efrain | 
           124 | 
                   $courseindexopen = false;
  | 
        
        
           | 1441 | 
           ariadna | 
           125 | 
                   break;
  | 
        
        
           | 1 | 
           efrain | 
           126 | 
           }
  | 
        
        
            | 
            | 
           127 | 
           $hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
  | 
        
        
            | 
            | 
           128 | 
           $PAGE->set_secondary_navigation(false);
  | 
        
        
            | 
            | 
           129 | 
           $renderer = $PAGE->get_renderer('core');
  | 
        
        
            | 
            | 
           130 | 
              | 
        
        
            | 
            | 
           131 | 
           $header = $PAGE->activityheader;
  | 
        
        
            | 
            | 
           132 | 
           $headercontent = $header->export_for_template($renderer);
  | 
        
        
            | 
            | 
           133 | 
              | 
        
        
            | 
            | 
           134 | 
           $secondarynavigation = false;
  | 
        
        
            | 
            | 
           135 | 
           $overflow = '';
  | 
        
        
            | 
            | 
           136 | 
              | 
        
        
            | 
            | 
           137 | 
           if ($PAGE->has_secondary_navigation()) {
  | 
        
        
            | 
            | 
           138 | 
               $tablistnav = $PAGE->has_tablist_secondary_navigation();
  | 
        
        
            | 
            | 
           139 | 
               $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
  | 
        
        
            | 
            | 
           140 | 
               $secondarynavigation = $moremenu->export_for_template($OUTPUT);
  | 
        
        
            | 
            | 
           141 | 
               $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
  | 
        
        
            | 
            | 
           142 | 
               if (!is_null($overflowdata)) {
  | 
        
        
            | 
            | 
           143 | 
                   $overflow = $overflowdata->export_for_template($OUTPUT);
  | 
        
        
            | 
            | 
           144 | 
               }
  | 
        
        
            | 
            | 
           145 | 
           }
  | 
        
        
            | 
            | 
           146 | 
           // End.
  | 
        
        
            | 
            | 
           147 | 
              | 
        
        
           | 1441 | 
           ariadna | 
           148 | 
           $isnotloggedin = (!isloggedin() || isguestuser()) ? true : false;
  | 
        
        
           | 1 | 
           efrain | 
           149 | 
              | 
        
        
            | 
            | 
           150 | 
           // Check if guest user.
  | 
        
        
            | 
            | 
           151 | 
           if (isguestuser()) {
  | 
        
        
            | 
            | 
           152 | 
               $extraclasses[] = 'moodle-guest-user';
  | 
        
        
            | 
            | 
           153 | 
           }
  | 
        
        
            | 
            | 
           154 | 
              | 
        
        
            | 
            | 
           155 | 
           // Default moodle setting menu.
  | 
        
        
            | 
            | 
           156 | 
           $buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
  | 
        
        
            | 
            | 
           157 | 
           // If the settings menu will be included in the header then don't add it here.
  | 
        
        
            | 
            | 
           158 | 
           $regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
  | 
        
        
            | 
            | 
           159 | 
              | 
        
        
            | 
            | 
           160 | 
           // End.
  | 
        
        
            | 
            | 
           161 | 
              | 
        
        
            | 
            | 
           162 | 
           if (theme_universe_get_setting('backtotop') == '1') {
  | 
        
        
            | 
            | 
           163 | 
               $extraclasses[] = 'back-to-top-on';
  | 
        
        
            | 
            | 
           164 | 
           }
  | 
        
        
            | 
            | 
           165 | 
              | 
        
        
            | 
            | 
           166 | 
           $bodyattributes = $OUTPUT->body_attributes($extraclasses);
  | 
        
        
            | 
            | 
           167 | 
              | 
        
        
            | 
            | 
           168 | 
           $templatecontext = [
  | 
        
        
            | 
            | 
           169 | 
               'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
  | 
        
        
            | 
            | 
           170 | 
               'output' => $OUTPUT,
  | 
        
        
            | 
            | 
           171 | 
               'bodyattributes' => $bodyattributes,
  | 
        
        
            | 
            | 
           172 | 
               'darkmodeon' => !empty($darkmodeon),
  | 
        
        
            | 
            | 
           173 | 
               'darkmodetheme' => !empty($darkmodetheme),
  | 
        
        
            | 
            | 
           174 | 
               'siteurl' => $siteurl,
  | 
        
        
            | 
            | 
           175 | 
               'sidepreblocks' => $blockshtml,
  | 
        
        
            | 
            | 
           176 | 
               'hasblocks' => $hasblocks,
  | 
        
        
            | 
            | 
           177 | 
               'regionmainsettingsmenu' => $regionmainsettingsmenu,
  | 
        
        
            | 
            | 
           178 | 
               'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
  | 
        
        
            | 
            | 
           179 | 
               'navdraweropen' => $navdraweropen,
  | 
        
        
            | 
            | 
           180 | 
               'draweropenright' => $draweropenright,
  | 
        
        
            | 
            | 
           181 | 
               'ctopbl' => $ctopbl,
  | 
        
        
            | 
            | 
           182 | 
               'cbottombl' => $cbottombl,
  | 
        
        
            | 
            | 
           183 | 
               'cstopbl' => $cstopbl,
  | 
        
        
            | 
            | 
           184 | 
               'csbottombl' => $csbottombl,
  | 
        
        
            | 
            | 
           185 | 
               'hasctopbl' => !empty($ctopbl),
  | 
        
        
            | 
            | 
           186 | 
               'hascbottombl' => !empty($cbottombl),
  | 
        
        
            | 
            | 
           187 | 
               'hascstopbl' => !empty($cstopbl),
  | 
        
        
            | 
            | 
           188 | 
               'hascsbottombl' => !empty($csbottombl),
  | 
        
        
            | 
            | 
           189 | 
               'sidecourseblocks' => $sidecourseblocks,
  | 
        
        
            | 
            | 
           190 | 
               'hassidecourseblocks' => $hassidecourseblocks,
  | 
        
        
            | 
            | 
           191 | 
               'isnotloggedin' => $isnotloggedin,
  | 
        
        
            | 
            | 
           192 | 
               // Moodle 4.
  | 
        
        
            | 
            | 
           193 | 
               'courseindexopen' => $courseindexopen,
  | 
        
        
            | 
            | 
           194 | 
               'blockdraweropen' => $blockdraweropen,
  | 
        
        
            | 
            | 
           195 | 
               'courseindex' => $courseindex,
  | 
        
        
            | 
            | 
           196 | 
               'secondarymoremenu' => $secondarynavigation ?: false,
  | 
        
        
            | 
            | 
           197 | 
               'headercontent' => $headercontent,
  | 
        
        
            | 
            | 
           198 | 
               'overflow' => $overflow,
  | 
        
        
            | 
            | 
           199 | 
               'addblockbutton' => $addblockbutton,
  | 
        
        
            | 
            | 
           200 | 
               'hidecourseindexnav' => $hidecourseindexnav,
  | 
        
        
            | 
            | 
           201 | 
           ];
  | 
        
        
            | 
            | 
           202 | 
              | 
        
        
            | 
            | 
           203 | 
           // Get and use the course page information banners HTML code, if any course page hints are configured.
  | 
        
        
            | 
            | 
           204 | 
           $coursepageinformationbannershtml = theme_universe_get_course_information_banners();
  | 
        
        
            | 
            | 
           205 | 
           if ($coursepageinformationbannershtml) {
  | 
        
        
            | 
            | 
           206 | 
               $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
  | 
        
        
            | 
            | 
           207 | 
           }
  | 
        
        
            | 
            | 
           208 | 
           // End.
  | 
        
        
            | 
            | 
           209 | 
              | 
        
        
            | 
            | 
           210 | 
           // Load theme settings.
  | 
        
        
            | 
            | 
           211 | 
           $themesettings = new \theme_universe\util\theme_settings();
  | 
        
        
            | 
            | 
           212 | 
              | 
        
        
            | 
            | 
           213 | 
           $templatecontext = array_merge($templatecontext, $themesettings->global_settings());
  | 
        
        
            | 
            | 
           214 | 
              | 
        
        
            | 
            | 
           215 | 
           $PAGE->requires->js_call_amd('theme_universe/rui', 'init');
  | 
        
        
            | 
            | 
           216 | 
           if (theme_universe_get_setting('backtotop') == '1') {
  | 
        
        
            | 
            | 
           217 | 
               $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
  | 
        
        
            | 
            | 
           218 | 
           }
  | 
        
        
            | 
            | 
           219 | 
              | 
        
        
            | 
            | 
           220 | 
           echo $OUTPUT->render_from_template('theme_universe/tmpl-columns1', $templatecontext);
  |