ILIAS  release_8 Revision v8.24
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 ()
 

Protected Member Functions

 getAutoplay ()
 

Protected Attributes

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 44 of file class.VideoViewGUI.php.

48 {
49 global $DIC;
50
51 $this->ui = $DIC->ui();
52 $this->rss_link = $rss_link;
53 $this->lng = $DIC->language();
54 $this->media_cast = $obj;
55 $this->tpl = $tpl;
56 $this->video_sequence = new VideoSequence($this->media_cast);
57 $this->user = $DIC->user();
58 $this->main_tpl = $DIC->ui()->mainTemplate();
59 $this->toolbar = $DIC->toolbar();
60 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\MediaCast\Presentation\VideoViewGUI\$rss_link, ILIAS\MediaCast\Presentation\VideoViewGUI\$tpl, 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 151 of file class.VideoViewGUI.php.

151 : bool
152 {
153 $video_cnt = count($this->video_sequence->getVideos());
154 if ($video_cnt <= 1) {
155 return false;
156 }
157 $autoplay = ($this->user->existsPref("mcst_autoplay"))
158 ? (bool) $this->user->getPref("mcst_autoplay")
159 : ($this->media_cast->getAutoplayMode() == \ilObjMediaCast::AUTOPLAY_ACT);
160 if ($this->media_cast->getAutoplayMode() == \ilObjMediaCast::AUTOPLAY_NO) {
161 $autoplay = false;
162 }
163 return $autoplay;
164 }

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:

◆ render()

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

ilTemplateException

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

293 : string
294 {
295 // this is current only to include the resize mechanism when
296 // the main menu is changed, so that the player is resized, too
298 $tpl = new \ilTemplate("tpl.video_cast_layout.html", true, true, "Modules/MediaCast/Presentation");
299 $side_column = $this->renderSideColumn();
300
301
302 if ($side_column != "") {
303 $tpl->setCurrentBlock("with_side_column");
304 $tpl->setVariable("SIDE", $side_column);
305 } else {
306 $tpl->setCurrentBlock("video_only");
307 }
308 $tpl->setVariable("MAIN", $this->renderMainColumn());
310 return $tpl->get();
311 }
static initJavascript(ilGlobalTemplateInterface $a_tpl=null)
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses 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.

References ILIAS\MediaCast\Presentation\VideoViewGUI\$tpl, ilGlobalTemplateInterface\get(), ilMediaPlayerGUI\initJavascript(), ILIAS\MediaCast\Presentation\VideoViewGUI\renderMainColumn(), ILIAS\MediaCast\Presentation\VideoViewGUI\renderSideColumn(), ilGlobalTemplateInterface\setCurrentBlock(), and ilGlobalTemplateInterface\setVariable().

+ Here is the call graph for this function:

◆ renderMainColumn()

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

ilTemplateException

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

75 : string
76 {
77 if (count($this->video_sequence->getVideos()) == 0) {
78 return "";
79 }
80
81 $widget = new VideoWidgetGUI($this->tpl, "mcst_video");
82 $widget->setVideo($this->video_sequence->getFirst());
83 return $widget->render();
84 }

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 166 of file class.VideoViewGUI.php.

166 : string
167 {
168 $mcst_settings = \ilMediaCastSettings::_getInstance();
169
170 $autoplay = $this->getAutoplay();
171
173 $tpl = new \ilTemplate("tpl.video_cast_side.html", true, true, "Modules/MediaCast/Presentation");
174
175 $factory = $this->ui->factory();
176 $renderer = $this->ui->renderer();
177
178 // items
179 $items = [];
180 $has_items = false;
181
182 $panel_items = [];
183
184 foreach ($this->video_sequence->getVideos() as $video) {
185 $has_items = true;
186 $preview = new VideoPreviewGUI(
187 $video->getPreviewPic(),
188 "il.VideoPlaylist.toggleItem('mcst_playlist', '" . $video->getId() . "');",
189 $video->getPlayingTime()
190 );
191 $completed = false;
192
193 $re = \ilChangeEvent::_lookupReadEvents($video->getId(), $this->user->getId());
194 if (count($re) > 0) {
195 if ($re[0]["read_count"] > 0) {
196 $completed = true;
197 }
198 }
199
200 $b = $factory->button()->shy($video->getTitle(), "")->withOnLoadCode(function ($id) use ($video) {
201 return
202 "$(\"#$id\").click(function() { il.VideoPlaylist.toggleItem('mcst_playlist', '" . $video->getId() . "'); return false;});";
203 });
204
205 $items[] = [
206 "id" => $video->getId(),
207 "resource" => $video->getResource(),
208 "preview" => $preview->render(),
209 "preview_pic" => $video->getPreviewPic(),
210 "title" => $video->getTitle(),
211 "linked_title" => $renderer->renderAsync($b),
212 "mime" => $video->getMime(),
213 "poster" => $video->getPreviewPic(),
214 "description" => nl2br($video->getDescription()),
215 "completed" => $completed,
216 "duration" => $video->getDuration()
217 ];
218 }
219
220 $panel = $factory->panel()->secondary()->listing(
221 "Videos",
222 []
223 );
224 $panel_html = $renderer->render($panel);
225 $panel_html = str_replace(
226 '<div class="panel-body">',
227 '<div class="panel-body"><div id="mcst_playlist"></div>',
228 $panel_html,
229 );
230
231 $tpl->setVariable("PANEL", $panel_html);
232 // previous items / next items links
233 if ($has_items) {
235 "PREV",
236 $renderer->render(
237 $factory->button()->standard($lng->txt("mcst_prev_items"), "")->withOnLoadCode(
238 function ($id) {
239 return
240 "$(\"#$id\").click(function() { il.VideoPlaylist.previousItems('mcst_playlist'); return false;});";
241 }
242 )
243 )
244 );
246 "NEXT",
247 $renderer->render(
248 $factory->button()->standard($lng->txt("mcst_next_items"), "")->withOnLoadCode(
249 function ($id) {
250 return
251 "$(\"#$id\").click(function() { il.VideoPlaylist.nextItems('mcst_playlist'); return false;});";
252 }
253 )
254 )
255 );
256
257 $item_tpl = new \ilTemplate("tpl.playlist_item.html", true, true, "Modules/MediaCast/Video");
258 $item_tpl->setVariable("TITLE", " ");
259 $item_content = str_replace("\n", "", $item_tpl->get());
260
261 $item = $factory->item()->standard("#video-title#")
262 ->withLeadImage(
263 $factory->image()->responsive("#img-src#", "#img-alt#")
264 );
265
266 $item_content = $renderer->render($item);
267 $item_content = str_replace("\n", "", $item_content);
268
269 $init_videos = $this->media_cast->getNumberInitialVideos() > 0
270 ? $this->media_cast->getNumberInitialVideos()
271 : 1;
272
273 $this->tpl->addOnLoadCode(
274 "il.VideoPlaylist.init('mcst_playlist', 'mcst_video', " . json_encode(
275 $items
276 ) . ", '$item_content', " . ($autoplay ? "true" : "false") . ", " .
277 (int) $init_videos . ", '" . $this->completed_callback . "', '" . $this->autoplay_callback . "', " . ((int) $mcst_settings->getVideoCompletionThreshold()) . ");"
278 );
279
280 if (count($items) === 1) {
281 return " ";
282 }
283
284 return $tpl->get();
285 }
286
287 return "";
288 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
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...
$preview
Definition: imgupload.php:81
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
$factory
Definition: metadata.php:75

