Proyectos de Subversion Moodle

Rev

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