Proyectos de Subversion Moodle

Rev

Rev 1317 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1317 Rev 1441
Línea 21... Línea 21...
21
use moodle_url;
21
use moodle_url;
22
use context_course;
22
use context_course;
23
use context_system;
23
use context_system;
24
use core_course_list_element;
24
use core_course_list_element;
25
use custom_menu;
25
use custom_menu;
-
 
26
use core_completion;
26
use action_menu_filler;
27
use action_menu_filler;
27
use action_menu_link_secondary;
28
use action_menu_link_secondary;
28
use action_menu;
29
use action_menu;
29
use action_link;
30
use action_link;
30
use core_text;
31
use core_text;
Línea 37... Línea 38...
37
use get_string;
38
use get_string;
38
use core_course_category;
39
use core_course_category;
39
use theme_universe\util\user;
40
use theme_universe\util\user;
40
use theme_universe\util\course;
41
use theme_universe\util\course;
Línea 41... Línea -...
41
 
-
 
42
require_once($CFG->dirroot . '/cesa/statics_blocks.php'); // Incluimos StaticsBlocks
-
 
43
 
-
 
44
 
42
 
45
/**
43
/**
46
 * Renderers to align Moodle's HTML with that expected by Bootstrap
44
 * Renderers to align Moodle's HTML with that expected by Bootstrap
47
 *
45
 *
48
 * @package    theme_universe
46
 * @package    theme_universe
49
 * @copyright  2023 Marcin Czaja (https://rosea.io)
47
 * @copyright  2023 Marcin Czaja (https://rosea.io)
50
 * @license    Commercial https://themeforest.net/licenses
48
 * @license    Commercial https://themeforest.net/licenses
51
 */
49
 */
52
class core_renderer extends \core_renderer
-
 
Línea 53... Línea 50...
53
{
50
class core_renderer extends \core_renderer {
54
 
-
 
55
    public function edit_button(moodle_url $url, string $method = 'post')
51
 
56
    {
52
    public function edit_button(moodle_url $url, string $method = 'post') {
57
        if ($this->page->theme->haseditswitch) {
53
        if ($this->page->theme->haseditswitch) {
58
            return;
54
            return;
59
        }
55
        }
Línea 74... Línea 70...
74
     * that should be included in the <head> tag. Designed to be called in theme
70
     * that should be included in the <head> tag. Designed to be called in theme
75
     * layout.php files.
71
     * layout.php files.
76
     *
72
     *
77
     * @return string HTML fragment.
73
     * @return string HTML fragment.
78
     */
74
     */
79
    public function standard_head_html()
75
    public function standard_head_html() {
80
    {
-
 
81
        $output = parent::standard_head_html();
76
        $output = parent::standard_head_html();
82
        global $USER;
77
        global $USER;
Línea 83... Línea 78...
83
 
78
 
84
        $googleanalyticscode = "<script
79
        $googleanalyticscode = "<script
Línea 105... Línea 100...
105
        }
100
        }
Línea 106... Línea 101...
106
 
101
 
107
        return $output;
102
        return $output;
Línea -... Línea 103...
-
 
103
    }
-
 
104
 
-
 
105
    /*
-
 
106
    *
-
 
107
    * Method to get reference to $CFG->themedir variable
-
 
108
    *
-
 
109
    */
-
 
110
    function theme_universe_themedir() {
-
 
111
        global $CFG;
-
 
112
 
-
 
113
        $teme_dir = '/theme';
-
 
114
 
-
 
115
        if (isset($CFG->themedir)) {
-
 
116
            $teme_dir = $CFG->themedir;
-
 
117
            $teme_dir = str_replace($CFG->dirroot, '', $CFG->themedir);
-
 
118
        }
-
 
119
 
-
 
120
        return $teme_dir;
Línea 108... Línea 121...
108
    }
121
    }
109
 
122
 
110
 
123
 
111
    /**
124
    /**
112
     *
125
     *
113
     * Method to load theme element form 'layout/parts' folder
126
     * Method to load theme element form 'layout/parts' folder
114
     *
-
 
Línea 115... Línea 127...
115
     */
127
     *
Línea 116... Línea 128...
116
    public function theme_part($name, $vars = array())
128
     */
117
    {
129
    public function theme_part($name, $vars = array()) {
Línea 143... Línea 155...
143
     * Renders the custom menu
155
     * Renders the custom menu
144
     *
156
     *
145
     * @param custom_menu $menu
157
     * @param custom_menu $menu
146
     * @return mixed
158
     * @return mixed
147
     */
159
     */
148
    protected function render_custom_menu(custom_menu $menu)
160
    protected function render_custom_menu(custom_menu $menu) {
149
    {
-
 
150
        if (!$menu->has_children()) {
161
        if (!$menu->has_children()) {
151
            return '';
162
            return '';
152
        }
163
        }
Línea 153... Línea 164...
153
 
164
 
Línea 163... Línea 174...
163
    /**
174
    /**
164
     * Outputs the favicon urlbase.
175
     * Outputs the favicon urlbase.
165
     *
176
     *
166
     * @return string an url
177
     * @return string an url
167
     */
178
     */
168
    public function favicon()
179
    public function favicon() {
169
    {
-
 
170
        global $CFG;
180
        global $CFG;
171
        $theme = theme_config::load('universe');
181
        $theme = theme_config::load('universe');
172
        $favicon = $theme->setting_file_url('favicon', 'favicon');
182
        $favicon = $theme->setting_file_url('favicon', 'favicon');
Línea 173... Línea 183...
173
 
183
 
Línea 179... Línea 189...
179
        }
189
        }
Línea 180... Línea 190...
180
 
190
 
181
        return parent::favicon();
191
        return parent::favicon();
Línea 182... Línea 192...
182
    }
192
    }
183
 
-
 
184
    public function render_lang_menu()
193
 
185
    {
194
    public function render_lang_menu() {
186
        $langs = get_string_manager()->get_list_of_translations();
195
        $langs = get_string_manager()->get_list_of_translations();
Línea 187... Línea 196...
187
        $haslangmenu = $this->lang_menu() != '';
196
        $haslangmenu = $this->lang_menu() != '';
Línea 209... Línea 218...
209
                return $this->render_from_template('theme_universe/lang_menu', $context);
218
                return $this->render_from_template('theme_universe/lang_menu', $context);
210
            }
219
            }
211
        }
220
        }
212
    }
221
    }
Línea 213... Línea 222...
213
 
222
 
214
    public function render_lang_menu_login()
-
 
215
    {
223
    public function render_lang_menu_login() {
216
        $langs = get_string_manager()->get_list_of_translations();
224
        $langs = get_string_manager()->get_list_of_translations();
217
        $haslangmenu = $this->lang_menu() != '';
225
        $haslangmenu = $this->lang_menu() != '';
Línea 218... Línea 226...
218
        $menu = new custom_menu;
226
        $menu = new custom_menu;
Línea 239... Línea 247...
239
                return $this->render_from_template('theme_universe/lang_menu_login', $context);
247
                return $this->render_from_template('theme_universe/lang_menu_login', $context);
240
            }
248
            }
241
        }
249
        }
242
    }
250
    }
Línea 243... Línea 251...
243
 
251
 
244
    public static function get_course_progress_count($course, $userid = 0)
-
 
245
    {
252
    public static function get_course_progress_count($course, $userid = 0) {
Línea 246... Línea 253...
246
        global $USER;
253
        global $USER;
247
 
254
 
248
        // Make sure we continue with a valid userid.
255
        // Make sure we continue with a valid userid.
Línea 287... Línea 294...
287
     *
294
     *
288
     * Outputs the course progress if course completion is on.
295
     * Outputs the course progress if course completion is on.
289
     *
296
     *
290
     * @return string Markup.
297
     * @return string Markup.
291
     */
298
     */
292
    protected function courseprogress($course)
299
    protected function courseprogress($course) {
293
    {
-
 
294
        global $USER;
300
        global $USER;
295
        $theme = \theme_config::load('universe');
301
        $theme = \theme_config::load('universe');
Línea 296... Línea 302...
296
 
302
 
297
        $output = '';
303
        $output = '';
Línea 308... Línea 314...
308
            $completion = new \completion_info($course);
314
            $completion = new \completion_info($course);
Línea 309... Línea 315...
309
 
315
 
310
            // Get the number of modules that support completion.
316
            // Get the number of modules that support completion.
311
            $modules = $completion->get_activities();
317
            $modules = $completion->get_activities();
-
 
318
            $count = count($modules);
312
            $count = count($modules);
319
 
313
            if (!$count) {
320
            if (!$count) {
314
                return null;
321
                return null;
Línea 315... Línea 322...
315
            }
322
            }
Línea 358... Línea 365...
358
    /**
365
    /**
359
     *
366
     *
360
     * Returns HTML to display course contacts.
367
     * Returns HTML to display course contacts.
361
     *
368
     *
362
     */
369
     */
363
    public function course_teachers()
370
    public function course_teachers() {
364
    {
-
 
365
        global $CFG, $COURSE, $DB;
371
        global $CFG, $COURSE, $DB;
366
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
372
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
367
        $course = new core_course_list_element($course);
373
        $course = new core_course_list_element($course);
368
        $instructors = $course->get_course_contacts();
374
        $instructors = $course->get_course_contacts();
Línea 384... Línea 390...
384
                    $content .= "<div class='course-contact-title-item'>
390
                    $content .= "<div class='course-contact-title-item'>
385
                        <a href='{$url}' 'title='{$name}'
391
                        <a href='{$url}' 'title='{$name}'
386
                            class='course-contact rui-user-{$roleshortname}'>";
392
                            class='course-contact rui-user-{$roleshortname}'>";
387
                    $content .= "<img src='{$picture}'
393
                    $content .= "<img src='{$picture}'
388
                        class='course-teacher-avatar' alt='{$name}'
394
                        class='course-teacher-avatar' alt='{$name}'
389
                        title='{$name} - {$role}' data-toggle='tooltip'/>";
395
                        title='{$name} - {$role}' data-bs-toggle='tooltip'/>";
390
                    $content .= "<div class='course-teacher-content'>
396
                    $content .= "<div class='course-teacher-content'>
391
                        <span class='course-teacher-role'>{$role}</span>
397
                        <span class='course-teacher-role'>{$role}</span>
392
                        <h4 class='course-teacher-name'>{$name}</h4></div>";
398
                        <h4 class='course-teacher-name'>{$name}</h4></div>";
393
                    $content .= "</a></div>";
399
                    $content .= "</a></div>";
394
                }
400
                }
Línea 397... Línea 403...
397
            $content .= html_writer::end_div(); // End .teachers-box.
403
            $content .= html_writer::end_div(); // End .teachers-box.
398
            return $content;
404
            return $content;
399
        }
405
        }
400
    }
406
    }
Línea 401... Línea 407...
401
 
407
 
402
    public function course_contacts()
-
 
