Proyectos de Subversion Moodle

Rev

Rev 1297 | Rev 1299 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1297 Rev 1298
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
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/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
namespace theme_universe_child\output;
17
namespace theme_universe\output;
18
 
18
 
19
use html_writer;
19
use html_writer;
20
use stdClass;
20
use stdClass;
Línea 29... Línea 29...
29
use action_link;
29
use action_link;
30
use core_text;
30
use core_text;
31
use coding_exception;
31
use coding_exception;
32
use navigation_node;
32
use navigation_node;
33
use context_header;
33
use context_header;
34
use core\oauth2\rest;
-
 
35
use pix_icon;
34
use pix_icon;
36
use renderer_base;
35
use renderer_base;
37
use theme_config;
36
use theme_config;
38
use get_string;
37
use get_string;
39
use core_course_category;
38
use core_course_category;
40
use theme_universe\util\user;
39
use theme_universe\util\user;
41
use theme_universe\util\course;
40
use theme_universe\util\course;
42
use core_completion\progress;
-
 
Línea 43... Línea 41...
43
 
41
 
Línea 44... Línea 42...
44
require_once($CFG->dirroot . '/cesa/statics_blocks.php'); // Incluimos StaticsBlocks
42
require_once($CFG->dirroot . '/cesa/statics_blocks.php'); // Incluimos StaticsBlocks
Línea 49... Línea 47...
49
 *
47
 *
50
 * @package    theme_universe
48
 * @package    theme_universe
