Proyectos de Subversion Moodle

Rev

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