19 declare(strict_types=1);
33 protected \ILIAS\HTTP\Services
$http;
34 protected \ILIAS\Data\Factory
$df;
45 protected \ILIAS\MediaObjects\MediaType\MediaTypeManager
$media_type;
51 protected \ILIAS\DI\UIServices
$ui;
55 string $parent_cmd =
"",
56 bool $a_edit_order =
false,
57 bool $a_presentation_mode =
false 61 $this->
ctrl = $DIC->ctrl();
62 $this->
lng = $DIC->language();
63 $this->
access = $DIC->access();
64 $ilCtrl = $DIC->ctrl();
65 $lng = $DIC->language();
66 $this->request = $DIC->mediaCast()
70 $this->
ui = $DIC->ui();
71 $this->edit_order = $a_edit_order;
72 $this->presentation_mode = $a_presentation_mode;
73 $this->mediacast = $parent_gui->
getObject();
74 $this->downloadable = $this->mediacast->getDownloadable();
78 $this->media_type = $DIC->mediaObjects()->internal()->domain()->mediaType();
79 $this->df = new \ILIAS\Data\Factory();
80 $this->
http = $DIC->http();
85 $form_action = $this->df->uri(
86 ILIAS_HTTP_PATH .
'/' .
87 $this->
ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
89 $this->url_builder =
new URLBuilder($form_action);
91 $this->url_builder->acquireParameters(
100 $f = $this->
ui->factory();
101 $c =
$f->table()->column();
103 'title' =>
$c->text($this->
lng->txt(
"title"))->withIsSortable(
false),
104 'type' =>
$c->text($this->
lng->txt(
"type"))->withIsSortable(
false),
105 'size' =>
$c->text($this->
lng->txt(
"size"))->withIsSortable(
false)
107 if ($this->playtime) {
108 $columns[
'playtime'] =
$c->text($this->
lng->txt(
"mcst_play_time"))->withIsSortable(
false);
110 $columns[
'creation_date'] =
$c->text($this->
lng->txt(
"created"))->withIsSortable(
false);
111 $columns[
'update_date'] =
$c->text($this->
lng->txt(
"last_update"))->withIsSortable(
false);
112 if ($this->preview) {
113 $columns[
'preview'] =
$c->text($this->
lng->txt(
"preview"))->withIsSortable(
false);
121 array $visible_column_ids,
125 ?array $additional_parameters
128 foreach ($this->mediacast->getSortedItemsArray() as $item) {
130 if ($cnt < $range->getStart() || $cnt > $range->
getEnd()) {
134 $row_id = (string) $item[
'id'];
136 $med = $mob->getMediaItem(
"Standard");
139 $data[
'title'] = $item[
"title"];
141 if ($item[
"update_date"] !== $item[
"creation_date"]) {
142 $data[
'update_date'] =
145 $data[
'update_date'] =
"-";
147 if ($item[
"playtime"] !==
"00:00:00") {
148 $data[
'playtime'] = $item[
"playtime"];
150 $data[
'playtime'] =
"-";
154 if (is_file($file)) {
155 $size = filesize($file);
156 $size = sprintf(
"%.1f MB", $size / 1024 / 1024);
157 $data[
'size'] = $size;
161 $data[
'type'] = $med->getFormat();
162 if ($mob->getVideoPreviewPic() !==
"") {
164 $image = $this->
ui->factory()->image()->responsive($mob->getVideoPreviewPic(), $item[
"title"]);
165 $html = $this->
ui->renderer()->render($image);
166 $html = str_replace(
"<img ",
"<img style='max-width:150px;' ", $html);
167 $data[
'preview'] = $html;
169 $data[
'preview'] =
"";
173 yield $row_builder->buildDataRow($row_id,
$data);
179 ?array $additional_parameters
181 return count($this->mediacast->getSortedItemsArray());
186 $action = $this->request->getTableAction($this->action_parameter_token->getName());
187 if ($action !==
"") {
191 $this->parent_gui->$action();
197 $f = $this->
ui->factory();
198 $a =
$f->table()->action();
200 $form_action = $this->df->uri(
201 ILIAS_HTTP_PATH .
'/' .
202 $this->
ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
209 $actions[
"editCastItem"] =
$a->single(
210 $this->
lng->txt(
"edit"),
211 $url_builder->
withParameter($action_parameter_token,
"editCastItem"),
215 $actions[
"showCastItem"] =
$a->single(
216 $this->
lng->txt(
"show"),
217 $url_builder->
withParameter($action_parameter_token,
"showCastItem"),
221 if ($this->playtime) {
222 $actions[
"determinePlaytime"] =
$a->single(
223 $this->
lng->txt(
"mcst_det_playtime"),
224 $url_builder->
withParameter($action_parameter_token,
"determinePlaytime"),
229 if ($this->downloadable) {
230 $actions[
"downloadItem"] =
$a->single(
231 $this->
lng->txt(
"download"),
232 $url_builder->
withParameter($action_parameter_token,
"downloadItem"),
237 $actions[
"confirmItemDeletion"] =
$a->standard(
238 $this->
lng->txt(
"delete"),
239 $url_builder->
withParameter($action_parameter_token,
"confirmItemDeletion"),
244 ->data($this->
lng->txt(
"mcst_items"), $this->
getColumns(), $this)
245 ->withActions($actions)
246 ->withRequest($this->
http->request());
250 protected function fillRow(array $a_set): void
259 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
261 if ($this->presentation_mode) {
262 $ilCtrl->setParameterByClass(
"ilobjmediacastgui",
"presentation",
"1");
266 if ($enable_internal_rss && !$this->presentation_mode) {
267 $this->tpl->setCurrentBlock(
"access");
268 $this->tpl->setVariable(
"TXT_ACCESS", $lng->
txt(
"news_news_item_visibility"));
270 $this->tpl->setVariable(
"VAL_ACCESS", $lng->
txt(
"news_visibility_public"));
272 $this->tpl->setVariable(
"VAL_ACCESS", $lng->
txt(
"news_visibility_users"));
274 $this->tpl->parseCurrentBlock();
277 $ilCtrl->setParameterByClass(
"ilobjmediacastgui",
"item_id",
"");
282 $med = $mob->getMediaItem(
"Standard");
284 $this->tpl->setVariable(
289 $this->tpl->setVariable(
291 $lng->
txt(
"mcst_play_time")
294 if (!$this->edit_order) {
295 if ($this->downloadable) {
296 $ilCtrl->setParameterByClass(
"ilobjmediacastgui",
"item_id", $a_set[
"id"]);
300 $a_mob = $mob->getMediaItem($purpose);
301 if (!is_object($a_mob)) {
304 $ilCtrl->setParameterByClass(
"ilobjmediacastgui",
"purpose", $a_mob->getPurpose());
306 $this->tpl->setCurrentBlock(
"downloadable");
307 $this->tpl->setVariable(
"TXT_DOWNLOAD", $lng->
txt(
"mcst_download_" . strtolower($a_mob->getPurpose())));
308 $this->tpl->setVariable(
"CMD_DOWNLOAD", $ilCtrl->getLinkTargetByClass(
"ilobjmediacastgui",
"downloadItem"));
309 $this->tpl->parseCurrentBlock();
315 ? $ilCtrl->getLinkTarget($this->parent_obj,
"handlePlayerEvent",
"",
true,
false)
317 if (!is_null($med)) {
318 if ($med->getLocationType() ===
"Reference") {
319 $file = $med->getLocation();
320 if (in_array($med->getFormat(), [
"video/vimeo",
"video/youtube"])) {
321 if (!is_int(strpos($file,
"?"))) {
322 $file .=
"?controls=0";
324 $file .=
"&controls=0";
333 if ($this->media_type->isAudio($med->getFormat())) {
334 $comp = $ui->factory()->player()->audio(
338 } elseif ($this->media_type->isVideo($med->getFormat())) {
339 $comp = $ui->factory()->player()->video(
342 } elseif ($this->media_type->isImage($med->getFormat())) {
343 $comp = $ui->factory()->image()->responsive($file,
"");
345 if (!is_null($comp)) {
346 $this->tpl->setVariable(
"PLAYER", $ui->renderer()->render($comp));
351 $ilCtrl->setParameterByClass(
"ilobjmediacastgui",
"item_id", $a_set[
"id"]);
352 if ($ilAccess->checkAccess(
"write",
"", $this->request->getRefId()) &&
353 !$this->presentation_mode) {
355 if (!is_int(strpos($med->getFormat(),
"image/"))) {
356 $this->tpl->setVariable(
"TXT_DET_PLAYTIME", $lng->
txt(
"mcst_det_playtime"));
357 $this->tpl->setVariable(
359 $ilCtrl->getLinkTargetByClass(
"ilobjmediacastgui",
"determinePlaytime")
362 $this->tpl->parseCurrentBlock();
364 $this->tpl->setCurrentBlock(
"edit_checkbox");
365 $this->tpl->setVariable(
"VAL_ID", $a_set[
"id"]);
366 $this->tpl->parseCurrentBlock();
370 $this->tpl->setCurrentBlock(
"edit_order");
371 $this->tpl->setVariable(
"VAL_ID", $a_set[
"id"]);
372 $this->tpl->setVariable(
"VAL_ORDER", $a_set[
"order"]);
373 $this->tpl->parseCurrentBlock();
378 if (!$this->presentation_mode) {
379 if ($a_set[
"mob_cnt_download"] > 0) {
380 $this->tpl->setCurrentBlock(
"prop");
381 $this->tpl->setVariable(
"TXT_PROP", $lng->
txt(
"mcst_download_cnt"));
382 $this->tpl->setVariable(
"VAL_PROP", $a_set[
"mob_cnt_download"]);
383 $this->tpl->parseCurrentBlock();
385 if ($a_set[
"mob_cnt_play"] > 0) {
386 $this->tpl->setCurrentBlock(
"prop");
387 $this->tpl->setVariable(
"TXT_PROP", $lng->
txt(
"mcst_play_cnt"));
388 $this->tpl->setVariable(
"VAL_PROP", $a_set[
"mob_cnt_play"]);
389 $this->tpl->parseCurrentBlock();
This describes a Data Table.
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...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
getEnd()
getEnd will return the (excluded) endpoint.
Both the subject and the direction need to be specified when expressing an order. ...
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static http()
Fetches the global http state from ILIAS.
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
static signFile(string $path_to_file)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
A simple class to express a range of whole positive numbers.