Proyectos de Subversion Moodle

Rev

Rev 1304 | Rev 1307 | 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
 
1304 ariadna 30
function course_allows_guest_access($courseid)
31
{
32
    global $DB;
33
    return $DB->record_exists('enrol', [
34
        'courseid' => $courseid,
35
        'enrol' => 'guest',
36
        'status' => 0 // habilitado
37
    ]);
38
}
39
 
40
$templatecontext['isguestuser'] = isguestuser();
41
$templatecontext['guestaccessenabled'] = course_allows_guest_access($PAGE->course->id);
1305 ariadna 42
$templatecontext['output']['main_content'] = $OUTPUT->main_content();
1304 ariadna 43
 
256 ariadna 44
$draweropenright = false;
45
$extraclasses = [];
46
 
47
// Moodle 4. - Add block button in editing mode.
48
$addblockbutton = $OUTPUT->addblockbutton();
49
if (isloggedin()) {
50
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
51
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
52
} else {
53
    $courseindexopen = false;
54
    $blockdraweropen = false;
55
}
56
 
57
if (defined('BEHAT_SITE_RUNNING')) {
58
    $blockdraweropen = true;
59
}
60
 
61
$extraclasses = ['uses-drawers'];
62
// End.
63
 
64
// Dark mode.
65
if (isloggedin()) {
66
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
67
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
68
 
69
    if (theme_universe_get_setting('darkmodetheme') == '1') {
70
        $darkmodeon = get_user_preferences('darkmode-on');
71
        if ($darkmodeon) {
72
            $extraclasses[] = 'theme-dark';
73
        }
74
    } else {
75
        $darkmodeon = false;
76
    }
77
} else {
78
    $navdraweropen = false;
79
}
80
 
81
if (theme_universe_get_setting('darkmodefirst') == '1') {
82
    $extraclasses[] = 'theme-dark';
83
    $darkmodetheme = false;
84
    $darkmodeon = true;
85
}
86
 
87
$siteurl = $CFG->wwwroot;
88
 
89
$blockshtml = $OUTPUT->render_statics_blocks();
90
$blockdraweropen = false;
91
 
92
if (theme_universe_get_setting('hidecourseindexnav') == true) {
93
    $hidecourseindexnav = true;
94
} else {
95
    $hidecourseindexnav = false;
96
}
97
 
98
if (theme_universe_get_setting('hidecourseindexnav') == false) {
912 ariadna 99
    $courseindex = $OUTPUT->universe_child_course_drawer();
256 ariadna 100
    if (!$courseindex) {
101
        $courseindexopen = false;
102
    }
103
    if ($courseindexopen == false) {
104
        $extraclasses[] = 'drawer-open-index--closed';
105
    } else {
106
        $extraclasses[] = 'drawer-open-index--open';
107
    }
108
} else {
109
    $courseindex = false;
110
    $courseindexopen = false;
111
}
112
 
113
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
114
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
115
 
888 ariadna 116
if ($draweropenright && $hasblocks) {
117
    $extraclasses[] = 'drawer-open-right';
118
}
119
 
886 ariadna 120
if ($PAGE->course->enablecompletion == '1') {
121
    $extraclasses[] = 'rui-course--enablecompletion';
122
}
123
 
256 ariadna 124
if ($PAGE->course->showactivitydates == '1') {
125
    $extraclasses[] = 'rui-course--showactivitydates';
126
}
127
 
128
if ($PAGE->course->visible == '1') {
129
    $extraclasses[] = 'rui-course--visible';
130
}
131
 
132
// Moodle 4.
133
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
134
 
135
$secondarynavigation = false;
136
$overflow = '';
137
if ($PAGE->has_secondary_navigation()) {
138
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
139
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
140
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
141
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
142
    if (!is_null($overflowdata)) {
143
        $overflow = $overflowdata->export_for_template($OUTPUT);
144
    }
145
}
146
 
147
$primary = new core\navigation\output\primary($PAGE);
148
$renderer = $PAGE->get_renderer('core');
149
$primarymenu = $primary->export_for_template($renderer);
150
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
151
// If the settings menu will be included in the header then don't add it here.
152
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
153
 
876 ariadna 154
$header = $PAGE->activityheader;
155
$headercontent = $header->export_for_template($renderer);
156
 
256 ariadna 157
// RUI.
158
$iscoursepage = true;
159
 
160
if ($hassidecourseblocks) {
161
    $extraclasses[] = 'page-has-blocks';
162
}
163
 
164
if (!isloggedin() || isguestuser()) {
165
    $isnotloggedin = true;
166
} else {
167
    $isnotloggedin = false;
168
}
169
 
170
// Check if guest user.
171
if (isguestuser()) {
172
    $extraclasses[] = 'moodle-guest-user';
173
}
174
 
175
if (theme_universe_get_setting('backtotop') == '1') {
176
    $extraclasses[] = 'back-to-top-on';
177
}
178
 
179
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
180
 
181
$templatecontext = [
182
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
183
    'output' => $OUTPUT,
184
    'bodyattributes' => $bodyattributes,
185
    'darkmodeon' => !empty($darkmodeon),
186
    'darkmodetheme' => !empty($darkmodetheme),
187
    'siteurl' => $siteurl,
188
    'staticblocks' => $staticblocks,
189
    'sidepreblocks' => $blockshtml,
190
    'hasblocks' => true,
191
    'navdraweropen' => $navdraweropen,
192
    'draweropenright' => $draweropenright,
193
    'isnotloggedin' => $isnotloggedin,
194
    'iscoursepage' => $iscoursepage,
195
    // Moodle 4.
196
    'courseindexopen' => $courseindexopen,
197
    'blockdraweropen' => $blockdraweropen,
198
    'courseindex' => $courseindex,
199
    'primarymoremenu' => $primarymenu['moremenu'],
200
    'secondarymoremenu' => $secondarynavigation ?: false,
201
    'forceblockdraweropen' => $forceblockdraweropen,
202
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
203
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
204
    'overflow' => $overflow,
205
    'headercontent' => $headercontent,
206
    'addblockbutton' => $addblockbutton,
207
    'hidecourseindexnav' => $hidecourseindexnav,
208
];
209
 
210
// Get and use the course page information banners HTML code, if any course page hints are configured.
211
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
212
if ($coursepageinformationbannershtml) {
213
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
214
}
215
// End.
216
 
217
// Load theme settings.
532 ariadna 218
$themesettings = new \theme_universe\util\theme_settings();
256 ariadna 219
 
220
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
221
 
544 ariadna 222
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
256 ariadna 223
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 224
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
256 ariadna 225
}
226
 
315 ariadna 227
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-incourse', $templatecontext);