403
    {
408
    public function course_contacts() {
404
        global $CFG, $COURSE, $DB;
409
        global $CFG, $COURSE, $DB;
405
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
410
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
406
        $course = new core_course_list_element($course);
411
        $course = new core_course_list_element($course);
Línea 407... Línea 412...
407
        $instructors = $course->get_course_contacts();
412
        $instructors = $course->get_course_contacts();
408
 
413
 
Línea 409... Línea 414...
409
        if (!empty($instructors)) {
414
        if (!empty($instructors)) {
410
            $content = html_writer::start_div('course-teachers-box w-100');
415
            $content = '';
411
 
416
 
412
            foreach ($instructors as $key => $instructor) {
417
            foreach ($instructors as $key => $instructor) {
Línea 420... Línea 425...
420
                $picture = $userutil->get_user_picture(384);
425
                $picture = $userutil->get_user_picture(384);
Línea 421... Línea 426...
421
 
426
 
422
                $user = $DB->get_record('user', array('id' => $key));
427
                $user = $DB->get_record('user', array('id' => $key));
Línea 423... Línea 428...
423
                $desc = $user->description;
428
                $desc = $user->description;
424
 
-
 
425
                $content .= "<div class='rui-block-team-item text-center text-md-left
429
 
426
                    d-inline-flex flex-wrap align-items-start align-items-md-center'>";
430
                $content .= "<div class='course-teachers-box my-0'>";
427
                $content .= "<div class='rui-card-team--img-smpl'><img src='{$picture}'
431
                $content .= "<div class='course-contact course-teacher-avatar mt-0'><img src='{$picture}'
428
                    class='rui-card-team--img-smpl mr-3 mr-md-5'
432
                    class='course-teacher-avatar'
-
 
433
                    alt='{$name}, {$role}'/></div>";
429
                    alt='{$name}, {$role}'/></div>";
434
                $content .= "<div class='course-contact-title-item d-block'>
430
                $content .= "<div class='rui-course-teacher--item col px-0 text-left'>
435
                    <span class='course-teacher-role d-block'>{$role}</span>
431
                    <a href='{$url}' 'title='{$name}'
436
                    <a href='{$url}' 'title='{$name}'
432
                        class='course-contact rui-user-{$roleshortname}'>
-
 
433
                        <h4 class='mb-0'>{$name}</h4></a>
437
                        class='d-flex flex-wrap course-contact rui-user-{$roleshortname}'>
434
                        <span class='rui-block-text--3 rui-block-text--light mb-3'>{$role}</span>";
438
                        <h4 class='course-teacher-name mb-0'>{$name}</h4></a></div>";
435
                $content .= "<div class='rui-block-text--2 mt-2'>{$desc}</div></div></div>";
-
 
-
 
439
                $content .= "<div class='rui-course-contact-desc'>{$desc}</div></div>";
436
            }
440
            }
437
            $content .= html_writer::end_div(); // End .teachers-box.
441
 
438
            return $content;
442
            return $content;
Línea 439... Línea 443...
439
        }
443
        }
440
    }
444
    }
441
 
445
 
442
    /**
446
    /**
443
     *
447
     *
444
     * Returns HTML to display course details.
448
     * Returns HTML to display course details.
445
     *
-
 
446
     */
449
     *
447
    protected function course_details()
-
 
448
    {
-
 
449
        global $CFG, $COURSE, $DB;
-
 
450
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
-
 
Línea 451... Línea 450...
451
        $course = new core_course_list_element($course);
450
     */
452
        $content = '';
451
    protected function course_details() {
453
        $tempcourse = $DB->get_record('course_categories', ['id' => $COURSE->id]);
452
        global $CFG, $COURSE, $DB;
454
 
453
 
455
        $content .= html_writer::start_div('rui-course-details mt-4');
454
        if ($this->page->theme->settings->ipcoursedates == 1) {
456
        $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
455
            $course = $DB->get_record('course', ['id' => $COURSE->id]);
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']);
456
            $course = new core_course_list_element($course);
459
        $content .= html_writer::end_div();
-
 
460
 
457
            $content = '';
461
        // Course End date.
458
            $tempcourse = $DB->get_record('course_categories', ['id' => $COURSE->id]);
462
        $courseenddate = $COURSE->enddate;
459
    
463
        if ($courseenddate != '0') {
460
            $content .= html_writer::start_div('rui-course-details d-flex');
-
 
461
            $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
-
 
462
            $content .= html_writer::tag('span', get_string('startdate', 'moodle'), ['class' => 'rui-custom-field-name']);
-
 
463
            $content .= html_writer::tag('span', userdate($course->startdate, get_string('strftimedaydate', 'core_langconfig')), ['class' => 'rui-custom-field-value']);
-
 
464
            $content .= html_writer::end_div();
-
 
465
    
-
 
466
            // Course End date.
-
 
467
            $courseenddate = $COURSE->enddate;
-
 
468
            if ($courseenddate != '0') {
-
 
469
                $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
-
 
470
                $content .= html_writer::tag('span', get_string('enddate', 'moodle'), ['class' => 'rui-course-enddate-label rui-custom-field-name']);
-
 
471
                $content .= html_writer::tag('span', userdate($courseenddate, get_string('strftimedaydate', 'core_langconfig')), ['class' => 'rui-course-enddate rui-custom-field-value']);
-
 
472
                $content .= html_writer::end_div();
464
            $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
473
            }
465
            $content .= html_writer::tag('span', get_string('enddate', 'moodle'), ['class' => 'rui-course-enddate-label rui-custom-field-name']);
-
 
Línea 466... Línea -...
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();
474
            $content .= html_writer::end_div(); // .rui-course-details.
Línea 468... Línea 475...
468
        }
475
    
469
        $content .= html_writer::end_div(); // .rui-course-details.
476
            return $content;
470
 
477
        }
471
        return $content;
478
 
472
    }
479
    }
473
 
480
 
474
    /**
-
 
475
     *
481
    /**
476
     * Returns HTML to display course summary.
482
     *
Línea 477... Línea 483...
477
     *
483
     * Returns HTML to display course summary.
Línea 498... Línea 504...
498
    /**
504
    /**
499
     * Outputs the pix url base
505
     * Outputs the pix url base
500
     *
506
     *
501
     * @return string an URL.
507
     * @return string an URL.
502
     */
508
     */
503
    public function get_pix_image_url_base()
509
    public function get_pix_image_url_base() {
504
    {
-
 
505
        global $CFG;
510
        global $CFG;
Línea 506... Línea 511...
506
 
511
 
507
        return $CFG->wwwroot . "/theme/universe/pix";
512
        return $CFG->wwwroot . "/theme/universe/pix";
Línea 508... Línea 513...
508
    }
513
    }
509
 
514
 
510
    /**
515
    /**
511
     *
516
     *
512
     */
-
 
513
    public function course_hero_url()
517
     */
Línea 514... Línea 518...
514
    {
518
    public function course_hero_url() {
Línea 515... Línea 519...
515
        global $CFG, $COURSE, $DB;
519
        global $CFG, $COURSE, $DB;
Línea 550... Línea 554...
550
 
554
 
551
    /**
555
    /**
552
     * Returns HTML to display course hero.
556
     * Returns HTML to display course hero.
553
     *
557
     *
554
     */
558
     */
555
    public function course_hero()
-
 
556
    {
559
    public function course_hero() {
Línea 557... Línea 560...
557
        global $CFG, $COURSE, $DB;
560
        global $CFG, $COURSE, $DB;
Línea 558... Línea 561...
558
 
561
 
Línea 572... Línea 575...
572
        }
575
        }
573
        return $html;
576
        return $html;
574
    }
577
    }
Línea 575... Línea -...
575
 
-
 
576
 
-
 
577
 
578
 
578
 
579
 
579
    /**
580
    /**
580
     * Breadcrumbs
581
     * Breadcrumbs
581
     *
582
     *
582
     */
-
 
583
    public function breadcrumbs()
583
     */
Línea 584... Línea 584...
584
    {
584
    public function breadcrumbs() {
585
        global $USER, $COURSE, $CFG;
585
        global $USER, $COURSE, $CFG;
586
 
586
 
Línea 597... Línea 597...
597
    /**
597
    /**
598
     * Wrapper for header elements.
598
     * Wrapper for header elements.
599
     *
599
     *
600
     * @return string HTML to display the main header.
600
     * @return string HTML to display the main header.
601
     */
601
     */
602
    public function simple_header()
602
    public function simple_header() {
603
    {
-
 
Línea 604... Línea 603...
604
 
603
 
605
        global $USER, $COURSE, $CFG;
604
        global $USER, $COURSE, $CFG;
Línea 606... Línea 605...
606
        $html = null;
605
        $html = null;
Línea 637... Línea 636...
637
        }
636
        }
Línea 638... Línea 637...
638
 
637
 
639
        return $html;
638
        return $html;
Línea -... Línea 639...
-
 
639
    }
-
 
640
 
-
 
641
 
640
    }
642
 
641
 
-
 
642
    public function display_course_progress()
643
 
643
    {
644
    public function display_course_progress() {
644
        $html = null;
645
        $html = null;
645
        $html .= $this->courseprogress($this->page->course);
646
        $html .= $this->courseprogress($this->page->course);
Línea 646... Línea 647...
646
        return $html;
647
        return $html;
647
    }
648
    }
648
 
649
 
649
    /**
650
    /**
650
     * Wrapper for header elements.
651
     * Wrapper for header elements.
651
     *
652
     *
652
     * @return string HTML to display the main header.
-
 
653
     */
653
     * @return string HTML to display the main header.
654
    public function full_header()
-
 
655
    {
654
     */
656
        global $USER, $COURSE, $CFG;
-
 
657
        $theme = \theme_config::load('universe');
655
    public function full_header() {
658
        $html = null;
-
 
659
        $pagetype = $this->page->pagetype;
656
        global $USER, $COURSE, $CFG;
660
        $homepage = get_home_page();
657
        $html = null;
661
        $homepagetype = null;
658
        $homepage = get_home_page();
662
        // Add a special case since /my/courses is a part of the /my subsystem.
659
        // Add a special case since /my/courses is a part of the /my subsystem.
663
        if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) {
660
        if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) {
Línea 687... Línea 684...
687
        $header->pageheadingbutton = $this->page_heading_button();
684
        $header->pageheadingbutton = $this->page_heading_button();
688
        $header->courseheader = $this->course_header();
685
        $header->courseheader = $this->course_header();
689
        $header->headeractions = $this->page->get_header_actions();
686
        $header->headeractions = $this->page->get_header_actions();
Línea 690... Línea 687...
690
 
687
 
-
 
688
        if ($this->page->theme->settings->ipcoursedetails == 1) {
-
 
689
            $html .= html_writer::start_tag('div', array('class' => 'rui-course-info-box'));
691
        if ($this->page->theme->settings->ipcoursedetails == 1) {
690
            $html .= html_writer::start_tag('div', array('class' => 'rui-cinfo-container d-flex flex-wrap'));
-
 
691
            $html .= $this->course_details();
-
 
692
            $html .= html_writer::start_tag('div', array('class' => 'rui-course-header-custom-f'));
-
 
693
            $courseutil = new course($COURSE);
-
 
694
            $html .= $courseutil->course_get_taux();
-
 
695
            $html .= html_writer::end_tag('div'); // .rui-course-header-custom-f.
-
 
696
            $html .= html_writer::end_tag('div');
692
            $html .= $this->course_details();
697
            $html .= html_writer::end_tag('div');
Línea 693... Línea 698...
693
        }
698
        }
694
 
699
 
695
        $html .= $this->render_from_template('theme_universe/header', $header);
700
        $html .= $this->render_from_template('theme_universe/header', $header);
Línea 705... Línea 710...
705
        $html .= html_writer::end_tag('div'); // End .rui-course-header.
710
        $html .= html_writer::end_tag('div'); // End .rui-course-header.
Línea 706... Línea 711...
706
 
711
 
707
        return $html;
712
        return $html;
Línea -... Línea 713...
-
 
713
    }
-
 
714
 
-
 
715
    /**
-
 
716
     * Wrapper for header elements.
-
 
717
     *
-
 
718
     * @return string HTML to display the main header.
-
 
719
     */
-
 
720
    public function efull_header() {
-
 
721
        global $USER, $COURSE, $CFG;
-
 
722
 
-
 
723
        $html = null;
-
 
724
 
-
 
725
        $html .= html_writer::start_tag('div', array('class' => 'rui-course-header'));
-
 
726
 
-
 
727
        if ($this->page->theme->settings->ipcoursedetails == 1) {
-
 
728
            $html .= html_writer::start_tag('div', array('class' => 'rui-course-info-box'));
-
 
729
            $html .= html_writer::start_tag('div', array('class' => 'rui-course-header-custom-f'));
-
 
730
            $courseutil = new course($COURSE);
-
 
731
            $html .= $courseutil->course_get_taux();
-
 
732
            $html .= html_writer::end_tag('div'); // .rui-course-header-custom-f.
-
 
733
            $html .= $this->course_details();
-
 
734
            $html .= html_writer::end_tag('div');
-
 
735
        }
-
 
736
 
-
 
737
        if ($this->page->theme->settings->ecoursesummary == 1) {
-
 
738
            $html .= $this->course_summary();
-
 
739
        }
-
 
740
 
-
 
741
        $html .= html_writer::end_tag('div'); // Rui-course-header.
-
 
742
        $html .= $this->get_enrollfields();
-
 
743
 
-
 
744
        return $html;
Línea 708... Línea 745...
708
    }
745
    }
