Proyectos de Subversion Moodle

Rev

Rev 1366 | Rev 1368 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

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