Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 161
Línea 44... Línea 44...
44
 *
44
 *
45
 * @package    theme_universe
45
 * @package    theme_universe
46
 * @copyright  2023 Marcin Czaja (https://rosea.io)
46
 * @copyright  2023 Marcin Czaja (https://rosea.io)
47
 * @license    Commercial https://themeforest.net/licenses
47
 * @license    Commercial https://themeforest.net/licenses
48
 */
48
 */
49
class core_renderer extends \core_renderer {
49
class core_renderer extends \core_renderer
-
 
50
{
Línea 50... Línea 51...
50
 
51
 
-
 
52
    public function edit_button(moodle_url $url, string $method = 'post')
51
    public function edit_button(moodle_url $url, string $method = 'post') {
53
    {
52
        if ($this->page->theme->haseditswitch) {
54
        if ($this->page->theme->haseditswitch) {
53
            return;
55
            return;
54
        }
56
        }
55
        $url->param('sesskey', sesskey());
57
        $url->param('sesskey', sesskey());
Línea 69... Línea 71...
69
     * that should be included in the <head> tag. Designed to be called in theme
71
     * that should be included in the <head> tag. Designed to be called in theme
70
     * layout.php files.
72
     * layout.php files.
71
     *
73
     *
72
     * @return string HTML fragment.
74
     * @return string HTML fragment.
73
     */
75
     */
74
    public function standard_head_html() {
76
    public function standard_head_html()
-
 
77
    {
75
        $output = parent::standard_head_html();
78
        $output = parent::standard_head_html();
76
        global $USER;
79
        global $USER;
Línea 77... Línea 80...
77
 
80
 
78
        $googleanalyticscode = "<script
81
        $googleanalyticscode = "<script
Línea 110... Línea 113...
110
    {
113
    {
111
        global $CFG;
114
        global $CFG;
Línea 112... Línea 115...
112
 
115
 
Línea 113... Línea 116...
113
        $teme_dir = '/theme';
116
        $teme_dir = '/theme';
114
 
-
 
115
        if ( isset( $CFG->themedir ) )
117
 
116
        {
118
        if (isset($CFG->themedir)) {
117
            $teme_dir = $CFG->themedir;
119
            $teme_dir = $CFG->themedir;
Línea 118... Línea 120...
118
            $teme_dir = str_replace($CFG->dirroot, '', $CFG->themedir);
120
            $teme_dir = str_replace($CFG->dirroot, '', $CFG->themedir);
Línea 125... Línea 127...
125
    /**
127
    /**
126
     *
128
     *
127
     * Method to load theme element form 'layout/parts' folder
129
     * Method to load theme element form 'layout/parts' folder
128
     *
130
     *
129
     */
131
     */
130
    public function theme_part($name, $vars = array()) {
132
    public function theme_part($name, $vars = array())
-
 
133
    {
Línea 131... Línea 134...
131
 
134
 
Línea 132... Línea 135...
132
        global $CFG;
135
        global $CFG;
133
 
136
 
Línea 156... Línea 159...
156
     * Renders the custom menu
159
     * Renders the custom menu
157
     *
160
     *
158
     * @param custom_menu $menu
161
     * @param custom_menu $menu
159
     * @return mixed
162
     * @return mixed
160
     */
163
     */
161
    protected function render_custom_menu(custom_menu $menu) {
164
    protected function render_custom_menu(custom_menu $menu)
-
 
165
    {
162
        if (!$menu->has_children()) {
166
        if (!$menu->has_children()) {
163
            return '';
167
            return '';
164
        }
168
        }
Línea 165... Línea 169...
165
 
169
 
Línea 175... Línea 179...
175
    /**
179
    /**
176
     * Outputs the favicon urlbase.
180
     * Outputs the favicon urlbase.
177
     *
181
     *
178
     * @return string an url
182
     * @return string an url
179
     */
183
     */
180
    public function favicon() {
184
    public function favicon()
-
 
185
    {
181
        global $CFG;
186
        global $CFG;
182
        $theme = theme_config::load('universe');
187
        $theme = theme_config::load('universe');
183
        $favicon = $theme->setting_file_url('favicon', 'favicon');
188
        $favicon = $theme->setting_file_url('favicon', 'favicon');
Línea 184... Línea 189...
184
 
189
 
Línea 190... Línea 195...
190
        }
195
        }
Línea 191... Línea 196...
191
 
196
 
192
        return parent::favicon();
197
        return parent::favicon();
Línea 193... Línea 198...
193
    }
198
    }
-
 
199
 
194
 
200
    public function render_lang_menu()
195
    public function render_lang_menu() {
201
    {
196
        $langs = get_string_manager()->get_list_of_translations();
202
        $langs = get_string_manager()->get_list_of_translations();
Línea 197... Línea 203...
197
        $haslangmenu = $this->lang_menu() != '';
203
        $haslangmenu = $this->lang_menu() != '';
Línea 219... Línea 225...
219
                return $this->render_from_template('theme_universe/lang_menu', $context);
225
                return $this->render_from_template('theme_universe/lang_menu', $context);
220
            }
226
            }
221
        }
227
        }
222
    }
228
    }
Línea 223... Línea 229...
223
 
229
 
-
 
230
    public function render_lang_menu_login()
224
    public function render_lang_menu_login() {
231
    {
225
        $langs = get_string_manager()->get_list_of_translations();
232
        $langs = get_string_manager()->get_list_of_translations();
226
        $haslangmenu = $this->lang_menu() != '';
233
        $haslangmenu = $this->lang_menu() != '';
Línea 227... Línea 234...
227
        $menu = new custom_menu;
234
        $menu = new custom_menu;
Línea 248... Línea 255...
248
                return $this->render_from_template('theme_universe/lang_menu_login', $context);
255
                return $this->render_from_template('theme_universe/lang_menu_login', $context);
249
            }
256
            }
250
        }
257
        }
251
    }
258
    }
Línea 252... Línea 259...
252
 
259
 
-
 
260
    public static function get_course_progress_count($course, $userid = 0)
253
    public static function get_course_progress_count($course, $userid = 0) {
261
    {
Línea 254... Línea 262...
254
        global $USER;
262
        global $USER;
255
 
263
 
256
        // Make sure we continue with a valid userid.
264
        // Make sure we continue with a valid userid.
Línea 295... Línea 303...
295
     *
303
     *
296
     * Outputs the course progress if course completion is on.
304
     * Outputs the course progress if course completion is on.
297
     *
305
     *
298
     * @return string Markup.
306
     * @return string Markup.
299
     */
307
     */
300
    protected function courseprogress($course) {
308
    protected function courseprogress($course)
-
 
309
    {
301
        global $USER;
310
        global $USER;
302
        $theme = \theme_config::load('universe');
311
        $theme = \theme_config::load('universe');
Línea 303... Línea 312...
303
 
312
 
304
        $output = '';
313
        $output = '';
Línea 365... Línea 374...
365
    /**
374
    /**
366
     *
375
     *
367
     * Returns HTML to display course contacts.
376
     * Returns HTML to display course contacts.
368
     *
377
     *
369
     */
378
     */
370
    public function course_teachers() {
379
    public function course_teachers()
-
 
380
    {
371
        global $CFG, $COURSE, $DB;
381
        global $CFG, $COURSE, $DB;
372
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
382
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
373
        $course = new core_course_list_element($course);
383
        $course = new core_course_list_element($course);
374
        $instructors = $course->get_course_contacts();
384
        $instructors = $course->get_course_contacts();
Línea 403... Línea 413...
403
            $content .= html_writer::end_div(); // End .teachers-box.
413
            $content .= html_writer::end_div(); // End .teachers-box.
404
            return $content;
414
            return $content;
405
        }
415
        }
406
    }
416
    }
Línea 407... Línea 417...
407
 
417
 
-
 
418
    public function course_contacts()
408
    public function course_contacts() {
419
    {
409
        global $CFG, $COURSE, $DB;
420
        global $CFG, $COURSE, $DB;
410
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
421
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
411
        $course = new core_course_list_element($course);
422
        $course = new core_course_list_element($course);
Línea 447... Línea 458...
447
    /**
458
    /**
448
     *
459
     *
449
     * Returns HTML to display course details.
460
     * Returns HTML to display course details.
450
     *
461
     *
451
     */
462
     */
452
    protected function course_details() {
463
    protected function course_details()
-
 
464
    {
453
        global $CFG, $COURSE, $DB;
465
        global $CFG, $COURSE, $DB;
454
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
466
        $course = $DB->get_record('course', ['id' => $COURSE->id]);
455
        $course = new core_course_list_element($course);
467
        $course = new core_course_list_element($course);
456
        $content = '';
468
        $content = '';
457
        $tempcourse = $DB->get_record('course_categories', ['id' => $COURSE->id]);
469
        $tempcourse = $DB->get_record('course_categories', ['id' => $COURSE->id]);
Línea 458... Línea 470...
458
 
470
 
-
 
471
        $content .= html_writer::start_div('rui-course-details mt-4');
-
 
472
        $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
-
 
473
        $content .= html_writer::tag('span', get_string('startdate', 'moodle'), ['class' => 'rui-custom-field-name']);
-
 
474
        $content .= html_writer::tag('span', date("F j, Y", $COURSE->startdate), ['class' => 'rui-custom-field-value']);
-
 
475
        $content .= html_writer::end_div();
-
 
476
 
-
 
477
        // Course End date.
-
 
478
        $courseenddate = $COURSE->enddate;
459
        $content .= html_writer::start_div('rui-course-details mt-4');
479
        if ($courseenddate != '0') {
460
            $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
480
            $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
461
                $content .= html_writer::tag('span', get_string('startdate', 'moodle'), ['class' => 'rui-custom-field-name']);
481
            $content .= html_writer::tag('span', get_string('enddate', 'moodle'), ['class' => 'rui-course-enddate-label rui-custom-field-name']);
462
                $content .= html_writer::tag('span', date("F j, Y", $COURSE->startdate), ['class' => 'rui-custom-field-value']);
482
            $content .= html_writer::tag('span', date("F j, Y", $courseenddate), ['class' => 'rui-course-enddate rui-custom-field-value']);
463
            $content .= html_writer::end_div();
-
 
464
 
-
 
465
            // Course End date.
-
 
466
            $courseenddate = $COURSE->enddate;
-
 
467
            if ($courseenddate != '0') {
-
 
468
                $content .= html_writer::start_div('rui-custom-field-box rui-course-startdate');
-
 
469
                    $content .= html_writer::tag('span', get_string('enddate', 'moodle'), ['class' => 'rui-course-enddate-label rui-custom-field-name']);
-
 
470
                    $content .= html_writer::tag('span', date("F j, Y", $courseenddate), ['class' => 'rui-course-enddate rui-custom-field-value']);
-
 
471
                $content .= html_writer::end_div();
483
            $content .= html_writer::end_div();
472
            }
484
        }
Línea 473... Línea 485...
473
        $content .= html_writer::end_div(); // .rui-course-details.
485
        $content .= html_writer::end_div(); // .rui-course-details.
474
 
486
 
Línea 475... Línea 487...
475
        return $content;
487
        return $content;
476
    }
488
    }
477
 
489
 
478
    /**
490
    /**
479
     *
491
     *
480
     * Returns HTML to display course summary.
492
     * Returns HTML to display course summary.
-
 
493
     *
481
     *
494
     */
482
     */
495
    protected function course_summary($courseid = 0, $content = '')
Línea 483... Línea 496...
483
    protected function course_summary($courseid = 0, $content = '') {
496
    {
Línea 501... Línea 514...
501
    /**
514
    /**
502
     * Outputs the pix url base
515
     * Outputs the pix url base
503
     *
516
     *
504
     * @return string an URL.
517
     * @return string an URL.
505
     */
518
     */
506
    public function get_pix_image_url_base() {
519
    public function get_pix_image_url_base()
-
 
520
    {
507
        global $CFG;
521
        global $CFG;
Línea 508... Línea 522...
508
 
522
 
509
        return $CFG->wwwroot . "/theme/universe/pix";
523
        return $CFG->wwwroot . "/theme/universe/pix";
Línea 510... Línea 524...
510
    }
524
    }
511
 
525
 
512
    /**
526
    /**
513
     *
527
     *
-
 
528
     */
514
     */
529
    public function course_hero_url()
Línea 515... Línea 530...
515
    public function course_hero_url() {
530
    {
Línea 516... Línea 531...
516
        global $CFG, $COURSE, $DB;
531
        global $CFG, $COURSE, $DB;
Línea 551... Línea 566...
551
 
566
 
552
    /**
567
    /**
553
     * Returns HTML to display course hero.
568
     * Returns HTML to display course hero.
554
     *
569
     *
555
     */
570
     */
-
 
571
    public function course_hero()
556
    public function course_hero() {
572
    {
Línea 557... Línea 573...
557
        global $CFG, $COURSE, $DB;
573
        global $CFG, $COURSE, $DB;
Línea 558... Línea 574...
558
 
574
 
Línea 576... Línea 592...
576
 
592
 
577
    /**
593
    /**
578
     * Breadcrumbs
594
     * Breadcrumbs
579
     *
595
     *
580
     */
596
     */
-
 
597
    public function breadcrumbs()
581
    public function breadcrumbs() {
598
    {
Línea 582... Línea 599...
582
        global $USER, $COURSE, $CFG;
599
        global $USER, $COURSE, $CFG;
583
 
600
 
584
        $header = new stdClass();
601
        $header = new stdClass();
Línea 594... Línea 611...
594
    /**
611
    /**
595
     * Wrapper for header elements.
612
     * Wrapper for header elements.
596
     *
613
     *
597
     * @return string HTML to display the main header.
614
     * @return string HTML to display the main header.
598
     */
615
     */
599
    public function simple_header() {
616
    public function simple_header()
-
 
617
    {
Línea 600... Línea 618...
600
 
618
 
601
        global $USER, $COURSE, $CFG;
619
        global $USER, $COURSE, $CFG;
Línea 602... Línea 620...
602
        $html = null;
620
        $html = null;
Línea 636... Línea 654...
636
    }
654
    }
Línea 637... Línea 655...
637
 
655
 
-
 
656
 
638
 
657
 
639
 
658
 
640
 
659
    public function display_course_progress()
641
    public function display_course_progress() {
660
    {
Línea 642... Línea 661...
642
        $html = null;
661
        $html = null;
643
        $html .= $this->courseprogress($this->page->course);
662
        $html .= $this->courseprogress($this->page->course);
644
        return $html;
663
        return $html;
645
    }
664
    }
646
 
665
 
647
    /**
666
    /**
-
 
667
     * Wrapper for header elements.
648
     * Wrapper for header elements.
668
     *
649
     *
669
     * @return string HTML to display the main header.
650
     * @return string HTML to display the main header.
670
     */
651
     */
671
    public function full_header()
652
    public function full_header() {
672
    {
Línea 708... Línea 728...
708
    /**
728
    /**
709
     * Wrapper for header elements.
729
     * Wrapper for header elements.
710
     *
730
     *
711
     * @return string HTML to display the main header.
731
     * @return string HTML to display the main header.
712
     */
732
     */
713
    public function clean_header() {
733
    public function clean_header()
-
 
734
    {
714
        global $USER, $COURSE, $CFG;
735
        global $USER, $COURSE, $CFG;
715
        $theme = \theme_config::load('universe');
736
        $theme = \theme_config::load('universe');
716
        $html = null;
737
        $html = null;
717
        $pagetype = $this->page->pagetype;
738
        $pagetype = $this->page->pagetype;
718
        $homepage = get_home_page();
739
        $homepage = get_home_page();
Línea 750... Línea 771...
750
    /**
771
    /**
751
     * Returns standard navigation between activities in a course.
772
     * Returns standard navigation between activities in a course.
752
     *
773
     *
753
     * @return string the navigation HTML.
774
     * @return string the navigation HTML.
754
     */
775
     */
755
    public function activity_navigation() {
776
    public function activity_navigation()
-
 
777
    {
756
        // First we should check if we want to add navigation.
778
        // First we should check if we want to add navigation.
757
        $context = $this->page->context;
779
        $context = $this->page->context;
758
        if (($this->page->pagelayout !== 'incourse' && $this->page->pagelayout !== 'frametop')
780
        if (($this->page->pagelayout !== 'incourse' && $this->page->pagelayout !== 'frametop')
759
            || $context->contextlevel != CONTEXT_MODULE
781
            || $context->contextlevel != CONTEXT_MODULE
760
        ) {
782
        ) {
Línea 822... Línea 844...
822
     * This is an optional menu that can be added to a layout by a theme. It contains the
844
     * This is an optional menu that can be added to a layout by a theme. It contains the
823
     * menu for the course administration, only on the course main page.
845
     * menu for the course administration, only on the course main page.
824
     *
846
     *
825
     * @return string
847
     * @return string
826
     */
848
     */
827
    public function context_header_settings_menu() {
849
    public function context_header_settings_menu()
-
 
850
    {
828
        $context = $this->page->context;
851
        $context = $this->page->context;
829
        $menu = new action_menu();
852
        $menu = new action_menu();
Línea 830... Línea 853...
830
 
853
 
831
        $items = $this->page->navbar->get_items();
854
        $items = $this->page->navbar->get_items();
Línea 922... Línea 945...
922
        }
945
        }
Línea 923... Línea 946...
923
 
946
 
924
        return $this->render($menu);
947
        return $this->render($menu);
Línea 925... Línea 948...
925
    }
948
    }
-
 
949
 
926
 
950
    public function customeditblockbtn()
927
    public function customeditblockbtn() {
951
    {
928
        $header = new stdClass();
952
        $header = new stdClass();
Línea 929... Línea 953...
929
        $header->settingsmenu = $this->context_header_settings_menu();
953
        $header->settingsmenu = $this->context_header_settings_menu();
Línea 939... Línea 963...
939
     *
963
     *
940
     * @param array $headerinfo Heading information.
964
     * @param array $headerinfo Heading information.
941
     * @param int $headinglevel What 'h' level to make the heading.
965
     * @param int $headinglevel What 'h' level to make the heading.
942
     * @return string A rendered context header.
966
     * @return string A rendered context header.
943
     */
967
     */
944
    public function context_header($headerinfo = null, $headinglevel = 1): string {
968
    public function context_header($headerinfo = null, $headinglevel = 1): string
-
 
969
    {
945
        global $DB, $USER, $CFG, $SITE;
970
        global $DB, $USER, $CFG, $SITE;
946
        require_once($CFG->dirroot . '/user/lib.php');
971
        require_once($CFG->dirroot . '/user/lib.php');
947
        $context = $this->page->context;
972
        $context = $this->page->context;
948
        $heading = null;
973
        $heading = null;
949
        $imagedata = null;
974
        $imagedata = null;
Línea 1054... Línea 1079...
1054
     *
1079
     *
1055
     * @param stdClass $user A user object, usually $USER.
1080
     * @param stdClass $user A user object, usually $USER.
1056
     * @param bool $withlinks true if a dropdown should be built.
1081
     * @param bool $withlinks true if a dropdown should be built.
1057
     * @return string HTML fragment.
1082
     * @return string HTML fragment.
1058
     */
1083
     */
1059
    public function user_menu($user = null, $withlinks = null) {
1084
    public function user_menu($user = null, $withlinks = null)
-
 
1085
    {
1060
        global $USER, $CFG;
1086
        global $USER, $CFG;
1061
        require_once($CFG->dirroot . '/user/lib.php');
1087
        require_once($CFG->dirroot . '/user/lib.php');
Línea 1062... Línea 1088...
1062
 
1088
 
1063
        if (is_null($user)) {
1089
        if (is_null($user)) {
Línea 1356... Línea 1382...
1356
     * Returns standard main content placeholder.
1382
     * Returns standard main content placeholder.
1357
     * Designed to be called in theme layout.php files.
1383
     * Designed to be called in theme layout.php files.
1358
     *
1384
     *
1359
     * @return string HTML fragment.
1385
     * @return string HTML fragment.
1360
     */
1386
     */
1361
    public function main_content() {
1387
    public function main_content()
-
 
1388
    {
1362
        // This is here because it is the only place we can inject the "main" role over the entire main content area
1389
        // This is here because it is the only place we can inject the "main" role over the entire main content area
1363
        // without requiring all theme's to manually do it, and without creating yet another thing people need to
1390
        // without requiring all theme's to manually do it, and without creating yet another thing people need to
1364
        // remember in the theme.
1391
        // remember in the theme.
1365
        // This is an unfortunate hack. DO NO EVER add anything more here.
1392
        // This is an unfortunate hack. DO NO EVER add anything more here.
1366
        // DO NOT add classes.
1393
        // DO NOT add classes.
Línea 1375... Línea 1402...
1375
     * @param int $level The level of importance of the heading. Defaulting to 2
1402
     * @param int $level The level of importance of the heading. Defaulting to 2
1376
     * @param string $classes A space-separated list of CSS classes. Defaulting to null
1403
     * @param string $classes A space-separated list of CSS classes. Defaulting to null
1377
     * @param string $id An optional ID
1404
     * @param string $id An optional ID
1378
     * @return string the HTML to output.
1405
     * @return string the HTML to output.
1379
     */
1406
     */
1380
    public function heading($text, $level = 2, $classes = null, $id = null) {
1407
    public function heading($text, $level = 2, $classes = null, $id = null)
-
 
1408
    {
1381
        $level = (int) $level;
1409
        $level = (int) $level;
1382
        if ($level < 1 || $level > 6) {
1410
        if ($level < 1 || $level > 6) {
1383
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
1411
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
1384
        }
1412
        }
1385
        return html_writer::tag('div', html_writer::tag('h' .
1413
        return html_writer::tag('div', html_writer::tag('h' .
Línea 1387... Línea 1415...
1387
            ' rui-main-content-title rui-main-content-title--h' .
1415
            ' rui-main-content-title rui-main-content-title--h' .
1388
            $level)), array('class' => 'rui-title-container'));
1416
            $level)), array('class' => 'rui-title-container'));
1389
    }
1417
    }
Línea 1390... Línea 1418...
1390
 
1418
 
-
 
1419
 
1391
 
1420
    public function headingwithavatar($text, $level = 2, $classes = null, $id = null)
1392
    public function headingwithavatar($text, $level = 2, $classes = null, $id = null) {
1421
    {
1393
        $level = (int) $level;
1422
        $level = (int) $level;
1394
        if ($level < 1 || $level > 6) {
1423
        if ($level < 1 || $level > 6) {
1395
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
1424
            throw new coding_exception('Heading level must be an integer between 1 and 6.');
Línea 1403... Línea 1432...
1403
     * Renders the login form.
1432
     * Renders the login form.
1404
     *
1433
     *
1405
     * @param \core_auth\output\login $form The renderable.
1434
     * @param \core_auth\output\login $form The renderable.
1406
     * @return string
1435
     * @return string
1407
     */
1436
     */
1408
    public function render_login(\core_auth\output\login $form) {
1437
    public function render_login(\core_auth\output\login $form)
-
 
1438
    {
1409
        global $CFG, $SITE;
1439
        global $CFG, $SITE;
Línea 1410... Línea 1440...
1410
 
1440
 
Línea 1411... Línea 1441...
1411
        $context = $form->export_for_template($this);
1441
        $context = $form->export_for_template($this);
Línea 1568... Línea 1598...
1568
     * Render the login signup form into a nice template for the theme.
1598
     * Render the login signup form into a nice template for the theme.
1569
     *
1599
     *
1570
     * @param mform $form
1600
     * @param mform $form
1571
     * @return string
1601
     * @return string
1572
     */
1602
     */
1573
    public function render_login_signup_form($form) {
1603
    public function render_login_signup_form($form)
-
 
1604
    {
1574
        global $SITE;
1605
        global $SITE;
Línea 1575... Línea 1606...
1575
 
1606
 
1576
        $context = $form->export_for_template($this);
1607
        $context = $form->export_for_template($this);
1577
        $url = $this->get_logo_url();
1608
        $url = $this->get_logo_url();
Línea 1651... Línea 1682...
1651
     * Renders the header bar.
1682
     * Renders the header bar.
1652
     *
1683
     *
1653
     * @param context_header $contextheader Header bar object.
1684
     * @param context_header $contextheader Header bar object.
1654
     * @return string HTML for the header bar.
1685
     * @return string HTML for the header bar.
1655
     */
1686
     */
1656
    protected function render_context_header(\context_header $contextheader) {
1687
    protected function render_context_header(\context_header $contextheader)
-
 
1688
    {
1657
        $heading = null;
1689
        $heading = null;
1658
        $imagedata = null;
1690
        $imagedata = null;
1659
        $html = null;
1691
        $html = null;
Línea 1660... Línea 1692...
1660
 
1692
 
Línea 1723... Línea 1755...
1723
        $html .= html_writer::end_div();
1755
        $html .= html_writer::end_div();
Línea 1724... Línea 1756...
1724
 
1756
 
1725
        return $html;
1757
        return $html;
Línea 1726... Línea 1758...
1726
    }
1758
    }
-
 
1759
 
1727
 
1760
    public function header()
1728
    public function header() {
1761
    {
Línea 1729... Línea 1762...
1729
        global $USER, $COURSE;
1762
        global $USER, $COURSE;
1730
        $theme = theme_config::load('universe');
1763
        $theme = theme_config::load('universe');
Línea 1756... Línea 1789...
1756
     * (We track up to 100 cms so as not to overflow the session.)
1789
     * (We track up to 100 cms so as not to overflow the session.)
1757
     * This is done for drawer regions containing fake blocks so we can show blocks automatically.
1790
     * This is done for drawer regions containing fake blocks so we can show blocks automatically.
1758
     *
1791
     *
1759
     * @return boolean true if the page has fakeblocks and this is the first visit.
1792
     * @return boolean true if the page has fakeblocks and this is the first visit.
1760
     */
1793
     */
1761
    public function firstview_fakeblocks(): bool {
1794
    public function firstview_fakeblocks(): bool
-
 
1795
    {
1762
        global $SESSION;
1796
        global $SESSION;
Línea 1763... Línea 1797...
1763
 
1797
 
1764
        $firstview = false;
1798
        $firstview = false;
1765
        if ($this->page->cm) {
1799
        if ($this->page->cm) {
Línea 1787... Línea 1821...
1787
     * Build the guest access hint HTML code.
1821
     * Build the guest access hint HTML code.
1788
     *
1822
     *
1789
     * @param int $courseid The course ID.
1823
     * @param int $courseid The course ID.
1790
     * @return string.
1824
     * @return string.
1791
     */
1825
     */
1792
    public function theme_universe_get_course_guest_access_hint($courseid) {
1826
    public function theme_universe_get_course_guest_access_hint($courseid)
-
 
1827
    {
1793
        global $CFG;
1828
        global $CFG;
1794
        require_once($CFG->dirroot . '/enrol/self/lib.php');
1829
        require_once($CFG->dirroot . '/enrol/self/lib.php');
Línea 1795... Línea 1830...
1795
 
1830
 
1796
        $html = '';
1831
        $html = '';
Línea 1817... Línea 1852...
1817
 
1852
 
1818
    /**
1853
    /**
1819
     * Color Customization
1854
     * Color Customization
1820
     * @return string HTML fragment.
1855
     * @return string HTML fragment.
1821
     */
1856
     */
-
 
1857
    public function additional_head_html()
1822
    public function additional_head_html() {
1858
    {
Línea 1823... Línea 1859...
1823
        global $SITE, $DB, $CFG, $COURSE, $PAGE;
1859
        global $SITE, $DB, $CFG, $COURSE, $PAGE;
Línea 1824... Línea 1860...
1824
 
1860
 
Línea 1913... Línea 1949...
1913
        }
1949
        }
Línea 1914... Línea 1950...
1914
 
1950
 
1915
        return $output;
1951
        return $output;
Línea 1916... Línea 1952...
1916
    }
1952
    }
-
 
1953
 
1917
 
1954
    public function custom_course_logo()
Línea 1918... Línea 1955...
1918
    public function custom_course_logo() {
1955
    {
Línea 1919... Línea 1956...
1919
        global $DB, $CFG, $COURSE, $PAGE;
1956
        global $DB, $CFG, $COURSE, $PAGE;
Línea 1964... Línea 2001...
1964
        }
2001
        }
Línea 1965... Línea 2002...
1965
 
2002
 
1966
        return $output;
2003
        return $output;
Línea 1967... Línea 2004...
1967
    }
2004
    }
-
 
2005
 
1968
 
2006
    public function custom_course_dmlogo()
Línea 1969... Línea 2007...
1969
    public function custom_course_dmlogo() {
2007
    {
Línea 1970... Línea 2008...
1970
        global $DB, $CFG, $COURSE, $PAGE;
2008
        global $DB, $CFG, $COURSE, $PAGE;
Línea 2015... Línea 2053...
2015
        }
2053
        }
Línea 2016... Línea 2054...
2016
 
2054
 
2017
        return $output;
2055
        return $output;
Línea 2018... Línea 2056...
2018
    }
2056
    }
-
 
2057
 
2019
 
2058
    public function custom_course_favicon()
Línea 2020... Línea 2059...
2020
    public function custom_course_favicon() {
2059
    {
Línea 2021... Línea 2060...
2021
        global $DB, $CFG, $COURSE, $PAGE;
2060
        global $DB, $CFG, $COURSE, $PAGE;
Línea 2066... Línea 2105...
2066
        }
2105
        }
Línea 2067... Línea 2106...
2067
 
2106
 
2068
        return $output;
2107
        return $output;
Línea 2069... Línea 2108...
2069
    }
2108
    }
-
 
2109
 
2070
 
2110
    public function custom_course_name()
Línea 2071... Línea 2111...
2071
    public function custom_course_name() {
2111
    {
Línea 2072... Línea 2112...
2072
        global $DB, $CFG, $COURSE, $PAGE;
2112
        global $DB, $CFG, $COURSE, $PAGE;
Línea 2088... Línea 2128...
2088
        }
2128
        }
Línea 2089... Línea 2129...
2089
 
2129
 
2090
        return $output;
2130
        return $output;
Línea 2091... Línea 2131...
2091
    }
2131
    }
2092
 
2132
 
2093
        /**
2133
    /**
2094
     * Get the course pattern datauri to show on a course card.
2134
     * Get the course pattern datauri to show on a course card.
2095
     *
2135
     *
2096
     * The datauri is an encoded svg that can be passed as a url.
2136
     * The datauri is an encoded svg that can be passed as a url.
2097
     * @param int $id Id to use when generating the pattern
2137
     * @param int $id Id to use when generating the pattern
2098
     * @return string datauri
2138
     * @return string datauri
-
 
2139
     */
2099
     */
2140
    public function get_generated_image_for_id($id)
Línea 2100... Línea 2141...
2100
    public function get_generated_image_for_id($id) {
2141
    {
2101
        global $CFG;
2142
        global $CFG;
2102
 
2143
 
Línea 2115... Línea 2156...
2115
            $pattern->setColor($color);
2156
            $pattern->setColor($color);
2116
            $pattern->patternbyid($id);
2157
            $pattern->patternbyid($id);
2117
            return $pattern->datauri();
2158
            return $pattern->datauri();
2118
        }
2159
        }
2119
    }
2160
    }
2120
    
2161
 
2121
    public function moremenu_group_item () {
2162
    public function moremenu_group_item()
-
 
2163
    {
2122
        global $CFG, $COURSE;
2164
        global $CFG, $COURSE;
Línea 2123... Línea 2165...
2123
 
2165
 
2124
        $theme = \theme_config::load('universe');
2166
        $theme = \theme_config::load('universe');
2125
        $courseid = $COURSE->id;
2167
        $courseid = $COURSE->id;
Línea 2129... Línea 2171...
2129
            if (has_capability('moodle/course:managegroups', \context_course::instance($COURSE->id))) {
2171
            if (has_capability('moodle/course:managegroups', \context_course::instance($COURSE->id))) {
2130
                $html = $sitehomeurl . "group/index.php?id=" . $courseid;
2172
                $html = $sitehomeurl . "group/index.php?id=" . $courseid;
2131
                return $html;
2173
                return $html;
2132
            }
2174
            }
2133
        }
2175
        }
2134
 
-
 
2135
    }
2176
    }
Línea 2136... Línea 2177...
2136
 
2177
 
-
 
2178
    public function moremenu_custom_items()
2137
    public function moremenu_custom_items () {
2179
    {
Línea 2138... Línea 2180...
2138
        global $CFG, $COURSE, $USER;
2180
        global $CFG, $COURSE, $USER;
2139
 
2181
 
2140
        $theme = \theme_config::load('universe');
2182
        $theme = \theme_config::load('universe');
Línea 2160... Línea 2202...
2160
                $secnav->title = theme_universe_get_setting("secnavcustomnavlabel" . $i);
2202
                $secnav->title = theme_universe_get_setting("secnavcustomnavlabel" . $i);
Línea 2161... Línea 2203...
2161
 
2203
 
2162
                $url = theme_universe_get_setting("secnavcustomnavurl" . $i);
2204
                $url = theme_universe_get_setting("secnavcustomnavurl" . $i);
2163
                $courseid = $COURSE->id;
2205
                $courseid = $COURSE->id;
2164
                $newurl = str_replace("{{courseID}}", $courseid, $url);
2206
                $newurl = str_replace("{{courseID}}", $courseid, $url);
2165
                
2207
 
2166
                // User role restriction.
2208
                // User role restriction.
2167
                $selectrole = theme_universe_get_setting("secnavuserroles" . $i);
2209
                $selectrole = theme_universe_get_setting("secnavuserroles" . $i);
2168
  
2210
 
2169
                if($roleid == $selectrole) {
2211
                if ($roleid == $selectrole) {
2170
                    $secnav->url = $newurl;
2212
                    $secnav->url = $newurl;
2171
                    $html .= $this->render_from_template('theme_universe/custom_sec_nav_item', $secnav);
2213
                    $html .= $this->render_from_template('theme_universe/custom_sec_nav_item', $secnav);
2172
                }  
2214
                }
2173
                if($roleid != $selectrole) {
2215
                if ($roleid != $selectrole) {
2174
                    $secnav->url = $newurl;
2216
                    $secnav->url = $newurl;
2175
                }
2217
                }
2176
                if($selectrole == 0) {
2218
                if ($selectrole == 0) {
2177
                    $secnav->url = $newurl;
2219
                    $secnav->url = $newurl;
2178
                    $html .= $this->render_from_template('theme_universe/custom_sec_nav_item', $secnav);
2220
                    $html .= $this->render_from_template('theme_universe/custom_sec_nav_item', $secnav);
2179
                }  
2221
                }
Línea 2180... Línea 2222...
2180
                // End.
2222
                // End.
2181
 
2223
 
2182
            }
2224
            }
2183
        }
2225
        }
2184
        return $html;
-
 
2185
    }
2226
        return $html;