ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\MediaCast\Presentation\VideoViewGUI Class Reference
+ Collaboration diagram for ILIAS\MediaCast\Presentation\VideoViewGUI:

Public Member Functions

 __construct (\ilObjMediaCast $obj, ?\ilGlobalTemplateInterface $tpl=null, string $rss_link="")
 
 setCompletedCallback (string $completed_callback)
 
 setAutoplayCallback (string $autoplay_callback)
 
 renderMainColumn ()
 
 renderToolbar ()
 
 renderSideColumn ()
 
 render ()
 
 show ()
 
 renderCommentsContainer ()
 

Protected Member Functions

 getAutoplay ()
 
 getDropdown ()
 

Protected Attributes

ilCtrlInterface $ctrl
 
ILIAS MediaCast MediaCastManager $mc_manager
 
string $rss_link
 
ilToolbarGUI $toolbar
 
ilGlobalTemplateInterface $main_tpl
 
ilObjMediaCast $media_cast
 
ilGlobalTemplateInterface $tpl
 
ILIAS DI UIServices $ui
 
ilLanguage $lng
 
ilObjUser $user
 
string $completed_callback = ""
 
string $autoplay_callback = ""
 
VideoSequence $video_sequence
 
string $video_wrapper_id = "mcst_video"
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 29 of file class.VideoViewGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MediaCast\Presentation\VideoViewGUI::__construct ( \ilObjMediaCast  $obj,
?\ilGlobalTemplateInterface  $tpl = null,
string  $rss_link = "" 
)

Definition at line 46 of file class.VideoViewGUI.php.

