Proyectos de Subversion Moodle

Rev

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