Proyectos de Subversion Moodle

Rev

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