51
 * @copyright  2023 Marcin Czaja (https://rosea.io)
49
 * @copyright  2023 Marcin Czaja (https://rosea.io)
52
 * @license    Commercial https://themeforest.net/licenses
50
 * @license    Commercial https://themeforest.net/licenses
53
 */
51
 */
54
class core_renderer extends \theme_universe\output\core_renderer
52
class core_renderer extends \core_renderer
55
{
53
{
Línea 56... Línea 54...
56
 
54
 
57
    public function cesa_navigation_course_menu_lateral_output()
55
    public function edit_button(moodle_url $url, string $method = 'post')
-
 
56
    {
-
 
57
        if ($this->page->theme->haseditswitch) {
-
 
58
            return;
-
 
59
        }
-
 
60
        $url->param('sesskey', sesskey());
-
 
61
        if ($this->page->user_is_editing()) {
-
 
62
            $url->param('edit', 'off');
-
 
63
            $editstring = get_string('turneditingoff');
-
 
64
        } else {
-
 
65
            $url->param('edit', 'on');
-
 
66
            $editstring = get_string('turneditingon');
-
 
67
        }
-
 
68
        $button = new \single_button($url, $editstring, 'post', ['class' => 'btn btn-primary']);
-
 
69
        return $this->render_single_button($button);
-
 
70
    }
-
 
71
 
-
 
72
    /**
-
 
73
     * The standard tags (meta tags, links to stylesheets and JavaScript, etc.)
-
 
74
     * that should be included in the <head> tag. Designed to be called in theme
-
 
75
     * layout.php files.
-
 
76
     *
-
 
77
     * @return string HTML fragment.
-
 
78
     */
-
 
79
    public function standard_head_html()
-
 
80
    {
-
 
81
        $output = parent::standard_head_html();
-
 
82
        global $USER;
-
 
83
 
-
 
84
        $googleanalyticscode = "<script
-
 
85
                                    async
-
 
86
                                    src='https://www.googletagmanager.com/gtag/js?id=GOOGLE-ANALYTICS-CODE'>
-
 
87
                                </script>
-
 
88
                                <script>
-
 
89
                                    window.dataLayer = window.dataLayer || [];
-
 
90
                                    function gtag() {
-
 
91
                                        dataLayer.push(arguments);
-
 
92
                                    }
-
 
93
                                    gtag('js', new Date());
-
 
94
                                    gtag('config', 'GOOGLE-ANALYTICS-CODE');
-
 
95
                                </script>";
-
 
96
 
-
 
97
        $theme = theme_config::load('universe');
-
 
98
 
-
 
99
        if (!empty($theme->settings->googleanalytics) && isloggedin()) {
-
 
100
            $output .= str_replace(
-
 
101
                "GOOGLE-ANALYTICS-CODE",
-
 
102
                trim($theme->settings->googleanalytics),
-
 
103
                $googleanalyticscode
-
 
104
            );
-
 
105
        }
-
 
106
 
-
 
107
        return $output;
Línea -... Línea 108...
-
 
108
    }
-
 
109
 
-
 
110
 
-
 
111
    /**
-
 
112
     *
-
 
113
     * Method to load theme element form 'layout/parts' folder
-
 
114
     *
Línea 58... Línea 115...
58
    {
115
     */
Línea -... Línea 116...
-
 
116
    public function theme_part($name, $vars = array())
-
 
117
    {
Línea -... Línea 118...
-
 
118
 
-
 
119
        global $CFG;
-
 
120
 
-
 
121
        $element = $name . '.php';
-
 
122
        $candidate1 = $this->page->theme->dir . '/layout/parts/' . $element;
-
 
123
 
-
 
124
        // Require for child theme.
-
 
125
        if (file_exists($candidate1)) {
-
 
126
            $candidate = $candidate1;
-
 
127
        } else {
-
 
128
            $candidate = $CFG->dirroot . theme_universe_themedir() . '/universe/layout/parts/' . $element;
Línea -... Línea 129...
-
 
129
        }
-
 
130
 
-
 
131
        if (!is_readable($candidate)) {
-
 
132
            debugging("Could not include element $name.");
-
 
133
            return;
Línea -... Línea 134...
-
 
134
        }
-
 
135
 
-
 
136
        ob_start();
-
 
137
        include($candidate);
-
 
138
        $output = ob_get_clean();
-
 
139
        return $output;
-
 
140
    }
-
 
141
 
59
 
142
    /**
60
 
143
     * Renders the custom menu
61
 
144
     *
Línea 62... Línea 145...
62
        global $CFG, $COURSE, $PAGE, $DB, $OUTPUT;
145
     * @param custom_menu $menu
-
 
146
     * @return mixed
-
 
147
     */
-
 
148
    protected function render_custom_menu(custom_menu $menu)
-
 
149
    {
-
 
150
        if (!$menu->has_children()) {
-
 
151
            return '';
-
 
152
        }
-
 
153
 
-
 
154
        $content = '';
-
 
155
        foreach ($menu->get_children() as $item) {
-
 
156
            $context = $item->export_for_template($this);
-
 
157
            $content .= $this->render_from_template('core/moremenu_children', $context);
-
 
158
        }
-
 
159
 
-
 
160
        return $content;
-
 
161
    }
-
 
162
 
-
 
163
    /**
-
 
164
     * Outputs the favicon urlbase.
-
 
165
     *
-
 
166
     * @return string an url
-
 
167
     */
Línea 63... Línea -...
63
 
-
 
64
 
168
    public function favicon()
65
 
-
 
66
 
169
    {
Línea 67... Línea 170...
67
        if (!$COURSE->id) {
170
        global $CFG;
-
 
171
        $theme = theme_config::load('universe');
Línea -... Línea 172...
-
 
172
        $favicon = $theme->setting_file_url('favicon', 'favicon');
-
 
173
 
-
 
174
        if (!empty(($favicon))) {
-
 
175
            $urlreplace = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
-
 
176
            $favicon = str_replace($urlreplace, '', $favicon);
-
 
177
 
-
 
178
            return new moodle_url($favicon);
-
 
179
        }
-
 
180
 
-
 
181
        return parent::favicon();
-
 
182
    }
-
 
183
 
-
 
184
    public function render_lang_menu()
-
 
185
    {
-
 
186
        $langs = get_string_manager()->get_list_of_translations();
-
 
187
        $haslangmenu = $this->lang_menu() != '';
-
 
188
        $menu = new custom_menu;
-
 
189
 
-
 
190
        if ($haslangmenu) {
-
 
191
            $strlang = get_string('language');
-
 
192
            $currentlang = current_language();
Línea 68... Línea -...
68
            return '';
-
 
69
        }
193
            if (isset($langs[$currentlang])) {
70
 
-
 
Línea 71... Línea -...
71
        $course_id = $COURSE->id;
-
 
72
 
194
                $currentlang = $langs[$currentlang];
73
        $parent = optional_param('parent', 0, PARAM_INT); // Course module id
195
            } else {
74
        if (!$parent) {
196
                $currentlang = $strlang;
75
            $parent = optional_param('amp;parent', 0, PARAM_INT); // Course module id
197
            }
-
 
198
            $this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000);
Línea -... Línea 199...
-
 
199
            foreach ($langs as $langtype => $langname) {
-
 
200
                $this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
-
 
201
            }
-
 
202
            foreach ($menu->get_children() as $item) {
-
 
203
                $context = $item->export_for_template($this);
-
 
204
            }
-
 
205
 
-
 
206
            $context->currentlangname = array_search($currentlang, $langs);
-
 
207
 
-
 
208
            if (isset($context)) {
-
 
209
                return $this->render_from_template('theme_universe/lang_menu', $context);
-
 
210
            }
-
 
211
        }
-
 
212
    }
-
 
213
 
-
 
214
    public function render_lang_menu_login()
-
 
215
    {
-
 
216
        $langs = get_string_manager()->get_list_of_translations();
-
 
217
        $haslangmenu = $this->lang_menu() != '';
-
 
218
        $menu = new custom_menu;
-
 
219
 
Línea -... Línea 220...
-
 
220
        if ($haslangmenu) {
Línea 76... Línea 221...
76
        }
221
            $strlang = get_string('language');
77
 
222
            $currentlang = current_language();
78
        //$PAGE->requires->js('/theme/edumynew/javascript/menu-lateral.js');
223
            if (isset($langs[$currentlang])) {
-
 
224
                $currentlang = $langs[$currentlang];
79
 
225
            } else {
80
 
-
 
81
        if ($parent) {
-
 
82
            $sql  = ' SELECT * FROM {subcourse} WHERE course = ' . $parent;
-
 
Línea -... Línea 226...
-
 
226
                $currentlang = $strlang;
-
 
227
            }
-
 
228
            $this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000);
Línea -... Línea 229...
-
 
229
            foreach ($langs as $langtype => $langname) {
-
 
230
                $this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
-
 
231
            }
-
 
232
            foreach ($menu->get_children() as $item) {
Línea 83... Línea 233...
83
            $sql .= ' AND refcourse = ' . $course_id;
233
                $context = $item->export_for_template($this);
Línea 84... Línea -...
84
 
-
 
85
            $recordParentRefCourse  = $DB->get_record_sql($sql);
-
 
86
            if ($recordParentRefCourse) {
-
 
87
                $course_id = $recordParentRefCourse->course;
-
 
88
            }
234
            }
89
        }
235
 
90
 
236
            $context->currentlangname = array_search($currentlang, $langs);
91
 
237
 
Línea -... Línea 238...
-
 
238
            if (isset($context)) {
-
 
239
                return $this->render_from_template('theme_universe/lang_menu_login', $context);
-
 
240
            }
Línea -... Línea 241...
-
 
241
        }
-
 
242
    }
-
 
243
 
-
 
244
    public static function get_course_progress_count($course, $userid = 0)
Línea -... Línea 245...
-
 
245
    {
-
 
246
        global $USER;
-
 
247
 
-
 
248
        // Make sure we continue with a valid userid.
-
 
249
        if (empty($userid)) {
-
 
250
            $userid = $USER->id;
Línea -... Línea 251...
-
 
251
        }
-
 
252
 
-
 
253
        $completion = new \completion_info($course);
92
 
254
 
-
 
255
        // First, let's make sure completion is enabled.
-
 
256
        if (!$completion->is_enabled()) {
Línea 93... Línea -...
93
        $course = get_course($course_id);
-
 
94
        $course_context = context_course::instance($course->id);
-
 
95
        $completioninfo = new \completion_info($course);
-
 
96
 
257
            return null;
97
        // $course_context = !empty($PAGE->cm->id)  ? $PAGE->cm : \context_course::instance($COURSE->id);
-
 
98
        // First we should check if we want to add navigation.
258
        }
99
        // Get a list of all the activities in the course.
-
 
100
 
-
 
101
 
-
 
102
 
-
 
103
        $menu = [];
-
 
Línea -... Línea 259...
-
 
259
 
-
 
260
        if (!$completion->is_tracked_user($userid)) {
104
 
261
            return null;
-
 
262
        }
-
 
263
 
-
 
264
        // Before we check how many modules have been completed see if the course has.
-
 
265
        if ($completion->is_course_complete($userid)) {
-
 
266
            return 100;
-
 
267
        }
-
 
268
 
Línea -... Línea 269...
-
 
269
        // Get the number of modules that support completion.
-
 
270
        $modules = $completion->get_activities();
Línea -... Línea 271...
-
 
271
        $count = count($modules);
-
 
272
        if (!$count) {
Línea -... Línea 273...
-
 
273
            return null;
-
 
274
        }
-
 
275
 
-
 
276
        // Get the number of modules that have been completed.
-
 
277
        $completed = 0;
-
 
278
        foreach ($modules as $module) {
Línea 105... Línea 279...
105
        $currentServerLink = strtolower(trim($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']));
279
            $data = $completion->get_data($module, true, $userid);
106
        $currentServerLink = html_entity_decode($currentServerLink);
280
            $completed += $data->completionstate == COMPLETION_INCOMPLETE ? 0 : 1;
107
        $currentServerLink = htmlentities($currentServerLink);
281
        }
108
 
282
 
109
        $parts = explode('&', $currentServerLink);
283
        return ($completed / $count) * 100;
110
        if (count($parts) > 1) {
284
    }
Línea 111... Línea 285...
111
            $currentServerLink = $parts[0];
285
 
112
        }
286
    /**
113
 
287
     *
-
 
288
     * Outputs the course progress if course completion is on.
-
 
289
     *
-
 
290
     * @return string Markup.
-
 
291
     */
-
 
292
    protected function courseprogress($course)
-
 
293
    {
-
 
294
        global $USER;
-
 
295
        $theme = \theme_config::load('universe');
-
 
296
 
-
 
297
        $output = '';
-
 
298
        $courseformat = course_get_format($course);
-
 
299
 
-
 
300
        if (get_class($courseformat) != 'format_tiles') {
-
 
301
            $completion = new \completion_info($course);
-
 
302
 
-
 
303
            // Start Course progress count.
-
 
304
            // Make sure we continue with a valid userid.
-
 
305
            if (empty($userid)) {
-
 
306
                $userid = $USER->id;
-
 
307
            }
-
 
308
            $completion = new \completion_info($course);
-
 
309
 
-
 
310
            // Get the number of modules that support completion.
114
 
311
            $modules = $completion->get_activities();
-
 
312
            $count = count($modules);
-
 
313
            if (!$count) {
-
 
314
                return null;
115
 
315
            }
-
 
316
 
-
 
317
            // Get the number of modules that have been completed.
116
 
318
            $completed = 0;
117
        $modules = get_fast_modinfo($course->id)->get_cms();
-
 
118
 
319
            foreach ($modules as $module) {
-
 
320
                $data = $completion->get_data($module, true, $userid);
Línea -... Línea 321...
-
 
321
                $completed += $data->completionstate == COMPLETION_INCOMPLETE ? 0 : 1;
-
 
322
            }
Línea 119... Línea -...
119
        $prevmod = null;
-
 
Línea -... Línea 323...
-
 
323
            $progresscountc = $completed;
-
 
324
            $progresscounttotal = $count;
-
 
325
            // End progress count.
-
 
326
 
-
 
327
            if ($completion->is_enabled()) {
-
 
328
                $templatedata = new \stdClass;
-
 
329
                $templatedata->progress = \core_completion\progress::get_course_progress_percentage($course);
-
 
330
                $templatedata->progresscountc = $progresscountc;
-
 
331
                $templatedata->progresscounttotal = $progresscounttotal;
-
 
332
 
-
 
333
                if (!is_null($templatedata->progress)) {
-
 
334
                    $templatedata->progress = floor($templatedata->progress);
-
 
335
                } else {
-
 
336
                    $templatedata->progress = 0;
-
 
337
                }
-
 
338
                if (get_config('theme_universe', 'courseprogressbar') == 1) {
-
 
339
                    $progressbar = '<div class="rui-course-progresschart">' .
-
 
340
                        $this->render_from_template('theme_universe/progress-chart', $templatedata) .
-
 
341
                        '</div>';
-
 
342
                    if (has_capability('report/progress:view',  \context_course::instance($course->id))) {
-
 
343
                        $courseprogress = new \moodle_url('/report/progress/index.php');
-
 
344
                        $courseprogress->param('course', $course->id);
-
 
345
                        $courseprogress->param('sesskey', sesskey());
-
 
346
                        $output .= html_writer::link($courseprogress, $progressbar, array('class' => 'rui-course-progressbar border rounded px-3 pt-2 mb-3'));
-
 
347
                    } else {
-
 
348
                        $output .= $progressbar;
-
 
349
                    }
-
 
350
                }
-
 
351
            }
-
 
352
        }
-
 
353
 
-
 
354
        return $output;
-
 
355
    }
-
 
356
 
-
 
357
 
-
 
358
    /**
-
 
359
     *
-
 
360
     * Returns HTML to display course contacts.
-
 
361
     *
-
 
362
     */
-
 
363
    public function course_teachers()
-
 
364
    {
-
 
365
        global $CFG, $COURSE, $DB;
Línea -... Línea 366...
-
 
366
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
-
 
367
        $course = new core_course_list_element($course);
-
 
368
        $instructors = $course->get_course_contacts();
-
 
369
 
-
 
370
        if (!empty($instructors)) {
-
 
371
            $content = html_writer::start_div('course-teachers-box');
-
 
372
 
-
 
373
            foreach ($instructors as $key => $instructor) {
-
 
374
                $name = $instructor['username'];
-
 
375
                $role = $instructor['rolename'];
-
 
376
                $roleshortname = $instructor['role']->shortname;
-
 
377
 
-
 
378
                if ($instructor['role']->id == '3') {
-
 
379
                    $url = $CFG->wwwroot . '/user/profile.php?id=' . $key;
-
 
380
                    $user = $instructor['user'];
-
 
381
                    $userutil = new user($user->id);
-
 
382
                    $picture = $userutil->get_user_picture();
120
        $nextmod = null;
383
 
-
 
384
                    $content .= "<div class='course-contact-title-item'>
-
 
385
                        <a href='{$url}' 'title='{$name}'
-
 
386
                            class='course-contact rui-user-{$roleshortname}'>";
121
        $currentmod = new stdClass();
387
                    $content .= "<img src='{$picture}'
-
 
388
                        class='course-teacher-avatar' alt='{$name}'
-
 
389
                        title='{$name} - {$role}' data-toggle='tooltip'/>";
-
 
390
                    $content .= "<div class='course-teacher-content'>
-
 
391
                        <span class='course-teacher-role'>{$role}</span>
-
 
392
                        <h4 class='course-teacher-name'>{$name}</h4></div>";
-
 
393
                    $content .= "</a></div>";
-
 
394
                }
-
 
395
            }
-
 
396
 
-
 
397
            $content .= html_writer::end_div(); // End .teachers-box.
-
 
398
            return $content;
-
 
399
        }
122
        $currentmod->name = "Sin Módulos";
400
    }
-
 
401
 
-
 
402
    public function course_contacts()
-
 
403
    {
-
 
404
        global $CFG, $COURSE, $DB;
-
 
405
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
-
 
406
        $course = new core_course_list_element($course);
-
 
407
        $instructors = $course->get_course_contacts();
-
 
408
 
-
 
409
        if (!empty($instructors)) {
-
 
410
            $content = html_writer::start_div('course-teachers-box w-100');
-
 
411
 
-
 
412
            foreach ($instructors as $key => $instructor) {
-
 
413
                $name = $instructor['username'];
-
 
414
                $role = $instructor['rolename'];
-
 
415
                $roleshortname = $instructor['role']->shortname;
-
 
416
 
-
 
417
                $url = $CFG->wwwroot . '/user/profile.php?id=' . $key;
-
 
418
                $user = $instructor['user'];
-
 
419
                $userutil = new user($user->id);
-
 
420
                $picture = $userutil->get_user_picture(384);
-
 
421
 
-
 
422
                $user = $DB->get_record('user', array('id' => $key));
-
 
423
                $desc = $user->description;
-
 
424
 
-
 
425
                $content .= "<div class='rui-block-team-item text-center text-md-left
-
 
426
                    d-inline-flex flex-wrap align-items-start align-items-md-center'>";
-
 
427
                $content .= "<div class='rui-card-team--img-smpl'><img src='{$picture}'
-
 
428
                    class='rui-card-team--img-smpl mr-3 mr-md-5'
-
 
429
                    alt='{$name}, {$role}'/></div>";
-
 
430
                $content .= "<div class='rui-course-teacher--item col px-0 text-left'>
-
 
431
                    <a href='{$url}' 'title='{$name}'
-
 
432
                        class='course-contact rui-user-{$roleshortname}'>
-
 
433
                        <h4 class='mb-0'>{$name}</h4></a>
-
 
434
                        <span class='rui-block-text--3 rui-block-text--light mb-3'>{$role}</span>";
-
 
435
                $content .= "<div class='rui-block-text--2 mt-2'>{$desc}</div></div></div>";
-
 
436
            }
-
 
437
            $content .= html_writer::end_div(); // End .teachers-box.
-
 
438
            return $content;
-
 
439
        }
-
 
440
    }
-
 
441
 
-
 
442
    /**
-
 
443
     *
-
 
444
     * Returns HTML to display course details.
-
 
445
     *
-
 
446
     */
Línea 123... Línea -...
123
        $mods = [];
-
 
124
        $menu = [];
447
    protected function course_details()
Línea 125... Línea 448...
125
        $numberOfTemary = 1;
448
    {
-
 
449
        global $CFG, $COURSE, $DB;
-
 
450
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
126
        $prevlink = new \StdClass();
451
        $course = new core_course_list_element($course);
Línea -... Línea 452...
-
 
452
        $content = '';
127
        $nextlink = new \StdClass();
453
        $tempcourse = $DB->get_record('course_categories', ['id' => $COURSE->id]);
-
 
454
 
Línea -... Línea 455...
-
 
455
        $content .= html_writer::start_div('rui-course-details mt-4');
-
 
456
        $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
Línea -... Línea 457...
-
 
457
        $content .= html_writer::tag('span', get_string('startdate', 'moodle'), ['class' => 'rui-custom-field-name']);
-
 
458
        $content .= html_writer::tag('span', date("F j, Y", $COURSE->startdate), ['class' => 'rui-custom-field-value']);
-
 
459
        $content .= html_writer::end_div();
-
 
460
 
-
 
461
        // Course End date.
-
 
462
        $courseenddate = $COURSE->enddate;
-
 
463
        if ($courseenddate != '0') {
-
 
464
            $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
-
 
465
            $content .= html_writer::tag('span', get_string('enddate', 'moodle'), ['class' => 'rui-course-enddate-label rui-custom-field-name']);
-
 
466
            $content .= html_writer::tag('span', date("F j, Y", $courseenddate), ['class' => 'rui-course-enddate rui-custom-field-value']);
-
 
467
            $content .= html_writer::end_div();
Línea -... Línea 468...
-
 
468
        }
-
 
469
        $content .= html_writer::end_div(); // .rui-course-details.
-
 
470
 
-
 
471
        return $content;
-
 
472
    }
-
 
473
 
-
 
474
    /**
-
 
475
     *
-
 
476
     * Returns HTML to display course summary.
-
 
477
     *
-
 
478
     */
-
 
479
    protected function course_summary($courseid = 0, $content = '')
-
 
480
    {
-
 
481
        global $COURSE, $CFG;
128
        $prevlink->url = "#";
482
        $output = '';
-
 
483
 
-
 
484
        require_once($CFG->libdir . '/filelib.php');
-
 
485
 
-
 
486
        $iscourseid = $courseid ? $courseid : $COURSE->id;
-
 
487
        $iscontent = $content ? $content : $COURSE->summary;
-
 
488
        $context = context_course::instance($iscourseid);
-
 
489
        $desc = file_rewrite_pluginfile_urls($iscontent, 'pluginfile.php', $context->id, 'course', 'summary', null);
129
        $nextlink->url = "#";
490
 
130
 
491
        $output .= html_writer::start_div('rui-course-desc');
131
        $isACoursePage = $course->id !== "1" ? true : false;
492
        $output .= format_text($desc, FORMAT_HTML);
Línea 132... Línea 493...
132
 
493
        $output .= html_writer::end_div();
133
 
494
 
134
 
-
 
135
 
495
        return $output;
-
 
496
    }
-
 
497
 
136
        $modules = get_fast_modinfo($COURSE->id)->get_cms();
498
    /**
Línea -... Línea 499...
-
 
499
     * Outputs the pix url base
-
 
500
     *
-
 
501
     * @return string an URL.
-
 
502
     */
-
 
503
    public function get_pix_image_url_base()
-
 
504
    {
-
 
505
        global $CFG;
-
 
506
 
-
 
507
        return $CFG->wwwroot . "/theme/universe/pix";
-
 
508
    }
-
 
509
 
-
 
510
    /**
-
 
511
     *
-
 
512
     */
-
 
513
    public function course_hero_url()
Línea 137... Línea 514...
137
        /*
514
    {
Línea -... Línea 515...
-
 
515
        global $CFG, $COURSE, $DB;
Línea -... Línea 516...
-
 
516
 
Línea -... Línea 517...
-
 
517
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
-
 
518
 
-
 
519
        $course = new core_course_list_element($course);
-
 
520
 
-
 
521
        $courseimage = '';
-
 
522
        $imageindex = 1;
-
 
523
        foreach ($course->get_course_overviewfiles() as $file) {
-
 
524
            $isimage = $file->is_valid_image();
-
 
525
 
-
 
526
            $url = new moodle_url("$CFG->wwwroot/pluginfile.php" . '/' .
Línea 138... Línea -...
138
            echo '<pre>';
-
 
139
            print_r($modules);
-
 
140
            echo '</pre>';
-
 
Línea -... Línea 527...
-
 
527
                $file->get_contextid() . '/' . $file->get_component() . '/' .
-
 
528
                $file->get_filearea() .
-
 
529
                $file->get_filepath() .
-
 
530
                $file->get_filename(), ['forcedownload' => !$isimage]);
-
 
531
 
-
 
532
            if ($isimage) {
-
 
533
                $courseimage = $url;
-
 
534
            }
-
 
535
 
-
 
536
            if ($imageindex == 2) {
-
 
537
                break;
-
 
538
            }
-
 
539
 
-
 
540
            $imageindex++;
-
 
541
        }
-
 
542
 
-
 
543
        $html = '';
-
 
544
        // Create html for header.
-
 
545
        if (!empty($courseimage)) {
-
 
546
            $html .= $courseimage;
-
 
547
        }
-
 
548
        return $html;
-
 
549
    }
-
 
550
 
-
 
551
    /**
-
 
552
     * Returns HTML to display course hero.
-
 
553
     *
-
 
554
     */
-
 
555
    public function course_hero()
-
 
556
    {
-
 
557
        global $CFG, $COURSE, $DB;
-
 
558
 
-
 
559
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
-
 
560
 
-
 
561
        $course = new core_course_list_element($course);
-
 
562
 
-
 
563
        $courseimage = '';
-
 
564
 
-
 
565
        $courseutil = new course($course);
-
 
566
        $courseimage = $courseutil->get_summary_image(false); // Remove repeatable pattern on the course page.
-
 
567
 
-
 
568
        $html = '';
-
 
569
        // Create html for header.
-
 
570
        if (!empty($courseimage)) {
-
 
571
            $html .= $courseimage;
-
 
572
        }
-
 
573
        return $html;
-
 
574
    }
-
 
575
 
-
 
576
 
-
 
577
 
-
 
578
 
-
 
579
    /**
-
 
580
     * Breadcrumbs
-
 
581
     *
-
 
582
     */
-
 
583
    public function breadcrumbs()
-
 
584
    {
-
 
585
        global $USER, $COURSE, $CFG;
-
 
586
 
-
 
587
        $header = new stdClass();
-
 
588
        $header->hasnavbar = empty($this->page->layout_options['nonavbar']);
-
 
589
        $header->navbar = $this->navbar();
-
 
590
        $header->courseheader = $this->course_header();
-
 
591
        $html = $this->render_from_template('theme_universe/breadcrumbs', $header);
-
 
592
 
-
 
593
        return $html;
-
 
594
    }
-
 
595
 
-
 
596
 
-
 
597
    /**
-
 
598
     * Wrapper for header elements.
-
 
599
     *
-
 
600
     * @return string HTML to display the main header.
-
 
601
     */
-
 
602
    public function simple_header()
-
 
603
    {
-
 
604
 
-
 
605
        global $USER, $COURSE, $CFG;
-
 
606
        $html = null;
-
 
607
 
-
 
608
        if (
-
 
609
            $this->page->include_region_main_settings_in_header_actions() &&
-
 
610
            !$this->page->blocks->is_block_present('settings')
-
 
611
        ) {
-
 
612
            // Only include the region main settings if the page has requested it and it doesn't already have
-
 
613
            // the settings block on it. The region main settings are included in the settings block and
-
 
614
            // duplicating the content causes behat failures.
-
 
615
            $this->page->add_header_action(html_writer::div(
-
 
616
                $this->region_main_settings_menu(),
-
 
617
                'd-print-none',
-
 
618
                ['id' => 'region-main-settings-menu']
-
 
619
            ));
-
 
620
        }
-
 
621
 
-
 
622
        $header = new stdClass();
-
 
623
        $header->settingsmenu = $this->context_header_settings_menu();
-
 
624
        $header->contextheader = $this->context_header();
-
 
625
        $header->hasnavbar = empty($this->page->layout_options['nonavbar']);
-
 
626
        $header->navbar = $this->navbar();
-
 
627
        $header->pageheadingbutton = $this->page_heading_button();
-
 
628
        $header->courseheader = $this->course_header();
-
 
629
        $header->headeractions = $this->page->get_header_actions();
-
 
630
 
-
 
631
        if ($this->page->pagelayout != 'admin') {
-
 
632
            $html .= $this->render_from_template('theme_universe/header', $header);
-
 
633
        }
-
 
634
 
-
 
635
        if ($this->page->pagelayout == 'admin') {
-
 
636
            $html .= $this->render_from_template('theme_universe/header_admin', $header);
-
 
637
        }
-
 
638
 
-
 
639
        return $html;
-
 
640
    }
-
 
641
 
-
 
642
    public function display_course_progress()
-
 
643
    {
-
 
644
        $html = null;
-
 
645
        $html .= $this->courseprogress($this->page->course);
-
 
646
        return $html;
-
 
647
    }
-
 
648
 
-
 
649
    /**
-
 
650
     * Wrapper for header elements.
-
 
651
     *
-
 
652
     * @return string HTML to display the main header.
-
 
653
     */
-
 
654
    public function full_header()
-
 
655
    {
-
 
656
        global $USER, $COURSE, $CFG;
-
 
657
        $theme = \theme_config::load('universe');
-
 
658
        $html = null;
-
 
659
        $pagetype = $this->page->pagetype;
-
 
660
        $homepage = get_home_page();
-
 
661
        $homepagetype = null;
-
 
662
        // Add a special case since /my/courses is a part of the /my subsystem.
-
 
663
        if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) {
-
 
664
            $homepagetype = 'my-index';
-
 
665
        } else if ($homepage == HOMEPAGE_SITE) {
-
 
666
            $homepagetype = 'site-index';
-
 
667
        }
-
 
668
        if (
-
 
669
            $this->page->include_region_main_settings_in_header_actions() &&
-
 
670
            !$this->page->blocks->is_block_present('settings')
-
 
671
        ) {
-
 
672
            // Only include the region main settings if the page has requested it and it doesn't already have
-
 
673
            // the settings block on it. The region main settings are included in the settings block and
-
 
674
            // duplicating the content causes behat failures.
-
 
675
            $this->page->add_header_action(html_writer::div(
-
 
676
                $this->region_main_settings_menu(),
-
 
677
                'd-print-none',
-
 
678
                ['id' => 'region-main-settings-menu']
-
 
679
            ));
-
 
680
        }
-
 
681
 
-
 
682
        $header = new stdClass();
-
 
683
        $header->settingsmenu = $this->context_header_settings_menu();
-
 
684
        $header->contextheader = $this->context_header();
-
 
685
        $header->hasnavbar = empty($this->page->layout_options['nonavbar']);
-
 
686
        $header->navbar = $this->navbar();
-
 
687
        $header->pageheadingbutton = $this->page_heading_button();
-
 
688
        $header->courseheader = $this->course_header();
-
 
689
        $header->headeractions = $this->page->get_header_actions();
-
 
690
 
-
 
691
        if ($this->page->theme->settings->ipcoursedetails == 1) {
-
 
692
            $html .= $this->course_details();
-
 
693
        }
-
 
694
 
-
 
695
        $html .= $this->render_from_template('theme_universe/header', $header);
-
 
696
        if ($this->page->theme->settings->ipcoursesummary == 1) {
-
 
697
            $html .= $this->course_summary();
-
 
698
        }
-
 
699
 
-
 
700
        $html .= html_writer::start_tag('div', array('class' => 'rui-course-header-color'));
-
 
701
        if ($this->page->theme->settings->cccteachers == 1) {
-
 
702
            $html .= $this->course_teachers();
-
 
703
        }
-
 
704
 
-
 
705
        $html .= html_writer::end_tag('div'); // End .rui-course-header.
-
 
706
 
-
 
707
        return $html;
-
 
708
    }
-
 
709
 
-
 
710
 
-
 
711
    /**
-
 
712
     * Wrapper for header elements.
-
 
713
     *
-
 
714
     * @return string HTML to display the main header.
-
 
715
     */
-
 
716
    public function clean_header()
-
 
717
    {
-
 
718
        global $USER, $COURSE, $CFG;
-
 
719
        $theme = \theme_config::load('universe');
-
 
720
        $html = null;
-
 
721
        $pagetype = $this->page->pagetype;
-
 
722
        $homepage = get_home_page();
-
 
723
        $homepagetype = null;
-
 
724
        // Add a special case since /my/courses is a part of the /my subsystem.
-
 
725
        if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) {
-
 
726
            $homepagetype = 'my-index';
-
 
727
        } else if ($homepage == HOMEPAGE_SITE) {
-
 
728
            $homepagetype = 'site-index';
-
 
729
        }
141
            */
730
        if (
-
 
731
            $this->page->include_region_main_settings_in_header_actions() &&
-
 
732
            !$this->page->blocks->is_block_present('settings')
142
 
733
        ) {
-
 
734
            // Only include the region main settings if the page has requested it and it doesn't already have
-
 
735
            // the settings block on it. The region main settings are included in the settings block and
-
 
736
            // duplicating the content causes behat failures.
-
 
737
            $this->page->add_header_action(html_writer::div(
143
        if (!empty($modules)) {
738
                $this->region_main_settings_menu(),
144
            // Put the modules into an array in order by the position they are shown in the course.
739
                'd-print-none',
-
 
740
                ['id' => 'region-main-settings-menu']
-
 
741
            ));
-
 
742
        }
-
 
743
 
-
 
744
        $header = new stdClass();
-
 
745
        $header->courseheader = $this->course_header();
-
 
746
        $header->headeractions = $this->page->get_header_actions();
-
 
747
 
-
 
748
        $html .= $this->render_from_template('theme_universe/header', $header);
-
 
749
 
-
 
750
        return $html;
-
 
751
    }
-
 
752
 
-
 
753
 
-
 
754
    /**
-
 
755
     * Returns standard navigation between activities in a course.
-
 
756
     *
-
 
757
     * @return string the navigation HTML.
-
 
758
     */
-
 
759
    public function activity_navigation()
-
 
760
    {
-
 
761
        // First we should check if we want to add navigation.
-
 
762
        $context = $this->page->context;
-
 
763
        if (($this->page->pagelayout !== 'incourse' && $this->page->pagelayout !== 'frametop')
-
 
764
            || $context->contextlevel != CONTEXT_MODULE
-
 
765
        ) {
-
 
766
            return '';
-
 
767
        }
-
 
768
        // If the activity is in stealth mode, show no links.
-
 
769
        if ($this->page->cm->is_stealth()) {
-
 
770
            return '';
-
 
771
        }
-
 
772
        $course = $this->page->cm->get_course();
-
 
773
        $courseformat = course_get_format($course);
-
 
774
 
-
 
775
        // Get a list of all the activities in the course.
-
 
776
        $modules = get_fast_modinfo($course->id)->get_cms();
-
 
777
        // Put the modules into an array in order by the position they are shown in the course.
-
 
778
        $mods = [];
-
 
779
        $activitylist = [];
-
 
780
        foreach ($modules as $module) {
-
 
781
            // Only add activities the user can access, aren't in stealth mode and have a url (eg. mod_label does not).
-
 
782
            if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
-
 
783
                continue;
-
 
784
            }
-
 
785
            $mods[$module->id] = $module;
-
 
786
            // No need to add the current module to the list for the activity dropdown menu.
-
 
787
            if ($module->id == $this->page->cm->id) {
-
 
788
                continue;
-
 
789
            }
-
 
790
            // Module name.
-
 
791
            $modname = $module->get_formatted_name();
-
 
792
            // Display the hidden text if necessary.
-
 
793
            if (!$module->visible) {
-
 
794
                $modname .= ' ' . get_string('hiddenwithbrackets');
-
 
795
            }
-
 
796
            // Module URL.
-
 
797
            $linkurl = new moodle_url($module->url, array('forceview' => 1));
-
 
798
            // Add module URL (as key) and name (as value) to the activity list array.
-
 
799
            $activitylist[$linkurl->out(false)] = $modname;
-
 
800
        }
-
 
801
        $nummods = count($mods);
-
 
802
        // If there is only one mod then do nothing.
-
 
803
        if ($nummods == 1) {
-
 
804
            return '';
-
 
805
        }
-
 
806
        // Get an array of just the course module ids used to get the cmid value based on their position in the course.
-
 
807
        $modids = array_keys($mods);
-
 
808
        // Get the position in the array of the course module we are viewing.
-
 
809
        $position = array_search($this->page->cm->id, $modids);
-
 
810
        $prevmod = null;
-
 
811
        $nextmod = null;
-
 
812
        // Check if we have a previous mod to show.
-
 
813
        if ($position > 0) {
-
 
814
            $prevmod = $mods[$modids[$position - 1]];
-
 
815
        }
-
 
816
        // Check if we have a next mod to show.
-
 
817
        if ($position < ($nummods - 1)) {
-
 
818
            $nextmod = $mods[$modids[$position + 1]];
-
 
819
        }
-
 
820
        $activitynav = new \core_course\output\activity_navigation($prevmod, $nextmod, $activitylist);
-
 
821
        $renderer = $this->page->get_renderer('core', 'course');
-
 
822
        return $renderer->render($activitynav);
-
 
823
    }
Línea 145... Línea 824...
145
            foreach ($modules as $module) {
824
 
146
                if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
825
 
147
                    continue;
826
    /**
148
                }
827
     * This is an optional menu that can be added to a layout by a theme. It contains the
149
                $mods[$module->id] = $module;
828
     * menu for the course administration, only on the course main page.
-
 
829
     *
150
            }
830
     * @return string
-
 
831
     */
Línea -... Línea 832...
-
 
832
    public function context_header_settings_menu()
-
 
833
    {
-
 
834
        $context = $this->page->context;
-
 
835
        $menu = new action_menu();
-
 
836
 
-
 
837
        $items = $this->page->navbar->get_items();
-
 
838
        $currentnode = end($items);
-
 
839
 
Línea -... Línea 840...
-
 
840
        $showcoursemenu = false;
-
 
841
        $showfrontpagemenu = false;
151
 
842
        $showusermenu = false;
-
 
843
 
-
 
844
        // We are on the course home page.
-
 
845
        if (($context->contextlevel == CONTEXT_COURSE) &&
-
 
846
            !empty($currentnode) &&
-
 
847
            ($currentnode->type == navigation_node::TYPE_COURSE || $currentnode->type == navigation_node::TYPE_SECTION)
-
 
848
        ) {
-
 
849
            $showcoursemenu = true;
-
 
850
        }
-
 
851
 
-
 
852
        $courseformat = course_get_format($this->page->course);
-
 
853
        // This is a single activity course format, always show the course menu on the activity main page.
-
 
854
        if (
-
 
855
            $context->contextlevel == CONTEXT_MODULE &&
-
 
856
            !$courseformat->has_view_page()
-
 
857
        ) {
-
 
858
 
-
 
859
            $this->page->navigation->initialise();
-
 
860
            $activenode = $this->page->navigation->find_active_node();
-
 
861
            // If the settings menu has been forced then show the menu.
-
 
862
            if ($this->page->is_settings_menu_forced()) {
-
 
863
                $showcoursemenu = true;
-
 
864
            } else if (!empty($activenode) && ($activenode->type == navigation_node::TYPE_ACTIVITY ||
-
 
865
                $activenode->type == navigation_node::TYPE_RESOURCE)) {
-
 
866
 
-
 
867
                // We only want to show the menu on the first page of the activity. This means
-
 
868
                // the breadcrumb has no additional nodes.
-
 
869
                if ($currentnode && ($currentnode->key == $activenode->key && $currentnode->type == $activenode->type)) {
-
 
870
                    $showcoursemenu = true;
-
 
871
                }
-
 
872
            }
-
 
873
        }
-
 
874
 
152
 
875
        // This is the site front page.
Línea -... Línea 876...
-
 
876
        if (
-
 
877
            $context->contextlevel == CONTEXT_COURSE &&
Línea -... Línea 878...
-
 
878
            !empty($currentnode) &&
-
 
879
            $currentnode->key === 'home'
-
 
880
        ) {
-
 
881
            $showfrontpagemenu = true;
-
 
882
        }
Línea 153... Línea -...
153
            $nummods = count($mods);
-
 
154
 
883
 
155
 
-
 
Línea -... Línea 884...
-
 
884
        // This is the user profile page.
-
 
885
        if (
Línea -... Línea 886...
-
 
886
            $context->contextlevel == CONTEXT_USER &&
-
 
887
            !empty($currentnode) &&
-
 
888
            ($currentnode->key === 'myprofile')
-
 
889
        ) {
-
 
890
            $showusermenu = true;
-
 
891
        }
-
 
892
 
-
 
893
        if ($showfrontpagemenu) {
-
 
894
            $settingsnode = $this->page->settingsnav->find('frontpage', navigation_node::TYPE_SETTING);
-
 
895
            if ($settingsnode) {
-
 
896
                // Build an action menu based on the visible nodes from this navigation tree.
-
 
897
                $skipped = $this->build_action_menu_from_navigation($menu, $settingsnode, false, true);
-
 
898
 
-
 
899
                // We only add a list to the full settings menu if we didn't include every node in the short menu.
-
 
900
                if ($skipped) {
-
 
901
                    $text = get_string('morenavigationlinks');
-
 
902
                    $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id));
-
 
903
                    $link = new action_link($url, $text, null, null, new pix_icon('t/edit', $text));
-
 
904
                    $menu->add_secondary_action($link);
-
 
905
                }
-
 
906
            }
-
 
907
        } else if ($showcoursemenu) {
-
 
908
            $settingsnode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE);
Línea -... Línea 909...
-
 
909
            if ($settingsnode) {
-
 
910
                // Build an action menu based on the visible nodes from this navigation tree.
-
 
911
                $skipped = $this->build_action_menu_from_navigation($menu, $settingsnode, false, true);
-
 
912
 
156
            // If there is only one mod then do nothing.
913
                // We only add a list to the full settings menu if we didn't include every node in the short menu.
157
            if ($nummods == 1) {
914
                if ($skipped) {
-
 
915
                    $text = get_string('morenavigationlinks');
-
 
916
                    $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id));
Línea 158... Línea 917...
158
            }
917
                    $link = new action_link($url, $text, null, null, new pix_icon('t/edit', $text));
159
 
-
 
160
            // Get an array of just the course module ids used to get the cmid value based on their position in the course.
918
                    $menu->add_secondary_action($link);
161
            $modids = array_keys($mods);
919
                }
162
 
920
            }
