Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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 two 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
// End.
49
 
50
// Dark mode.
51
if (isloggedin()) {
52
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
53
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
54
 
1441 ariadna 55
    switch (theme_universe_get_setting('darkmodetheme')) {
56
        case '1':
57
            $darkmodeon = get_user_preferences('darkmode-on');
58
            if ($darkmodeon) {
59
                $extraclasses[] = 'theme-dark';
60
            }
61
            break;
62
        default:
63
            $darkmodeon = false;
64
            break;
1 efrain 65
    }
66
} else {
67
    $navdraweropen = false;
68
}
69
 
70
if (theme_universe_get_setting('darkmodefirst') == '1') {
71
    $extraclasses[] = 'theme-dark';
72
    $darkmodetheme = false;
73
    $darkmodeon = true;
74
}
75
 
76
$siteurl = $CFG->wwwroot;
77
 
78
$blockshtml = $OUTPUT->blocks('side-pre');
79
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
80
if (!$hasblocks) {
81
    $blockdraweropen = false;
82
}
83
 
1441 ariadna 84
$hidecourseindexnav = (theme_universe_get_setting('hidecourseindexnav') == true) ? true : false;
1 efrain 85
 
1441 ariadna 86
switch (theme_universe_get_setting('hidecourseindexnav')) {
87
    case false:
88
        $courseindex = core_course_drawer();
89
        if (!$courseindex) {
90
            $courseindexopen = false;
91
        }
92
        $extraclasses[] = ($courseindexopen == false) ? 'drawer-open-index--closed' : 'drawer-open-index--open';
93
        break;
94
    default:
95
        $courseindex = false;
1 efrain 96
        $courseindexopen = false;
1441 ariadna 97
        break;
1 efrain 98
}
99
 
100
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
101
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
102
 
103
if ($draweropenright && $hasblocks) {
104
    $extraclasses[] = 'drawer-open-right';
105
}
106
 
107
// Moodle 4.
108
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
109
 
110
$secondarynavigation = false;
111
$overflow = '';
112
if ($PAGE->has_secondary_navigation()) {
113
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
114
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
115
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
116
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
117
    if (!is_null($overflowdata)) {
118
        $overflow = $overflowdata->export_for_template($OUTPUT);
119
    }
120
}
121
 
122
$primary = new core\navigation\output\primary($PAGE);
123
$renderer = $PAGE->get_renderer('core');
124
$primarymenu = $primary->export_for_template($renderer);
125
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
126
// If the settings menu will be included in the header then don't add it here.
127
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
128
 
129
$header = $PAGE->activityheader;
130
$headercontent = $header->export_for_template($renderer);
131
 
132
// RUI.
133
$iscoursepage = true;
134
 
135
if ($hassidecourseblocks) {
136
    $extraclasses[] = 'page-has-blocks';
137
}
138
 
139
if (!isloggedin() || isguestuser()) {
140
    $isnotloggedin = true;
141
} else {
142
    $isnotloggedin = false;
143
}
144
 
145
// Check if guest user.
146
if (isguestuser()) {
147
    $extraclasses[] = 'moodle-guest-user';
148
}
149
 
150
if (theme_universe_get_setting('backtotop') == '1') {
151
    $extraclasses[] = 'back-to-top-on';
152
}
153
 
154
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
155
 
156
$templatecontext = [
157
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
158
    'output' => $OUTPUT,
159
    'bodyattributes' => $bodyattributes,
160
    'darkmodeon' => !empty($darkmodeon),
161
    'darkmodetheme' => !empty($darkmodetheme),
162
    'siteurl' => $siteurl,
163
    'sidepreblocks' => $blockshtml,
164
    'hasblocks' => $hasblocks,
165
    'navdraweropen' => $navdraweropen,
166
    'draweropenright' => $draweropenright,
167
    'isnotloggedin' => $isnotloggedin,
168
    // Moodle 4.
169
    'courseindexopen' => $courseindexopen,
170
    'blockdraweropen' => $blockdraweropen,
171
    'courseindex' => $courseindex,
172
    'primarymoremenu' => $primarymenu['moremenu'],
173
    'secondarymoremenu' => $secondarynavigation ?: false,
174
    'forceblockdraweropen' => $forceblockdraweropen,
175
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
176
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
177
    'overflow' => $overflow,
178
    'headercontent' => $headercontent,
179
    'addblockbutton' => $addblockbutton,
180
    'hidecourseindexnav' => $hidecourseindexnav,
181
];
182
 
183
// Get and use the course page information banners HTML code, if any course page hints are configured.
184
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
185
if ($coursepageinformationbannershtml) {
186
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
187
}
188
// End.
189
 
190
// Load theme settings.
191
$themesettings = new \theme_universe\util\theme_settings();
192
 
193
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
194
 
195
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
196
if (theme_universe_get_setting('backtotop') == '1') {
197
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
198
}
199
 
200
echo $OUTPUT->render_from_template('theme_universe/tmpl-report', $templatecontext);