ILIAS  release_8 Revision v8.24
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
38 $main_tpl->addJavaScript("Modules/MediaCast/Video/js/video_widget.js");
39 $this->main_tpl = $main_tpl;
40 $this->dom_wrapper_id = $dom_wrapper_id;
41 $this->ui = $DIC->ui();
42 $this->lng = $DIC->language();
43 }
44
45 public function setVideo(?VideoItem $a_val = null): void
46 {
47 $this->video = $a_val;
48 }
49
50 public function getVideo(): ?VideoItem
51 {
52 return $this->video;
53 }
54
58 public function render(): string
59 {
60 $ui = $this->ui;
61 $video = $ui->factory()->player()->video("")->withPoster("");
62 $video_tpl_html = $ui->renderer()->render($video);
63 $video_tpl_html = str_replace("\n", "", $video_tpl_html);
64
65 $tpl = new \ilTemplate("tpl.wrapper.html", true, true, "Modules/MediaCast/Video");
66 $f = $ui->factory();
67
68 $tpl->setVariable("ID", $this->dom_wrapper_id);
69 $this->main_tpl->addOnLoadCode(
70 "il.VideoWidget.init('" . $this->dom_wrapper_id . "', '" . $video_tpl_html . "');"
71 );
72
73 if (!is_null($this->getVideo())) {
74 $this->main_tpl->addOnLoadCode(
75 "il.VideoWidget.loadFile('" .
76 $this->dom_wrapper_id . "', '" .
77 $this->getVideo()->getResource() . "', false);"
78 );
79 }
80
81 $item = $f->item()->standard('#title#')
82 ->withDescription('#description#');
83 $item_html = $ui->renderer()->render($item);
84 $item_html = str_replace(
85 "#title#",
86 '<span data-elementtype="title"></span>',
87 $item_html
88 );
89 $item_html = str_replace(
90 "#description#",
91 '<span data-elementtype="description-wrapper"><span data-elementtype="description"></span></span>',
92 $item_html
93 );
94 $tpl->setVariable("ITEM", $item_html);
95
96
97 /*
98 $back = $f->button()->standard("<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>", "")
99 ->withOnLoadCode(function ($id) {
100 return
101 "$(\"#$id\").click(function() { il.VideoWidget.previous(\"".$this->dom_wrapper_id."\"); return false;});";
102 });
103 $next = $f->button()->standard("<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>", "")
104 ->withOnLoadCode(function ($id) {
105 return
106 "$(\"#$id\").click(function() { il.VideoWidget.next(\"".$this->dom_wrapper_id."\"); return false;});";
107 });*/
108
109
110 /*
111 $description_link = $f->button()->shy($this->lng->txt("mcst_show_description"), "")->withOnLoadCode(function ($id) {
112 return
113 "$(\"#$id\").click(function() { $(document).find(\"[data-elementtype='description']\").removeClass('ilNoDisplay'); $(document).find(\"[data-elementtype='description-trigger']\").addClass('ilNoDisplay'); return false;});";
114 });
115 $tpl->setVariable("DESCRIPTION_LINK", $ui->renderer()->render($description_link));*/
116
117 //$tpl->setVariable("VIEWCONTROL", $ui->renderer()->render([$back,$next]));
118
119 /*
120 $tpl->setCurrentBlock("autoplay");
121 $tpl->setVariable("TXT_AUTOPLAY",
122 $this->lng->txt("mcst_autoplay"));
123 $tpl->parseCurrentBlock();*/
124
125 return $tpl->get();
126 }
127}
__construct(\ilGlobalTemplateInterface $main_tpl, string $dom_wrapper_id)
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...