Proyectos de Subversion Moodle

Rev

Rev 1320 | Ir a la última revisión | | 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
 
1321 ariadna 40
$templatecontext['debug_guest'] = isguestuser();
41
$templatecontext['debug_can_access'] = can_access_course($PAGE->course) ? 'sí' : 'no';
1304 ariadna 42
 
256 ariadna 43
$draweropenright = false;
44
$extraclasses = [];
45
 
46
// Moodle 4. - Add block button in editing mode.
47
$addblockbutton = $OUTPUT->addblockbutton();
48
if (isloggedin()) {
49
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
50
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
51
} else {
52
    $courseindexopen = false;
53
    $blockdraweropen = false;
54
}
55
 
56
if (defined('BEHAT_SITE_RUNNING')) {
57
    $blockdraweropen = true;
58
}
59
 
60
$extraclasses = ['uses-drawers'];
61
// End.
62
 
63
// Dark mode.
64
if (isloggedin()) {
65
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
66
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
67
 
68
    if (theme_universe_get_setting('darkmodetheme') == '1') {
69
        $darkmodeon = get_user_preferences('darkmode-on');
70
        if ($darkmodeon) {
71
            $extraclasses[] = 'theme-dark';
72
        }
73
    } else {
74
        $darkmodeon = false;
75
    }
76
} else {
77
    $navdraweropen = false;
78
}
79
 
80
if (theme_universe_get_setting('darkmodefirst') == '1') {
81
    $extraclasses[] = 'theme-dark';
82
    $darkmodetheme = false;
83
    $darkmodeon = true;
84
}
85
 
86
$siteurl = $CFG->wwwroot;
87
 
88
$blockshtml = $OUTPUT->render_statics_blocks();
89
$blockdraweropen = false;
90
 
91
if (theme_universe_get_setting('hidecourseindexnav') == true) {
92
    $hidecourseindexnav = true;
93
} else {
94
    $hidecourseindexnav = false;
95
}
96
 
97
if (theme_universe_get_setting('hidecourseindexnav') == false) {
912 ariadna 98
    $courseindex = $OUTPUT->universe_child_course_drawer();
256 ariadna 99
    if (!$courseindex) {
100
        $courseindexopen = false;
101
    }
102
    if ($courseindexopen == false) {
103
        $extraclasses[] = 'drawer-open-index--closed';
104
    } else {
105
        $extraclasses[] = 'drawer-open-index--open';
106
    }
107
} else {
108
    $courseindex = false;
109
    $courseindexopen = false;
110
}
111
 
112
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
113
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
114
 
888 ariadna 115
if ($draweropenright && $hasblocks) {
116
    $extraclasses[] = 'drawer-open-right';
117
}
118
 
886 ariadna 119
if ($PAGE->course->enablecompletion == '1') {
120
    $extraclasses[] = 'rui-course--enablecompletion';
121
}
122
 
256 ariadna 123
if ($PAGE->course->showactivitydates == '1') {
124
    $extraclasses[] = 'rui-course--showactivitydates';
125
}
126
 
127
if ($PAGE->course->visible == '1') {
128
    $extraclasses[] = 'rui-course--visible';
129
}
130
 
131
// Moodle 4.
132
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
133
 
134
$secondarynavigation = false;
135
$overflow = '';
136
if ($PAGE->has_secondary_navigation()) {
137
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
138
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
139
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
140
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
141
    if (!is_null($overflowdata)) {
142
        $overflow = $overflowdata->export_for_template($OUTPUT);
143
    }
144
}
145
 
146
$primary = new core\navigation\output\primary($PAGE);
147
$renderer = $PAGE->get_renderer('core');
148
$primarymenu = $primary->export_for_template($renderer);
149
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
150
// If the settings menu will be included in the header then don't add it here.
151
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
152
 
876 ariadna 153
$header = $PAGE->activityheader;
154
$headercontent = $header->export_for_template($renderer);
155
 
256 ariadna 156
// RUI.
157
$iscoursepage = true;
158
 
159
if ($hassidecourseblocks) {
160
    $extraclasses[] = 'page-has-blocks';
161
}
162
 
163
if (!isloggedin() || isguestuser()) {
164
    $isnotloggedin = true;
165
} else {
166
    $isnotloggedin = false;
167
}
168
 
1320 ariadna 169
if (isguestuser() || !isloggedin()) {
170
    require_login($PAGE->course, false); // no requiere inscripción
171
}
172
 
256 ariadna 173
// Check if guest user.
174
if (isguestuser()) {
175
    $extraclasses[] = 'moodle-guest-user';
176
}
177
 
178
if (theme_universe_get_setting('backtotop') == '1') {
179
    $extraclasses[] = 'back-to-top-on';
180
}
181
 
182
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
1321 ariadna 183
$templatecontext['main_content'] = $OUTPUT->main_content();
256 ariadna 184
 
185
$templatecontext = [
186
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
187
    'output' => $OUTPUT,
188
    'bodyattributes' => $bodyattributes,
189
    'darkmodeon' => !empty($darkmodeon),
190
    'darkmodetheme' => !empty($darkmodetheme),
191
    'siteurl' => $siteurl,
192
    'staticblocks' => $staticblocks,
193
    'sidepreblocks' => $blockshtml,
194
    'hasblocks' => true,
195
    'navdraweropen' => $navdraweropen,
196
    'draweropenright' => $draweropenright,
197
    'isnotloggedin' => $isnotloggedin,
198
    'iscoursepage' => $iscoursepage,
199
    // Moodle 4.
200
    'courseindexopen' => $courseindexopen,
201
    'blockdraweropen' => $blockdraweropen,
202
    'courseindex' => $courseindex,
203
    'primarymoremenu' => $primarymenu['moremenu'],
204
    'secondarymoremenu' => $secondarynavigation ?: false,
205
    'forceblockdraweropen' => $forceblockdraweropen,
206
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
207
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
208
    'overflow' => $overflow,
209
    'headercontent' => $headercontent,
210
    'addblockbutton' => $addblockbutton,
211
    'hidecourseindexnav' => $hidecourseindexnav,
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);