Proyectos de Subversion Moodle

Rev

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