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