Proyectos de Subversion Moodle

Rev

Rev 1118 | Rev 1120 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
533 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
 
1115 efrain 25
 
533 ariadna 26
defined('MOODLE_INTERNAL') || die();
27
 
1119 efrain 28
global $CFG, $PAGE, $OUTPUT;
29
 
533 ariadna 30
require_once($CFG->libdir . '/behat/lib.php');
31
require_once($CFG->dirroot . '/course/lib.php');
32
 
1116 efrain 33
 
1119 efrain 34
if(!empty($PAGE->course)) {
35
 
36
   // $mods = [];
37
    $modules = get_fast_modinfo($PAGE->course->id)->get_cms();
38
    if(!empty($modules))
39
    foreach ($modules as $module)
40
    {
41
        if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
42
            continue;
43
        }
44
 
45
        $linkurl = new \moodle_url($module->url, array('forceview' => 1));
46
 
47
        echo 'linkurl = ' . $linkurl;
48
        exit;
49
 
50
        $attributes = [];
51
       // $nextlink = new \action_link($linkurl, $OUTPUT->rarrow(), null, $attributes);
52
    }
53
 
54
 
1118 efrain 55
print_r($PAGE->course);
1119 efrain 56
 
57
}
1117 efrain 58
exit;
1116 efrain 59
 
60
 
533 ariadna 61
$draweropenright = false;
62
$extraclasses = [];
63
 
64
$courseindexopen = false;
65
$blockdraweropen = false;
66
 
67
// Moodle 4. - Add block button in editing mode.
68
$addblockbutton = $OUTPUT->addblockbutton();
69
if (isloggedin()) {
70
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
71
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
72
} else {
73
    $courseindexopen = false;
74
    $blockdraweropen = false;
75
}
76
 
77
if (defined('BEHAT_SITE_RUNNING')) {
78
    $blockdraweropen = true;
79
}
80
 
81
$extraclasses = ['uses-drawers'];
82
// End.
83
 
84
// Dark mode.
85
if (isloggedin()) {
86
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
87
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
88
 
89
    if (theme_universe_get_setting('darkmodetheme') == '1') {
90
        $darkmodeon = get_user_preferences('darkmode-on');
91
        if ($darkmodeon) {
92
            $extraclasses[] = 'theme-dark';
93
        }
94
        $darkmodetheme = true;
95
    } else {
96
        $darkmodeon = false;
97
    }
98
} else {
99
    $navdraweropen = false;
100
}
101
 
102
if (theme_universe_get_setting('darkmodefirst') == '1') {
103
    $extraclasses[] = 'theme-dark';
104
    $darkmodetheme = false;
105
    $darkmodeon = true;
106
}
107
 
108
$siteurl = $CFG->wwwroot;
109
 
110
$blockshtml = $OUTPUT->blocks('side-pre');
111
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
112
if (!$hasblocks) {
113
    $blockdraweropen = false;
114
}
115
 
116
if (theme_universe_get_setting('hidecourseindexnav') == true) {
117
    $hidecourseindexnav = true;
118
} else {
119
    $hidecourseindexnav = false;
120
}
121
 
122
if (theme_universe_get_setting('hidecourseindexnav') == false) {
123
    $courseindex = core_course_drawer();
124
    if (!$courseindex) {
125
        $courseindexopen = false;
126
    }
127
    if ($courseindexopen == false) {
128
        $extraclasses[] = 'drawer-open-index--closed';
129
    } else {
130
        $extraclasses[] = 'drawer-open-index--open';
131
    }
132
} else {
133
    $courseindex = false;
134
    $courseindexopen = false;
135
}
136
 
137
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
138
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
139
 
140
 
141
if ($draweropenright && $hasblocks) {
142
    $extraclasses[] = 'drawer-open-right';
143
}
144
 
145
$ctopbl = $OUTPUT->blocks('ctopbl');
146
$cbottombl = $OUTPUT->blocks('cbottombl');
147
$cstopbl = $OUTPUT->blocks('cstopbl');
148
$csbottombl = $OUTPUT->blocks('csbottombl');
149
$coursetab1 = $OUTPUT->blocks('coursetab-a');
150
$coursetab2 = $OUTPUT->blocks('coursetab-b');
151
$coursetab3 = $OUTPUT->blocks('coursetab-c');
152
$coursetab4 = $OUTPUT->blocks('coursetab-d');
153
$coursetab5 = $OUTPUT->blocks('coursetab-e');
154
 
155
// Moodle 4.
156
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
157
 
158
$secondarynavigation = false;
159
$overflow = '';
160
if ($PAGE->has_secondary_navigation()) {
161
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
162
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
163
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
164
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
165
    if (!is_null($overflowdata)) {
166
        $overflow = $overflowdata->export_for_template($OUTPUT);
167
    }
168
}
169
 
170
$primary = new core\navigation\output\primary($PAGE);
171
$renderer = $PAGE->get_renderer('core');
172
$primarymenu = $primary->export_for_template($renderer);
173
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
174
// If the settings menu will be included in the header then don't add it here.
175
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
176
 
177
$header = $PAGE->activityheader;
178
$headercontent = $header->export_for_template($renderer);
179
 
180
// RUI.
181
$iscoursepage = true;
182
 
183
if ($hassidecourseblocks) {
184
    $extraclasses[] = 'page-has-blocks';
185
}
186
 
187
if (!isloggedin() || isguestuser()) {
188
    $isnotloggedin = true;
189
} else {
190
    $isnotloggedin = false;
191
}
192
 
193
// Check if guest user.
194
if (isguestuser()) {
195
    $extraclasses[] = 'moodle-guest-user';
196
}
197
 
198
// Start - Course Image Position (theme settings).
199
$courseimage = theme_universe_get_setting('ipcourseimage');
200
 
201
if ($hassidecourseblocks) {
202
    $extraclasses[] = 'page-has-blocks';
203
}
204
 
205
if ($PAGE->course->enablecompletion == '1') {
206
    $extraclasses[] = 'rui-course--enablecompletion';
207
}
208
 
209
if ($PAGE->course->showactivitydates == '1') {
210
    $extraclasses[] = 'rui-course--showactivitydates';
211
}
212
 
213
if ($PAGE->course->visible == '1') {
214
    $extraclasses[] = 'rui-course--visible';
215
}
216
 
217
$iscoursepage = true;
218
 
219
if (theme_universe_get_setting('backtotop') == '1') {
220
    $extraclasses[] = 'back-to-top-on';
221
}
222
 
223
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
224
 
225
$templatecontext = [
226
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
227
    'output' => $OUTPUT,
228
    'bodyattributes' => $bodyattributes,
229
    'darkmodeon' => !empty($darkmodeon),
230
    'darkmodetheme' => !empty($darkmodetheme),
231
    'siteurl' => $siteurl,
232
    'sidepreblocks' => $blockshtml,
233
    'hasblocks' => $hasblocks,
234
    'navdraweropen' => $navdraweropen,
235
    'draweropenright' => $draweropenright,
236
    'isnotloggedin' => $isnotloggedin,
237
    'ctopbl' => $ctopbl,
238
    'cbottombl' => $cbottombl,
239
    'cstopbl' => $cstopbl,
240
    'csbottombl' => $csbottombl,
241
    'coursetab-a' => $coursetab1,
242
    'coursetab-b' => $coursetab2,
243
    'coursetab-c' => $coursetab3,
244
    'coursetab-d' => $coursetab4,
245
    'coursetab-e' => $coursetab5,
246
    'hasctopbl' => !empty($ctopbl),
247
    'hascbottombl' => !empty($cbottombl),
248
    'hascstopbl' => !empty($cstopbl),
249
    'hascsbottombl' => !empty($csbottombl),
250
    'sidecourseblocks' => $sidecourseblocks,
251
    'hassidecourseblocks' => $hassidecourseblocks,
252
    'ipcourseimage' => $courseimage,
253
    'iscoursepage' => $iscoursepage,
254
    // Moodle 4.
255
    'courseindexopen' => $courseindexopen,
256
    'blockdraweropen' => $blockdraweropen,
257
    'courseindex' => $courseindex,
258
    'primarymoremenu' => $primarymenu['moremenu'],
259
    'secondarymoremenu' => $secondarynavigation ?: false,
260
    'headercontent' => $headercontent,
261
    'forceblockdraweropen' => $forceblockdraweropen,
262
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
263
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
264
    'overflow' => $overflow,
265
    'addblockbutton' => $addblockbutton,
266
    'hidecourseindexnav' => $hidecourseindexnav,
267
];
268
 
269
// Get and use the course page information banners HTML code, if any course page hints are configured.
270
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
271
if ($coursepageinformationbannershtml) {
272
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
273
}
274
// End.
275
 
276
// Load theme settings.
277
$themesettings = new \theme_universe\util\theme_settings();
278
 
279
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
280
$templatecontext = array_merge($templatecontext, $themesettings->course_settings());
281
 
544 ariadna 282
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
533 ariadna 283
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 284
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
533 ariadna 285
}
286
 
287
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-course', $templatecontext);