Proyectos de Subversion Moodle

Rev

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