709
 
746
 
710
 
747
 
711
    /**
748
    /**
712
     * Wrapper for header elements.
749
     * Wrapper for header elements.
713
     *
750
     *
714
     * @return string HTML to display the main header.
-
 
715
     */
751
     * @return string HTML to display the main header.
716
    public function clean_header()
-
 
717
    {
752
     */
718
        global $USER, $COURSE, $CFG;
-
 
-
 
753
    public function clean_header() {
719
        $theme = \theme_config::load('universe');
754
        global $USER, $COURSE, $CFG;
720
        $html = null;
-
 
721
        $pagetype = $this->page->pagetype;
755
        $html = null;
722
        $homepage = get_home_page();
756
 
723
        $homepagetype = null;
757
        $homepage = get_home_page();
724
        // Add a special case since /my/courses is a part of the /my subsystem.
758
        // Add a special case since /my/courses is a part of the /my subsystem.
725
        if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) {
759
        if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) {
Línea 754... Línea 788...
754
    /**
788
    /**
755
     * Returns standard navigation between activities in a course.
789
     * Returns standard navigation between activities in a course.
756
     *
790
     *
757
     * @return string the navigation HTML.
791
     * @return string the navigation HTML.
758
     */
792
     */
759
    public function activity_navigation()
793
    public function activity_navigation() {
760
    {
-
 
761
        // First we should check if we want to add navigation.
794
        // First we should check if we want to add navigation.
762
        $context = $this->page->context;
795
        $context = $this->page->context;
763
        if (($this->page->pagelayout !== 'incourse' && $this->page->pagelayout !== 'frametop')
796
        if (($this->page->pagelayout !== 'incourse' && $this->page->pagelayout !== 'frametop')
764
            || $context->contextlevel != CONTEXT_MODULE
797
            || $context->contextlevel != CONTEXT_MODULE
765
        ) {
798
        ) {
Línea 827... Línea 860...
827
     * This is an optional menu that can be added to a layout by a theme. It contains the
860
     * This is an optional menu that can be added to a layout by a theme. It contains the
828
     * menu for the course administration, only on the course main page.
861
     * menu for the course administration, only on the course main page.
829
     *
862
     *
830
     * @return string
863
     * @return string
831
     */
864
     */
832
    public function context_header_settings_menu()
865
    public function context_header_settings_menu() {
833
    {
-
 
834
        $context = $this->page->context;
866
        $context = $this->page->context;
835
        $menu = new action_menu();
867
        $menu = new action_menu();
Línea 836... Línea 868...
836
 
868
 
837
        $items = $this->page->navbar->get_items();
869
        $items = $this->page->navbar->get_items();
Línea 928... Línea 960...
928
        }
960
        }
Línea 929... Línea 961...
929
 
961
 
930
        return $this->render($menu);
962
        return $this->render($menu);
Línea 931... Línea 963...
931
    }
963
    }
932
 
-
 
933
    public function customeditblockbtn()
964
 
934
    {
965
    public function customeditblockbtn() {
935
        $header = new stdClass();
966
        $header = new stdClass();
Línea 936... Línea 967...
936
        $header->settingsmenu = $this->context_header_settings_menu();
967
        $header->settingsmenu = $this->context_header_settings_menu();
Línea 946... Línea 977...
946
     *
977
     *
947
     * @param array $headerinfo Heading information.
978
     * @param array $headerinfo Heading information.
948
     * @param int $headinglevel What 'h' level to make the heading.
979
     * @param int $headinglevel What 'h' level to make the heading.
949
     * @return string A rendered context header.
980
     * @return string A rendered context header.
950
     */
981
     */
951
    public function context_header($headerinfo = null, $headinglevel = 1): string
982
    public function context_header($headerinfo = null, $headinglevel = 1): string {
952
    {
-
 
953
        global $DB, $USER, $CFG, $SITE;
983
        global $DB, $USER, $CFG, $SITE;
954
        require_once($CFG->dirroot . '/user/lib.php');
984
        require_once($CFG->dirroot . '/user/lib.php');
955
        $context = $this->page->context;
985
        $context = $this->page->context;
956
        $heading = null;
986
        $heading = null;
957
        $imagedata = null;
987
        $imagedata = null;
Línea 997... Línea 1027...
997
                if (!empty($CFG->messaging) && has_capability('moodle/site:sendmessage', $context)) {
1027
                if (!empty($CFG->messaging) && has_capability('moodle/site:sendmessage', $context)) {
998
                    $userbuttons = array(
1028
                    $userbuttons = array(
999
                        'messages' => array(
1029
                        'messages' => array(
1000
                            'buttontype' => 'message',
1030
                            'buttontype' => 'message',
1001
                            'title' => get_string('message', 'message'),
1031
                            'title' => get_string('message', 'message'),
1002
                            'url' => new moodle_url('/message/index.php', array('id' => $user->id)),
1032
                            'url' => new moodle_url('/message/index.php', ['id' => $user->id]),
1003
                            'image' => 'message',
1033
                            'image' => 't/message',
1004
                            'linkattributes' => \core_message\helper::messageuser_link_params($user->id),
1034
                            'linkattributes' => \core_message\helper::messageuser_link_params($user->id),
1005
                            'page' => $this->page
1035
                            'page' => $this->page
1006
                        )
1036
                        )
1007
                    );
1037
                    );
Línea 1008... Línea 1038...
1008
 
1038
 
1009
                    if ($USER->id != $user->id) {
1039
                    if ($USER->id != $user->id) {
1010
                        $iscontact = \core_message\api::is_contact($USER->id, $user->id);
1040
                        $iscontact = \core_message\api::is_contact($USER->id, $user->id);
1011
                        $contacttitle = $iscontact ? 'removefromyourcontacts' : 'addtoyourcontacts';
1041
                        $contacttitle = $iscontact ? 'removefromyourcontacts' : 'addtoyourcontacts';
1012
                        $contacturlaction = $iscontact ? 'removecontact' : 'addcontact';
1042
                        $contacturlaction = $iscontact ? 't/removecontact' : 't/addcontact';
1013
                        $contactimage = $iscontact ? 'removecontact' : 'addcontact';
1043
                        $contactimage = $iscontact ? 't/removecontact' : 't/addcontact';
1014
                        $userbuttons['togglecontact'] = array(
1044
                        $userbuttons['togglecontact'] = array(
1015
                            'buttontype' => 'togglecontact',
1045
                            'buttontype' => 'togglecontact',
1016
                            'title' => get_string($contacttitle, 'message'),
1046
                            'title' => get_string($contacttitle, 'message'),
1017
                            'url' => new moodle_url(
1047
                            'url' => new moodle_url(
Línea 1062... Línea 1092...
1062
     *
1092
     *
1063
     * @param stdClass $user A user object, usually $USER.
1093
     * @param stdClass $user A user object, usually $USER.
1064
     * @param bool $withlinks true if a dropdown should be built.
1094
     * @param bool $withlinks true if a dropdown should be built.
1065
     * @return string HTML fragment.
1095
     * @return string HTML fragment.
1066
     */
1096
     */
1067
    public function user_menu($user = null, $withlinks = null)
1097
    public function user_menu($user = null, $withlinks = null) {
1068
    {
-
 
1069
        global $USER, $CFG;
1098
        global $USER, $CFG;
1070
        require_once($CFG->dirroot . '/user/lib.php');
1099
        require_once($CFG->dirroot . '/user/lib.php');
Línea 1071... Línea 1100...
1071
 
1100
 
1072
        if (is_null($user)) {
1101
        if (is_null($user)) {
Línea 1096... Línea 1125...
1096
        $loginpage = $this->is_login_page();
1125
        $loginpage = $this->is_login_page();
1097
        $loginurl = get_login_url();
1126
        $loginurl = get_login_url();
1098
        // If not logged in, show the typical not-logged-in string.
1127
        // If not logged in, show the typical not-logged-in string.
1099
        if (!isloggedin()) {
1128
        if (!isloggedin()) {
1100
            if (!$loginpage) {
1129
            if (!$loginpage) {
1101
                $returnstr .= "<a class=\"rui-topbar-btn rui-login-btn\" href=\"$loginurl\"><span class=\"rui-login-btn-txt\">" .
1130
                $returnstr .= "<a class=\"rui-topbar-btn rui-login-btn text-decoration-none\" href=\"$loginurl\"><span class=\"rui-login-btn-txt\">" .
1102
                    get_string('login') .
1131
                    get_string('login') .
1103
                    '</span>
1132
                    '</span>
1104
                <svg class="ml-2" width="20" height="20" fill="none" viewBox="0 0 24 24">
1133
                <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"
1134
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
1106
                d="M9.75 8.75L13.25 12L9.75 15.25"></path>
1135
                d="M9.75 8.75L13.25 12L9.75 15.25"></path>
Línea 1148... Línea 1177...
1148
            12 20ZM11.9785 4.00003L12.0236 4.00003L12 4L11.9785 4.00003Z"
1177
            12 20ZM11.9785 4.00003L12.0236 4.00003L12 4L11.9785 4.00003Z"
1149
                fill="currentColor"
1178
                fill="currentColor"
1150
                /></svg>';
1179
                /></svg>';
1151
            $returnstr = '<div class="rui-badge-guest">' . $icon . get_string('loggedinasguest') . '</div>';
1180
            $returnstr = '<div class="rui-badge-guest">' . $icon . get_string('loggedinasguest') . '</div>';
1152
            if (!$loginpage && $withlinks) {
1181
            if (!$loginpage && $withlinks) {
1153
                $returnstr .= "<a class=\"rui-topbar-btn rui-login-btn\"
1182
                $returnstr .= "<a class=\"text-decoration-none rui-topbar-btn rui-login-btn\"
1154
                    href=\"$loginurl\"><span class=\"rui-login-btn-txt\">" .
1183
                    href=\"$loginurl\"><span class=\"rui-login-btn-txt\">" .
1155
                    get_string('login') .
1184
                    get_string('login') .
1156
                    '</span>
1185
                    '</span>
1157
                <svg class="ml-2"
1186
                <svg class="ml-2"
1158
                    width="20"
1187
                    width="20"
Línea 1241... Línea 1270...
1241
        // Role.
1270
        // Role.
1242
        if (!empty($opts->metadata['asotherrole'])) {
1271
        if (!empty($opts->metadata['asotherrole'])) {
1243
            $role = core_text::strtolower(preg_replace('#[ ]+#', '-', trim($opts->metadata['rolename'])));
1272
            $role = core_text::strtolower(preg_replace('#[ ]+#', '-', trim($opts->metadata['rolename'])));
1244
            $usermeta .= html_writer::span(
1273
            $usermeta .= html_writer::span(
1245
                $opts->metadata['rolename'],
1274
                $opts->metadata['rolename'],
1246
                'meta role role-' . $role
1275
                "meta role role-$role"
1247
            );
1276
            );
1248
        }
1277
        }
Línea 1249... Línea 1278...
1249
 
1278
 
1250
        // User login failures.
1279
        // User login failures.
Línea 1365... Línea 1394...
1365
     * Returns standard main content placeholder.
1394
     * Returns standard main content placeholder.
1366
     * Designed to be called in theme layout.php files.
1395
     * Designed to be called in theme layout.php files.
1367
     *
1396
     *
1368
     * @return string HTML fragment.
1397
     * @return string HTML fragment.
1369
     */
1398
     */
1370
    public function main_content()
1399
    public function main_content() {
-
 
1400
        // This is here because it is the only place we can inject the "main" role over the entire main content area
-
 
1401
        // without requiring all theme's to manually do it, and without creating yet another thing people need to
1371
    {
1402
        // remember in the theme.
1372
        $this->page->set_state(moodle_page::STATE_IN_BODY);
1403
        // This is an unfortunate hack. DO NO EVER add anything more here.
-
 
1404
        // DO NOT add classes.
-
 
1405
        // DO NOT add an id.
1373
        return $this->render_from_template('core/local/content', []);
1406
        return '<div class="main-content" role="main">' . $this->unique_main_content_token . '</div>';
1374
    }
1407
    }
Línea 1375... Línea 1408...
1375
 
1408
 
1376
    /**
1409
    /**
1377
     * Outputs a heading
1410
     * Outputs a heading
Línea 1380... Línea 1413...
1380
     * @param int $level The level of importance of the heading. Defaulting to 2
1413
     * @param int $level The level of importance of the heading. Defaulting to 2
1381
     * @param string $classes A space-separated list of CSS classes. Defaulting to null
1414
     * @param string $classes A space-separated list of CSS classes. Defaulting to null
1382
     * @param string $id An optional ID
1415
     * @param string $id An optional ID
1383
     * @return string the HTML to output.
1416
     * @return string the HTML to output.
1384
     */
1417
     */
1385
    public function heading($text, $level = 2, $classes = null, $id = null)
1418
    public function heading($text, $level = 2, $classes = null, $id = null) {
1386
    {
-
 
1387
        $level = (int) $level;
1419
        $level = (int) $level;
1388
        if ($level < 1 || $level > 6) {
1420
        if ($level < 1 || $level > 6) {
1389
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
1421
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
1390
        }
1422
        }
1391
        return html_writer::tag('div', html_writer::tag('h' .
1423
        return html_writer::tag('div', html_writer::tag('h' .
Línea 1393... Línea 1425...
1393
            ' rui-main-content-title rui-main-content-title--h' .
1425
            ' rui-main-content-title rui-main-content-title--h' .
1394
            $level)), array('class' => 'rui-title-container'));
1426
            $level)), array('class' => 'rui-title-container'));
1395
    }
1427
    }
Línea 1396... Línea 1428...
1396
 
1428
 
1397
 
-
 
1398
    public function headingwithavatar($text, $level = 2, $classes = null, $id = null)
1429
 
1399
    {
1430
    public function headingwithavatar($text, $level = 2, $classes = null, $id = null) {
1400
        $level = (int) $level;
1431
        $level = (int) $level;
1401
        if ($level < 1 || $level > 6) {
1432
        if ($level < 1 || $level > 6) {
1402
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
1433
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
Línea 1410... Línea 1441...
1410
     * Renders the login form.
1441
     * Renders the login form.
1411
     *
1442
     *
1412
     * @param \core_auth\output\login $form The renderable.
1443
     * @param \core_auth\output\login $form The renderable.
1413
     * @return string
1444
     * @return string
1414
     */
1445
     */
1415
    public function render_login(\core_auth\output\login $form)
1446
    public function render_login(\core_auth\output\login $form) {
1416
    {
-
 
1417
        global $CFG, $SITE;
1447
        global $CFG, $SITE;
Línea 1418... Línea 1448...
1418
 
1448
 
Línea 1419... Línea 1449...
1419
        $context = $form->export_for_template($this);
1449
        $context = $form->export_for_template($this);
Línea 1434... Línea 1464...
1434
            $SITE->fullname,
1464
            $SITE->fullname,
1435
            true,
1465
            true,
1436
            ['context' => context_course::instance(SITEID), "escape" => false]
1466
            ['context' => context_course::instance(SITEID), "escape" => false]
1437
        );
1467
        );
Línea 1438... Línea 1468...
1438
 
1468
 
1439
        if ($this->page->theme->settings->setloginlayout == 1) {
1469
        $setloginlayout = $this->page->theme->settings->setloginlayout;
-
 
1470
        switch ($setloginlayout) {
1440
            $context->loginlayout1 = 1;
1471
            case 1:
-
 
1472
                $context->loginlayout1 = 1;
-
 
1473
                break;
1441
        } else if ($this->page->theme->settings->setloginlayout == 2) {
1474
            case 2:
1442
            $context->loginlayout2 = 1;
1475
                $context->loginlayout2 = 1;
1443
            if (isset($this->page->theme->settings->loginbg)) {
1476
                if (isset($this->page->theme->settings->loginbg)) {
1444
                $context->loginlayoutimg = 1;
1477
                    $context->loginlayoutimg = 1;
-
 
1478
                }
1445
            }
1479
                break;
1446
        } else if ($this->page->theme->settings->setloginlayout == 3) {
1480
            case 3:
1447
            $context->loginlayout3 = 1;
1481
                $context->loginlayout3 = 1;
1448
            if (isset($this->page->theme->settings->loginbg)) {
1482
                if (isset($this->page->theme->settings->loginbg)) {
1449
                $context->loginlayoutimg = 1;
1483
                    $context->loginlayoutimg = 1;
-
 
1484
                }
1450
            }
1485
                break;
1451
        } else if ($this->page->theme->settings->setloginlayout == 4) {
1486
            case 4:
-
 
1487
                $context->loginlayout4 = 1;
1452
            $context->loginlayout4 = 1;
1488
                break;
1453
        } else if ($this->page->theme->settings->setloginlayout == 5) {
1489
            case 5:
-
 
1490
                $context->loginlayout5 = 1;
1454
            $context->loginlayout5 = 1;
1491
                break;
Línea 1455... Línea 1492...
1455
        }
1492
        }
1456
 
1493
 
1457
        if (isset($this->page->theme->settings->loginlogooutside)) {
1494
        if (isset($this->page->theme->settings->loginlogooutside)) {
Línea 1488... Línea 1525...
1488
        }
1525
        }
Línea 1489... Línea 1526...
1489
 
1526
 
1490
        if (isset($this->page->theme->settings->loginhtmlcontent2)) {
1527
        if (isset($this->page->theme->settings->loginhtmlcontent2)) {
1491
            $context->loginhtmlcontent2 = format_text(($this->page->theme->settings->loginhtmlcontent2),
1528
            $context->loginhtmlcontent2 = format_text(($this->page->theme->settings->loginhtmlcontent2),
1492
                FORMAT_HTML,
1529
                FORMAT_HTML,
1493
                array('noclean' => true)
1530
                ['noclean' => true]
1494
            );
1531
            );
Línea 1495... Línea 1532...
1495
        }
1532
        }
1496
 
1533
 
1497
        if (isset($this->page->theme->settings->loginhtmlcontent3)) {
1534
        if (isset($this->page->theme->settings->loginhtmlcontent3)) {
1498
            $context->loginhtmlcontent3 = format_text(($this->page->theme->settings->loginhtmlcontent3),
1535
            $context->loginhtmlcontent3 = format_text(($this->page->theme->settings->loginhtmlcontent3),
1499
                FORMAT_HTML,
1536
                FORMAT_HTML,
1500
                array('noclean' => true)
1537
                ['noclean' => true]
Línea 1501... Línea 1538...
1501
            );
1538
            );
1502
        }
1539
        }
1503
 
1540
 
1504
        if (isset($this->page->theme->settings->loginhtmlcontent2)) {
1541
        if (isset($this->page->theme->settings->loginhtmlcontent2)) {
1505
            $context->loginhtmlcontent2 = format_text(($this->page->theme->settings->loginhtmlcontent2),
1542
            $context->loginhtmlcontent2 = format_text(($this->page->theme->settings->loginhtmlcontent2),
1506
                FORMAT_HTML,
1543
                FORMAT_HTML,
Línea 1507... Línea 1544...
1507
                array('noclean' => true)
1544
                ['noclean' => true]
1508
            );
1545
            );
1509
        }
1546
        }
1510
 
1547
 
1511
        if (isset($this->page->theme->settings->logincustomfooterhtml)) {
1548
        if (isset($this->page->theme->settings->logincustomfooterhtml)) {
1512
            $context->logincustomfooterhtml = format_text(($this->page->theme->settings->logincustomfooterhtml),
1549
            $context->logincustomfooterhtml = format_text(($this->page->theme->settings->logincustomfooterhtml),
Línea 1513... Línea 1550...
1513
                FORMAT_HTML,
1550
                FORMAT_HTML,
1514
                array('noclean' => true)
1551
                ['noclean' => true]
1515
            );
1552
            );
1516
        }
1553
        }
1517
 
1554
 
1518
        if (isset($this->page->theme->settings->loginhtmlblockbottom)) {
1555
        if (isset($this->page->theme->settings->loginhtmlblockbottom)) {
Línea 1519... Línea 1556...
1519
            $context->loginhtmlblockbottom = format_text(($this->page->theme->settings->loginhtmlblockbottom),
1556
            $context->loginhtmlblockbottom = format_text(($this->page->theme->settings->loginhtmlblockbottom),
1520
                FORMAT_HTML,
1557
                FORMAT_HTML,
1521
                array('noclean' => true)
1558
                ['noclean' => true]
1522
            );
1559
            );
1523
        }
1560
        }
1524
 
1561
 
Línea 1525... Línea 1562...
1525
        if (isset($this->page->theme->settings->loginfootercontent)) {
1562
        if (isset($this->page->theme->settings->loginfootercontent)) {
1526
            $context->loginfootercontent = format_text(($this->page->theme->settings->loginfootercontent),
1563
            $context->loginfootercontent = format_text(($this->page->theme->settings->loginfootercontent),
1527
                FORMAT_HTML,
1564
                FORMAT_HTML,
1528
                array('noclean' => true)
1565
                ['noclean' => true]
1529
            );
1566
            );
1530
        }
1567
        }
Línea 1531... Línea 1568...
1531
 
1568
 
1532
        if (isset($this->page->theme->settings->footercopy)) {
1569
        if (isset($this->page->theme->settings->footercopy)) {
1533
            $context->footercopy = format_text(($this->page->theme->settings->footercopy),
1570
            $context->footercopy = format_text(($this->page->theme->settings->footercopy),
1534
                FORMAT_HTML,
1571
                FORMAT_HTML,
1535
                array('noclean' => true)
1572
                ['noclean' => true]
1536
            );
1573
            );
Línea 1537... Línea 1574...
1537
        }
1574
        }
1538
 
1575
 
1539
        if (isset($this->page->theme->settings->loginintrotext)) {
1576
        if (isset($this->page->theme->settings->loginintrotext)) {
1540
            $context->loginintrotext = format_text(($this->page->theme->settings->loginintrotext),
1577
            $context->loginintrotext = format_text(($this->page->theme->settings->loginintrotext),
1541
                FORMAT_HTML,
1578
                FORMAT_HTML,
1542
                array('noclean' => true)
1579
                ['noclean' => true]
Línea 1543... Línea 1580...
1543
            );
1580
            );
1544
        }
1581
        }
Línea 1576... Línea 1613...
1576
     * Render the login signup form into a nice template for the theme.
1613
     * Render the login signup form into a nice template for the theme.
1577
     *
1614
     *
1578
     * @param mform $form
1615
     * @param mform $form
1579
     * @return string
1616
     * @return string
1580
     */
1617
     */
1581
    public function render_login_signup_form($form)
1618
    public function render_login_signup_form($form) {
1582
    {
-
 
1583
        global $SITE;
1619
        global $SITE;
Línea 1584... Línea 1620...
1584
 
1620
 
1585
        $context = $form->export_for_template($this);
1621
        $context = $form->export_for_template($this);
1586
        $url = $this->get_logo_url();
1622
        $url = $this->get_logo_url();
Línea 1592... Línea 1628...
1592
            $SITE->fullname,
1628
            $SITE->fullname,
1593
            true,
1629
            true,
1594
            ['context' => context_course::instance(SITEID), "escape" => false]
1630
            ['context' => context_course::instance(SITEID), "escape" => false]
1595
        );
1631
        );
Línea 1596... Línea 1632...
1596
 
1632
 
-
 
1633
        $setloginlayout = $this->page->theme->settings->setloginlayout;
1597
        if ($this->page->theme->settings->setloginlayout == 1) {
1634
 
-
 
1635
        switch ($setloginlayout) {
1598
            $context['loginlayout1'] = 1;
1636
            case 1:
-
 
1637
                $context['loginlayout1'] = 1;
-
 
1638
                break;
1599
        } else if ($this->page->theme->settings->setloginlayout == 2) {
1639
            case 2:
1600
            $context['loginlayout2'] = 1;
1640
                $context['loginlayout2'] = 1;
1601
            if (isset($this->page->theme->settings->loginbg)) {
1641
                if (isset($this->page->theme->settings->loginbg)) {
1602
                $context['loginlayoutimg'] = 1;
1642
                    $context['loginlayoutimg'] = 1;
-
 
1643
                }
1603
            }
1644
                break;
1604
        } else if ($this->page->theme->settings->setloginlayout == 3) {
1645
            case 3:
1605
            $context['loginlayout3'] = 1;
1646
                $context['loginlayout3'] = 1;
1606
            if (isset($this->page->theme->settings->loginbg)) {
1647
                if (isset($this->page->theme->settings->loginbg)) {
1607
                $context['loginlayoutimg'] = 1;
1648
                    $context['loginlayoutimg'] = 1;
-
 
1649
                }
1608
            }
1650
                break;
1609
        } else if ($this->page->theme->settings->setloginlayout == 4) {
1651
            case 4:
-
 
1652
                $context['loginlayout4'] = 1;
1610
            $context['loginlayout4'] = 1;
1653
                break;
1611
        } else if ($this->page->theme->settings->setloginlayout == 5) {
1654
            case 5:
-
 
1655
                $context['loginlayout5'] = 1;
1612
            $context['loginlayout5'] = 1;
1656
                break;
Línea 1613... Línea 1657...
1613
        }
1657
        }
1614
 
1658
 
1615
        if (isset($this->page->theme->settings->loginlogooutside)) {
1659
        if (isset($this->page->theme->settings->loginlogooutside)) {
Línea 1616... Línea 1660...
1616
            $context['loginlogooutside'] = $this->page->theme->settings->loginlogooutside;
1660
            $context['loginlogooutside'] = $this->page->theme->settings->loginlogooutside;
1617
        }
1661
        }
1618
 
1662
 
1619
        if (isset($this->page->theme->settings->stringbacktologin)) {
1663
        if (isset($this->page->theme->settings->stringbacktologin)) {
1620
            $context['stringbacktologin'] = format_text(($this->page->theme->settings->stringbacktologin),
1664
            $context['stringbacktologin'] = format_text(($this->page->theme->settings->stringbacktologin),
1621
                FORMAT_HTML,
1665
                FORMAT_HTML,
1622
                array('noclean' => true)
1666
                ['noclean' => true]
1623
            );
1667
            );
1624
        }
1668
        }
1625
        if (isset($this->page->theme->settings->signupintrotext)) {
1669
        if (isset($this->page->theme->settings->signupintrotext)) {
1626
            $context['signupintrotext'] = format_text(($this->page->theme->settings->signupintrotext),
1670
            $context['signupintrotext'] = format_text(($this->page->theme->settings->signupintrotext),
1627
                FORMAT_HTML,
1671
                FORMAT_HTML,
1628
                array('noclean' => true)
1672
                ['noclean' => true]
1629
            );
1673
            );
1630
        }
1674
        }
1631
        if (isset($this->page->theme->settings->signuptext)) {
1675
        if (isset($this->page->theme->settings->signuptext)) {
1632
            $context['signuptext'] = format_text(($this->page->theme->settings->signuptext),
1676
            $context['signuptext'] = format_text(($this->page->theme->settings->signuptext),
1633
                FORMAT_HTML,
1677
                FORMAT_HTML,
Línea 1634... Línea 1678...
1634
                array('noclean' => true)
1678
                ['noclean' => true]
1635
            );
1679
            );
Línea 1646... Línea 1690...
1646
        }
1690
        }
Línea 1647... Línea 1691...
1647
 
1691
 
1648
        if (isset($this->page->theme->settings->loginfootercontent)) {
1692
        if (isset($this->page->theme->settings->loginfootercontent)) {
1649
            $context['loginfootercontent'] = format_text(($this->page->theme->settings->loginfootercontent),
1693
            $context['loginfootercontent'] = format_text(($this->page->theme->settings->loginfootercontent),
1650
                FORMAT_HTML,
1694
                FORMAT_HTML,
1651
                array('noclean' => true)
1695
                ['noclean' => true]
1652
            );
1696
            );
Línea 1653... Línea 1697...
1653
        }
1697
        }
1654
 
1698
 
Línea 1660... Línea 1704...
1660
     * Renders the header bar.
1704
     * Renders the header bar.
1661
     *
1705
     *
1662
     * @param context_header $contextheader Header bar object.
1706
     * @param context_header $contextheader Header bar object.
1663
     * @return string HTML for the header bar.
1707
     * @return string HTML for the header bar.
1664
     */
1708
     */
1665
    protected function render_context_header(\context_header $contextheader)
1709
    protected function render_context_header(\context_header $contextheader) {
1666
    {
-
 
1667
        $heading = null;
1710
        $heading = null;
1668
        $imagedata = null;
1711
        $imagedata = null;
1669
        $html = null;
1712
        $html = null;
Línea 1670... Línea 1713...
1670
 
1713
 
Línea 1733... Línea 1776...
1733
        $html .= html_writer::end_div();
1776
        $html .= html_writer::end_div();
Línea 1734... Línea 1777...
1734
 
1777
 
1735
        return $html;
1778
        return $html;
Línea 1736... Línea 1779...
1736
    }
1779
    }
1737
 
-
 
1738
    public function header()
1780
 
1739
    {
1781
    public function header() {
Línea 1740... Línea 1782...
1740
        global $USER, $COURSE;
1782
        global $USER, $COURSE;
1741
        $theme = theme_config::load('universe');
1783
        $theme = theme_config::load('universe');
Línea 1767... Línea 1809...
1767
     * (We track up to 100 cms so as not to overflow the session.)
1809
     * (We track up to 100 cms so as not to overflow the session.)
1768
     * This is done for drawer regions containing fake blocks so we can show blocks automatically.
1810
     * This is done for drawer regions containing fake blocks so we can show blocks automatically.
1769
     *
1811
     *
1770
     * @return boolean true if the page has fakeblocks and this is the first visit.
1812
     * @return boolean true if the page has fakeblocks and this is the first visit.
1771
     */
1813
     */
1772
    public function firstview_fakeblocks(): bool
1814
    public function firstview_fakeblocks(): bool {
1773
    {
-
 
1774
        global $SESSION;
1815
        global $SESSION;
Línea 1775... Línea 1816...
1775
 
1816
 
1776
        $firstview = false;
1817
        $firstview = false;
1777
        if ($this->page->cm) {
1818
        if ($this->page->cm) {
Línea 1799... Línea 1840...
1799
     * Build the guest access hint HTML code.
1840
     * Build the guest access hint HTML code.
1800
     *
1841
     *
1801
     * @param int $courseid The course ID.
1842
     * @param int $courseid The course ID.
1802
     * @return string.
1843
     * @return string.
1803
     */
1844
     */
1804
    public function theme_universe_get_course_guest_access_hint($courseid)
1845
    public function theme_universe_get_course_guest_access_hint($courseid) {
1805
    {
-
 
1806
        global $CFG;
1846
        global $CFG;
1807
        require_once($CFG->dirroot . '/enrol/self/lib.php');
1847
        require_once($CFG->dirroot . '/enrol/self/lib.php');
Línea 1808... Línea 1848...
1808
 
1848
 
1809
        $html = '';
1849
        $html = '';
Línea 1830... Línea 1870...
1830
 
1870
 
1831
    /**
1871
    /**
1832
     * Color Customization
1872
     * Color Customization
1833
     * @return string HTML fragment.
1873
     * @return string HTML fragment.
1834
     */
1874
     */
1835
    public function additional_head_html()
-
 
1836
    {
1875
    public function additional_head_html() {
1837
        global $SITE, $DB, $CFG, $COURSE, $PAGE;
-
 
1838
 
1876
        global $SITE, $DB, $CFG, $COURSE, $PAGE;
1839
        $output = null;
-
 
1840
 
1877
        $output = null;
1841
        if ($PAGE->pagelayout == 'course' || $PAGE->pagelayout == 'incourse') {
1878
        if ($PAGE->pagelayout == 'course' || $PAGE->pagelayout == 'incourse') {
-
 
1879
            $customfieldid1 = $DB->get_record('customfield_field', array('shortname' => 'maincolor1'));
1842
            if ($DB->record_exists('customfield_field', array('shortname' => 'maincolor1'), 'id')) {
1880
            $mainthemecolor = $customfieldid1 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid1->id, 'instanceid' => $COURSE->id)) : null;
-
 
1881
            $customfieldid2 = $DB->get_record('customfield_field', array('shortname' => 'maincolor2'));
1843
                // Get custom field by name
1882
            // $mainthemecolor2 = $customfieldid2 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid2->id, 'instanceid' => $COURSE->id)) : null;
-
 
1883
            $customfieldid3 = $DB->get_record('customfield_field', array('shortname' => 'topbarcolor'));
1844
                $customfieldid1 = $DB->get_record('customfield_field', array('shortname' => 'maincolor1'));
1884
            $topbarcolor = $customfieldid3 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid3->id, 'instanceid' => $COURSE->id)) : null;
-
 
1885
            $customfieldid4 = $DB->get_record('customfield_field', array('shortname' => 'dmtopbarcolor'));
-
 
1886
            $dmtopbarcolor = $customfieldid4 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid4->id, 'instanceid' => $COURSE->id)) : null;
-
 
1887
            // $customfieldid5 = $DB->get_record('customfield_field', array('shortname' => 'colortopbartext'));
-
 
1888
            // $colortopbartext = $customfieldid5 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid5->id, 'instanceid' => $COURSE->id)) : null;
-
 
1889
 
-
 
1890
            $customfieldid6 = $DB->get_record('customfield_field', array('shortname' => 'footertextcolor'));
-
 
1891
            $footertextcolor = $customfieldid6 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid6->id, 'instanceid' => $COURSE->id)) : null;
-
 
1892
 
1845
                // Get value
1893
            $customfieldid7 = $DB->get_record('customfield_field', array('shortname' => 'footerbgcolor'));
-
 
1894
            $footercolor = $customfieldid7 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid7->id, 'instanceid' => $COURSE->id)) : null;
-
 
1895
 
-
 
1896
            $customfieldid8 = $DB->get_record('customfield_field', array('shortname' => 'topbarcolor2'));
-
 
1897
            $topbarcolor2 = $customfieldid8 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid8->id, 'instanceid' => $COURSE->id)) : null;
-
 
1898
 
-
 
1899
            $customfieldid9 = $DB->get_record('customfield_field', array('shortname' => 'dmtopbarcolor2'));
-
 
1900
            $dmtopbarcolor2 = $customfieldid9 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid9->id, 'instanceid' => $COURSE->id)) : null;
-
 
1901
 
-
 
1902
            $customfieldid10 = $DB->get_record('customfield_field', array('shortname' => 'topbartextcolor'));
-
 
1903
            $topbartextcolor = $customfieldid10 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid10->id, 'instanceid' => $COURSE->id)) : null;
-
 
1904
            $customfieldid11 = $DB->get_record('customfield_field', array('shortname' => 'topbartexthovercolor'));
-
 
1905
            $topbartexthovercolor = $customfieldid11 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid11->id, 'instanceid' => $COURSE->id)) : null;
-
 
1906
            $customfieldid12 = $DB->get_record('customfield_field', array('shortname' => 'topbarbghovercolor'));
-
 
1907
            $topbarbghovercolor = $customfieldid12 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid12->id, 'instanceid' => $COURSE->id)) : null;
-
 
1908
 
-
 
1909
            $customfieldid13 = $DB->get_record('customfield_field', array('shortname' => 'dmtopbartextcolor'));
-
 
1910
            $dmtopbartextcolor = $customfieldid13 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid13->id, 'instanceid' => $COURSE->id)) : null;
-
 
1911
            $customfieldid14 = $DB->get_record('customfield_field', array('shortname' => 'dmtopbartexthovercolor'));
-
 
1912
            $dmtopbartexthovercolor = $customfieldid14 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid14->id, 'instanceid' => $COURSE->id)) : null;
-
 
1913
            $customfieldid15 = $DB->get_record('customfield_field', array('shortname' => 'dmtopbarbghovercolor'));
-
 
1914
            $dmtopbarbghovercolor = $customfieldid15 ? $DB->get_record('customfield_data', array('fieldid' => $customfieldid15->id, 'instanceid' => $COURSE->id)) : null;
-
 
1915
 
1846
                $mainthemecolor = $DB->get_record('customfield_data', array('fieldid' => $customfieldid1->id, 'instanceid' => $COURSE->id));
1916
 
1847
            } else {
1917
            $css = ':root { ';
-
 
1918
            if ($mainthemecolor && !empty($mainthemecolor->value)) {
-
 
1919
                $css .= '--main-theme-color: ' . $mainthemecolor->value . '; ';
-
 
1920
                $css .= '--primary-color-100: ' . \theme_universe\toolbox::tint($mainthemecolor->value, .1) . '; ';
-
 
1921
                $css .= '--primary-color-200: ' . \theme_universe\toolbox::tint($mainthemecolor->value, .2) . '; ';
-
 
1922
                $css .= '--primary-color-300: ' . \theme_universe\toolbox::tint($mainthemecolor->value, .3) . '; ';
-
 
1923
                $css .= '--primary-color-400: ' . \theme_universe\toolbox::tint($mainthemecolor->value, .4) . '; ';
-
 
1924
                $css .= '--primary-color-500: ' . \theme_universe\toolbox::tint($mainthemecolor->value, .5) . '; ';
-
 
1925
                $css .= '--primary-color-700: ' . \theme_universe\toolbox::shade($mainthemecolor->value, .5) . '; ';
-
 
1926
                $css .= '--primary-color-800: ' . \theme_universe\toolbox::shade($mainthemecolor->value, .3) . '; ';
-
 
1927
                $css .= '--primary-color-900: ' . \theme_universe\toolbox::shade($mainthemecolor->value, .1) . '; ';
-
 
1928
                //$css .= '--main-theme-color-gradient: ' . $mainthemecolor->value . '; ';
-
 
1929
                $css .= '--btn-primary-color-bg: ' . $mainthemecolor->value . '; ';
-
 
1930
                $css .= '--btn-primary-color-bg-hover: ' . \theme_universe\toolbox::shade($mainthemecolor->value, .5) . '; ';
1848
                $mainthemecolor = null;
1931
                //$css .= '--main-theme-color-gradient-2: ' . ($mainthemecolor2 && !empty($mainthemecolor2->value) ? $mainthemecolor2->value :  \theme_universe\toolbox::shade($mainthemecolor->value, .3)) . '; ';
Línea 1849... Línea 1932...
1849
            }
1932
            }
1850
 
1933
 
1851
            if ($DB->record_exists('customfield_field', array('shortname' => 'maincolor2'), 'id')) {
1934
            if ($topbarcolor && !empty($topbarcolor->value)) {
1852
                $customfieldid2 = $DB->get_record('customfield_field', array('shortname' => 'maincolor2'));
1935
                $css .= '--topbar-color: ' . $topbarcolor->value . '; ';
Línea 1853... Línea 1936...
1853
                $mainthemecolor2 = $DB->get_record('customfield_data', array('fieldid' => $customfieldid2->id, 'instanceid' => $COURSE->id));
1936
                $css .= '--dm-topbar-color: ' . ($dmtopbarcolor && !empty($dmtopbarcolor->value) ? $dmtopbarcolor->value : $dmtopbarcolor->value) . '; ';
1854
            }
-
 
1855
 
1937
            }
1856
            if ($DB->record_exists('customfield_field', array('shortname' => 'topbarcolor'), 'id')) {
-
 
1857
                // Get custom field by name
-
 
1858
                $customfieldid3 = $DB->get_record('customfield_field', array('shortname' => 'topbarcolor'));
1938
 
Línea 1859... Línea 1939...
1859
                // Get value
1939
            if ($topbarcolor2 && !empty($topbarcolor2->value)) {
1860
                $topbarcolor = $DB->get_record('customfield_data', array('fieldid' => $customfieldid3->id, 'instanceid' => $COURSE->id));
-
 
1861
            }
-
 
1862
 
-
 
1863
            if ($DB->record_exists('customfield_field', array('shortname' => 'dmtopbarcolor'), 'id')) {
1940
                $css .= '--topbar-color-2: ' . $topbarcolor2->value . '; ';
1864
                // Get custom field by name
-
 
1865
                $customfieldid3 = $DB->get_record('customfield_field', array('shortname' => 'dmtopbarcolor'));
-
 
1866
                // Get value
1941
            }
Línea -... Línea 1942...
-
 
1942
 
-
 
1943
            if ($dmtopbarcolor2 && !empty($dmtopbarcolor2->value)) {
-
 
1944
                $css .= '--dm-topbar-color-2: ' . ($dmtopbarcolor2 && !empty($dmtopbarcolor2->value) ? $dmtopbarcolor2->value : $dmtopbarcolor2->value) . '; ';
Línea 1867... Línea 1945...
1867
                $dmtopbarcolor = $DB->get_record('customfield_data', array('fieldid' => $customfieldid3->id, 'instanceid' => $COURSE->id));
1945
            }
1868
            } else {
-
 
1869
                $dmtopbarcolor = null;
1946
 
1870
            }
-
 
1871
 
-
 
1872
 
-
 
1873
            if ($DB->record_exists('customfield_field', array('shortname' => 'footerbgcolor'), 'id')) {
-
 
1874
                // Get custom field by name
1947
            if ($topbartextcolor && !empty($topbartextcolor->value)) {
Línea -... Línea 1948...
-
 
1948
                $css .= '--topbar-btn-text: ' . ($topbartextcolor && !empty($topbartextcolor->value) ? $topbartextcolor->value : $topbartextcolor->value) . '; ';
-
 
1949
            }
-
 
1950
 
Línea -... Línea 1951...
-
 
1951
            if ($topbarbghovercolor && !empty($topbarbghovercolor->value)) {
-
 
1952
                $css .= '--topbar-btn-hover: ' . ($topbarbghovercolor && !empty($topbarbghovercolor->value) ? $topbarbghovercolor->value : $topbarbghovercolor->value) . '; ';
1875
                $customfieldid4 = $DB->get_record('customfield_field', array('shortname' => 'footerbgcolor'));
1953
            }
Línea 1876... Línea -...
1876
                // Get value
-
 
1877
                $footercolor = $DB->get_record('customfield_data', array('fieldid' => $customfieldid4->id, 'instanceid' => $COURSE->id));
-
 
1878
            } else {
-
 
1879
                $footercolor = null;
1954
 
1880
            }
-
 
1881
 
-
 
1882
 
1955
            if ($topbartexthovercolor && !empty($topbartexthovercolor->value)) {
1883
            $css = '';
1956
                $css .= '--topbar-btn-hover-text: ' . ($topbartexthovercolor && !empty($topbartexthovercolor->value) ? $topbartexthovercolor->value : $topbartexthovercolor->value) . '; ';
1884
 
-
 
Línea 1885... Línea -...
1885
            $css .= ':root { ';
-
 
1886
            if ($DB->record_exists('customfield_field', array('shortname' => 'maincolor1'), 'id')) {
-
 
1887
                if ($mainthemecolor != null) {
1957
            }
1888
                    $css .= '--main-theme-color: ' . $mainthemecolor->value . '; ';
-
 
1889
                    $css .= '--primary-color-100: ' . $mainthemecolor->value . '30; ';
1958
 
1890
                    $css .= '--primary-color-300: ' . $mainthemecolor->value . '70; ';
-
 
1891
                    $css .= '--main-theme-color-gradient: ' . $mainthemecolor->value . '; ';
-
 
1892
                    $css .= '--btn-primary-color-bg: ' . $mainthemecolor->value . '; ';
-
 
1893
                    $css .= '--btn-primary-color-bg-hover: ' . $mainthemecolor->value . '95; ';
1959
            if ($dmtopbartextcolor && !empty($dmtopbartextcolor->value)) {
Línea 1894... Línea -...
1894
 
-
 
1895
                    if ($DB->record_exists('customfield_field', array('shortname' => 'maincolor2'), 'id')) {
1960
                $css .= '--dm-topbar-btn-text: ' . ($dmtopbartextcolor && !empty($dmtopbartextcolor->value) ? $dmtopbartextcolor->value : $dmtopbartextcolor->value) . '; ';
1896
                        if ($mainthemecolor2 != null) {
1961
            }
1897
                            $css .= '--main-theme-color-gradient-2: ' . $mainthemecolor2->value . '; ';
-
 
1898
                        } else {
-
 
1899
                            $css .= '--main-theme-color-gradient-2: ' . $mainthemecolor->value . '30; ';
-
 
1900
                        }
-
 
1901
                    }
-
 
1902
                }
-
 
1903
            }
1962
 
Línea 1904... Línea -...
1904
 
-
 
1905
            if ($DB->record_exists('customfield_field', array('shortname' => 'topbarcolor'), 'id')) {
1963
            if ($dmtopbarbghovercolor && !empty($dmtopbarbghovercolor->value)) {
1906
                if ($topbarcolor != null) {
1964
                $css .= '--dm-topbar-btn-hover: ' . ($dmtopbarbghovercolor && !empty($dmtopbarbghovercolor->value) ? $dmtopbarbghovercolor->value : $dmtopbarbghovercolor->value) . '; ';
1907
                    $css .= '--topbar-color: ' . $topbarcolor->value . '; ';
-
 
1908
                    if ($dmtopbarcolor != null) {
1965
            }
Línea 1909... Línea 1966...
1909
                        $css .= '--dm-topbar-color: ' . $dmtopbarcolor->value . '; ';
1966
 
1910
                    } else {
-
 
1911
                        $css .= '--dm-topbar-color: ' . $topbarcolor->value . '; ';
1967
            if ($dmtopbartexthovercolor && !empty($dmtopbartexthovercolor->value)) {
1912
                    }
1968
                $css .= '--dm-topbar-btn-hover-text: ' . ($dmtopbartexthovercolor && !empty($dmtopbartexthovercolor->value) ? $dmtopbartexthovercolor->value : $dmtopbartexthovercolor->value) . '; ';
1913
                }
1969
            }
1914
            }
1970
 
1915
 
-
 
1916
            if ($DB->record_exists('customfield_field', array('shortname' => 'footerbgcolor'), 'id')) {
1971
            if ($footercolor && !empty($footercolor->value)) {
1917
                if ($footercolor != null) {
1972
                $css .= '--footer-color: ' . $footercolor->value . '; ';
Línea 1918... Línea 1973...
1918
                    $css .= '--footer-color: ' . $footercolor->value . '; ';
1973
            }
1919
                }
-
 
1920
            }
1974
 
Línea 1921... Línea 1975...
1921
 
1975
            if ($footertextcolor && !empty($footertextcolor->value)) {
Línea 1922... Línea 1976...
1922
            $css .= '}';
1976
                $css .= '--footer-text-color: ' . $footertextcolor->value . '; ';
Línea 1979... Línea 2033...
1979
        }
2033
        }
Línea 1980... Línea 2034...
1980
 
2034
 
1981
        return $output;
2035
        return $output;
Línea 1982... Línea 2036...
1982
    }
2036
    }
1983
 
-
 
1984
    public function custom_course_dmlogo()
2037
 
Línea 1985... Línea 2038...
1985
    {
2038
    public function custom_course_dmlogo() {
Línea 1986... Línea 2039...
1986
        global $DB, $CFG, $COURSE, $PAGE;
2039
        global $DB, $CFG, $COURSE, $PAGE;
Línea 2026... Línea 2079...
2026
                    );
2079
                    );
Línea 2027... Línea 2080...
2027
 
2080
 
2028
                    $output .= $fileurl;
2081
                    $output .= $fileurl;
2029
                }
2082
                }
-
 
2083
            }
2030
            }
2084
            return $output;
2031
        }
-
 
2032
 
-
 
2033
        return $output;
2085
        }
Línea 2034... Línea 2086...
2034
    }
2086
    }
2035
 
-
 
2036
    public function custom_course_favicon()
2087
 
Línea 2037... Línea 2088...
2037
    {
2088
    public function custom_course_favicon() {
Línea 2038... Línea 2089...
2038
        global $DB, $CFG, $COURSE, $PAGE;
2089
        global $DB, $CFG, $COURSE, $PAGE;
Línea 2083... Línea 2134...
2083
        }
2134
        }
Línea 2084... Línea 2135...
2084
 
2135
 
2085
        return $output;
2136
        return $output;
Línea 2086... Línea 2137...
2086
    }
2137
    }
2087
 
-
 
2088
    public function custom_course_name()
2138
 
Línea 2089... Línea 2139...
2089
    {
2139
    public function custom_course_name() {
Línea 2090... Línea 2140...
2090
        global $DB, $CFG, $COURSE, $PAGE;
2140
        global $DB, $CFG, $COURSE, $PAGE;
Línea 2113... Línea 2163...
2113
     *
2163
     *
2114
     * The datauri is an encoded svg that can be passed as a url.
2164
     * The datauri is an encoded svg that can be passed as a url.
2115
     * @param int $id Id to use when generating the pattern
2165
     * @param int $id Id to use when generating the pattern
2116
     * @return string datauri
2166
     * @return string datauri
2117
     */
2167
     */
2118
    public function get_generated_image_for_id($id)
2168
    public function get_generated_image_for_id($id) {
2119
    {
-
 
2120
        global $CFG;
2169
        global $CFG;
Línea 2121... Línea 2170...
2121
 
2170
 
2122
        $theme = \theme_config::load('universe');
2171
        $theme = \theme_config::load('universe');
2123
        // Add custom course cover.
2172
        // Add custom course cover.
Línea 2135... Línea 2184...
2135
            $pattern->patternbyid($id);
2184
            $pattern->patternbyid($id);
2136
            return $pattern->datauri();
2185
            return $pattern->datauri();
2137
        }
2186
        }
2138
    }
2187
    }
Línea 2139... Línea 2188...
2139
 
2188
 
2140
    public function moremenu_group_item()
-
 
2141
    {
2189
    public function moremenu_group_item() {
Línea 2142... Línea -...
2142
        global $CFG, $COURSE;
-
 
2143
 
2190
        global $CFG, $COURSE;
2144
        $theme = \theme_config::load('universe');
2191
 
Línea 2145... Línea 2192...
2145
        $courseid = $COURSE->id;
2192
        $courseid = $COURSE->id;
2146
        $sitehomeurl = new moodle_url('/');
2193
        $sitehomeurl = new moodle_url('/');
Línea 2151... Línea 2198...
2151
                return $html;
2198
                return $html;
2152
            }
2199
            }
2153
        }
2200
        }
2154
    }
