ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ->withDescription('#description#');
88 $item_html = $ui->renderer()->render($item);
89 $item_html = str_replace(
90 "#title#",
91 '<span data-elementtype="title"></span>',
92 $item_html
93 );
94 $item_html = str_replace(
95 "#description#",
96 '<span data-elementtype="description-wrapper"><span data-elementtype="description"></span></span>',
97 $item_html
98 );
99 $tpl->setVariable("ITEM", $item_html);
100
101
102 /*
103 $back = $f->button()->standard("<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>", "")
104 ->withOnLoadCode(function ($id) {
105 return
106 "$(\"#$id\").click(function() { il.VideoWidget.previous(\"".$this->dom_wrapper_id."\"); return false;});";
107 });
108 $next = $f->button()->standard("<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>", "")
109 ->withOnLoadCode(function ($id) {
110 return
111 "$(\"#$id\").click(function() { il.VideoWidget.next(\"".$this->dom_wrapper_id."\"); return false;});";
112 });*/
113
114
115 /*
116 $description_link = $f->button()->shy($this->lng->txt("mcst_show_description"), "")->withOnLoadCode(function ($id) {
117 return
118 "$(\"#$id\").click(function() { $(document).find(\"[data-elementtype='description']\").removeClass('ilNoDisplay'); $(document).find(\"[data-elementtype='description-trigger']\").addClass('ilNoDisplay'); return false;});";
119 });
120 $tpl->setVariable("DESCRIPTION_LINK", $ui->renderer()->render($description_link));*/
121
122 //$tpl->setVariable("VIEWCONTROL", $ui->renderer()->render([$back,$next]));
123
124 /*
125 $tpl->setCurrentBlock("autoplay");
126 $tpl->setVariable("TXT_AUTOPLAY",
127 $this->lng->txt("mcst_autoplay"));
128 $tpl->parseCurrentBlock();*/
129
130 return $tpl->get();
131 }
132}
__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