Proyectos de Subversion Moodle

Rev

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