Proyectos de Subversion Moodle

Rev

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

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