Proyectos de Subversion Moodle

Rev

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