Proyectos de Subversion Moodle

Rev

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