163
            // Get the position in the array of the course module we are viewing.
-
 
Línea -... Línea 921...
-
 
921
        } else if ($showusermenu) {
-
 
922
            // Get the course admin node from the settings navigation.
-
 
923
            $settingsnode = $this->page->settingsnav->find('useraccount', navigation_node::TYPE_CONTAINER);
-
 
924
            if ($settingsnode) {
-
 
925
                // Build an action menu based on the visible nodes from this navigation tree.
-
 
926
                $this->build_action_menu_from_navigation($menu, $settingsnode);
-
 
927
            }
-
 
928
        }
-
 
929
 
164
            $position = array_search($course_context->id, $modids);   //array_search($this->page->cm->id, $modids);
930
        return $this->render($menu);
165
 
931
    }
-
 
932
 
-
 
933
    public function customeditblockbtn()
-
 
934
    {
-
 
935
        $header = new stdClass();
-
 
936
        $header->settingsmenu = $this->context_header_settings_menu();
-
 
937
        $header->pageheadingbutton = $this->page_heading_button();
-
 
938
 
-
 
939
        $html = $this->render_from_template('theme_universe/header_settings_menu', $header);
-
 
940
 
-
 
941
        return $html;
-
 
942
    }
-
 
943
 
-
 
944
    /**
-
 
945
     * Renders the context header for the page.
-
 
946
     *
-
 
947
     * @param array $headerinfo Heading information.
-
 
948
     * @param int $headinglevel What 'h' level to make the heading.
-
 
949
     * @return string A rendered context header.
-
 
950
     */
