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