Proyectos de Subversion Moodle

Rev

Rev 535 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
535 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
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
if ($PAGE->course->enablecompletion == '1') {
110
    $extraclasses[] = 'rui-course--enablecompletion';
111
}
112
 
113
if ($PAGE->course->showactivitydates == '1') {
114
    $extraclasses[] = 'rui-course--showactivitydates';
115
}
116
 
117
if ($PAGE->course->visible == '1') {
118
    $extraclasses[] = 'rui-course--visible';
119
}
120
 
121
// Moodle 4.
122
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
123
 
124
$secondarynavigation = false;
125
$overflow = '';
126
if ($PAGE->has_secondary_navigation()) {
127
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
128
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
129
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
130
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
131
    if (!is_null($overflowdata)) {
132
        $overflow = $overflowdata->export_for_template($OUTPUT);
133
    }
134
}
135
 
136
$primary = new core\navigation\output\primary($PAGE);
137
$renderer = $PAGE->get_renderer('core');
138
$primarymenu = $primary->export_for_template($renderer);
139
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
140
// If the settings menu will be included in the header then don't add it here.
141
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
142
 
143
$header = $PAGE->activityheader;
144
$headercontent = $header->export_for_template($renderer);
145
 
146
// RUI.
147
$iscoursepage = false;
148
 
149
if ($hassidecourseblocks) {
150
    $extraclasses[] = 'page-has-blocks';
151
}
152
 
153
if (!isloggedin() || isguestuser()) {
154
    $isnotloggedin = true;
155
} else {
156
    $isnotloggedin = false;
157
}
158
 
159
// Check if guest user.
160
if (isguestuser()) {
161
    $extraclasses[] = 'moodle-guest-user';
162
}
163
 
164
if (theme_universe_get_setting('backtotop') == '1') {
165
    $extraclasses[] = 'back-to-top-on';
166
}
167
 
168
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
169
 
170
$templatecontext = [
171
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
172
    'output' => $OUTPUT,
173
    'bodyattributes' => $bodyattributes,
174
    'darkmodeon' => !empty($darkmodeon),
175
    'darkmodetheme' => !empty($darkmodetheme),
176
    'siteurl' => $siteurl,
177
    'sidepreblocks' => $blockshtml,
178
    'hasblocks' => $hasblocks,
179
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
180
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
181
    'navdraweropen' => $navdraweropen,
182
    'draweropenright' => $draweropenright,
183
    'isnotloggedin' => $isnotloggedin,
184
    'iscoursepage' => $iscoursepage,
185
    // Moodle 4.
186
    'courseindexopen' => $courseindexopen,
187
    'blockdraweropen' => $blockdraweropen,
188
    'courseindex' => $courseindex,
189
    'primarymoremenu' => $primarymenu['moremenu'],
190
    'secondarymoremenu' => $secondarynavigation ?: false,
191
    'forceblockdraweropen' => $forceblockdraweropen,
192
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
193
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
194
    'overflow' => $overflow,
195
    'headercontent' => $headercontent,
196
    'addblockbutton' => $addblockbutton,
197
    'hidecourseindexnav' => $hidecourseindexnav,
198
];
199
 
200
// Get and use the course page information banners HTML code, if any course page hints are configured.
201
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
202
if ($coursepageinformationbannershtml) {
203
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
204
}
205
// End.
206
 
207
// Load theme settings.
208
$themesettings = new \theme_universe\util\theme_settings();
209
 
210
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
211
 
544 ariadna 212
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
535 ariadna 213
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 214
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
535 ariadna 215
}
216
 
217
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-columns2', $templatecontext);