ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI Class Reference
+ Collaboration diagram for ILIAS\MetaData\Vocabularies\Dispatch\Presentation\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\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::__construct ( \ilObjMediaCast  $obj,
?\ilGlobalTemplateInterface  $tpl = null,
string  $rss_link = "" 
)

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

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

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
+ Here is the call graph for this function:

Member Function Documentation

◆ getAutoplay()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::getAutoplay ( )
protected

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

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

Referenced by ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\renderSideColumn(), and ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\renderToolbar().

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

◆ getDropdown()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::getDropdown ( )
protected

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

References $id, null, ILIAS\Repository\ui(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\renderToolbar().

178  : ?\ILIAS\UI\Component\Dropdown\Standard
179  {
180 
181  $actions = [];
182  foreach ($this->video_sequence->getVideos() as $video) {
183  $actions[] = $this->ui->factory()->button()->shy(
184  $video->getTitle(),
185  "#"
186  )->withOnLoadCode(function (string $id) use ($video) {
187  return "document.getElementById('$id').addEventListener('click', () => {il.VideoPlaylist.toggleItem('mcst_playlist', '" . $video->getId() . "'); $('.ilToolbarStickyItem .dropdown.open').removeClass('open');});";
188  });
189  }
190  if (count($actions) > 0) {
191  return $this->ui->factory()->dropdown()->standard($actions);
192  }
193  return null;
194  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::render ( )
Exceptions

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

References ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\renderMainColumn(), and ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\renderSideColumn().

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

◆ renderCommentsContainer()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::renderCommentsContainer ( )

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

References ILIAS\Repository\ctrl().

Referenced by ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\show().

364  {
365  if ($this->mc_manager->commentsActive()) {
366  $target = $this->ctrl->getLinkTargetByClass(
367  \ilObjMediaCastGUI::class,
368  "showComments"
369  );
370  return "<div data-mcst-comments='$target'></div>";
371  }
372  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderMainColumn()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::renderMainColumn ( )
Exceptions

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

Referenced by ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\render(), and ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\show().

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  }
+ Here is the caller graph for this function:

◆ renderSideColumn()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::renderSideColumn ( )

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

References Vendor\Package\$b, $id, ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\$lng, $renderer, ilMediaCastSettings\_getInstance(), ilChangeEvent\_lookupReadEvents(), ILIAS\Repository\ctrl(), ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\getAutoplay(), ILIAS\Repository\ui(), ILIAS\Repository\user(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\render(), and ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\show().

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

◆ renderToolbar()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::renderToolbar ( )

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

References Vendor\Package\$f, $id, ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\$lng, $renderer, ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\$rss_link, ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\$toolbar, ilMediaCastSettings\_getInstance(), ilObjMediaCast\AUTOPLAY_NO, ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\getAutoplay(), ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\getDropdown(), ILIAS\Repository\ui(), and ILIAS\GlobalScreen\Scope\Footer\Factory\withOpenInNewViewport().

Referenced by ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI\show().

92  : void
93  {
95  $lng = $this->lng;
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)) {
128  $toolbar->addStickyItem($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"),
157  )->withOpenInNewViewport(true)
158  ];
159  $toolbar->addComponent($f->dropdown()->standard($actions));
160  }
161  }
$renderer
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...
addComponent(\ILIAS\UI\Component\Component $a_comp)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
addStickyItem( $a_item, bool $a_output_label=false)
Add a sticky item.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAutoplayCallback()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::setAutoplayCallback ( string  $autoplay_callback)

◆ setCompletedCallback()

ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::setCompletedCallback ( string  $completed_callback)

◆ show()

Field Documentation

◆ $autoplay_callback

string ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$autoplay_callback = ""
protected

◆ $completed_callback

string ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$completed_callback = ""
protected

◆ $ctrl

ilCtrlInterface ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$ctrl
protected

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

◆ $lng

ilLanguage ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$lng
protected

◆ $main_tpl

ilGlobalTemplateInterface ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$main_tpl
protected

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

◆ $mc_manager

ILIAS MediaCast MediaCastManager ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$mc_manager
protected

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

◆ $media_cast

ilObjMediaCast ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$media_cast
protected

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

◆ $rss_link

string ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$rss_link
protected

◆ $toolbar

ilToolbarGUI ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$toolbar
protected

◆ $tpl

ilGlobalTemplateInterface ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$tpl
protected

◆ $ui

ILIAS DI UIServices ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$ui
protected

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

◆ $user

ilObjUser ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$user
protected

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

◆ $video_sequence

VideoSequence ILIAS\MetaData\Vocabularies\Dispatch\Presentation\Presentation\VideoViewGUI::$video_sequence
protected

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

◆ $video_wrapper_id

string ILIAS\MetaData\Vocabularies\Dispatch\Presentation\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: