Proyectos de Subversion Moodle

Rev

Rev 154 | | 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
$courseindexopen = false;
34
$blockdraweropen = false;
35
 
36
// Moodle 4. - Add block button in editing mode.
37
$addblockbutton = $OUTPUT->addblockbutton();
38
if (isloggedin()) {
39
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
40
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
41
} else {
42
    $courseindexopen = false;
43
    $blockdraweropen = false;
44
}
45
 
46
if (defined('BEHAT_SITE_RUNNING')) {
47
    $blockdraweropen = true;
48
}
49
 
50
$extraclasses = ['uses-drawers'];
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
 
154 ariadna 82
$blockshtml = $OUTPUT->blocks('side-pre');
83
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
1 efrain 84
if (!$hasblocks) {
85
    $blockdraweropen = false;
86
}
87
 
1441 ariadna 88
$hidecourseindexnav = (theme_universe_get_setting('hidecourseindexnav') == true) ? true : false;
1 efrain 89
 
1441 ariadna 90
switch (theme_universe_get_setting('hidecourseindexnav')) {
91
    case false:
92
        $courseindex = core_course_drawer();
93
        if (!$courseindex) {
94
            $courseindexopen = false;
95
        }
96
        $extraclasses[] = ($courseindexopen == false) ? 'drawer-open-index--closed' : 'drawer-open-index--open';
97
        break;
98
    default:
99
        $courseindex = false;
1 efrain 100
        $courseindexopen = false;
1441 ariadna 101
        break;
1 efrain 102
}
103
 
104
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
105
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
106
 
107
 
108
if ($draweropenright && $hasblocks) {
109
    $extraclasses[] = 'drawer-open-right';
110
}
111
 
112
$ctopbl = $OUTPUT->blocks('ctopbl');
113
$cbottombl = $OUTPUT->blocks('cbottombl');
114
$cstopbl = $OUTPUT->blocks('cstopbl');
115
$csbottombl = $OUTPUT->blocks('csbottombl');
116
$coursetab1 = $OUTPUT->blocks('coursetab-a');
117
$coursetab2 = $OUTPUT->blocks('coursetab-b');
118
$coursetab3 = $OUTPUT->blocks('coursetab-c');
119
$coursetab4 = $OUTPUT->blocks('coursetab-d');
120
$coursetab5 = $OUTPUT->blocks('coursetab-e');
121
 
122
// Moodle 4.
123
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
124
 
125
$secondarynavigation = false;
126
$overflow = '';
127
if ($PAGE->has_secondary_navigation()) {
128
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
129
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
130
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
131
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
132
    if (!is_null($overflowdata)) {
133
        $overflow = $overflowdata->export_for_template($OUTPUT);
134
    }
135
}
136
 
137
$primary = new core\navigation\output\primary($PAGE);
138
$renderer = $PAGE->get_renderer('core');
139
$primarymenu = $primary->export_for_template($renderer);
140
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
141
// If the settings menu will be included in the header then don't add it here.
142
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
143
 
144
$header = $PAGE->activityheader;
145
$headercontent = $header->export_for_template($renderer);
146
 
147
// RUI.
148
$iscoursepage = true;
149
 
150
if ($hassidecourseblocks) {
151
    $extraclasses[] = 'page-has-blocks';
152
}
153
 
1441 ariadna 154
$isnotloggedin = (!isloggedin() || isguestuser()) ? true : false;
1 efrain 155
 
156
// Check if guest user.
157
if (isguestuser()) {
158
    $extraclasses[] = 'moodle-guest-user';
159
}
160
 
161
// Start - Course Image Position (theme settings).
162
$courseimage = theme_universe_get_setting('ipcourseimage');
163
 
164
if ($hassidecourseblocks) {
165
    $extraclasses[] = 'page-has-blocks';
166
}
167
 
168
if ($PAGE->course->enablecompletion == '1') {
169
    $extraclasses[] = 'rui-course--enablecompletion';
170
}
171
 
172
if ($PAGE->course->showactivitydates == '1') {
173
    $extraclasses[] = 'rui-course--showactivitydates';
174
}
175
 
176
if ($PAGE->course->visible == '1') {
177
    $extraclasses[] = 'rui-course--visible';
178
}
179
 
180
$iscoursepage = true;
181
 
182
if (theme_universe_get_setting('backtotop') == '1') {
183
    $extraclasses[] = 'back-to-top-on';
184
}
185
 
186
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
187
 
188
$templatecontext = [
189
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
190
    'output' => $OUTPUT,
191
    'bodyattributes' => $bodyattributes,
192
    'darkmodeon' => !empty($darkmodeon),
193
    'darkmodetheme' => !empty($darkmodetheme),
194
    'siteurl' => $siteurl,
154 ariadna 195
    'sidepreblocks' => $blockshtml,
1 efrain 196
    'hasblocks' => $hasblocks,
197
    'navdraweropen' => $navdraweropen,
198
    'draweropenright' => $draweropenright,
199
    'isnotloggedin' => $isnotloggedin,
200
    'ctopbl' => $ctopbl,
201
    'cbottombl' => $cbottombl,
202
    'cstopbl' => $cstopbl,
203
    'csbottombl' => $csbottombl,
204
    'coursetab-a' => $coursetab1,
205
    'coursetab-b' => $coursetab2,
206
    'coursetab-c' => $coursetab3,
207
    'coursetab-d' => $coursetab4,
208
    'coursetab-e' => $coursetab5,
209
    'hasctopbl' => !empty($ctopbl),
210
    'hascbottombl' => !empty($cbottombl),
211
    'hascstopbl' => !empty($cstopbl),
212
    'hascsbottombl' => !empty($csbottombl),
213
    'sidecourseblocks' => $sidecourseblocks,
214
    'hassidecourseblocks' => $hassidecourseblocks,
215
    'ipcourseimage' => $courseimage,
216
    'iscoursepage' => $iscoursepage,
217
    // Moodle 4.
218
    'courseindexopen' => $courseindexopen,
219
    'blockdraweropen' => $blockdraweropen,
220
    'courseindex' => $courseindex,
221
    'primarymoremenu' => $primarymenu['moremenu'],
222
    'secondarymoremenu' => $secondarynavigation ?: false,
223
    'headercontent' => $headercontent,
224
    'forceblockdraweropen' => $forceblockdraweropen,
225
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
226
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
227
    'overflow' => $overflow,
228
    'addblockbutton' => $addblockbutton,
229
    'hidecourseindexnav' => $hidecourseindexnav,
230
];
231
 
232
// Get and use the course page information banners HTML code, if any course page hints are configured.
233
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
234
if ($coursepageinformationbannershtml) {
235
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
236
}
237
// End.
238
 
239
// Load theme settings.
240
$themesettings = new \theme_universe\util\theme_settings();
241
 
242
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
243
$templatecontext = array_merge($templatecontext, $themesettings->course_settings());
244
 
245
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
246
if (theme_universe_get_setting('backtotop') == '1') {
247
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
248
}
249
 
250
echo $OUTPUT->render_from_template('theme_universe/tmpl-course', $templatecontext);