2201
    }
Línea 2155... Línea 2202...
2155
 
2202
 
2156
    public function moremenu_custom_items()
-
 
2157
    {
2203
    public function moremenu_custom_items() {
Línea 2158... Línea -...
2158
        global $CFG, $COURSE, $USER;
-
 
2159
 
2204
        global $CFG, $COURSE, $USER;
2160
        $theme = \theme_config::load('universe');
2205
 
Línea 2161... Línea 2206...
2161
        $html = '';
2206
        $html = '';
2162
        $secnavcount = theme_universe_get_setting('secnavitemscount');
2207
        $secnavcount = theme_universe_get_setting('secnavitemscount');
2163
 
2208
 
2164
        // Get current user role ID.
-
 
2165
        $context = context_course::instance($COURSE->id);
-
 
2166
        $roles = get_user_roles($context, $USER->id, true);
2209
        // Get user role ID.
2167
        $role = 999;
2210
        $context = context_course::instance($COURSE->id);
2168
        $roleid = 999;
2211
        $roles = get_user_roles($context, $USER->id, true);
-
 
2212
        $role = key($roles);
-
 
2213
        if ($role != null) {
2169
        $role = key($roles);
2214
            $roleid = $roles[$role]->id;
2170
        if ($role != null) {
-
 
2171
            $roleid = $roles[$role]->roleid;
2215
        } else {
Línea 2172... Línea 2216...
2172
        }
2216
            $roleid = 99;
Línea 2173... Línea 2217...
2173
 
2217
        }
Línea 2180... Línea 2224...
2180
                $secnav->title = theme_universe_get_setting("secnavcustomnavlabel" . $i);
2224
                $secnav->title = theme_universe_get_setting("secnavcustomnavlabel" . $i);
Línea 2181... Línea 2225...
2181
 
2225
 
2182
                $url = theme_universe_get_setting("secnavcustomnavurl" . $i);
2226
                $url = theme_universe_get_setting("secnavcustomnavurl" . $i);
2183
                $courseid = $COURSE->id;
2227
                $courseid = $COURSE->id;
-
 
2228
                $newurl = str_replace("{{courseID}}", $courseid, $url);
Línea 2184... Línea 2229...
2184
                $newurl = str_replace("{{courseID}}", $courseid, $url);
2229
                $secnav->url = $newurl;
2185
 
2230
 
Línea 2186... Línea 2231...
2186
                // User role restriction.
2231
                // User role restriction.
2187
                $selectrole = theme_universe_get_setting("secnavuserroles" . $i);
-
 
2188
 
2232
                $selectrole = theme_universe_get_setting("secnavuserrole" . $i);
2189
                if ($roleid == $selectrole) {
-
 
2190
                    $secnav->url = $newurl;
2233
 
2191
                    $html .= $this->render_from_template('theme_universe/custom_sec_nav_item', $secnav);
2234
                if ($selectrole == 1) {
2192
                }
2235
                    if ($roleid == 1 || $roleid == 2 || $roleid == 3 || $roleid == 4) {
2193
                if ($roleid != $selectrole) {
2236
                        $secnav->isadmin = true;
2194
                    $secnav->url = $newurl;
2237
                        $secnav->nonrestriction = false;
2195
                }
2238
                    }
2196
                if ($selectrole == 0) {
2239
                } else {
2197
                    $secnav->url = $newurl;
2240
                    $secnav->isadmin = false;
Línea -... Línea 2241...
-
 
2241
                    $secnav->nonrestriction = true;
2198
                    $html .= $this->render_from_template('theme_universe/custom_sec_nav_item', $secnav);
2242
                }
2199
                }
2243
                // End.
2200
                // End.
2244
 
2201
 
2245
                $html .= $this->render_from_template('theme_universe/custom_sec_nav_item', $secnav);
-
 
2246
            }
-
 
2247
        }