-
 
951
    public function context_header($headerinfo = null, $headinglevel = 1): string
-
 
952
    {
-
 
953
        global $DB, $USER, $CFG, $SITE;
-
 
954
        require_once($CFG->dirroot . '/user/lib.php');
-
 
955
        $context = $this->page->context;
-
 
956
        $heading = null;
-
 
957
        $imagedata = null;
-
 
958
        $subheader = null;
-
 
959
        $userbuttons = null;
-
 
960
 
-
 
961
        // Make sure to use the heading if it has been set.
-
 
962
        if (isset($headerinfo['heading'])) {
-
 
963
            $heading = $headerinfo['heading'];
-
 
964
        } else {
-
 
965
            $heading = $this->page->heading;
-
 
966
        }
-
 
967
 
-
 
968
        // The user context currently has images and buttons. Other contexts may follow.
-
 
969
        if ((isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) && $this->page->pagetype !== 'my-index') {
-
 
970
            if (isset($headerinfo['user'])) {
-
 
971
                $user = $headerinfo['user'];
-
 
972
            } else {
-
 
973
                // Look up the user information if it is not supplied.
-
 
974
                $user = $DB->get_record('user', array('id' => $context->instanceid));
-
 
975
            }
-
 
976
 
-
 
977
            // If the user context is set, then use that for capability checks.
-
 
978
            if (isset($headerinfo['usercontext'])) {
-
 
979
                $context = $headerinfo['usercontext'];
-
 
980
            }
-
 
981
 
166
            $currentmod = $mods[$modids[$position]];
982
            // Only provide user information if the user is the current user, or a user which the current user can view.
167
 
983
            // When checking user_can_view_profile(), either:
-
 
984
            // If the page context is course, check the course context (from the page object) or;
-
 
985
            // If page context is NOT course, then check across all courses.
168
 
986
            $course = ($this->page->context->contextlevel == CONTEXT_COURSE) ? $this->page->course : null;
-
 
987
 
-
 
988
            if (user_can_view_profile($user, $course)) {
-
 
989
                // Use the user's full name if the heading isn't set.
169
 
990
                if (empty($heading)) {
-
 
991
                    $heading = fullname($user);
-
 
992
                }
-
 
993
 
-
 
994
                $imagedata = $this->user_picture($user, array('size' => 100));
-
 
995
 
Línea 170... Línea -...
170
            // Check if we have a previous mod to show.
-
 
Línea -... Línea 996...
-
 
996
                // Check to see if we should be displaying a message button.
-
 
997
                if (!empty($CFG->messaging) && has_capability('moodle/site:sendmessage', $context)) {
-
 
998
                    $userbuttons = array(
-
 
999
                        'messages' => array(
-
 
1000
                            'buttontype' => 'message',
-
 
1001
                            'title' => get_string('message', 'message'),
-
 
1002
                            'url' => new moodle_url('/message/index.php', array('id' => $user->id)),
-
 
1003
                            'image' => 'message',
-
 
1004
                            'linkattributes' => \core_message\helper::messageuser_link_params($user->id),
-
 
1005
                            'page' => $this->page
-
 
1006
                        )
-
 
1007
                    );
Línea -... Línea 1008...
-
 
1008
 
-
 
1009
                    if ($USER->id != $user->id) {
171
            if ($position > 0) {
1010
                        $iscontact = \core_message\api::is_contact($USER->id, $user->id);
Línea 172... Línea 1011...
172
                $prevmod = $mods[$modids[$position - 1]];
1011
                        $contacttitle = $iscontact ? 'removefromyourcontacts' : 'addtoyourcontacts';
173
            }
1012
                        $contacturlaction = $iscontact ? 'removecontact' : 'addcontact';
-
 
1013
                        $contactimage = $iscontact ? 'removecontact' : 'addcontact';
174
 
1014
                        $userbuttons['togglecontact'] = array(
175
            // Check if we have a next mod to show.
1015
                            'buttontype' => 'togglecontact',
176
            if ($position < ($nummods - 1)) {
-
 
177
                $nextmod = $mods[$modids[$position + 1]];
1016
                            'title' => get_string($contacttitle, 'message'),
Línea -... Línea 1017...
-
 
1017
                            'url' => new moodle_url(
-
 
1018
                                '/message/index.php',
-
 
1019
                                array(
-
 
1020
                                    'user1' => $USER->id,
-
 
1021
                                    'user2' => $user->id,
Línea -... Línea 1022...
-
 
1022
                                    $contacturlaction => $user->id,
Línea -... Línea 1023...
-
 
1023
                                    'sesskey' => sesskey()
-
 
1024
                                )
-
 
1025
                            ),
-
 
1026
                            'image' => $contactimage,
Línea 178... Línea 1027...
178
            }
1027
                            'linkattributes' => \core_message\helper::togglecontact_link_params($user, $iscontact),
-
 
1028
                            'page' => $this->page
-
 
1029
                        );
-
 
1030
                    }
-
 
1031
 
-
 
1032
                    $this->page->requires->string_for_js('changesmadereallygoaway', 'moodle');
-
 
1033
                }
-
 
1034
            } else {
-
 
1035
                $heading = null;
-
 
1036
            }
-
 
1037
        }
-
 
1038
 
-
 
1039
        $prefix = null;
-
 
1040
        if ($context->contextlevel == CONTEXT_MODULE) {
-
 
1041
            if ($this->page->course->format === 'singleactivity') {
-
 
1042
                $heading = $this->page->course->fullname;
-
 
1043
            } else {
-
 
1044
                $heading = $this->page->cm->get_formatted_name();
-
 
1045
                $imagedata = $this->pix_icon('monologo', '', $this->page->activityname, ['class' => 'activityicon']);
-
 
1046
                $purposeclass = plugin_supports('mod', $this->page->activityname, FEATURE_MOD_PURPOSE);
-
 
1047
                $purposeclass .= ' activityiconcontainer';
-
 
1048
                $purposeclass .= ' modicon_' . $this->page->activityname;
-
 
1049
                $imagedata = html_writer::tag('div', $imagedata, ['class' => $purposeclass]);
-
 
1050
                $prefix = get_string('modulename', $this->page->activityname);
-
 
1051
            }
Línea -... Línea 1052...
-
 
1052
        }
-
 
1053
 
-
 
1054
        $contextheader = new \context_header($heading, $headinglevel, $imagedata, $userbuttons, $prefix);
-
 
1055
        return $this->render_context_header($contextheader);
-
 
1056
    }
-
 
1057
 
-
 
1058
 
-
 
1059
    /**
-
 
1060
     * Construct a user menu, returning HTML that can be echoed out by a
-
 
1061
     * layout file.
-
 
1062
     *
-
 
1063
     * @param stdClass $user A user object, usually $USER.
-
 
1064
     * @param bool $withlinks true if a dropdown should be built.
-
 
1065
     * @return string HTML fragment.
-
 
1066
     */
-
 
1067
    public function user_menu($user = null, $withlinks = null)
-
 
1068
    {
-
 
1069
        global $USER, $CFG;
-
 
1070
        require_once($CFG->dirroot . '/user/lib.php');
-
 
1071
 
-
 
1072
        if (is_null($user)) {
-
 
1073
            $user = $USER;
-
 
1074
        }
-
 
1075
 
-
 
1076
        // Note: this behaviour is intended to match that of core_renderer::login_info,
-
 
1077
        // but should not be considered to be good practice; layout options are
-
 
1078
        // intended to be theme-specific. Please don't copy this snippet anywhere else.
-
 
1079
        if (is_null($withlinks)) {
-
 
1080
            $withlinks = empty($this->page->layout_options['nologinlinks']);
-
 
1081
        }
179
        }
1082
 
-
 
1083
        // Add a class for when $withlinks is false.
-
 
1084
        $usermenuclasses = 'usermenu';
-
 
1085
        if (!$withlinks) {
-
 
1086
            $usermenuclasses .= ' withoutlinks';
-
 
1087
        }
-
 
1088
 
-
 
1089
        $returnstr = "";
180
 
1090
 
-
 
1091
        // If during initial install, return the empty return string.
-
 
1092
        if (during_initial_install()) {
-
 
1093
            return $returnstr;
-
 
1094
        }
-
 
1095
 
-
 
1096
        $loginpage = $this->is_login_page();
-
 
1097
        $loginurl = get_login_url();
-
 
1098
        // If not logged in, show the typical not-logged-in string.
-
 
