Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 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
 
30
$draweropenright = false;
31
$extraclasses = [];
32
 
33
// Moodle 4. - Add block button in editing mode.
34
$courseindexopen = false;
35
$blockdraweropen = false;
36
$blockfilteropen = false;
37
 
38
$addblockbutton = $OUTPUT->addblockbutton();
39
if (isloggedin()) {
40
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
41
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
42
    $blockfilteropen = (get_user_preferences('coursefilter-on', true) == true);
43
}
44
 
45
$extraclasses = ['uses-drawers'];
46
// End.
47
 
48
// Dark mode.
49
if (isloggedin()) {
50
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
51
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
52
 
53
    switch (theme_universe_get_setting('darkmodetheme')) {
54
        case '1':
55
            $darkmodeon = get_user_preferences('darkmode-on');
56
            if ($darkmodeon) {
57
                $extraclasses[] = 'theme-dark';
58
            }
59
            break;
60
        default:
61
            $darkmodeon = false;
62
            break;
63
    }
64
} else {
65
    $navdraweropen = false;
66
}
67
 
68
if (theme_universe_get_setting('darkmodefirst') == '1') {
69
    $extraclasses[] = 'theme-dark';
70
    $darkmodetheme = false;
71
    $darkmodeon = true;
72
}
73
 
74
$siteurl = $CFG->wwwroot;
75
 
76
$blockshtml = $OUTPUT->blocks('side-pre');
77
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
78
if (!$hasblocks) {
79
    $blockdraweropen = false;
80
}
81
 
82
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
83
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
84
 
85
if ($draweropenright && $hasblocks) {
86
    $extraclasses[] = 'drawer-open-right';
87
}
88
 
89
if ($PAGE->course->enablecompletion == '1') {
90
    $extraclasses[] = 'rui-course--enablecompletion';
91
}
92
 
93
if ($PAGE->course->showactivitydates == '1') {
94
    $extraclasses[] = 'rui-course--showactivitydates';
95
}
96
 
97
if ($PAGE->course->visible == '1') {
98
    $extraclasses[] = 'rui-course--visible';
99
}
100
 
101
// Moodle 4.
102
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
103
 
104
$secondarynavigation = false;
105
$overflow = '';
106
if ($PAGE->has_secondary_navigation()) {
107
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
108
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
109
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
110
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
111
    if (!is_null($overflowdata)) {
112
        $overflow = $overflowdata->export_for_template($OUTPUT);
113
    }
114
}
115
 
116
$primary = new core\navigation\output\primary($PAGE);
117
$renderer = $PAGE->get_renderer('core');
118
$primarymenu = $primary->export_for_template($renderer);
119
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
120
// If the settings menu will be included in the header then don't add it here.
121
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
122
 
123
$header = $PAGE->activityheader;
124
$headercontent = $header->export_for_template($renderer);
125
 
126
// RUI.
127
$iscoursepage = false;
128
 
129
if ($hassidecourseblocks) {
130
    $extraclasses[] = 'page-has-blocks';
131
}
132
 
133
$isnotloggedin = (!isloggedin() || isguestuser()) ? true : false;
134
 
135
// Check if guest user.
136
if (isguestuser()) {
137
    $extraclasses[] = 'moodle-guest-user';
138
}
139
 
140
if (theme_universe_get_setting('backtotop') == '1') {
141
    $extraclasses[] = 'back-to-top-on';
142
}
143
 
144
if(theme_universe_get_setting('showcoursefilter') == '0') {
145
    $blockfilteropen = false;
146
}
147
 
148
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
149
 
150
$templatecontext = [
151
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
152
    'output' => $OUTPUT,
153
    'bodyattributes' => $bodyattributes,
154
    'darkmodeon' => !empty($darkmodeon),
155
    'darkmodetheme' => !empty($darkmodetheme),
156
    'siteurl' => $siteurl,
157
    'sidepreblocks' => $blockshtml,
158
    'hasblocks' => $hasblocks,
159
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
160
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
161
    'draweropenright' => $draweropenright,
162
    'isnotloggedin' => $isnotloggedin,
163
    'iscoursepage' => $iscoursepage,
164
    // Moodle 4.
165
    'blockdraweropen' => $blockdraweropen,
166
    'blockfilteropen' => $blockfilteropen,
167
    'primarymoremenu' => $primarymenu['moremenu'],
168
    'secondarymoremenu' => $secondarynavigation ?: false,
169
    'forceblockdraweropen' => $forceblockdraweropen,
170
    'overflow' => $overflow,
171
    'headercontent' => $headercontent,
172
    'addblockbutton' => $addblockbutton
173
];
174
 
175
// Get and use the course page information banners HTML code, if any course page hints are configured.
176
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
177
if ($coursepageinformationbannershtml) {
178
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
179
}
180
// End.
181
 
182
// Load theme settings.
183
$themesettings = new \theme_universe\util\theme_settings();
184
 
185
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
186
 
187
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
188
if (theme_universe_get_setting('backtotop') == '1') {
189
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
190
}
191
 
192
echo $OUTPUT->render_from_template('theme_universe/tmpl-category', $templatecontext);