-
 
2248
        return $html;
-
 
2249
    }
-
 
2250
 
-
 
2251
    /**
-
 
2252
     *  Display only fields dedicated to enrollment page
-
 
2253
     */
-
 
2254
    public function get_enrollfields() {
-
 
2255
        global $COURSE;
-
 
2256
        $course = get_course($COURSE->id);
-
 
2257
 
-
 
2258
        $courseelement = new \core_course_list_element($course);
-
 
2259
 
-
 
2260
        if ($courseelement->has_custom_fields()) {
-
 
2261
            $fields = $courseelement->get_custom_fields();
-
 
2262
            $content = '';
-
 
2263
 
-
 
2264
            foreach ($fields as $field) {
-
 
2265
                if (empty($field->get_value())) {
-
 
2266
                    continue;
-
 
2267
                }
-
 
2268
 
-
 
2269
                // Get field shortname
-
 
2270
                $customfieldname = $field->get_field()->get('name');
-
 
2271
                $customfieldvalue = $field->get_value();
-
 
2272
                $customfieldshortname =  $field->get_field()->get('shortname');
-
 
2273
 
-
 
2274
                // Array with custom fields which need to be hidden.
-
 
2275
                $hiddencustomfields = array("enrolldesc", "enrollvideo");
-
 
2276
                $hiddencftitles = array("tool_courserating");
-
 
2277
 
-
 
2278
                if (in_array($customfieldshortname, $hiddencustomfields)) {
-
 
2279
                    $content .= html_writer::start_tag('div', array('class' => 'rui-custom-field-box'));
-
 
2280
                    $content .= html_writer::tag('div', $customfieldvalue, array('class' => 'rui-custom-field-value'));
-
 
2281
                    $content .= html_writer::end_tag('div');
-
 
2282
                }
-
 
2283
            }
-
 
2284
            return $content;
-
 
2285
        } else {
-
 
2286
            return false;
-
 
2287
        }
-
 
2288
    }
