Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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