Proyectos de Subversion Moodle

Rev

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