-
 
2289
 
-
 
2290
    public function show_course_filter() {
-
 
2291
        global $CFG;
-
 
2292
 
-
 
2293
        $showcoursefilter = $this->page->theme->settings->showcoursefilter;
-
 
2294
 
-
 
2295
        $siteurl = $CFG->wwwroot;
-
 
2296
        $currentUrl = $this->page->url->out(false);
-
 
2297
        $compareString = $siteurl . '/course/index.php';
-
 
2298
 
-
 
2299
        // Check if the current URL starts with the compare string
-
 
2300
        if (strpos($currentUrl, $compareString) === 0 && $showcoursefilter == 1) {
-
 
2301
            // Now, check if the length of the current URL is exactly the same as the compare string
-
 
2302
            if (strlen($currentUrl) == strlen($compareString)) {
-
 
2303
                // The current URL matches 'course/index.php'.
-
 
2304
                return false;
-
 
2305
            } else {
-
 
2306
                // The current URL matches 'course/index.php' but has additional content appended.
-
 
2307
                return true;
-
 
2308
            }
-
 
2309
        } else {
-
 
2310
            // The current URL does not match 'course/index.php'.
-
 
2311
            return true;
-
 
2312
        }
-
 
2313
    }
-
 
2314
 
-
 
2315
    /**
-
 
2316
     * 
-
 
2317
     * Returns list of languages.
-
 
2318
     * 
-
 
2319
     */
