Proyectos de Subversion Moodle

Rev

Rev 1321 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
256 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
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->libdir . '/behat/lib.php');
28
require_once($CFG->dirroot . '/course/lib.php');
29
 
1304 ariadna 30
function course_allows_guest_access($courseid)
31
{
32
    global $DB;
33
    return $DB->record_exists('enrol', [
34
        'courseid' => $courseid,
35
        'enrol' => 'guest',
36
        'status' => 0 // habilitado
37
    ]);
38
}
39
 
256 ariadna 40
$draweropenright = false;
41
$extraclasses = [];
42
 
43
// Moodle 4. - Add block button in editing mode.
44
$addblockbutton = $OUTPUT->addblockbutton();
45
if (isloggedin()) {
46
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
47
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
48
} else {
49
    $courseindexopen = false;
50
    $blockdraweropen = false;
51
}
52
 
53
if (defined('BEHAT_SITE_RUNNING')) {
54
    $blockdraweropen = true;
55
}
56
 
57
$extraclasses = ['uses-drawers'];
58
// End.
59
 
60
// Dark mode.
61
if (isloggedin()) {
62
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
63
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
64
 
65
    if (theme_universe_get_setting('darkmodetheme') == '1') {
66
        $darkmodeon = get_user_preferences('darkmode-on');
67
        if ($darkmodeon) {
68
            $extraclasses[] = 'theme-dark';
69
        }
70
    } else {
71
        $darkmodeon = false;
72
    }
73
} else {
74
    $navdraweropen = false;
75
}
76
 
77
if (theme_universe_get_setting('darkmodefirst') == '1') {
78
    $extraclasses[] = 'theme-dark';
79
    $darkmodetheme = false;
80
    $darkmodeon = true;
81
}
82
 
83
$siteurl = $CFG->wwwroot;
84
 
85
$blockshtml = $OUTPUT->render_statics_blocks();
86
$blockdraweropen = false;
87
 
88
if (theme_universe_get_setting('hidecourseindexnav') == true) {
89
    $hidecourseindexnav = true;
90
} else {
91
    $hidecourseindexnav = false;
92
}
93
 
94
if (theme_universe_get_setting('hidecourseindexnav') == false) {
912 ariadna 95
    $courseindex = $OUTPUT->universe_child_course_drawer();
256 ariadna 96
    if (!$courseindex) {
97
        $courseindexopen = false;
98
    }
99
    if ($courseindexopen == false) {
100
        $extraclasses[] = 'drawer-open-index--closed';
101
    } else {
102
        $extraclasses[] = 'drawer-open-index--open';
103
    }
104
} else {
105
    $courseindex = false;
106
    $courseindexopen = false;
107
}
108
 
109
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
110
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
111
 
888 ariadna 112
if ($draweropenright && $hasblocks) {
113
    $extraclasses[] = 'drawer-open-right';
114
}
115
 
886 ariadna 116
if ($PAGE->course->enablecompletion == '1') {
117
    $extraclasses[] = 'rui-course--enablecompletion';
118
}
119
 
256 ariadna 120
if ($PAGE->course->showactivitydates == '1') {
121
    $extraclasses[] = 'rui-course--showactivitydates';
122
}
123
 
124
if ($PAGE->course->visible == '1') {
125
    $extraclasses[] = 'rui-course--visible';
126
}
127
 
128
// Moodle 4.
129
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
130
 
131
$secondarynavigation = false;
132
$overflow = '';
133
if ($PAGE->has_secondary_navigation()) {
134
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
135
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
136
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
137
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
138
    if (!is_null($overflowdata)) {
139
        $overflow = $overflowdata->export_for_template($OUTPUT);
140
    }
141
}
142
 
143
$primary = new core\navigation\output\primary($PAGE);
144
$renderer = $PAGE->get_renderer('core');
145
$primarymenu = $primary->export_for_template($renderer);
146
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
147
// If the settings menu will be included in the header then don't add it here.
148
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
149
 
876 ariadna 150
$header = $PAGE->activityheader;
151
$headercontent = $header->export_for_template($renderer);
152
 
256 ariadna 153
// RUI.
154
$iscoursepage = true;
155
 
156
if ($hassidecourseblocks) {
157
    $extraclasses[] = 'page-has-blocks';
158
}
159
 
160
if (!isloggedin() || isguestuser()) {
161
    $isnotloggedin = true;
162
} else {
163
    $isnotloggedin = false;
164
}
165
 
1320 ariadna 166
if (isguestuser() || !isloggedin()) {
167
    require_login($PAGE->course, false); // no requiere inscripción
168
}
169
 
256 ariadna 170
// Check if guest user.
171
if (isguestuser()) {
172
    $extraclasses[] = 'moodle-guest-user';
173
}
174
 
175
if (theme_universe_get_setting('backtotop') == '1') {
176
    $extraclasses[] = 'back-to-top-on';
177
}
178
 
179
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
1321 ariadna 180
$templatecontext['main_content'] = $OUTPUT->main_content();
256 ariadna 181
 
182
$templatecontext = [
183
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
184
    'output' => $OUTPUT,
185
    'bodyattributes' => $bodyattributes,
186
    'darkmodeon' => !empty($darkmodeon),
187
    'darkmodetheme' => !empty($darkmodetheme),
188
    'siteurl' => $siteurl,
189
    'staticblocks' => $staticblocks,
190
    'sidepreblocks' => $blockshtml,
191
    'hasblocks' => true,
192
    'navdraweropen' => $navdraweropen,
193
    'draweropenright' => $draweropenright,
194
    'isnotloggedin' => $isnotloggedin,
195
    'iscoursepage' => $iscoursepage,
196
    // Moodle 4.
197
    'courseindexopen' => $courseindexopen,
198
    'blockdraweropen' => $blockdraweropen,
199
    'courseindex' => $courseindex,
200
    'primarymoremenu' => $primarymenu['moremenu'],
201
    'secondarymoremenu' => $secondarynavigation ?: false,
202
    'forceblockdraweropen' => $forceblockdraweropen,
203
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
204
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
205
    'overflow' => $overflow,
206
    'headercontent' => $headercontent,
207
    'addblockbutton' => $addblockbutton,
208
    'hidecourseindexnav' => $hidecourseindexnav,
1322 ariadna 209
    'debug_guest' => isguestuser(),
210
    'debug_can_access' => can_access_course($PAGE->course) ? 'sí' : 'no',
211
 
256 ariadna 212
];
213
 
214
// Get and use the course page information banners HTML code, if any course page hints are configured.
215
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
216
if ($coursepageinformationbannershtml) {
217
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
218
}
219
// End.
220
 
221
// Load theme settings.
532 ariadna 222
$themesettings = new \theme_universe\util\theme_settings();
256 ariadna 223
 
224
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
225
 
544 ariadna 226
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
256 ariadna 227
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 228
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
256 ariadna 229
}
230
 
315 ariadna 231
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-incourse', $templatecontext);