Proyectos de Subversion Moodle

Rev

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