Proyectos de Subversion Moodle

Rev

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