-
 
2320
    public function course_lang_list() {
-
 
2321
        $langs = get_string_manager()->get_list_of_translations();
-
 
2322
 
-
 
2323
        $output = '';
-
 
2324
 
-
 
2325
        foreach ((array)$langs as $langtype => $langname) {
-
 
2326
            $total = html_writer::empty_tag('span', array('class' => 'total'));
-
 
2327
            $output .= html_writer::div($langname . $total, 'filtering-filter', array('data-filter-name' => $langtype));
-
 
2328
        }
-
 
2329
 
-
 
2330
        return $output;
-
 
2331
    }
-
 
2332
 
-
 
2333
 
-
 
2334
 
-
 
2335
    /**
-
 
2336
     * 
-
 
2337
     * Returns list of teachers.
-
 
2338
     *
-
 
2339
     */
-
 
2340
    function course_teachers_list() {
-
 
2341
        global $DB, $CFG, $COURSE;
-
 
2342
 
-
 
2343
        $output = null;
-
 
2344
 
-
 
2345
        $uniqueTeachers = [];
-
 
2346
 
-
 
2347
        // Get the current page URL.
-
 
2348
        //$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
-
 
2349
        $currentURL = $_SERVER['REQUEST_URI'];
-
 
2350
        // Parse the URL and extract the query string.
-
 
2351
        $query_str = parse_url($currentURL, PHP_URL_QUERY);
-
 
2352
        // Parse the query string into an associative array.
-
 
2353
        parse_str($query_str, $query_params);
-
 
2354
        // Get the category ID.
-
 
2355
        $categoryid = $query_params['categoryid'] ?? 'Category ID not found';
-
 
2356
        // End - Get the current page URL.
-
 
2357
 
-
 
2358
        // Fetch the course details
-
 
2359
        $courses = $DB->get_records('course', ['category' => $categoryid]);
-
 
2360
 
-
 
2361
        // Iterate over each course
-
 
2362
        foreach ($courses as $course) {
-
 
2363
            // Get context of the current course
-
 
2364
            $context = context_course::instance($course->id);
-
 
2365
 
-
 
2366
            // Get all users with the teacher role in the current course
-
 
2367
            $teachers = get_role_users(3, $context) + get_role_users(4, $context); // Teacher role ID is 3 and 4, adjust if necessary
-
 
2368
 
-
 
2369
            if (isset($teachers) && is_array($teachers)) {
-
 
2370
                // Iterate through the list of teachers for the current course
-
 
2371
                foreach ($teachers as $teacher) {
-
 
2372
                    // Check if the teacher ID already exists in the uniqueTeachers array
-
 
2373
                    if (!isset($uniqueTeachers[$teacher->id])) {
-
 
2374
                        // If the teacher ID does not exist, add it to the uniqueTeachers array
-
 
2375
                        $uniqueTeachers[$teacher->id] = $teacher;
-
 
2376
                    }
-
 
2377
                }
-
 
2378
            } else {
-
 
2379
                $uniqueTeachers = null;
-
 
2380
            }
-
 
2381
        }
-
 
2382
 
-
 
2383
        if (!empty($uniqueTeachers)) {
-
 
2384
            // Output the list of unique teachers
-
 
2385
            foreach ($uniqueTeachers as $teacher) {
-
 
2386
                $total = html_writer::empty_tag('span', ['class' => 'total']);
-
 
2387
                $teachername = "{$teacher->firstname} {$teacher->lastname}";
-
 
2388
                $output .= html_writer::div("$teachername$total", 'filtering-filter', ['data-filter-name' => $teachername]);
-
 
2389
            }
-
 
2390
 
-
 
2391
            return $output;
-
 
2392
        }
-
 
2393
    }
-
 
2394
 
-
 
2395
    /**
-
 
2396
     * 
-
 
2397
     * Returns custom filter list based on parameters.
-
 
2398
     *
-
 
2399
     * @param string $filterNameSetting The name of the filter setting.
-
 
2400
     * @param string $filterShowSetting The show filter setting.
-
 
2401
     * @return string The HTML output for the filter list.
-
 
2402
     */
-
 
2403
    function get_course_customfilter_list($filterNameSetting, $filterShowSetting) {
-
 
2404
        global $DB, $COURSE;
-
 
2405
 
-
 
2406
        // Theme Settings.
-
 
2407
        $coursefilteron = $this->page->theme->settings->$filterShowSetting;
-
 
2408
        $customfiltername = $this->page->theme->settings->$filterNameSetting;
-
 
2409
 
-
 
2410
        if ($coursefilteron == 1 && $customfiltername != null) {
-
 
2411
            // Variables.
-
 
2412
            $fieldsarr = [];
-
 
2413
            $uniqueFields = [];
-
 
2414
            $filtertitle = '';
-
 
2415
            $record = $DB->get_record('customfield_field', ['shortname' => $customfiltername]);
-
 
2416
 
-
 
2417
            // Get the current page URL.
-
 
2418
            //$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
-
 
2419
            $currentURL = $_SERVER['REQUEST_URI'];
-
 
2420
            // Parse the URL and extract the query string.
-
 
2421
            $query_str = parse_url($currentURL, PHP_URL_QUERY);
-
 
2422
            // Parse the query string into an associative array.
-
 
2423
            parse_str($query_str, $query_params);
-
 
2424
            // Get the category ID.
-
 
2425
            $categoryid = $query_params['categoryid'] ?? 'Category ID not found';
-
 
2426
            // End - Get the current page URL.
-
 
2427
 
-
 
2428
            // Fetch the course details.
-
 
2429
            $courses = $DB->get_records('course', ['category' => $categoryid]);
-
 
2430
 
-
 
2431
            // Iterate over each course.
-
 
2432
            foreach ($courses as $course) {
-
 
2433
                // Get custom fields.
-
 
2434
                $courseelement = new core_course_list_element($course);
-
 
2435
                $fields = $courseelement->get_custom_fields();
-
 
2436
 
-
 
2437
                foreach ($fields as $field) {
-
 
2438
                    if (empty($field->get_value())) {
-
 
2439
                        continue;
-
 
2440
                    }
-
 
2441
 
-
 
2442
                    $customfieldshortname = $field->get_field()->get('shortname');
-
 
2443
                    $customfieldtype = $field->get_field()->get('type');
-
 
2444
 
-
 
2445
                    if ($customfieldshortname == $customfiltername) {
-
 
2446
                        if (str_contains($field->get_value(), ',')) {
-
 
2447
                            $itemsArray = explode(",", $field->get_value());
-
 
2448
                            foreach ($itemsArray as $item) {
-
 
2449
                                $uniqueFields[$item] = $item;
-
 
2450
                            }
-
 
2451
                        }
-
 
2452
                        if($customfieldtype === 'select') {
-
 
2453
 
-
 
2454
                            //$fieldid = $DB->get_record('customfield_field', ['id' => $record->fieldid]);
-
 
2455
                            $jsonString = $record->configdata;
-
 
2456
                                    
-
 
2457
                            // Decode JSON string into a PHP associative array
-
 
2458
                            $array = json_decode($jsonString, true);
-
 
2459
                            // Check if decoding was successful
-
 
2460
                            if (json_last_error() === JSON_ERROR_NONE) {
-
 
2461
                                // Access the 'options' key
-
 
2462
                                $options = $array['options'];
-
 
2463
                            } else {
-
 
2464
                                // Handle JSON decoding error
-
 
2465
                                echo "Error decoding JSON: " . json_last_error_msg();
-
 
2466
                            }
-
 
2467
                            $optionsArray = explode("\r\n", $options);
-
 
2468
                            $temp = $field->get_value() - 1;
-
 
2469
                            if($temp >= 0) {
-
 
2470
                                $uniqueFields[$field->get_value()] = $optionsArray[$temp];
-
 
2471
                            }
-
 
2472
                        } else {
-
 
2473
                            $uniqueFields[$field->get_value()] = $field->get_value();
-
 
2474
                        }
-
 
2475
 
-
 
2476
                    }
-
 
2477
                }
-
 
2478
            }
-
 
2479
 
-
 
2480
            // Filter - List.
-
 
2481
            if ($record != null) {
-
 
2482
                // Output the list of unique fields.
-
 
2483
                foreach ($uniqueFields as $field) {
-
 
2484
                    $fieldsarr[] = format_string($field);
-
 
2485
                }
-
 
2486
 
-
 
2487
                // Filter - Title.
-
 
2488
                $filtertitle = $record->name;
-
 
2489
            }
-
 
2490
 
-
 
2491
            $filtergroupno = $customfiltername;
-
 
2492
 
-
 
2493
            // Filter - Template.
-
 
2494
            $coursefilter = new stdClass();
-
 
2495
            $coursefilter->shortname = $customfiltername;
-
 
2496
            $coursefilter->filtergroupno = format_string($filtergroupno);
-
 
2497
            $coursefilter->title = format_string($filtertitle);
-
 
2498
            $coursefilter->item = $fieldsarr;
-
 
2499
 
-
 
2500
            return $this->render_from_template('theme_universe/course_filter_item', $coursefilter);
-
 
2501
        }
-
 
2502
    }
-
 
2503
 
-
 
2504
    /**
-
 
2505
     * 
-
 
2506
     * Returns list #1.
-
 
2507
     *
-
 
2508
     */
-
 
2509
    public function course_customfilter1_list() {
-
 
2510
        return $this->get_course_customfilter_list('customfilter1', 'showfilter1', 'customfilter1');
-
 
2511
    }
-
 
2512
 
-
 
2513
    /**
-
 
2514
     * 
-
 
2515
     * Returns list #2.
-
 
2516
     *
-
 
2517
     */
-
 
2518
    public function course_customfilter2_list() {
-
 
2519
        return $this->get_course_customfilter_list('customfilter2', 'showfilter2', 'customfilter2');
-
 
2520
    }
-
 
2521
 
-
 
2522
    /**
-
 
2523
     * 
-
 
2524
     * Returns list #3.
-
 
2525
     *
-
 
2526
     */
-
 
2527
    public function course_customfilter3_list() {
-
 
2528
        return $this->get_course_customfilter_list('customfilter3', 'showfilter3', 'customfilter3');
-
 
2529
    }
-
 
2530
 
-
 
2531
    /**
-
 
2532
     * 
-
 
2533
     * Returns list #4.
-
 
2534
     *
-
 
2535
     */
-
 
2536
    public function course_customfilter4_list() {
-
 
2537
        return $this->get_course_customfilter_list('customfilter4', 'showfilter4', 'customfilter4');
-
 
2538
    }
-
 
2539
 
-
 
2540
    /**
-
 
2541
     * 
-
 
2542
     * Returns list #5.
-
 
2543
     *
-
 
2544
     */
-
 
2545
    public function course_customfilter5_list() {
-
 
2546
        return $this->get_course_customfilter_list('customfilter5', 'showfilter5', 'customfilter5');
-
 
2547
    }
-
 
2548
 
-
 
2549
    /**
-
 
2550
     * 
-
 
2551
     * Returns list #6.
-
 
2552
     *
2202
            }
2553
     */