Proyectos de Subversion Moodle

Rev

Rev 256 | | 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();
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
 
1441 ariadna 55
    switch (theme_universe_get_setting('darkmodetheme')) {
56
        case '1':
57
            $darkmodeon = get_user_preferences('darkmode-on');
58
            if ($darkmodeon) {
59
                $extraclasses[] = 'theme-dark';
60
            }
61
            break;
62
        default:
63
            $darkmodeon = false;
64
            break;
1 efrain 65
    }
66
} else {
67
    $navdraweropen = false;
68
}
69
 
70
if (theme_universe_get_setting('darkmodefirst') == '1') {
71
    $extraclasses[] = 'theme-dark';
72
    $darkmodetheme = false;
73
    $darkmodeon = true;
74
}
75
 
76
$siteurl = $CFG->wwwroot;
77
 
256 ariadna 78
$blockshtml = $OUTPUT->blocks('side-pre');
79
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
80
if (!$hasblocks) {
81
    $blockdraweropen = false;
82
}
195 ariadna 83
 
1441 ariadna 84
$hidecourseindexnav = (theme_universe_get_setting('hidecourseindexnav') == true) ? true : false;
1 efrain 85
 
1441 ariadna 86
switch (theme_universe_get_setting('hidecourseindexnav')) {
87
    case false:
88
        $courseindex = core_course_drawer();
89
        if (!$courseindex) {
90
            $courseindexopen = false;
91
        }
92
        $extraclasses[] = ($courseindexopen == false) ? 'drawer-open-index--closed' : 'drawer-open-index--open';
93
        break;
94
    default:
95
        $courseindex = false;
1 efrain 96
        $courseindexopen = false;
1441 ariadna 97
        break;
1 efrain 98
}
99
 
100
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
101
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
102
 
103
if ($draweropenright && $hasblocks) {
104
    $extraclasses[] = 'drawer-open-right';
105
}
106
 
107
if ($PAGE->course->enablecompletion == '1') {
108
    $extraclasses[] = 'rui-course--enablecompletion';
109
}
110
 
111
if ($PAGE->course->showactivitydates == '1') {
112
    $extraclasses[] = 'rui-course--showactivitydates';
113
}
114
 
115
if ($PAGE->course->visible == '1') {
116
    $extraclasses[] = 'rui-course--visible';
117
}
118
 
119
// Moodle 4.
201 ariadna 120
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
1 efrain 121
 
122
$secondarynavigation = false;
123
$overflow = '';
124
if ($PAGE->has_secondary_navigation()) {
125
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
126
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
127
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
128
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
129
    if (!is_null($overflowdata)) {
130
        $overflow = $overflowdata->export_for_template($OUTPUT);
131
    }
132
}
133
 
134
$primary = new core\navigation\output\primary($PAGE);
135
$renderer = $PAGE->get_renderer('core');
136
$primarymenu = $primary->export_for_template($renderer);
137
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
138
// If the settings menu will be included in the header then don't add it here.
139
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
140
 
141
$header = $PAGE->activityheader;
142
$headercontent = $header->export_for_template($renderer);
143
 
144
// RUI.
145
$iscoursepage = true;
146
 
147
if ($hassidecourseblocks) {
148
    $extraclasses[] = 'page-has-blocks';
149
}
150
 
1441 ariadna 151
$isnotloggedin = (!isloggedin() || isguestuser()) ? true : false;
1 efrain 152
 
153
// Check if guest user.
154
if (isguestuser()) {
155
    $extraclasses[] = 'moodle-guest-user';
156
}
157
 
1441 ariadna 158
// Back to top.
1 efrain 159
if (theme_universe_get_setting('backtotop') == '1') {
160
    $extraclasses[] = 'back-to-top-on';
161
}
162
 
1441 ariadna 163
// Custom Enrollment Page.
164
$enrollmentcustomlayout = false;
165
if ($PAGE->pagetype === 'enrol-index') {
166
    $enrollmentcustomlayout = true;
167
}
168
 
1 efrain 169
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
170
 
171
$templatecontext = [
172
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
173
    'output' => $OUTPUT,
174
    'bodyattributes' => $bodyattributes,
175
    'darkmodeon' => !empty($darkmodeon),
176
    'darkmodetheme' => !empty($darkmodetheme),
177
    'siteurl' => $siteurl,
195 ariadna 178
    'sidepreblocks' => $blockshtml,
256 ariadna 179
    'hasblocks' => $hasblocks,
1 efrain 180
    'navdraweropen' => $navdraweropen,
181
    'draweropenright' => $draweropenright,
182
    'isnotloggedin' => $isnotloggedin,
183
    'iscoursepage' => $iscoursepage,
184
    // Moodle 4.
185
    'courseindexopen' => $courseindexopen,
186
    'blockdraweropen' => $blockdraweropen,
187
    'courseindex' => $courseindex,
188
    'primarymoremenu' => $primarymenu['moremenu'],
189
    'secondarymoremenu' => $secondarynavigation ?: false,
190
    'forceblockdraweropen' => $forceblockdraweropen,
191
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
192
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
193
    'overflow' => $overflow,
194
    'headercontent' => $headercontent,
195
    'addblockbutton' => $addblockbutton,
196
    'hidecourseindexnav' => $hidecourseindexnav,
1441 ariadna 197
    'enrollmentcustomlayout' => $enrollmentcustomlayout
1 efrain 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
 
212
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
213
if (theme_universe_get_setting('backtotop') == '1') {
214
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
215
}
216
 
217
echo $OUTPUT->render_from_template('theme_universe/tmpl-incourse', $templatecontext);