References Vendor\Package\$b, $factory, $id, ILIAS\MediaCast\Presentation\VideoViewGUI\$lng, $panel, $preview, ILIAS\MediaCast\Presentation\VideoViewGUI\$tpl, ilMediaCastSettings\_getInstance(), ilChangeEvent\_lookupReadEvents(), function, ilGlobalTemplateInterface\get(), ILIAS\MediaCast\Presentation\VideoViewGUI\getAutoplay(), ilGlobalTemplateInterface\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 86 of file class.VideoViewGUI.php.

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

References Vendor\Package\$f, $factory, $id, ILIAS\MediaCast\Presentation\VideoViewGUI\$lng, ILIAS\MediaCast\Presentation\VideoViewGUI\$toolbar, ilMediaCastSettings\_getInstance(), ilToolbarGUI\addComponent(), ilToolbarGUI\addSeparator(), ilObjMediaCast\AUTOPLAY_NO, ILIAS\MediaCast\Presentation\VideoViewGUI\getAutoplay(), 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 67 of file class.VideoViewGUI.php.

67 : void
68 {
69 $this->autoplay_callback = $autoplay_callback;
70 }

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

◆ setCompletedCallback()

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

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

62 : void
63 {
64 $this->completed_callback = $completed_callback;
65 }

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

◆ show()

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

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

313 : void
314 {
315 if (is_object($this->tpl)) {
316 $this->renderToolbar();
317 $this->tpl->setContent($this->renderMainColumn());
318 $this->tpl->setRightContent($this->renderSideColumn());
319 }
320 }

References 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

◆ $lng

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

◆ $main_tpl

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

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

◆ $media_cast

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

Definition at line 34 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 36 of file class.VideoViewGUI.php.

◆ $user

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

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

◆ $video_sequence

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

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

◆ $video_wrapper_id

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

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


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