1099
        if (!isloggedin()) {
-
 
1100
            if (!$loginpage) {
-
 
1101
                $returnstr .= "<a class=\"rui-topbar-btn rui-login-btn\" href=\"$loginurl\"><span class=\"rui-login-btn-txt\">" .
-
 
1102
                    get_string('login') .
-
 
1103
                    '</span>
-
 
1104
                <svg class="ml-2" width="20" height="20" fill="none" viewBox="0 0 24 24">
-
 
1105
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
-
 
1106
                d="M9.75 8.75L13.25 12L9.75 15.25"></path>
-
 
1107
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
181
 
1108
                d="M9.75 4.75H17.25C18.3546 4.75 19.25 5.64543 19.25 6.75V17.25C19.25 18.3546 18.3546 19.25 17.25 19.25H9.75">
Línea -... Línea 1109...
-
 
1109
                </path>
-
 
1110
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 12H4.75"></path>
182
        //$sections = $DB->get_records('course_sections', ['course' => $COURSE->id], 'section ASC', 'id,name,section,sequence,visible');
1111
                </svg></a>';
-
 
1112
            }
-
 
1113
            return html_writer::div(
183
 
1114
                html_writer::span(
-
 
1115
                    $returnstr,
-
 
1116
                    'login'
Línea -... Línea 1117...
-
 
1117
                ),
-
 
1118
                $usermenuclasses
-
 
1119
            );
-
 
1120
        }
-
 
1121
 
-
 
1122
        // If logged in as a guest user, show a string to that effect.
-
 
1123
        if (isguestuser()) {
-
 
1124
            $icon = '<svg class="mr-2"
-
 
1125
                width="24"
-
 
1126
                height="24"
-
 
1127
                viewBox="0 0 24 24"
-
 
1128
                fill="none"
-
 
1129
                xmlns="http://www.w3.org/2000/svg">
-
 
1130
            <path d="M10 12C10 12.5523 9.55228 13 9 13C8.44772 13 8 12.5523 8
-
 
1131
            12C8 11.4477 8.44772 11 9 11C9.55228 11 10 11.4477 10 12Z"
-
 
1132
                fill="currentColor"
-
 
1133
                />
-
 
1134
            <path d="M15 13C15.5523 13 16 12.5523 16 12C16 11.4477 15.5523 11
-
 
1135
            15 11C14.4477 11 14 11.4477 14 12C14 12.5523 14.4477 13 15 13Z"
-
 
1136
                fill="currentColor"
-
 
1137
                />
-
 
1138
            <path fill-rule="evenodd"
-
 
1139
                clip-rule="evenodd"
-
 
1140
                d="M12.0244 2.00003L12 2C6.47715 2 2 6.47715 2 12C2 17.5228
-
 
1141
                6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.74235
-
 
1142
            17.9425 2.43237 12.788 2.03059L12.7886 2.0282C12.5329 2.00891
-
 
1143
            12.278 1.99961 12.0244 2.00003ZM12 20C16.4183 20 20 16.4183 20
-
 
1144
            12C20 11.3014 19.9105 10.6237 19.7422
-
 
1145
            9.97775C16.1597 10.2313 12.7359 8.52461 10.7605 5.60246C9.31322
-
 
1146
            7.07886 7.2982 7.99666 5.06879 8.00253C4.38902 9.17866 4 10.5439 4
-
 
1147
            12C4 16.4183 7.58172 20
-
 
1148
            12 20ZM11.9785 4.00003L12.0236 4.00003L12 4L11.9785 4.00003Z"
-
 
1149
                fill="currentColor"
-
 
1150
                /></svg>';
-
 
1151
            $returnstr = '<div class="rui-badge-guest">' . $icon . get_string('loggedinasguest') . '</div>';
-
 
1152
            if (!$loginpage && $withlinks) {
-
 
1153
                $returnstr .= "<a class=\"rui-topbar-btn rui-login-btn\"
-
 
1154
                    href=\"$loginurl\"><span class=\"rui-login-btn-txt\">" .
-
 
1155
                    get_string('login') .
-
 
1156
                    '</span>
-
 
1157
                <svg class="ml-2"
-
 
1158
                    width="20"
-
 
1159
                    height="20"
-
 
1160
                    fill="none"
-
 
1161
                    viewBox="0 0 24 24">
-
 
1162
                <path stroke="currentColor"
-
 
1163
                    stroke-linecap="round"
-
 
1164
                    stroke-linejoin="round"
-
 
1165
                    stroke-width="2"
-
 
1166
                    d="M9.75 8.75L13.25 12L9.75 15.25"></path>
-
 
1167
                <path stroke="currentColor"
-
 
1168
                    stroke-linecap="round"
-
 
1169
                    stroke-linejoin="round"
-
 
1170
                    stroke-width="2"
-
 
1171
                    d="M9.75 4.75H17.25C18.3546 4.75 19.25 5.64543 19.25
-
 
1172
                    6.75V17.25C19.25 18.3546 18.3546 19.25 17.25 19.25H9.75"></path>
-
 
1173
                    <path stroke="currentColor"
184
 
1174
                        stroke-linecap="round"
-
 
1175
                        stroke-linejoin="round"
-
 
1176
                        stroke-width="2"
-
 
1177
                        d="M13 12H4.75"></path></svg></a>';
-
 
1178
            }
-
 
1179
 
-
 
1180
            return html_writer::div(
-
 
1181
                html_writer::span(
-
 
1182
                    $returnstr,
-
 
1183
                    'login'
-
 
1184
                ),
-
 
1185
                $usermenuclasses
-
 
1186
            );
-
 
1187
        }
-
 
1188
 
-
 
1189
        // Get some navigation opts.
-
 
1190
        $opts = user_get_user_navigation_info($user, $this->page, array('avatarsize' => 56));
-
 
1191
 
-
 
1192
        $avatarclasses = "avatars";
-
 
1193
        $avatarcontents = html_writer::span($opts->metadata['useravatar'], 'avatar current');
-
 
1194
        $usertextcontents = '<span class="rui-fullname">' . $opts->metadata['userfullname'] . '</span>';
-
 
1195
        $usertextmail = $user->email;
-
 
1196
        $usernick = '<svg class="mr-1"
-
 
1197
            width="16"
-
 
1198
            height="16"
-
 
1199
            fill="none"
-
 
1200
            viewBox="0 0 24 24">
-
 
1201
        <path stroke="currentColor"
-
 
1202
            stroke-linecap="round"
-
 
1203
            stroke-linejoin="round"
-
 
1204
            stroke-width="2"
-
 
1205
            d="M12 13V15"></path>
-
 
1206
        <circle cx="12"
-
 
1207
            cy="9"
-
 
1208
            r="1"
-
 
1209
            fill="currentColor"></circle>
-
 
1210
        <circle cx="12"
-
 
1211
            cy="12"
Línea -... Línea 1212...
-
 
1212
            r="7.25"
-
 
1213
            stroke="currentColor"
-
 
1214
            stroke-linecap="round"
-
 
1215
            stroke-linejoin="round"
-
 
1216
            stroke-width="1.5"></circle>
-
 
1217
        </svg>' . $user->username;
-
 
1218
 
-
 
1219
        // Other user.
-
 
1220
        $usermeta = '';
-
 
1221
        if (!empty($opts->metadata['asotheruser'])) {
-
 
1222
            $avatarcontents .= html_writer::span(
-
 
1223
                $opts->metadata['realuseravatar'],
-
 
1224
                'avatar realuser'
-
 
1225
            );
-
 
1226
            $usermeta .= $opts->metadata['realuserfullname'];
-
 
1227
            $usermeta .= html_writer::tag(
-
 
1228
                'span',
-
 
1229
                get_string(
-
 
1230
                    'loggedinas',
-
 
1231
                    'moodle',
-
 
1232
                    html_writer::span(
-
 
1233
                        $opts->metadata['userfullname'],
-
 
1234
                        'value'
-
 
1235
                    )
-
 
1236
                ),
-
 
1237
                array('class' => 'meta viewingas')
-
 
1238
            );
-
 
1239
        }
-
 
1240
 
-
 
1241
        // Role.
-
 
1242
        if (!empty($opts->metadata['asotherrole'])) {
-
 
1243
            $role = core_text::strtolower(preg_replace('#[ ]+#', '-', trim($opts->metadata['rolename'])));
-
 
1244
            $usermeta .= html_writer::span(
-
 
1245
                $opts->metadata['rolename'],
-
 
1246
                'meta role role-' . $role
-
 
1247
            );
-
 
1248
        }
-
 
1249
 
185
 
1250
        // User login failures.
-
 
1251
        if (!empty($opts->metadata['userloginfail'])) {
-
 
1252
            $usermeta .= html_writer::div(
-
 
1253
                '<svg class="mr-1"
-
 
1254
                width="16"
-
 
1255
                height="16"
-
 
1256
                fill="none"
-
 
1257
                viewBox="0 0 24 24"><path stroke="currentColor"
-
 
1258
                stroke-linecap="round"
-
 
1259
                stroke-linejoin="round"
-
 
1260
                stroke-width="1.5"
-
 
1261
                d="M4.9522 16.3536L10.2152 5.85658C10.9531 4.38481 13.0539
186
 
1262
                4.3852 13.7913 5.85723L19.0495 16.3543C19.7156 17.6841 18.7487
-
 
1263
                19.25 17.2613 19.25H6.74007C5.25234
-
 
1264
                19.25 4.2854 17.6835 4.9522 16.3536Z">
-
 
1265
                </path><path stroke="currentColor"
-
 
1266
                stroke-linecap="round"
-
 
1267
                stroke-linejoin="round"
-
 
1268
                stroke-width="2"
-
 
1269
                d="M12 10V12"></path>
-
 
1270
                <circle cx="12" cy="16" r="1" fill="currentColor"></circle></svg>' .
-
 
1271
                    $opts->metadata['userloginfail'],
-
 
1272
                'meta loginfailures'
187
        $modinfo = get_fast_modinfo($course);
1273
            );
Línea -... Línea 1274...
-
 
1274
        }
-
 
1275
 
188
        $records  =  $modinfo->get_section_info_all();
1276
        // MNet.
189
        $sections = [];
1277
        if (!empty($opts->metadata['asmnetuser'])) {
190
 
1278
            $mnet = strtolower(preg_replace('#[ ]+#', '-', trim($opts->metadata['mnetidprovidername'])));
191
        foreach ($records as $record) {
1279
            $usermeta .= html_writer::span(
-
 
1280
                $opts->metadata['mnetidprovidername'],
-
 
1281
                'meta mnet mnet-' . $mnet
-
 
1282
            );
-
 
1283
        }
-
 
1284
 
-
 
1285
        $returnstr .= html_writer::span(
-
 
1286
            html_writer::span($avatarcontents, $avatarclasses),
-
 
1287
            'userbutton'
Línea 192... Línea -...
192
            if (!$record->visible) {
-
 
Línea -... Línea 1288...
-
 
1288
        );
-
 
1289
 
-
 
1290
        // Create a divider (well, a filler).
-
 
1291
        $divider = new action_menu_filler();
-
 
1292
        $divider->primary = false;
-
 
1293
 
-
 
1294
        $am = new action_menu();
-
 
1295
        $am->set_menu_trigger(
-
 
1296
            $returnstr
-
 
1297
        );
-
 
1298
        $am->set_action_label(get_string('usermenu'));
-
 
1299
        $am->set_nowrap_on_items();
193
                continue;
1300
 
194
            }
1301
        if ($CFG->enabledashboard) {
-
 
1302
            $dashboardlink = '<div class="dropdown-item-wrapper"><a class="dropdown-item" href="' .
-
 
1303
                new moodle_url('/my/') .
-
 
1304
                '" data-identifier="dashboard,moodle" title="dashboard,moodle">' .
-
 
1305
                get_string('myhome', 'moodle') .
-
 
1306
                '</a></div>';
-
 
1307
        } else {
-
 
1308
            $dashboardlink = null;
-
 
1309
        }
-
 
1310
 
-
 
1311
        $am->add(
-
 
1312
            '<div class="dropdown-user-wrapper"><div class="dropdown-user">' . $usertextcontents  . '</div>'
-
 
1313
                . '<div class="dropdown-user-mail text-truncate" title="' . $usertextmail . '">' . $usertextmail . '</div>'
-
 
1314
                . '<span class="dropdown-user-nick w-100">' . $usernick . '</span>'
-
 
1315
                . '<div class="dropdown-user-meta"><span class="badge-xs badge-sq badge-warning flex-wrap">' .
195
 
1316
                $usermeta . '</span></div>'
-
 
1317
                . '</div><div class="dropdown-divider dropdown-divider-user"></div>' . $dashboardlink
-
 
1318
        );
-
 
1319
 
-
 
1320
        if ($withlinks) {
-
 
1321
            $navitemcount = count($opts->navitems);
-
 
1322
            $idx = 0;
-
 
1323
            foreach ($opts->navitems as $key => $value) {
-
 
1324
 
-
 
1325
                switch ($value->itemtype) {
Línea 196... Línea 1326...
196
            $section = new \stdClass();
1326
                    case 'divider':
-
 
1327
                        // If the nav item is a divider, add one and skip link processing.
-
 
1328
                        $am->add($divider);
-
 
1329
                        break;
197
            $section->id = $record->id;
1330
 
-
 
1331
                    case 'invalid':
198
            $section->section = $record->section;
1332
                        // Silently skip invalid entries (should we post a notification?).
-
 
1333
                        break;
-
 
1334
 
-
 
1335
                    case 'link':
Línea -... Línea 1336...
-
 
1336
                        $al = '<a class="dropdown-item" href="' .
-
 
1337
                            $value->url .
-
 
1338
                            '" data-identifier="' .
-
 
1339
                            $value->titleidentifier .
-
 
1340
                            '" title="' .
-
 
1341
                            $value->titleidentifier .
-
 
1342
                            '">' .
-
 
1343
                            $value->title . '</a>';
-
 
1344
                        $am->add($al);
-
 
1345
                        break;
-
 
1346
                }
-
 
1347
 
-
 
1348
                $idx++;
-
 
1349
 
-
 
1350
                // Add dividers after the first item and before the last item.
-
 
1351
                if ($idx == 1 || $idx == $navitemcount - 1) {
-
 
1352
                    $am->add($divider);
-
 
1353
                }
-
 
1354
            }
199
            $section->name = $record->name;
1355
        }
200
            $section->parent = $record->parent;
1356
 
-
 
1357
        return html_writer::div(
-
 
1358
            $this->render($am),
-
 
1359
            $usermenuclasses
-
 
1360
        );
-
 
1361
    }
