Proyectos de Subversion Moodle

Rev

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