Proyectos de Subversion Moodle

Rev

Rev 1 | Rev 131 | 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
 
129 ariadna 79
$customblocks = $OUTPUT->blocks('bellow-custom');
1 efrain 80
$blockshtml = $OUTPUT->blocks('side-pre');
81
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
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,
202
    'sidepreblocks' => $blockshtml,
129 ariadna 203
    'customblocks' => $customblocks,
1 efrain 204
    'hasblocks' => $hasblocks,
205
    'navdraweropen' => $navdraweropen,
206
    'draweropenright' => $draweropenright,
207
    'isnotloggedin' => $isnotloggedin,
208
    'ctopbl' => $ctopbl,
209
    'cbottombl' => $cbottombl,
210
    'cstopbl' => $cstopbl,
211
    'csbottombl' => $csbottombl,
212
    'coursetab-a' => $coursetab1,
213
    'coursetab-b' => $coursetab2,
214
    'coursetab-c' => $coursetab3,
215
    'coursetab-d' => $coursetab4,
216
    'coursetab-e' => $coursetab5,
217
    'hasctopbl' => !empty($ctopbl),
218
    'hascbottombl' => !empty($cbottombl),
219
    'hascstopbl' => !empty($cstopbl),
220
    'hascsbottombl' => !empty($csbottombl),
221
    'sidecourseblocks' => $sidecourseblocks,
222
    'hassidecourseblocks' => $hassidecourseblocks,
223
    'ipcourseimage' => $courseimage,
224
    'iscoursepage' => $iscoursepage,
225
    // Moodle 4.
226
    'courseindexopen' => $courseindexopen,
227
    'blockdraweropen' => $blockdraweropen,
228
    'courseindex' => $courseindex,
229
    'primarymoremenu' => $primarymenu['moremenu'],
230
    'secondarymoremenu' => $secondarynavigation ?: false,
231
    'headercontent' => $headercontent,
232
    'forceblockdraweropen' => $forceblockdraweropen,
233
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
234
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
235
    'overflow' => $overflow,
236
    'addblockbutton' => $addblockbutton,
237
    'hidecourseindexnav' => $hidecourseindexnav,
238
];
239
 
240
// Get and use the course page information banners HTML code, if any course page hints are configured.
241
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
242
if ($coursepageinformationbannershtml) {
243
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
244
}
245
// End.
246
 
247
// Load theme settings.
248
$themesettings = new \theme_universe\util\theme_settings();
249
 
250
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
251
$templatecontext = array_merge($templatecontext, $themesettings->course_settings());
252
 
253
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
254
if (theme_universe_get_setting('backtotop') == '1') {
255
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
256
}
257
 
258
echo $OUTPUT->render_from_template('theme_universe/tmpl-course', $templatecontext);