Proyectos de Subversion Moodle

Rev

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