-
 
1362
 
-
 
1363
 
-
 
1364
    /**
Línea -... Línea 1365...
-
 
1365
     * Returns standard main content placeholder.
-
 
1366
     * Designed to be called in theme layout.php files.
-
 
1367
     *
-
 
1368
     * @return string HTML fragment.
-
 
1369
     */
-
 
1370
    public function main_content()
201
            $section->visible = 1;
1371
    {
-
 
1372
        // This is here because it is the only place we can inject the "main" role over the entire main content area
202
 
1373
        // without requiring all theme's to manually do it, and without creating yet another thing people need to
-
 
1374
        // remember in the theme.
203
 
1375
        // This is an unfortunate hack. DO NO EVER add anything more here.
-
 
1376
        // DO NOT add classes.
-
 
1377
        // DO NOT add an id.
204
            array_push($sections, $section);
1378
        return '<div class="main-content" role="main">' . $this->unique_main_content_token . '</div>';
-
 
1379
    }
205
        }
1380
 
-
 
1381
    /**
Línea 206... Línea 1382...
206
 
1382
     * Outputs a heading
-
 
1383
     *
-
 
1384
     * @param string $text The text of the heading
Línea 207... Línea 1385...
207
 
1385
     * @param int $level The level of importance of the heading. Defaulting to 2
208
 
1386
     * @param string $classes A space-separated list of CSS classes. Defaulting to null
-
 
1387
     * @param string $id An optional ID
Línea 209... Línea 1388...
209
        $openParent = 0;
1388
     * @return string the HTML to output.
210
        $maxSections = count($sections);
1389
     */
-
 
1390
    public function heading($text, $level = 2, $classes = null, $id = null)
Línea -... Línea 1391...
-
 
