Proyectos de Subversion Moodle

Rev

Rev 201 | Rev 231 | Ir a la última revisión | | 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 = [];
228 ariadna 32
$staticblocks = $OUTPUT->render_statics_blocks();
1 efrain 33
 
34
// Moodle 4. - Add block button in editing mode.
35
$addblockbutton = $OUTPUT->addblockbutton();
36
if (isloggedin()) {
37
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
38
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
39
} else {
40
    $courseindexopen = false;
41
    $blockdraweropen = false;
42
}
43
 
44
if (defined('BEHAT_SITE_RUNNING')) {
45
    $blockdraweropen = true;
46
}
47
 
48
$extraclasses = ['uses-drawers'];
49
// End.
50
 
51
// Dark mode.
52
if (isloggedin()) {
53
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
54
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
55
 
56
    if (theme_universe_get_setting('darkmodetheme') == '1') {
57
        $darkmodeon = get_user_preferences('darkmode-on');
58
        if ($darkmodeon) {
59
            $extraclasses[] = 'theme-dark';
60
        }
61
    } else {
62
        $darkmodeon = false;
63
    }
64
} else {
65
    $navdraweropen = false;
66
}
67
 
68
if (theme_universe_get_setting('darkmodefirst') == '1') {
69
    $extraclasses[] = 'theme-dark';
70
    $darkmodetheme = false;
71
    $darkmodeon = true;
72
}
73
 
74
$siteurl = $CFG->wwwroot;
75
 
195 ariadna 76
$blockshtml = $OUTPUT->blocks('side-pre');
77
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
78
if (!$hasblocks) {
79
    $blockdraweropen = false;
80
}
81
 
1 efrain 82
if (theme_universe_get_setting('hidecourseindexnav') == true) {
83
    $hidecourseindexnav = true;
84
} else {
85
    $hidecourseindexnav = false;
86
}
87
 
88
if (theme_universe_get_setting('hidecourseindexnav') == false) {
89
    $courseindex = core_course_drawer();
90
    if (!$courseindex) {
91
        $courseindexopen = false;
92
    }
93
    if ($courseindexopen == false) {
94
        $extraclasses[] = 'drawer-open-index--closed';
95
    } else {
96
        $extraclasses[] = 'drawer-open-index--open';
97
    }
98
} else {
99
    $courseindex = false;
100
    $courseindexopen = false;
101
}
102
 
103
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
104
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
105
 
106
if ($draweropenright && $hasblocks) {
107
    $extraclasses[] = 'drawer-open-right';
108
}
109
 
110
if ($PAGE->course->enablecompletion == '1') {
111
    $extraclasses[] = 'rui-course--enablecompletion';
112
}
113
 
114
if ($PAGE->course->showactivitydates == '1') {
115
    $extraclasses[] = 'rui-course--showactivitydates';
116
}
117
 
118
if ($PAGE->course->visible == '1') {
119
    $extraclasses[] = 'rui-course--visible';
120
}
121
 
122
// Moodle 4.
201 ariadna 123
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
1 efrain 124
 
125
$secondarynavigation = false;
126
$overflow = '';
127
if ($PAGE->has_secondary_navigation()) {
128
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
129
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
130
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
131
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
132
    if (!is_null($overflowdata)) {
133
        $overflow = $overflowdata->export_for_template($OUTPUT);
134
    }
135
}
136
 
137
$primary = new core\navigation\output\primary($PAGE);
138
$renderer = $PAGE->get_renderer('core');
139
$primarymenu = $primary->export_for_template($renderer);
140
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
141
// If the settings menu will be included in the header then don't add it here.
142
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
143
 
144
$header = $PAGE->activityheader;
145
$headercontent = $header->export_for_template($renderer);
146
 
147
// RUI.
148
$iscoursepage = true;
149
 
150
if ($hassidecourseblocks) {
151
    $extraclasses[] = 'page-has-blocks';
152
}
153
 
154
if (!isloggedin() || isguestuser()) {
155
    $isnotloggedin = true;
156
} else {
157
    $isnotloggedin = false;
158
}
159
 
160
// Check if guest user.
161
if (isguestuser()) {
162
    $extraclasses[] = 'moodle-guest-user';
163
}
164
 
165
if (theme_universe_get_setting('backtotop') == '1') {
166
    $extraclasses[] = 'back-to-top-on';
167
}
168
 
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,
228 ariadna 178
    'staticblocks' => $staticblocks,
195 ariadna 179
    'sidepreblocks' => $blockshtml,
180
    'hasblocks' => $hasblocks,
1 efrain 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
 
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);