Proyectos de Subversion Moodle

Rev

Rev 549 | | 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
 
29
$draweropenright = false;
30
$extraclasses = [];
31
 
32
// Moodle 4. - Add block button in editing mode.
33
$addblockbutton = $OUTPUT->addblockbutton();
1441 ariadna 34
$blockdraweropen = (isloggedin()) ? get_user_preferences('drawer-open-block') == true : false;
1 efrain 35
 
36
if (defined('BEHAT_SITE_RUNNING')) {
37
    $blockdraweropen = true;
38
}
39
 
40
$extraclasses = ['uses-drawers'];
41
// End.
42
 
43
// Dark mode.
44
if (isloggedin()) {
45
    $navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');
46
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
47
 
1441 ariadna 48
    switch (theme_universe_get_setting('darkmodetheme')) {
49
        case '1':
50
            $darkmodeon = get_user_preferences('darkmode-on');
51
            if ($darkmodeon) {
52
                $extraclasses[] = 'theme-dark';
53
            }
54
            $darkmodetheme = true;
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');
73
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
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
// Dashboard Blocks.
86
$blockshtml2 = $OUTPUT->blocks('dtopblocks');
87
$blockshtml3 = $OUTPUT->blocks('dbottomblocks');
88
$blockshtml4 = $OUTPUT->blocks('dmiddleblocks');
89
// End.
90
 
91
// Moodle 4.
92
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
93
 
94
$secondarynavigation = false;
95
$overflow = '';
96
if ($PAGE->has_secondary_navigation()) {
97
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
98
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
99
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
100
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
101
    if (!is_null($overflowdata)) {
102
        $overflow = $overflowdata->export_for_template($OUTPUT);
103
    }
104
}
105
 
106
$primary = new core\navigation\output\primary($PAGE);
107
$renderer = $PAGE->get_renderer('core');
108
$primarymenu = $primary->export_for_template($renderer);
109
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions()
110
    && !$PAGE->has_secondary_navigation();
111
// If the settings menu will be included in the header then don't add it here.
112
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
113
 
114
$header = $PAGE->activityheader;
115
$headercontent = $header->export_for_template($renderer);
116
 
117
if ($hassidecourseblocks) {
118
    $extraclasses[] = 'page-has-blocks';
119
}
120
 
1441 ariadna 121
$isnotloggedin = (!isloggedin() || isguestuser()) ? true : false;
1 efrain 122
 
123
// Check if guest user.
124
if (isguestuser()) {
125
    $extraclasses[] = 'moodle-guest-user';
126
}
127
 
128
if (theme_universe_get_setting('backtotop') == '1') {
129
    $extraclasses[] = 'back-to-top-on';
130
}
131
 
132
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
133
 
134
$templatecontext = [
1441 ariadna 135
    'sitename' => format_string($SITE->shortname,
1 efrain 136
        true,
1441 ariadna 137
        ['context' => context_course::instance(SITEID), "escape" => false]),
1 efrain 138
    'output' => $OUTPUT,
139
    'bodyattributes' => $bodyattributes,
140
    'darkmodeon' => !empty($darkmodeon),
141
    'darkmodetheme' => !empty($darkmodetheme),
142
    'siteurl' => $siteurl,
143
    'sidepreblocks' => $blockshtml,
144
    'dtopblocks' => $blockshtml2,
145
    'dbottomblocks' => $blockshtml3,
146
    'dmiddleblocks' => $blockshtml4,
147
    'hasblocks' => $hasblocks,
148
    'hasdtopblocks' => !empty($blockshtml2),
149
    'hasdbottomblocks' => !empty($blockshtml3),
150
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
151
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
152
    'navdraweropen' => $navdraweropen,
153
    'draweropenright' => $draweropenright,
154
    'isnotloggedin' => $isnotloggedin,
155
    // Moodle 4.
156
    'blockdraweropen' => $blockdraweropen,
157
    'primarymoremenu' => $primarymenu['moremenu'],
158
    'secondarymoremenu' => $secondarynavigation ?: false,
159
    'forceblockdraweropen' => $forceblockdraweropen,
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
 
549 ariadna 182
echo $OUTPUT->render_from_template('theme_universe/tmpl-dashboard', $templatecontext);