Proyectos de Subversion Moodle

Rev

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