Proyectos de Subversion Moodle

Rev

Rev 885 | Rev 887 | Ir a la última revisión | | 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) {
85
    $courseindex = core_course_drawer();
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
 
886 ariadna 102
if ($PAGE->course->enablecompletion == '1') {
103
    $extraclasses[] = 'rui-course--enablecompletion';
104
}
105
 
256 ariadna 106
if ($draweropenright && $hasblocks) {
107
    $extraclasses[] = 'drawer-open-right';
108
}
109
 
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);
885 ariadna 142
$completed = false;
876 ariadna 143
 
886 ariadna 144
if ($currentmod->completionview != 1 && $currentmod->completion != 2) {
145
    if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
146
        $completed = true;
872 ariadna 147
    }
864 ariadna 148
}
149
 
256 ariadna 150
// RUI.
151
$iscoursepage = true;
152
 
153
if ($hassidecourseblocks) {
154
    $extraclasses[] = 'page-has-blocks';
155
}
156
 
157
if (!isloggedin() || isguestuser()) {
158
    $isnotloggedin = true;
159
} else {
160
    $isnotloggedin = false;
161
}
162
 
163
// Check if guest user.
164
if (isguestuser()) {
165
    $extraclasses[] = 'moodle-guest-user';
166
}
167
 
168
if (theme_universe_get_setting('backtotop') == '1') {
169
    $extraclasses[] = 'back-to-top-on';
170
}
171
 
172
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
173
 
174
$templatecontext = [
175
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
176
    'output' => $OUTPUT,
177
    'bodyattributes' => $bodyattributes,
178
    'darkmodeon' => !empty($darkmodeon),
179
    'darkmodetheme' => !empty($darkmodetheme),
180
    'siteurl' => $siteurl,
181
    'staticblocks' => $staticblocks,
182
    'sidepreblocks' => $blockshtml,
183
    'hasblocks' => true,
184
    'navdraweropen' => $navdraweropen,
185
    'draweropenright' => $draweropenright,
186
    'isnotloggedin' => $isnotloggedin,
187
    'iscoursepage' => $iscoursepage,
188
    // Moodle 4.
189
    'courseindexopen' => $courseindexopen,
190
    'blockdraweropen' => $blockdraweropen,
191
    'courseindex' => $courseindex,
192
    'primarymoremenu' => $primarymenu['moremenu'],
193
    'secondarymoremenu' => $secondarynavigation ?: false,
194
    'forceblockdraweropen' => $forceblockdraweropen,
195
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
196
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
197
    'overflow' => $overflow,
198
    'headercontent' => $headercontent,
199
    'addblockbutton' => $addblockbutton,
200
    'hidecourseindexnav' => $hidecourseindexnav,
863 ariadna 201
    'completed' => $completed
256 ariadna 202
];
203
 
204
// Get and use the course page information banners HTML code, if any course page hints are configured.
205
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
206
if ($coursepageinformationbannershtml) {
207
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
208
}
209
// End.
210
 
211
// Load theme settings.
532 ariadna 212
$themesettings = new \theme_universe\util\theme_settings();
256 ariadna 213
 
214
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
215
 
544 ariadna 216
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
256 ariadna 217
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 218
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
256 ariadna 219
}
220
 
315 ariadna 221
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-incourse', $templatecontext);