Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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