| 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 secure layout for the universe theme.
  | 
        
        
            | 
            | 
           19 | 
            *
  | 
        
        
            | 
            | 
           20 | 
            * @package   theme_universe
  | 
        
        
           | 1441 | 
           ariadna | 
           21 | 
            * @copyright 2022 - 2023 Marcin Czaja (https://rosea.io)
  | 
        
        
           | 1 | 
           efrain | 
           22 | 
            * @license   Commercial https://themeforest.net/licenses
  | 
        
        
            | 
            | 
           23 | 
            */
  | 
        
        
            | 
            | 
           24 | 
              | 
        
        
            | 
            | 
           25 | 
           defined('MOODLE_INTERNAL') || die();
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           $extraclasses = [];
  | 
        
        
            | 
            | 
           28 | 
              | 
        
        
            | 
            | 
           29 | 
           // Dark mode.
  | 
        
        
            | 
            | 
           30 | 
           if (isloggedin()) {
  | 
        
        
           | 1441 | 
           ariadna | 
           31 | 
               $draweropenright = get_user_preferences('sidepre-open', 'true') == 'true';
  | 
        
        
           | 1 | 
           efrain | 
           32 | 
              | 
        
        
           | 1441 | 
           ariadna | 
           33 | 
               switch (theme_universe_get_setting('darkmodetheme')) {
  | 
        
        
            | 
            | 
           34 | 
                   case '1':
  | 
        
        
            | 
            | 
           35 | 
                       $darkmodeon = get_user_preferences('darkmode-on');
  | 
        
        
            | 
            | 
           36 | 
                       if ($darkmodeon) {
  | 
        
        
            | 
            | 
           37 | 
                           $extraclasses[] = 'theme-dark';
  | 
        
        
            | 
            | 
           38 | 
                       }
  | 
        
        
            | 
            | 
           39 | 
                       break;
  | 
        
        
            | 
            | 
           40 | 
                   default:
  | 
        
        
            | 
            | 
           41 | 
                       $darkmodeon = false;
  | 
        
        
            | 
            | 
           42 | 
                       break;
  | 
        
        
           | 1 | 
           efrain | 
           43 | 
               }
  | 
        
        
            | 
            | 
           44 | 
           }
  | 
        
        
            | 
            | 
           45 | 
              | 
        
        
            | 
            | 
           46 | 
           if (theme_universe_get_setting('darkmodefirst') == '1') {
  | 
        
        
            | 
            | 
           47 | 
               $extraclasses[] = 'theme-dark';
  | 
        
        
            | 
            | 
           48 | 
               $darkmodetheme = false;
  | 
        
        
            | 
            | 
           49 | 
           }
  | 
        
        
            | 
            | 
           50 | 
              | 
        
        
            | 
            | 
           51 | 
           $blockshtml = $OUTPUT->blocks('side-pre');
  | 
        
        
            | 
            | 
           52 | 
           $hasblocks = strpos($blockshtml, 'data-block=') !== false;
  | 
        
        
            | 
            | 
           53 | 
           $bodyattributes = $OUTPUT->body_attributes();
  | 
        
        
            | 
            | 
           54 | 
           $siteurl = $CFG->wwwroot;
  | 
        
        
            | 
            | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
           if (theme_universe_get_setting('backtotop') == '1') {
  | 
        
        
            | 
            | 
           57 | 
               $extraclasses[] = 'back-to-top-on';
  | 
        
        
            | 
            | 
           58 | 
           }
  | 
        
        
            | 
            | 
           59 | 
              | 
        
        
            | 
            | 
           60 | 
           $bodyattributes = $OUTPUT->body_attributes($extraclasses);
  | 
        
        
            | 
            | 
           61 | 
           $templatecontext = [
  | 
        
        
            | 
            | 
           62 | 
               'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
  | 
        
        
            | 
            | 
           63 | 
               'output' => $OUTPUT,
  | 
        
        
            | 
            | 
           64 | 
               'sidepreblocks' => $blockshtml,
  | 
        
        
            | 
            | 
           65 | 
               'hasblocks' => $hasblocks,
  | 
        
        
            | 
            | 
           66 | 
               'bodyattributes' => $bodyattributes,
  | 
        
        
            | 
            | 
           67 | 
               'draweropenright' => $draweropenright,
  | 
        
        
            | 
            | 
           68 | 
               'darkmodeon' => !empty($darkmodeon),
  | 
        
        
            | 
            | 
           69 | 
               'darkmodetheme' => !empty($darkmodetheme),
  | 
        
        
            | 
            | 
           70 | 
               'siteurl' => $siteurl
  | 
        
        
            | 
            | 
           71 | 
           ];
  | 
        
        
            | 
            | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
           // Load theme settings.
  | 
        
        
            | 
            | 
           74 | 
           $themesettings = new \theme_universe\util\theme_settings();
  | 
        
        
            | 
            | 
           75 | 
           $templatecontext = array_merge($templatecontext, $themesettings->global_settings());
  | 
        
        
            | 
            | 
           76 | 
              | 
        
        
            | 
            | 
           77 | 
           $PAGE->requires->js_call_amd('theme_universe/rui', 'init');
  | 
        
        
            | 
            | 
           78 | 
           if (theme_universe_get_setting('backtotop') == '1') {
  | 
        
        
            | 
            | 
           79 | 
               $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
  | 
        
        
            | 
            | 
           80 | 
           }
  | 
        
        
            | 
            | 
           81 | 
              | 
        
        
            | 
            | 
           82 | 
           echo $OUTPUT->render_from_template('theme_universe/secure', $templatecontext);
  |