1391
    {
-
 
1392
        $level = (int) $level;
211
        for ($i = 0; $i < $maxSections; $i++) {
1393
        if ($level < 1 || $level > 6) {
212
 
1394
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
-
 
1395
        }
-
 
1396
        return html_writer::tag('div', html_writer::tag('h' .
Línea 213... Línea 1397...
213
 
1397
            $level, $text, array('id' => $id, 'class' => renderer_base::prepare_classes($classes) .
214
 
1398
            ' rui-main-content-title rui-main-content-title--h' .
-
 
1399
            $level)), array('class' => 'rui-title-container'));
215
            $j = $i + 1;
1400
    }
-
 
1401
 
-
 
1402
 
Línea -... Línea 1403...
-
 
1403
    public function headingwithavatar($text, $level = 2, $classes = null, $id = null)
-
 
1404
    {
-
 
1405
        $level = (int) $level;
-
 
1406
        if ($level < 1 || $level > 6) {
-
 
1407
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
-
 
1408
        }
Línea 216... Línea 1409...
216
            if ($j < $maxSections) {
1409
        return html_writer::tag('div', html_writer::tag('h' .
217
 
-
 
218
                if ($sections[$j]->parent) {
1410
            $level, $text, array('id' => $id, 'class' => renderer_base::prepare_classes($classes) .
219
                    $openParent = true;
1411
            ' rui-main-content-title-with-avatar')), array('class' => 'rui-title-container-with-avatar'));
220
                    $sections[$i]->close_section_parent = 0;
1412
    }
221
                    $sections[$i]->close_section = 0;
1413
 
-
 
1414
    /**
Línea 222... Línea 1415...
222
                } else {
1415
     * Renders the login form.
223
                    $sections[$i]->close_section_parent = $openParent ? 1 : 0;
-
 
224
 
1416
     *
225
                    $sections[$i]->close_section = 1;
-
 
226
                }
1417
     * @param \core_auth\output\login $form The renderable.
227
            } else {
1418
     * @return string
228
                $sections[$i]->close_section_parent = $openParent ? 1 : 0;
1419
     */
229
                $sections[$i]->close_section = 1;
1420
    public function render_login(\core_auth\output\login $form)
Línea 230... Línea 1421...
230
            }
1421
    {
-
 
1422
        global $CFG, $SITE;
-
 
1423
 
231
 
1424
        $context = $form->export_for_template($this);
-
 
1425
 
-
 
1426
        // Override because rendering is not supported in template yet.
Línea 232... Línea 1427...
232
            // print_r($section);
1427
        if ($CFG->rememberusername == 0) {
-
 
1428
            $context->cookieshelpiconformatted = $this->help_icon('cookiesenabledonlysession');
233
 
1429
        } else {
234
 
1430
            $context->cookieshelpiconformatted = $this->help_icon('cookiesenabled');
235
        }
1431
        }
-
 
1432
        $context->errorformatted = $this->error_text($context->error);
Línea 236... Línea 1433...
236
 
1433
        $url = $this->get_logo_url();
-
 
1434
        if ($url) {
-
 
1435
            $url = $url->out(false);
237
        /*
1436
        }
-
 
1437
        $context->logourl = $url;
-
 
1438
        $context->sitename = format_string(
Línea 238... Línea 1439...
238
             echo '<pre>';
1439
            $SITE->fullname,
239
           print_r($sections);
-
 
240
           echo '</pre>';
1440
            true,
241
      
1441
            ['context' => context_course::instance(SITEID), "escape" => false]
242
      */
1442
        );
243
 
1443
 
244
 
1444
        if ($this->page->theme->settings->setloginlayout == 1) {
Línea -... Línea 1445...
-
 
1445
            $context->loginlayout1 = 1;
245
 
1446
        } else if ($this->page->theme->settings->setloginlayout == 2) {
-
 
1447
            $context->loginlayout2 = 1;
-
 
1448
            if (isset($this->page->theme->settings->loginbg)) {
-
 
1449
                $context->loginlayoutimg = 1;
-
 
1450
            }
Línea 246... Línea 1451...
246
 
1451
        } else if ($this->page->theme->settings->setloginlayout == 3) {
-
 
1452
            $context->loginlayout3 = 1;
247
        foreach ($sections as $key =>  $section) {
1453
            if (isset($this->page->theme->settings->loginbg)) {
248
 
1454
                $context->loginlayoutimg = 1;
249
            if (!$section->visible) {
1455
            }
250
                continue;
-
 
251
            }
1456
        } else if ($this->page->theme->settings->setloginlayout == 4) {
Línea -... Línea 1457...
-
 
1457
            $context->loginlayout4 = 1;
-
 
1458
        } else if ($this->page->theme->settings->setloginlayout == 5) {
252
 
1459
            $context->loginlayout5 = 1;
253
            $activities = [];
1460
        }
-
 
1461
 
-
 
1462
        if (isset($this->page->theme->settings->loginlogooutside)) {
-
 
1463
            $context->loginlogooutside = $this->page->theme->settings->loginlogooutside;
-
 
1464
        }
-
 
1465
 
-
 
1466
        if (isset($this->page->theme->settings->customsignupoutside)) {
-
 
1467
            $context->customsignupoutside = $this->page->theme->settings->customsignupoutside;
254
            $section_active = false;
1468
        }
-
 
1469
 
-
 
1470
        if (isset($this->page->theme->settings->loginidprovtop)) {
-
 
1471
            $context->loginidprovtop = $this->page->theme->settings->loginidprovtop;
-
 
1472
        }
-
 
1473
 
-
 
1474
        if (isset($this->page->theme->settings->stringca)) {
-
 
1475
            $context->stringca = format_text(($this->page->theme->settings->stringca),
255
 
1476
                FORMAT_HTML,
-
 
1477
                array('noclean' => true)
-
 
1478
            );
256
            foreach ($modules as $module) {
1479
        }
-
 
1480
 
-
 
1481
        if (isset($this->page->theme->settings->stringca)) {
-
 
1482
            $context->stringca = format_text(($this->page->theme->settings->stringca),
257
 
1483
                FORMAT_HTML,
-
 
1484
                array('noclean' => true)
-
 
1485
            );
-
 
1486
        }
-
 
1487
 
-
 
1488
        if (isset($this->page->theme->settings->loginhtmlcontent1)) {
-
 
1489
            $context->loginhtmlcontent1 = format_text(($this->page->theme->settings->loginhtmlcontent1),
-
 
1490
                FORMAT_HTML,
-
 
1491
                array('noclean' => true)
-
 
1492
            );
-
 
1493
        }
-
 
1494
 
-
 
1495
        if (isset($this->page->theme->settings->loginhtmlcontent2)) {
258
                if ($module->section  != $section->id) {
1496
            $context->loginhtmlcontent2 = format_text(($this->page->theme->settings->loginhtmlcontent2),
259
                    continue;
1497
                FORMAT_HTML,
-
 
1498
                array('noclean' => true)
260
                }
1499
            );
-
 
1500
        }
261
 
1501
 
-
 
1502
        if (isset($this->page->theme->settings->loginhtmlcontent3)) {
-
 
1503
            $context->loginhtmlcontent3 = format_text(($this->page->theme->settings->loginhtmlcontent3),
-
 
1504
                FORMAT_HTML,
262
                if (!$module->uservisible || $module->is_stealth()) {
1505
                array('noclean' => true)
-
 
1506
            );
-
 
1507
        }
-
 
1508
 
-
 
1509
        if (isset($this->page->theme->settings->loginhtmlcontent2)) {
263
                    // if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
1510
            $context->loginhtmlcontent2 = format_text(($this->page->theme->settings->loginhtmlcontent2),
-
 
1511
                FORMAT_HTML,
-
 
1512
                array('noclean' => true)
264
                    continue;
1513
            );
265
                }
1514
        }
-
 
1515
 
-
 
1516
        if (isset($this->page->theme->settings->logincustomfooterhtml)) {
-
 
1517
            $context->logincustomfooterhtml = format_text(($this->page->theme->settings->logincustomfooterhtml),
-
 
1518
                FORMAT_HTML,
266
 
1519
                array('noclean' => true)
-
 
1520
            );
-
 
1521
        }
-
 
1522
 
-
 
1523
        if (isset($this->page->theme->settings->loginhtmlblockbottom)) {
-
 
1524
            $context->loginhtmlblockbottom = format_text(($this->page->theme->settings->loginhtmlblockbottom),
-
 
1525
                FORMAT_HTML,
-
 
1526
                array('noclean' => true)
-
 
1527
            );
-
 
1528
        }
Línea -... Línea 1529...
-
 
1529
 
-
 
1530
        if (isset($this->page->theme->settings->loginfootercontent)) {
-
 
1531
            $context->loginfootercontent = format_text(($this->page->theme->settings->loginfootercontent),
-
 
1532
                FORMAT_HTML,
-
 
1533
                array('noclean' => true)
-
 
1534
            );
-
 
1535
        }
-
 
1536
 
-
 
1537
        if (isset($this->page->theme->settings->footercopy)) {
-
 
1538
            $context->footercopy = format_text(($this->page->theme->settings->footercopy),
-
 
1539
                FORMAT_HTML,
-
 
1540
                array('noclean' => true)
-
 
1541
            );
-
 
1542
        }
-
 
1543
 
-
 
1544
        if (isset($this->page->theme->settings->loginintrotext)) {
-
 
1545
            $context->loginintrotext = format_text(($this->page->theme->settings->loginintrotext),
-
 
1546
                FORMAT_HTML,
-
 
1547
                array('noclean' => true)
-
 
1548
            );
-
 
1549
        }
-
 
1550
 
-
 
1551
        if (isset($this->page->theme->settings->loginintrotext)) {
-
 
1552
            $context->loginintrotext = format_text(($this->page->theme->settings->loginintrotext),
-
 
1553
                FORMAT_HTML,
-
 
1554
                array('noclean' => true)
-
 
1555
            );
-
 
1556
        }
Línea -... Línea 1557...
-
 
1557
 
-
 
1558
        if (isset($this->page->theme->settings->customloginlogo)) {
-
 
1559
            $context->customloginlogo = $this->page->theme->setting_file_url('customloginlogo', 'customloginlogo');
-
 
1560
        }
-
 
1561
 
-
 
1562
        if (isset($this->page->theme->settings->loginbg)) {
-
 
1563
            $context->loginbg = $this->page->theme->setting_file_url('loginbg', 'loginbg');
-
 
1564
        }
-
 
1565
 
-
 
1566
        if (isset($this->page->theme->settings->hideforgotpassword)) {
-
 
1567
            $context->hideforgotpassword = $this->page->theme->settings->hideforgotpassword == 1;
-
 
1568
        }
-
 
1569
 
-
 
1570
        if (isset($this->page->theme->settings->logininfobox)) {
-
 
1571
            $context->logininfobox = format_text(($this->page->theme->settings->logininfobox),
-
 
1572
                FORMAT_HTML,
-
 
1573
                array('noclean' => true)
-
 
1574
            );
-
 
1575
        }
-
 
1576
 
-
 
1577
        return $this->render_from_template('core/loginform', $context);
-
 
1578
    }
-
 
1579
 
-
 
1580
    /**
-
 
1581
     * Render the login signup form into a nice template for the theme.
-
 
1582
     *
-
 
1583
     * @param mform $form
-
 
1584
     * @return string
-
 
1585
     */
-
 
1586
    public function render_login_signup_form($form)
-
 
1587
    {
-
 
1588
        global $SITE;
-
 
1589
 
-
 
1590
        $context = $form->export_for_template($this);
-
 
1591
        $url = $this->get_logo_url();
-
 
1592
        if ($url) {
-
 
1593
            $url = $url->out(false);
-
 
1594
        }
-
 
1595
        $context['logourl'] = $url;
-
 
1596
        $context['sitename'] = format_string(
-
 
1597
            $SITE->fullname,
-
 
1598
            true,
-
 
1599
            ['context' => context_course::instance(SITEID), "escape" => false]
-
 
1600
        );
-
 
1601
 
-
 
1602
        if ($this->page->theme->settings->setloginlayout == 1) {
-
 
1603
            $context['loginlayout1'] = 1;
-
 
1604
        } else if ($this->page->theme->settings->setloginlayout == 2) {
-
 
1605
            $context['loginlayout2'] = 1;
267
                $mods[$module->id] = $module;
1606
            if (isset($this->page->theme->settings->loginbg)) {
-
 
1607
                $context['loginlayoutimg'] = 1;
-
 
1608
            }
-
 
1609
        } else if ($this->page->theme->settings->setloginlayout == 3) {
-
 
1610
            $context['loginlayout3'] = 1;
-
 
1611
            if (isset($this->page->theme->settings->loginbg)) {
-
 
1612
                $context['loginlayoutimg'] = 1;
-
 
1613
            }
268
 
1614
        } else if ($this->page->theme->settings->setloginlayout == 4) {
-
 
1615
            $context['loginlayout4'] = 1;
-
 
1616
        } else if ($this->page->theme->settings->setloginlayout == 5) {
-
 
1617
            $context['loginlayout5'] = 1;
-
 
1618
        }
269
                $duration = '';
1619
 
-
 
1620
        if (isset($this->page->theme->settings->loginlogooutside)) {
-
 
1621
            $context['loginlogooutside'] = $this->page->theme->settings->loginlogooutside;
-
 
1622
        }
-
 
1623
 
-
 
1624
        if (isset($this->page->theme->settings->stringbacktologin)) {
-
 
1625
            $context['stringbacktologin'] = format_text(($this->page->theme->settings->stringbacktologin),
-
 
1626
                FORMAT_HTML,
-
 
1627
                array('noclean' => true)
-
 
1628
            );
270
                $type = '';
1629
        }
-
 
1630
        if (isset($this->page->theme->settings->signupintrotext)) {
271
                $filepath = '';
1631
            $context['signupintrotext'] = format_text(($this->page->theme->settings->signupintrotext),
272
 
1632
                FORMAT_HTML,
-
 
1633
                array('noclean' => true)
-
 
1634
            );
273
                $sql = 'SELECT md.name, cm.instance  FROM {modules} md  ' .
1635
        }
-
 
1636
        if (isset($this->page->theme->settings->signuptext)) {
274
                    ' JOIN {course_modules} cm ON cm.module = md.id ' .
1637
            $context['signuptext'] = format_text(($this->page->theme->settings->signuptext),
-
 
1638
                FORMAT_HTML,
-
 
1639
                array('noclean' => true)
-
 
1640
            );
-
 
1641
        }
-
 
1642
 
Línea 275... Línea -...
275
                    ' WHERE cm.id = '  . $module->id . ' LIMIT 1 ';
-
 
276
 
-
 
277
                $record = $DB->get_record_sql($sql);
-
 
278
                if ($record) {
-
 
279
 
-
 
280
                    /*
1643
        if (!empty($this->page->theme->settings->customloginlogo)) {
281
                        echo '<pre>';
-
 
282
                        print_r($record);
-
 
283
                        echo '<pre>';
-
 
284
                        */
-
 
285
 
1644
            $url = $this->page->theme->setting_file_url('customloginlogo', 'customloginlogo');
286
                    $type = $record->name;
-
 
Línea -... Línea 1645...
-
 
1645
            $context['customloginlogo'] = $url;
-
 
1646
        }
-
 
1647
 
-
 
1648
        if (!empty($this->page->theme->settings->loginbg)) {
Línea -... Línea 1649...
-
 
1649
            $url = $this->page->theme->setting_file_url('loginbg', 'loginbg');
-
 
1650
            $context['loginbg'] = $url;
-
 
1651
        }
-
 
1652
 
287
 
1653
        if (isset($this->page->theme->settings->loginfootercontent)) {
-
 
1654
            $context['loginfootercontent'] = format_text(($this->page->theme->settings->loginfootercontent),
288
                    if ($type == 'hvp') {
1655
                FORMAT_HTML,
-
 
1656
                array('noclean' => true)
-
 
1657
            );
-
 
1658
        }
-
 
1659
 
-
 
1660
        return $this->render_from_template('core/signup_form_layout', $context);
-
 
1661
    }
-
 
1662
 
-
 
1663
 
-
 
1664
    /**
-
 
1665
     * Renders the header bar.
-
 
1666
     *
-
 
1667
     * @param context_header $contextheader Header bar object.
Línea -... Línea 1668...
-
 
1668
     * @return string HTML for the header bar.
-
 
1669
     */
-
 
1670
    protected function render_context_header(\context_header $contextheader)
-
 
1671
    {
-
 
1672
        $heading = null;
-
 
1673
        $imagedata = null;
-
 
1674
        $html = null;
-
 
1675
 
-
 
1676
        // Generate the heading first and before everything else as we might have to do an early return.
-
 
1677
        if (!isset($contextheader->heading)) {
-
 
1678
            $heading = $this->heading($this->page->heading, $contextheader->headinglevel);
-
 
1679
        } else {
-
 
1680
            $heading = $this->heading($contextheader->heading, $contextheader->headinglevel);
-
 
1681
        }
-
 
1682
 
-
 
1683
        // All the html stuff goes here.
-
 
1684
        $html = html_writer::start_div('page-context-header d-flex align-items-center flex-wrap');
-
 
1685
 
289
                        $instance   = $record->instance;
1686
        // Image data.
-
 
1687
        if (isset($contextheader->imagedata)) {
-
 
1688
            // Header specific image.
-
 
1689
            $html .= html_writer::div($contextheader->imagedata, 'page-header-image');
-
 
1690
        }
-
 
1691
 
-
 
1692
        // Headings.
-
 
1693
        if (isset($contextheader->prefix)) {
-
 
1694
            $prefix = html_writer::div($contextheader->prefix, 'text-muted text-uppercase small line-height-3');
-
 
1695
            $heading = $prefix . $heading;
-
 
1696
        }
290
 
1697
 
-
 
1698
        if (!isset($contextheader->heading)) {
-
 
1699
            $html .= html_writer::tag('h3', $heading, array('class' => 'rui-page-title rui-page-title--page'));
-
 
1700
        } else if (isset($contextheader->imagedata)) {
-
 
1701
            $html .= html_writer::tag(
-
 
1702
                'div',
-
 
1703
                $this->heading($contextheader->heading, 4),
-
 
1704
                array('class' => 'rui-page-title rui-page-title--icon')
-
 
1705
            );
-
 
1706
        } else {
-
 
1707
            $html .= html_writer::tag('h2', $heading, array('class' => 'page-header-headings
-
 
1708
                rui-page-title rui-page-title--context'));
-
 
1709
        }
-
 
1710
 
-
 
1711
        // Buttons.
Línea -... Línea 1712...
-
 
1712
        if (isset($contextheader->additionalbuttons)) {
-
 
1713
            $html .= html_writer::start_div('btn-group header-button-group my-2 my-lg-0 ml-lg-4');
-
 
1714
            foreach ($contextheader->additionalbuttons as $button) {
291
                        $sql = 'SELECT json_content FROM {hvp} WHERE id = ' . $instance . ' LIMIT 1';
1715
                if (!isset($button->page)) {
-
 
1716
                    // Include js for messaging.
292
                        $record = $DB->get_record_sql($sql);
1717
                    if ($button['buttontype'] === 'togglecontact') {
-
 
1718
                        \core_message\helper::togglecontact_requirejs();
-
 
1719
                    }
-
 
1720
                    if ($button['buttontype'] === 'message') {
293
 
1721
                        \core_message\helper::messageuser_requirejs();
-
 
1722
                    }
294
                        if ($record) {
1723
                    $image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
295
                            $json_content = json_decode($record->json_content);
1724
                        'class' => 'iconsmall',
-
 
1725
                        'role' => 'presentation'
-
 
1726
                    ));
-
 
1727
                    $image .= html_writer::span($button['title'], 'header-button-title');
296
 
1728
                } else {
Línea -... Línea 1729...
-
 
1729
                    $image = html_writer::empty_tag('img', array(
-
 
1730
                        'src' => $button['formattedimage'],
-
 
1731
                        'role' => 'presentation'
-
 
1732
                    ));
-
 
1733
                }
-
 
1734
                $html .= html_writer::link($button['url'], html_writer::tag('span', $image), $button['linkattributes']);
-
 
1735
            }
-
 
1736
            $html .= html_writer::end_div();
-
 
1737
        }
-
 
1738
        $html .= html_writer::end_div();
-
 
1739
 
-
 
1740
        return $html;
-
 
1741
    }
-
 
1742
 
-
 
1743
    public function header()
-
 
1744
    {
297
                            if (!empty($json_content->interactiveVideo->video->files[0]->path)) {
1745
        global $USER, $COURSE;
-
 
1746
        $theme = theme_config::load('universe');
-
 
1747
 
-
 
1748
        $context = context_course::instance($COURSE->id);
298
                                $filepath = trim($json_content->interactiveVideo->video->files[0]->path);
1749
        $roles = get_user_roles($context, $USER->id, true);
-
 
1750
 
-
 
1751
        if (is_array($roles) && !empty($roles)) {
-
 
1752
            foreach ($roles as $role) {
-
 
1753
                $this->page->add_body_class('role-' . $role->shortname);
299
                                $filepath = trim(str_replace('#tmp', '', $filepath));
1754
            }
-
 
1755
        } else {
-
 
1756
            $this->page->add_body_class('role-none');
-
 
1757
        }
-
 
1758
 
-
 
1759
        if ($theme->settings->topbareditmode == '1') {
-
 
1760
            $this->page->add_body_class('rui-editmode--top');
-
 
1761
        } else {
-
 
1762
            $this->page->add_body_class('rui-editmode--footer');
-
 
1763
        }
-
 
1764
 
-
 
1765
        return parent::header();
-
 
1766
    }
-
 
1767
 
-
 
1768
 
-
 
1769
    /**
-
 
1770
     * See if this is the first view of the current cm in the session if it has fake blocks.
-
 
1771
     *
-
 
1772
     * (We track up to 100 cms so as not to overflow the session.)
-
 
1773
     * This is done for drawer regions containing fake blocks so we can show blocks automatically.
-
 
1774
     *
-
 
1775
     * @return boolean true if the page has fakeblocks and this is the first visit.
-
 
1776
     */
-
 
1777
    public function firstview_fakeblocks(): bool
-
 
1778
    {
-
 
1779
        global $SESSION;
-
 
1780
 
-
 
1781
        $firstview = false;
-
 
1782
        if ($this->page->cm) {
-
 
1783
            if (!$this->page->blocks->region_has_fakeblocks('side-pre')) {
-
 
1784
                return false;
300
 
1785
            }
-
 
1786
            if (!property_exists($SESSION, 'firstview_fakeblocks')) {
-
 
1787
                $SESSION->firstview_fakeblocks = [];
-
 
1788
            }
-
 
1789
            if (array_key_exists($this->page->cm->id, $SESSION->firstview_fakeblocks)) {
-
 
1790
                $firstview = false;
-
 
1791
            } else {
-
 
1792
                $SESSION->firstview_fakeblocks[$this->page->cm->id] = true;
-
 
1793
                $firstview = true;
-
 
1794
                if (count($SESSION->firstview_fakeblocks) > 100) {
-
 
1795
                    array_shift($SESSION->firstview_fakeblocks);
-
 
1796
                }
-
 
1797
            }
-
 
1798
        }
-
 
1799
        return $firstview;
-
 
1800
    }
-
 
1801
 
-
 
1802
 
-
 
1803
    /**
-
 
1804
     * Build the guest access hint HTML code.
-
 
1805
     *
-
 
1806
     * @param int $courseid The course ID.
-
 
1807
     * @return string.
-
 
1808
     */
301
 
1809
    public function theme_universe_get_course_guest_access_hint($courseid)
-
 
1810
    {
-
 
1811
        global $CFG;
-
 
1812
        require_once($CFG->dirroot . '/enrol/self/lib.php');
-
 
1813
 
-
 
1814
        $html = '';
-
 
1815
        $instances = enrol_get_instances($courseid, true);
-
 
1816
        $plugins = enrol_get_plugins(true);
-
 
1817
        foreach ($instances as $instance) {
-
 
1818
            if (!isset($plugins[$instance->enrol])) {
-
 
1819
                continue;
-
 
1820
            }
-
 
1821
            $plugin = $plugins[$instance->enrol];
-
 
1822
            if ($plugin->show_enrolme_link($instance)) {
-
 
1823
                $html = html_writer::tag('div', get_string(
-
 
1824
                    'showhintcourseguestaccesssettinglink',
-
 
1825
                    'theme_universe',
-
 
1826
                    array('url' => $CFG->wwwroot . '/enrol/index.php?id=' . $courseid)
-
 
1827
                ));
-
 
1828
                break;
302
                                $arr = explode('/', $filepath);
1829
            }
Línea -... Línea 1830...
-
 
1830
        }
-
 
1831
 
-
 
1832
        return $html;
-
 
1833
    }
-
 
1834
 
-
 
1835
 
-
 
1836
    /**
-
 
1837
     * Color Customization
Línea -... Línea 1838...
-
 
1838
     * @return string HTML fragment.
-
 
1839
     */
-
 
1840
    public function additional_head_html()
-
 
1841
    {
-
 
1842
        global $SITE, $DB, $CFG, $COURSE, $PAGE;
-
 
1843
 
-
 
1844
        $output = null;
-
 
1845
 
-
 
1846
        if ($PAGE->pagelayout == 'course' || $PAGE->pagelayout == 'incourse') {
303
                                if (count($arr) > 1) {
1847
            if ($DB->record_exists('customfield_field', array('shortname' => 'maincolor1'), 'id')) {
-
 
1848
                // Get custom field by name
-
 
1849
                $customfieldid1 = $DB->get_record('customfield_field', array('shortname' => 'maincolor1'));
-
 
1850
                // Get value
-
 
1851
                $mainthemecolor = $DB->get_record('customfield_data', array('fieldid' => $customfieldid1->id, 'instanceid' => $COURSE->id));
-
 
1852
            } else {
-
 
1853
                $mainthemecolor = null;
-
 
1854
            }
-
 
1855
 
304
                                    $filename = $arr[count($arr) - 1];
1856
            if ($DB->record_exists('customfield_field', array('shortname' => 'maincolor2'), 'id')) {
-
 
1857
                $customfieldid2 = $DB->get_record('customfield_field', array('shortname' => 'maincolor2'));
305
                                } else {
1858
                $mainthemecolor2 = $DB->get_record('customfield_data', array('fieldid' => $customfieldid2->id, 'instanceid' => $COURSE->id));
-
 
1859
            }
306
                                    $filename = $arr[0];
1860
 
Línea -... Línea 1861...
-
 
1861
            if ($DB->record_exists('customfield_field', array('shortname' => 'topbarcolor'), 'id')) {
-
 
1862
                // Get custom field by name
-
 
1863
                $customfieldid3 = $DB->get_record('customfield_field', array('shortname' => 'topbarcolor'));
Línea -... Línea 1864...
-
 
1864
                // Get value
307
                                }
1865
                $topbarcolor = $DB->get_record('customfield_data', array('fieldid' => $customfieldid3->id, 'instanceid' => $COURSE->id));
-
 
1866
            }
-
 
1867
 
-
 
1868
            if ($DB->record_exists('customfield_field', array('shortname' => 'dmtopbarcolor'), 'id')) {
-
 
1869
                // Get custom field by name
-
 
1870
                $customfieldid3 = $DB->get_record('customfield_field', array('shortname' => 'dmtopbarcolor'));
-
 
1871
                // Get value
-
 
1872
                $dmtopbarcolor = $DB->get_record('customfield_data', array('fieldid' => $customfieldid3->id, 'instanceid' => $COURSE->id));
Línea 308... Línea 1873...
308
 
1873
            } else {
-
 
1874
                $dmtopbarcolor = null;
-
 
1875
            }
-
 
1876
 
-
 
1877
 
309
                                $record = $DB->get_record('files', ['filename' => $filename]);
1878
            if ($DB->record_exists('customfield_field', array('shortname' => 'footerbgcolor'), 'id')) {
310
                                if ($record) {
1879
                // Get custom field by name
Línea 311... Línea 1880...
311
                                    $duration = $this->extractDurationFromVideo($record, $filename);
1880
                $customfieldid4 = $DB->get_record('customfield_field', array('shortname' => 'footerbgcolor'));
312
                                }
1881
                // Get value
313
                            }
1882
                $footercolor = $DB->get_record('customfield_data', array('fieldid' => $customfieldid4->id, 'instanceid' => $COURSE->id));
Línea -... Línea 1883...
-
 
1883
            } else {
-
 
1884
                $footercolor = null;
-
 
1885
            }
-
 
1886
 
-
 
1887
 
-
 
1888
            $css = '';
-
 
1889
 
-
 
1890
            $css .= ':root { ';
-
 
1891
            if ($DB->record_exists('customfield_field', array('shortname' => 'maincolor1'), 'id')) {
-
 
1892
                if ($mainthemecolor != null) {
-
 
1893
                    $css .= '--main-theme-color: ' . $mainthemecolor->value . '; ';
314
                        }
1894
                    $css .= '--primary-color-100: ' . $mainthemecolor->value . '30; ';
-
 
1895
                    $css .= '--primary-color-300: ' . $mainthemecolor->value . '70; ';
-
 
1896
                    $css .= '--main-theme-color-gradient: ' . $mainthemecolor->value . '; ';
-
 
1897
                    $css .= '--btn-primary-color-bg: ' . $mainthemecolor->value . '; ';
-
 
1898
                    $css .= '--btn-primary-color-bg-hover: ' . $mainthemecolor->value . '95; ';
-
 
1899
 
-
 
1900
                    if ($DB->record_exists('customfield_field', array('shortname' => 'maincolor2'), 'id')) {
315
                    }
1901
                        if ($mainthemecolor2 != null) {
-
 
1902
                            $css .= '--main-theme-color-gradient-2: ' . $mainthemecolor2->value . '; ';
-
 
1903
                        } else {
-
 
1904
                            $css .= '--main-theme-color-gradient-2: ' . $mainthemecolor->value . '30; ';
-
 
1905
                        }
-
 
1906
                    }
-
 
1907
                }
-
 
1908
            }
-
 
1909
 
-
 
1910
            if ($DB->record_exists('customfield_field', array('shortname' => 'topbarcolor'), 'id')) {
-
 
1911
                if ($topbarcolor != null) {
-
 
1912
                    $css .= '--topbar-color: ' . $topbarcolor->value . '; ';
-
 
1913
                    if ($dmtopbarcolor != null) {
-
 
1914
                        $css .= '--dm-topbar-color: ' . $dmtopbarcolor->value . '; ';
-
 
1915
                    } else {
-
 
1916
                        $css .= '--dm-topbar-color: ' . $topbarcolor->value . '; ';
-
 
1917
                    }
-
 
1918
                }
-
 
1919
            }
-
 
1920
 
-
 
1921
            if ($DB->record_exists('customfield_field', array('shortname' => 'footerbgcolor'), 'id')) {
-
 
1922
                if ($footercolor != null) {
-
 
1923
                    $css .= '--footer-color: ' . $footercolor->value . '; ';
-
 
1924
                }
-
 
1925
            }
316
                }
1926
 
Línea -... Línea 1927...
-
 
1927
            $css .= '}';
-
 
1928
 
-
 
1929
            if ($css) {
-
 
1930
                $output .= '<style>' . $css . '</style>';
-
 
1931
            }
-
 
1932
        }
-
 
1933
 
-
 
1934
        return $output;
-
 
1935
    }
317
 
1936
 
-
 
1937
    public function custom_course_logo()
318
                $modname = $module->get_formatted_name();
1938
    {
-
 
1939
        global $DB, $CFG, $COURSE, $PAGE;
-
 
1940
 
319
                $modcontent = $module->get_formatted_content();
1941
        $output = null;
-
 
1942
 
-
 
1943
        if ($PAGE->pagelayout == 'course' || $PAGE->pagelayout == 'incourse') {
320
 
1944
            if ($DB->record_exists('customfield_field', array('shortname' => 'customcourselogo'))) {
321
                if (empty($module->url)) {
1945
                // Get custom field ID
-
 
1946
                $customfieldpic = $DB->get_record('customfield_field', array('shortname' => 'customcourselogo'));
-
 
1947
                $customfieldpicid = $customfieldpic->id;
-
 
1948
                // Get value
-
 
1949
                $customlogo = $DB->get_record(
-
 
1950
                    'customfield_data',
-
 
1951
                    array('fieldid' => $customfieldpicid, 'instanceid' => $COURSE->id)
-
 
1952
                );
-
 
1953
 
-
 
1954
                $customlogoid = $customlogo->id;
-
 
1955
                $contextid = $customlogo->contextid;
-
 
1956
 
-
 
1957
                if ($customfieldpic != null) {
-
 
1958
                    $files = get_file_storage()->get_area_files(
-
 
1959
                        $contextid,
-
 
1960
                        'customfield_picture',
-
 
1961
                        'file',
-
 
1962
                        $customlogoid,
Línea -... Línea 1963...
-
 
1963
                        '',
-
 
1964
                        false
-
 
1965
                    );
322
                    $linkurl = '';
1966
 
-
 
1967
                    if (empty($files)) {
-
 
1968
                        return null;
-
 
1969
                    }
-
 
1970
 
-
 
1971
                    $file = reset($files);
Línea -... Línea 1972...
-
 
1972
                    $fileurl = moodle_url::make_pluginfile_url(
-
 
1973
                        $file->get_contextid(),
-
 
1974
                        $file->get_component(),
-
 
1975
                        $file->get_filearea(),
-
 
1976
                        $file->get_itemid(),
323
                    $currentLink = '';
1977
                        $file->get_filepath(),
324
                } else {
1978
                        $file->get_filename()
Línea 325... Línea 1979...
325
 
1979
                    );
326
                    $linkurl = new moodle_url($module->url, array('forceview' => 1));
1980
 
327
                    $linkurl = strtolower(trim($linkurl->__toString()));
1981
                    $output .= $fileurl;
Línea -... Línea 1982...
-
 
1982
                }
-
 
1983
            }
-
 
1984
        }
328
 
1985
 
-
 
1986
        return $output;
-
 
1987
    }
-
 
1988
 
-
 
1989
    public function custom_course_dmlogo()
329
                    $parts = explode('&', $linkurl);
1990
    {
-
 
1991
        global $DB, $CFG, $COURSE, $PAGE;
-
 
1992
 
330
                    if (count($parts) > 1) {
1993
        $output = null;
-
 
1994
 
-
 
1995
        if ($PAGE->pagelayout == 'course' || $PAGE->pagelayout == 'incourse') {
331
                        $currentLink = $parts[0];
1996
            if ($DB->record_exists('customfield_field', array('shortname' => 'customcoursedmlogo'))) {
Línea -... Línea 1997...
-
 
1997
                // Get custom field ID
-
 
1998
                $customfieldpic = $DB->get_record('customfield_field', array('shortname' => 'customcoursedmlogo'));
-
 
1999
                $customfieldpicid = $customfieldpic->id;
-
 
2000
                // Get value
-
 
2001
                $customlogo = $DB->get_record(
-
 
2002
                    'customfield_data',
-
 
2003
                    array('fieldid' => $customfieldpicid, 'instanceid' => $COURSE->id)
-
 
2004
                );
-
 
2005
 
-
 
2006
                $customlogoid = $customlogo->id;
-
 
2007
                $contextid = $customlogo->contextid;
-
 
2008
 
-
 
2009
                if ($customfieldpic != null) {
-
 
2010
                    $files = get_file_storage()->get_area_files(
-
 
2011
                        $contextid,
332
                    } else {
2012
                        'customfield_picture',
-
 
2013
                        'file',
-
 
2014
                        $customlogoid,
333
                        $currentLink = $linkurl;
2015
                        '',
-
 
2016
                        false
-
 
2017
                    );
-
 
2018
 
334
                    }
2019
                    if (empty($files)) {
-
 
2020
                        return null;
-
 
2021
                    }
-
 
2022
 
-
 
2023
                    $file = reset($files);
-
 
2024
                    $fileurl = moodle_url::make_pluginfile_url(
-
 
2025
                        $file->get_contextid(),
335
                }
2026
                        $file->get_component(),
-
 
2027
                        $file->get_filearea(),
Línea -... Línea 2028...
-
 
2028
                        $file->get_itemid(),
-
 
2029
                        $file->get_filepath(),
-
 
2030
                        $file->get_filename()
-
 
2031
                    );
336
 
2032
 
-
 
2033
                    $output .= $fileurl;
-
 
2034
                }
-
 
2035
            }
337
                $completiondata = $completioninfo->get_data($module, true);
2036
        }
-
 
2037
 
-
 
2038
        return $output;
338
 
2039
    }
-
 
2040
 
339
                if (strcasecmp($currentLink,  $currentServerLink) == 0) {
2041
    public function custom_course_favicon()
-
 
2042
    {
Línea -... Línea 2043...
-
 
2043
        global $DB, $CFG, $COURSE, $PAGE;
-
 
2044
 
-
 
2045
        $output = null;
-
 
2046
 
340
                    $active = true;
2047
        if ($PAGE->pagelayout == 'course' || $PAGE->pagelayout == 'incourse') {
-
 
2048
            if ($DB->record_exists('customfield_field', array('shortname' => 'customcoursefavicon'))) {
341
                    $section_active = true;
2049
                // Get custom field ID
-
 
2050
                $customfieldpic = $DB->get_record('customfield_field', array('shortname' => 'customcoursefavicon'));
-
 
2051
                $customfieldpicid = $customfieldpic->id;
342
                } else {
2052
                // Get value
343
                    $active = false;
2053
                $customfavicon = $DB->get_record(
-
 
2054
                    'customfield_data',
-
 
2055
                    array('fieldid' => $customfieldpicid, 'instanceid' => $COURSE->id)
-
 
2056
                );
-
 
2057
 
-
 
2058
                $customfaviconid = $customfavicon->id;
344
                }
2059
                $contextid = $customfavicon->contextid;
Línea -... Línea 2060...
-
 
2060
 
-
 
2061
                if ($customfieldpic != null) {
-
 
2062
                    $files = get_file_storage()->get_area_files(
-
 
2063
                        $contextid,
-
 
2064
                        'customfield_picture',
-
 
2065
                        'file',
-
 
2066
                        $customfaviconid,
-
 
2067
                        '',
-
 
2068
                        false
-
 
2069
                    );
-
 
2070
 
-
 
2071
                    if (empty($files)) {
-
 
2072
                        return null;
-
 
2073
                    }
-
 
2074
 
-
 
2075
                    $file = reset($files);
-
 
2076
                    $fileurl = moodle_url::make_pluginfile_url(
-
 
2077
                        $file->get_contextid(),
-
 
2078
                        $file->get_component(),
-
 
2079
                        $file->get_filearea(),
-
 
2080
                        $file->get_itemid(),
-
 
2081
                        $file->get_filepath(),
-
 
2082
                        $file->get_filename()
-
 
2083
                    );
-
 
2084
 
-
 
2085
                    $output .= $fileurl;
-
 
2086
                }
-
 
2087
            }
-
 
2088
        }
-
 
2089
 
345
 
2090
        return $output;
346
                array_push($activities, [
2091
    }
347
                    'active' => $active,
2092