Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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