50 {
51 global $DIC;
52
53 $this->ui = $DIC->ui();
54 $this->rss_link = $rss_link;
55 $this->lng = $DIC->language();
56 $this->media_cast = $obj;
57 $this->tpl = $tpl;
58 $this->video_sequence = new VideoSequence($this->media_cast);
59 $this->user = $DIC->user();
60 $this->main_tpl = $DIC->ui()->mainTemplate();
61 $this->toolbar = $DIC->toolbar();
62 $this->ctrl = $DIC->ctrl();
63 $this->mc_manager = $DIC->mediaCast()->internal()->domain()->mediaCast(
64 $this->media_cast
65 );
66 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\MediaCast\Presentation\VideoViewGUI\$rss_link, ILIAS\MediaCast\Presentation\VideoViewGUI\$tpl, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getAutoplay()

ILIAS\MediaCast\Presentation\VideoViewGUI::getAutoplay ( )
protected

Definition at line 163 of file class.VideoViewGUI.php.

163 : bool
164 {
165 $video_cnt = count($this->video_sequence->getVideos());
166 if ($video_cnt <= 1) {
167 return false;
168 }
169 $autoplay = (bool) ($this->user->getPref("mcst_autoplay") ??
170 ($this->media_cast->getAutoplayMode() == \ilObjMediaCast::AUTOPLAY_ACT));
171 if ($this->media_cast->getAutoplayMode() == \ilObjMediaCast::AUTOPLAY_NO) {
172 $autoplay = false;
173 }
174 return $autoplay;
175 }

References ilObjMediaCast\AUTOPLAY_ACT, ilObjMediaCast\AUTOPLAY_NO, and ILIAS\Repository\user().

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\renderSideColumn(), and ILIAS\MediaCast\Presentation\VideoViewGUI\renderToolbar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDropdown()

ILIAS\MediaCast\Presentation\VideoViewGUI::getDropdown ( )
protected

Definition at line 177 of file class.VideoViewGUI.php.

178 {
179
180 $actions = [];
181 foreach ($this->video_sequence->getVideos() as $video) {
182 $actions[] = $this->ui->factory()->button()->shy(
183 $video->getTitle(),
184 "#"
185 )->withOnLoadCode(function (string $id) use ($video) {
186 return "document.getElementById('$id').addEventListener('click', () => {il.VideoPlaylist.toggleItem('mcst_playlist', '" . $video->getId() . "'); $('.ilToolbarStickyItem .dropdown.open').removeClass('open');});";
187 });
188 }
189 if (count($actions) > 0) {
190 return $this->ui->factory()->dropdown()->standard($actions);
191 }
192 return null;
193 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This describes a Standard Dropdown.
Definition: Standard.php:27

References $id, and ILIAS\Repository\ui().

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\renderToolbar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ILIAS\MediaCast\Presentation\VideoViewGUI::render ( )
Exceptions

ilTemplateException

Definition at line 330 of file class.VideoViewGUI.php.

330 : string
331 {
332 // this is current only to include the resize mechanism when
333 // the main menu is changed, so that the player is resized, too
334 //\ilMediaPlayerGUI::initJavascript();
335 $tpl = new \ilTemplate("tpl.video_cast_layout.html", true, true, "components/ILIAS/MediaCast/Presentation");
336 $side_column = $this->renderSideColumn();
337
338
339 if ($side_column != "") {
340 $tpl->setCurrentBlock("with_side_column");
341 $tpl->setVariable("SIDE", $side_column);
342 } else {
343 $tpl->setCurrentBlock("video_only");
344 }
345 $tpl->setVariable("MAIN", $this->renderMainColumn());
347 return $tpl->get();
348 }
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

References ILIAS\MediaCast\Presentation\VideoViewGUI\$tpl, ILIAS\UICore\GlobalTemplate\get(), ILIAS\MediaCast\Presentation\VideoViewGUI\renderMainColumn(), ILIAS\MediaCast\Presentation\VideoViewGUI\renderSideColumn(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call graph for this function:

◆ renderCommentsContainer()

ILIAS\MediaCast\Presentation\VideoViewGUI::renderCommentsContainer ( )

Definition at line 362 of file class.VideoViewGUI.php.

363 {
364 if ($this->mc_manager->commentsActive()) {
365 $target = $this->ctrl->getLinkTargetByClass(
366 \ilObjMediaCastGUI::class,
367 "showComments"
368 );
369 return "<div data-mcst-comments='$target'></div>";
370 }
371 }

References ILIAS\Repository\ctrl().

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\show().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderMainColumn()

ILIAS\MediaCast\Presentation\VideoViewGUI::renderMainColumn ( )
Exceptions

ilTemplateException

Definition at line 81 of file class.VideoViewGUI.php.

81 : string
82 {
83 if (count($this->video_sequence->getVideos()) == 0) {
84 return "";
85 }
86
87 $widget = new VideoWidgetGUI($this->tpl, "mcst_video");
88 $widget->setVideo($this->video_sequence->getFirst());
89 return $widget->render();
90 }

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\render(), and ILIAS\MediaCast\Presentation\VideoViewGUI\show().

+ Here is the caller graph for this function:

◆ renderSideColumn()

ILIAS\MediaCast\Presentation\VideoViewGUI::renderSideColumn ( )

Definition at line 195 of file class.VideoViewGUI.php.

195 : string
196 {
197 $mcst_settings = \ilMediaCastSettings::_getInstance();
198
199 $autoplay = $this->getAutoplay();
200
202 $tpl = new \ilTemplate("tpl.video_cast_side.html", true, true, "components/ILIAS/MediaCast/Presentation");
203
204 $factory = $this->ui->factory();
205 $renderer = $this->ui->renderer();
206
207 // items
208 $items = [];
209 $has_items = false;
210
211 $panel_items = [];
212
213 foreach ($this->video_sequence->getVideos() as $video) {
214 $has_items = true;
215 $preview = new VideoPreviewGUI(
216 $video->getPreviewPic(),
217 "il.VideoPlaylist.toggleItem('mcst_playlist', '" . $video->getId() . "');",
218 $video->getPlayingTime()
219 );
220 $completed = false;
221
222 $re = \ilChangeEvent::_lookupReadEvents($video->getId(), $this->user->getId());
223 if (count($re) > 0) {
224 if ($re[0]["read_count"] > 0) {
225 $completed = true;
226 }
227 }
228
229 $b = $factory->button()->shy($video->getTitle(), "")->withOnLoadCode(function ($id) use ($video) {
230 return
231 "$(\"#$id\").click(function() { il.VideoPlaylist.toggleItem('mcst_playlist', '" . $video->getId() . "'); return false;});";
232 });
233
234 $this->ctrl->setParameterByClass(
235 \ilObjMediaCastGUI::class,
236 "mob_id",
237 $video->getId()
238 );
239 $items[] = [
240 "id" => $video->getId(),
241 "resource" => $video->getResource(),
242 "preview" => $preview->render(),
243 "preview_pic" => $video->getPreviewPic(),
244 "title" => $video->getTitle(),
245 "linked_title" => $renderer->renderAsync($b),
246 "mime" => $video->getMime(),
247 "poster" => $video->getPreviewPic(),
248 "description" => nl2br($video->getDescription()),
249 "completed" => $completed,
250 "duration" => $video->getDuration(),
251 "renderUrl" => $this->ctrl->getLinkTargetByClass(
252 \ilObjMediaCastGUI::class,
253 "renderVideo"
254 )
255 ];
256 }
257
258 $panel = $factory->panel()->secondary()->listing(
259 "Videos",
260 []
261 );
262 $panel_html = $renderer->render($panel);
263 $panel_html = str_replace(
264 '<div class="panel-body">',
265 '<div class="panel-body"><div id="mcst_playlist"></div>',
266 $panel_html,
267 );
268
269 $tpl->setVariable("PANEL", $panel_html);
270 // previous items / next items links
271 if ($has_items) {
273 "PREV",
274 $renderer->render(
275 $factory->button()->standard($lng->txt("mcst_prev_items"), "")->withOnLoadCode(
276 function ($id) {
277 return
278 "$(\"#$id\").click(function() { il.VideoPlaylist.previousItems('mcst_playlist'); return false;});";
279 }
280 )
281 )
282 );
284 "NEXT",
285 $renderer->render(
286 $factory->button()->standard($lng->txt("mcst_next_items"), "")->withOnLoadCode(
287 function ($id) {
288 return
289 "$(\"#$id\").click(function() { il.VideoPlaylist.nextItems('mcst_playlist'); return false;});";
290 }
291 )
292 )
293 );
294
295 $item_tpl = new \ilTemplate("tpl.playlist_item.html", true, true, "components/ILIAS/MediaCast/Video");
296 $item_tpl->setVariable("TITLE", " ");
297 $item_content = str_replace(["\n", "\r"], "", $item_tpl->get());
298
299 $item = $factory->item()->standard("#video-title#")
300 ->withLeadImage(
301 $factory->image()->responsive("#img-src#", "#img-alt#")
302 );
303
304 $item_content = $renderer->render($item);
305 $item_content = str_replace(["\n", "\r"], "", $item_content);
306
307 $init_videos = $this->media_cast->getNumberInitialVideos() > 0
308 ? $this->media_cast->getNumberInitialVideos()
309 : 1;
310 $this->tpl->addOnLoadCode(
311 "il.VideoPlaylist.init('mcst_playlist', 'mcst_video', " . json_encode(
312 $items
313 ) . ", '$item_content', " . ($autoplay ? "true" : "false") . ", " .
314 (int) $init_videos . ", '" . $this->completed_callback . "', '" . $this->autoplay_callback . "', " . ((int) $mcst_settings->getVideoCompletionThreshold()) . ");"
315 );
316
317 if (count($items) === 1) {
318 return " ";
319 }
320
321 return $tpl->get();
322 }
323
324 return "";
325 }
$renderer
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...

References Vendor\Package\$b, $id, ILIAS\MediaCast\Presentation\VideoViewGUI\$lng, $renderer, ILIAS\MediaCast\Presentation\VideoViewGUI\$tpl, ilMediaCastSettings\_getInstance(), ilChangeEvent\_lookupReadEvents(), ILIAS\Repository\ctrl(), ILIAS\UICore\GlobalTemplate\get(), ILIAS\MediaCast\Presentation\VideoViewGUI\getAutoplay(), ILIAS\UICore\GlobalTemplate\setVariable(), ilLanguage\txt(), and ILIAS\Repository\ui().

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\render(), and ILIAS\MediaCast\Presentation\VideoViewGUI\show().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderToolbar()

ILIAS\MediaCast\Presentation\VideoViewGUI::renderToolbar ( )

Definition at line 92 of file class.VideoViewGUI.php.

92 : void
93 {
96
97 $video_cnt = count($this->video_sequence->getVideos());
98
99 $mcst_settings = \ilMediaCastSettings::_getInstance();
100
101 $autoplay = $this->getAutoplay();
102
103 $factory = $this->ui->factory();
104 $renderer = $this->ui->renderer();
105
106 if ($video_cnt > 1) {
107 $back = $factory->button()->standard(
108 "<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
109 ""
110 )
111 ->withOnLoadCode(function ($id) {
112 return
113 "$(\"#$id\").click(function() { il.VideoWidget.previous(\"" . $this->video_wrapper_id . "\"); return false;});";
114 });
115 $next = $factory->button()->standard(
116 "<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>",
117 ""
118 )
119 ->withOnLoadCode(function ($id) {
120 return
121 "$(\"#$id\").click(function() { il.VideoWidget.next(\"" . $this->video_wrapper_id . "\"); return false;});";
122 });
123
124 $toolbar->addStickyItem($back);
125
126 $dd = $this->getDropdown();
127 if (!is_null($dd)) {
129 }
130
131 $toolbar->addStickyItem($next);
132 }
133
134 // autoplay
135 if ($this->media_cast->getAutoplayMode() !== \ilObjMediaCast::AUTOPLAY_NO && $video_cnt > 1) {
137 $s = new SignalGenerator();
138 $autoplay_on = $s->create();
139 $autoplay_off = $s->create();
140 $button = $factory->button()->toggle($lng->txt("mcst_autoplay"), $autoplay_on, $autoplay_off, $autoplay);
141 $toolbar->addStickyItem($button);
142 $this->main_tpl->addOnLoadCode("
143 $(document).on('" . $autoplay_on . "', function (event, signalData) {
144 il.VideoPlaylist.autoplay('mcst_playlist', true);
145 });
146 $(document).on('" . $autoplay_off . "', function (event, signalData) {
147 il.VideoPlaylist.autoplay('mcst_playlist', false);
148 });");
149 }
150
151 if ($video_cnt > 0 && $this->rss_link !== "") {
152 $f = $this->ui->factory();
153 $actions = [
154 $f->link()->standard(
155 $lng->txt("mcst_webfeed"),
156 $this->rss_link
157 )->withOpenInNewViewport(true)
158 ];
159 $toolbar->addComponent($f->dropdown()->standard($actions));
160 }
161 }
addComponent(\ILIAS\UI\Component\Component $a_comp)
addStickyItem( $a_item, bool $a_output_label=false)
Add a sticky item.

References Vendor\Package\$f, $id, ILIAS\MediaCast\Presentation\VideoViewGUI\$lng, $renderer, ILIAS\MediaCast\Presentation\VideoViewGUI\$toolbar, ilMediaCastSettings\_getInstance(), ilToolbarGUI\addComponent(), ilToolbarGUI\addSeparator(), ilToolbarGUI\addStickyItem(), ilObjMediaCast\AUTOPLAY_NO, ILIAS\MediaCast\Presentation\VideoViewGUI\getAutoplay(), ILIAS\MediaCast\Presentation\VideoViewGUI\getDropdown(), ilLanguage\txt(), and ILIAS\Repository\ui().

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\show().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAutoplayCallback()

ILIAS\MediaCast\Presentation\VideoViewGUI::setAutoplayCallback ( string  $autoplay_callback)

Definition at line 73 of file class.VideoViewGUI.php.

73 : void
74 {
75 $this->autoplay_callback = $autoplay_callback;
76 }

References ILIAS\MediaCast\Presentation\VideoViewGUI\$autoplay_callback.

◆ setCompletedCallback()

ILIAS\MediaCast\Presentation\VideoViewGUI::setCompletedCallback ( string  $completed_callback)

Definition at line 68 of file class.VideoViewGUI.php.

68 : void
69 {
70 $this->completed_callback = $completed_callback;
71 }

References ILIAS\MediaCast\Presentation\VideoViewGUI\$completed_callback.

◆ show()

ILIAS\MediaCast\Presentation\VideoViewGUI::show ( )

Definition at line 350 of file class.VideoViewGUI.php.

350 : void
351 {
352 if (is_object($this->tpl)) {
353 $this->renderToolbar();
354 $this->tpl->setContent(
355 $this->renderMainColumn() .
357 );
358 $this->tpl->setRightContent($this->renderSideColumn());
359 }
360 }

References ILIAS\MediaCast\Presentation\VideoViewGUI\renderCommentsContainer(), ILIAS\MediaCast\Presentation\VideoViewGUI\renderMainColumn(), ILIAS\MediaCast\Presentation\VideoViewGUI\renderSideColumn(), and ILIAS\MediaCast\Presentation\VideoViewGUI\renderToolbar().

+ Here is the call graph for this function:

Field Documentation

◆ $autoplay_callback

string ILIAS\MediaCast\Presentation\VideoViewGUI::$autoplay_callback = ""
protected

◆ $completed_callback

string ILIAS\MediaCast\Presentation\VideoViewGUI::$completed_callback = ""
protected

◆ $ctrl

ilCtrlInterface ILIAS\MediaCast\Presentation\VideoViewGUI::$ctrl
protected

Definition at line 31 of file class.VideoViewGUI.php.

◆ $lng

ilLanguage ILIAS\MediaCast\Presentation\VideoViewGUI::$lng
protected

◆ $main_tpl

ilGlobalTemplateInterface ILIAS\MediaCast\Presentation\VideoViewGUI::$main_tpl
protected

Definition at line 35 of file class.VideoViewGUI.php.

◆ $mc_manager

ILIAS MediaCast MediaCastManager ILIAS\MediaCast\Presentation\VideoViewGUI::$mc_manager
protected

Definition at line 32 of file class.VideoViewGUI.php.

◆ $media_cast

ilObjMediaCast ILIAS\MediaCast\Presentation\VideoViewGUI::$media_cast
protected

Definition at line 36 of file class.VideoViewGUI.php.

◆ $rss_link

string ILIAS\MediaCast\Presentation\VideoViewGUI::$rss_link
protected

◆ $toolbar

ilToolbarGUI ILIAS\MediaCast\Presentation\VideoViewGUI::$toolbar
protected

◆ $tpl

◆ $ui

ILIAS DI UIServices ILIAS\MediaCast\Presentation\VideoViewGUI::$ui
protected

Definition at line 38 of file class.VideoViewGUI.php.

◆ $user

ilObjUser ILIAS\MediaCast\Presentation\VideoViewGUI::$user
protected

Definition at line 40 of file class.VideoViewGUI.php.

◆ $video_sequence

VideoSequence ILIAS\MediaCast\Presentation\VideoViewGUI::$video_sequence
protected

Definition at line 43 of file class.VideoViewGUI.php.

◆ $video_wrapper_id

string ILIAS\MediaCast\Presentation\VideoViewGUI::$video_wrapper_id = "mcst_video"
protected

Definition at line 44 of file class.VideoViewGUI.php.


The documentation for this class was generated from the following file: