ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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.

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().

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: feed.php:28
+ 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.

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

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\renderSideColumn(), and ILIAS\MediaCast\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\MediaCast\Presentation\VideoViewGUI::getDropdown ( )
protected

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

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

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

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  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This describes a Standard Dropdown.
Definition: Standard.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

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

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

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

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

◆ renderCommentsContainer()

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

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

References ILIAS\Repository\ctrl().

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

356  {
357  if ($this->mc_manager->commentsActive()) {
358  $target = $this->ctrl->getLinkTargetByClass(
359  \ilObjMediaCastGUI::class,
360  "showComments"
361  );
362  return "<div data-mcst-comments='$target'></div>";
363  }
364  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderMainColumn()

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

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

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\render(), and ILIAS\MediaCast\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\MediaCast\Presentation\VideoViewGUI::renderSideColumn ( )

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

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

Referenced by ILIAS\MediaCast\Presentation\VideoViewGUI\render(), and ILIAS\MediaCast\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, "Modules/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  $items[] = [
236  "id" => $video->getId(),
237  "resource" => $video->getResource(),
238  "preview" => $preview->render(),
239  "preview_pic" => $video->getPreviewPic(),
240  "title" => $video->getTitle(),
241  "linked_title" => $renderer->renderAsync($b),
242  "mime" => $video->getMime(),
243  "poster" => $video->getPreviewPic(),
244  "description" => nl2br($video->getDescription()),
245  "completed" => $completed,
246  "duration" => $video->getDuration()
247  ];
248  }
249 
250  $panel = $factory->panel()->secondary()->listing(
251  "Videos",
252  []
253  );
254  $panel_html = $renderer->render($panel);
255  $panel_html = str_replace(
256  '<div class="panel-body">',
257  '<div class="panel-body"><div id="mcst_playlist"></div>',
258  $panel_html,
259  );
260 
261  $tpl->setVariable("PANEL", $panel_html);
262  // previous items / next items links
263  if ($has_items) {
264  $tpl->setVariable(
265  "PREV",
266  $renderer->render(
267  $factory->button()->standard($lng->txt("mcst_prev_items"), "")->withOnLoadCode(
268  function ($id) {
269  return
270  "$(\"#$id\").click(function() { il.VideoPlaylist.previousItems('mcst_playlist'); return false;});";
271  }
272  )
273  )
274  );
275  $tpl->setVariable(
276  "NEXT",
277  $renderer->render(
278  $factory->button()->standard($lng->txt("mcst_next_items"), "")->withOnLoadCode(
279  function ($id) {
280  return
281  "$(\"#$id\").click(function() { il.VideoPlaylist.nextItems('mcst_playlist'); return false;});";
282  }
283  )
284  )
285  );
286 
287  $item_tpl = new \ilTemplate("tpl.playlist_item.html", true, true, "Modules/MediaCast/Video");
288  $item_tpl->setVariable("TITLE", " ");
289  $item_content = str_replace(["\n", "\r"], "", $item_tpl->get());
290 
291  $item = $factory->item()->standard("#video-title#")
292  ->withLeadImage(
293  $factory->image()->responsive("#img-src#", "#img-alt#")
294  );
295 
296  $item_content = $renderer->render($item);
297  $item_content = str_replace(["\n", "\r"], "", $item_content);
298 
299  $init_videos = $this->media_cast->getNumberInitialVideos() > 0
300  ? $this->media_cast->getNumberInitialVideos()
301  : 1;
302 
303  $this->tpl->addOnLoadCode(
304  "il.VideoPlaylist.init('mcst_playlist', 'mcst_video', " . json_encode(
305  $items
306  ) . ", '$item_content', " . ($autoplay ? "true" : "false") . ", " .
307  (int) $init_videos . ", '" . $this->completed_callback . "', '" . $this->autoplay_callback . "', " . ((int) $mcst_settings->getVideoCompletionThreshold()) . ");"
308  );
309 
310  if (count($items) === 1) {
311  return " ";
312  }
313 
314  return $tpl->get();
315  }
316 
317  return "";
318  }
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...
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
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\MediaCast\Presentation\VideoViewGUI::renderToolbar ( )

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

References Vendor\Package\$f, $id, ILIAS\MediaCast\Presentation\VideoViewGUI\$lng, ILIAS\MediaCast\Presentation\VideoViewGUI\$rss_link, ILIAS\MediaCast\Presentation\VideoViewGUI\$toolbar, ilMediaCastSettings\_getInstance(), ilObjMediaCast\AUTOPLAY_NO, ILIAS\MediaCast\Presentation\VideoViewGUI\getAutoplay(), ILIAS\MediaCast\Presentation\VideoViewGUI\getDropdown(), and ILIAS\Repository\ui().

Referenced by ILIAS\MediaCast\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  }
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\MediaCast\Presentation\VideoViewGUI::setAutoplayCallback ( string  $autoplay_callback)

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

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

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

◆ setCompletedCallback()

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

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

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

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

◆ show()

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

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

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

◆ $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: