ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.VideoWidgetGUI.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\MediaCast\Video;
20
25{
26 protected string $dom_wrapper_id;
27 protected \ILIAS\DI\UIServices $ui;
28 protected \ilLanguage $lng;
29 protected ?VideoItem $video = null;
30 protected \ilGlobalTemplateInterface $main_tpl;
31
32 public function __construct(
34 string $dom_wrapper_id
35 ) {
36 global $DIC;
37 $debug = false;
38 if (!$debug) {
39 $main_tpl->addJavaScript("assets/js/video_widget.js");
40 } else {
41 $main_tpl->addJavaScript("../components/ILIAS/MediaCast/resources/video_widget.js");
42 }
43
44 $this->main_tpl = $main_tpl;
45 $this->dom_wrapper_id = $dom_wrapper_id;
46 $this->ui = $DIC->ui();
47 $this->lng = $DIC->language();
48 }
49
50 public function setVideo(?VideoItem $a_val = null): void
51 {
52 $this->video = $a_val;
53 }
54
55 public function getVideo(): ?VideoItem
56 {
57 return $this->video;
58 }
59
63 public function render(): string
64 {
65 $ui = $this->ui;
66 $video = $ui->factory()->player()->video("")->withPoster("");
67 $video_tpl_html = $ui->renderer()->render($video);
68 $video_tpl_html = str_replace(["\n", "\r"], "", $video_tpl_html);
69
70 $tpl = new \ilTemplate("tpl.wrapper.html", true, true, "components/ILIAS/MediaCast/Video");
71 $f = $ui->factory();
72
73 $tpl->setVariable("ID", $this->dom_wrapper_id);
74 $this->main_tpl->addOnLoadCode(
75 "il.VideoWidget.init('" . $this->dom_wrapper_id . "', '" . $video_tpl_html . "');"
76 );
77
78 if (!is_null($this->getVideo())) {
79 /*$this->main_tpl->addOnLoadCode(
80 "il.VideoWidget.loadFile('" .
81 $this->dom_wrapper_id . "', '" .
82 $this->getVideo()->getResource() . "', false);"
83 );*/
84 }
85
86 $item = $f->item()->standard('#title#')
87 ->withMainAction(
88 $f->link()->standard('#download#', "#")
89 )
90 ->withDescription('#description#');
91 $item_html = $ui->renderer()->render($item);
92 $item_html = str_replace(
93 "#title#",
94 '<span data-elementtype="title"></span>',
95 $item_html
96 );
97 $item_html = str_replace(
98 "#download#",
99 '<span data-elementtype="download">' .
100 $this->lng->txt("download") .
101 '</span>',
102 $item_html
103 );
104 $item_html = str_replace(
105 "#description#",
106 '<span data-elementtype="description-wrapper"><span data-elementtype="description"></span></span>',
107 $item_html
108 );
109 $tpl->setVariable("ITEM", $item_html);
110
111 return $tpl->get();
112 }
113}
__construct(\ilGlobalTemplateInterface $main_tpl, string $dom_wrapper_id)
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26