Proyectos de Subversion Moodle

Rev

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