ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMediaCastManageTableGUI Class Reference
+ Inheritance diagram for ilMediaCastManageTableGUI:
+ Collaboration diagram for ilMediaCastManageTableGUI:

Public Member Functions

 __construct (ilObjMediaCastGUI $parent_gui, string $parent_cmd="", bool $a_edit_order=false, bool $a_presentation_mode=false)
 
 getRows (Table\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 
 handleCommand ()
 
 get ()
 

Protected Member Functions

 getColumns ()
 
 fillRow (array $a_set)
 

Protected Attributes

 $parent_obj
 
ilTemplate $tpl
 
URLBuilder $url_builder
 
ILIAS HTTP Services $http
 
ILIAS Data Factory $df
 
string $parent_cmd
 
ilLanguage $lng
 
ilCtrlInterface $ctrl
 
bool $preview
 
bool $playtime
 
ilObjMediaCast $mediacast
 
URLBuilderToken $action_parameter_token
 
URLBuilderToken $row_id_token
 
ilObjMediaCastGUI $parent_gui
 
ILIAS MediaObjects MediaType MediaTypeManager $media_type
 
bool $presentation_mode
 
StandardGUIRequest $request
 
ilAccessHandler $access
 
bool $downloadable = false
 
bool $edit_order
 
ILIAS DI UIServices $ui
 

Detailed Description

Definition at line 28 of file class.ilMediaCastManageTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMediaCastManageTableGUI::__construct ( ilObjMediaCastGUI  $parent_gui,
string  $parent_cmd = "",
bool  $a_edit_order = false,
bool  $a_presentation_mode = false 
)

Definition at line 53 of file class.ilMediaCastManageTableGUI.php.

References $action_parameter_token, $DIC, $parent_cmd, $parent_gui, $row_id_token, $url_builder, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilObjectGUI\getObject(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\ui(), ilObjMediaCast\VIEW_IMG_GALLERY, and ilObjMediaCast\VIEW_PODCAST.

58  {
59  global $DIC;
60 
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()
67  ->internal()
68  ->gui()
69  ->standardRequest();
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();
75 
76  $this->parent_gui = $parent_gui;
77  $this->parent_cmd = $parent_cmd;
78  $this->media_type = $DIC->mediaObjects()->internal()->domain()->mediaType();
79  $this->df = new \ILIAS\Data\Factory();
80  $this->http = $DIC->http();
81 
82  $this->playtime = ($this->mediacast->getViewMode() !== ilObjMediaCast::VIEW_IMG_GALLERY);
83  $this->preview = ($this->mediacast->getViewMode() !== ilObjMediaCast::VIEW_PODCAST);
84 
85  $form_action = $this->df->uri(
86  ILIAS_HTTP_PATH . '/' .
87  $this->ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
88  );
89  $this->url_builder = new URLBuilder($form_action);
91  $this->url_builder->acquireParameters(
92  ["mcst"], // namespace
93  "table_action", //this is the actions's parameter name
94  "ids" //this is the parameter name to be used for row-ids
95  );
96  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
URLBuilder.
Definition: URLBuilder.php:39
+ Here is the call graph for this function:

Member Function Documentation

◆ fillRow()

ilMediaCastManageTableGUI::fillRow ( array  $a_set)
protected

Definition at line 250 of file class.ilMediaCastManageTableGUI.php.

References $access, $ctrl, $lng, $presentation_mode, ilObjMediaCast\$purposes, $ui, ilObject\_exists(), ilObjMediaObject\_getURL(), ilObjMediaObject\_lookupItemPath(), NEWS_PUBLIC, ilWACSignedPath\signFile(), and ilLanguage\txt().

250  : void
251  {
252  $lng = $this->lng;
253  $ilCtrl = $this->ctrl;
254  $ilAccess = $this->access;
255  $size = 0;
256  $ui = $this->ui;
257 
258  $news_set = new ilSetting("news");
259  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
260 
261  if ($this->presentation_mode) {
262  $ilCtrl->setParameterByClass("ilobjmediacastgui", "presentation", "1");
263  }
264 
265  // access
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"));
269  if ($a_set["visibility"] == NEWS_PUBLIC) {
270  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
271  } else {
272  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
273  }
274  $this->tpl->parseCurrentBlock();
275  }
276 
277  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", "");
278 
279  if (ilObject::_exists($a_set["mob_id"])) {
280 
281  $mob = new ilObjMediaObject($a_set["mob_id"]);
282  $med = $mob->getMediaItem("Standard");
283 
284  $this->tpl->setVariable(
285  "VAL_DESCRIPTION",
286  $a_set["content"]
287  );
288 
289  $this->tpl->setVariable(
290  "TXT_DURATION",
291  $lng->txt("mcst_play_time")
292  );
293 
294  if (!$this->edit_order) {
295  if ($this->downloadable) {
296  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
297  // to keep always the order of the purposes
298  // iterate through purposes and display the according mediaitems
299  foreach (ilObjMediaCast::$purposes as $purpose) {
300  $a_mob = $mob->getMediaItem($purpose);
301  if (!is_object($a_mob)) {
302  continue;
303  }
304  $ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", $a_mob->getPurpose());
305  $file = ilObjMediaObject::_lookupItemPath($a_mob->getMobId(), false, false, $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();
310  }
311  }
312 
313  // the news id will be used as player id, see also ilObjMediaCastGUI
314  $event_url = ($this->presentation_mode)
315  ? $ilCtrl->getLinkTarget($this->parent_obj, "handlePlayerEvent", "", true, false)
316  : "";
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";
323  } else {
324  $file .= "&controls=0";
325  }
326  }
327  } else {
329  ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation()
330  );
331  }
332  $comp = null;
333  if ($this->media_type->isAudio($med->getFormat())) {
334  $comp = $ui->factory()->player()->audio(
335  $file,
336  ""
337  );
338  } elseif ($this->media_type->isVideo($med->getFormat())) {
339  $comp = $ui->factory()->player()->video(
340  $file
341  );
342  } elseif ($this->media_type->isImage($med->getFormat())) {
343  $comp = $ui->factory()->image()->responsive($file, "");
344  }
345  if (!is_null($comp)) {
346  $this->tpl->setVariable("PLAYER", $ui->renderer()->render($comp));
347  }
348  }
349 
350  // edit link
351  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
352  if ($ilAccess->checkAccess("write", "", $this->request->getRefId()) &&
353  !$this->presentation_mode) {
354 
355  if (!is_int(strpos($med->getFormat(), "image/"))) {
356  $this->tpl->setVariable("TXT_DET_PLAYTIME", $lng->txt("mcst_det_playtime"));
357  $this->tpl->setVariable(
358  "CMD_DET_PLAYTIME",
359  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "determinePlaytime")
360  );
361  }
362  $this->tpl->parseCurrentBlock();
363 
364  $this->tpl->setCurrentBlock("edit_checkbox");
365  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
366  $this->tpl->parseCurrentBlock();
367  // $this->tpl->touchBlock("contrl_col");
368  }
369  } else {
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();
374  // $this->tpl->touchBlock("contrl_col");
375  }
376 
377  // download and play counter
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();
384  }
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();
390  }
391  }
392  }
393  }
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 _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
const NEWS_PUBLIC
static array $purposes
static _lookupItemPath(int $a_mob_id, bool $a_url_encode=false, bool $a_web=true, string $a_purpose="")
Get path for item with specific purpose.
static signFile(string $path_to_file)
static _getURL(int $a_mob_id)
get directory for files of media object
+ Here is the call graph for this function:

◆ get()

ilMediaCastManageTableGUI::get ( )

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

References Vendor\Package\$a, $action_parameter_token, Vendor\Package\$f, $row_id_token, $url_builder, ILIAS\Repository\ctrl(), getColumns(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\ui(), and ILIAS\UI\URLBuilder\withParameter().

195  : Table\Data
196  {
197  $f = $this->ui->factory();
198  $a = $f->table()->action();
199 
200  $form_action = $this->df->uri(
201  ILIAS_HTTP_PATH . '/' .
202  $this->ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
203  );
204 
208 
209  $actions["editCastItem"] = $a->single(
210  $this->lng->txt("edit"),
213  );
214 
215  $actions["showCastItem"] = $a->single(
216  $this->lng->txt("show"),
219  )->withAsync();
220 
221  if ($this->playtime) {
222  $actions["determinePlaytime"] = $a->single(
223  $this->lng->txt("mcst_det_playtime"),
224  $url_builder->withParameter($action_parameter_token, "determinePlaytime"),
226  );
227  }
228 
229  if ($this->downloadable) {
230  $actions["downloadItem"] = $a->single(
231  $this->lng->txt("download"),
234  );
235  }
236 
237  $actions["confirmItemDeletion"] = $a->standard(
238  $this->lng->txt("delete"),
239  $url_builder->withParameter($action_parameter_token, "confirmItemDeletion"),
241  )->withAsync();
242 
243  $table = $f->table()
244  ->data($this->lng->txt("mcst_items"), $this->getColumns(), $this)
245  ->withActions($actions)
246  ->withRequest($this->http->request());
247  return $table;
248  }
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.
Definition: URLBuilder.php:165
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:

◆ getColumns()

ilMediaCastManageTableGUI::getColumns ( )
protected

Definition at line 98 of file class.ilMediaCastManageTableGUI.php.

References Vendor\Package\$c, Vendor\Package\$f, ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by get().

98  : array
99  {
100  $f = $this->ui->factory();
101  $c = $f->table()->column();
102  $columns = [
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)
106  ];
107  if ($this->playtime) {
108  $columns['playtime'] = $c->text($this->lng->txt("mcst_play_time"))->withIsSortable(false);
109  }
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);
114  }
115 
116  return $columns;
117  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

ilMediaCastManageTableGUI::getRows ( Table\DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
?array  $filter_data,
?array  $additional_parameters 
)

Definition at line 119 of file class.ilMediaCastManageTableGUI.php.

References $data, ilObjMediaObject\_lookupItemPath(), ilDatePresentation\formatDate(), ILIAS\Data\Range\getEnd(), IL_CAL_DATETIME, and ILIAS\Repository\ui().

126  : \Generator {
127  $cnt = 0;
128  foreach ($this->mediacast->getSortedItemsArray() as $item) {
129  $cnt++;
130  if ($cnt < $range->getStart() || $cnt > $range->getEnd()) {
131  continue;
132  }
133 
134  $row_id = (string) $item['id'];
135  $mob = new ilObjMediaObject($item["mob_id"]);
136  $med = $mob->getMediaItem("Standard");
137 
138 
139  $data['title'] = $item["title"];
140  $data['creation_date'] = ilDatePresentation::formatDate(new ilDateTime($item["creation_date"], IL_CAL_DATETIME));
141  if ($item["update_date"] !== $item["creation_date"]) {
142  $data['update_date'] =
143  ilDatePresentation::formatDate(new ilDateTime($item["update_date"], IL_CAL_DATETIME));
144  } else {
145  $data['update_date'] = "-";
146  }
147  if ($item["playtime"] !== "00:00:00") {
148  $data['playtime'] = $item["playtime"];
149  } else {
150  $data['playtime'] = "-";
151  }
152 
153  $file = ilObjMediaObject::_lookupItemPath($med->getMobId(), false, false, "Standard");
154  if (is_file($file)) {
155  $size = filesize($file);
156  $size = sprintf("%.1f MB", $size / 1024 / 1024);
157  $data['size'] = $size;
158  } else {
159  $data['size'] = "-";
160  }
161  $data['type'] = $med->getFormat();
162  if ($mob->getVideoPreviewPic() !== "") {
163  // workaround since we dont have image columns yet
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;
168  } else {
169  $data['preview'] = "";
170  }
171 
172 
173  yield $row_builder->buildDataRow($row_id, $data);
174  }
175  }
const IL_CAL_DATETIME
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.
Definition: Range.php:76
static _lookupItemPath(int $a_mob_id, bool $a_url_encode=false, bool $a_web=true, string $a_purpose="")
Get path for item with specific purpose.
+ Here is the call graph for this function:

◆ getTotalRowCount()

ilMediaCastManageTableGUI::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

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

180  : ?int {
181  return count($this->mediacast->getSortedItemsArray());
182  }

◆ handleCommand()

ilMediaCastManageTableGUI::handleCommand ( )

Definition at line 184 of file class.ilMediaCastManageTableGUI.php.

184  : void
185  {
186  $action = $this->request->getTableAction($this->action_parameter_token->getName());
187  if ($action !== "") {
188  $action .= "Object";
189  // currently done in request wrapper
190  //$ids = $this->request->getTableIds($this->row_id_token->getName());
191  $this->parent_gui->$action();
192  }
193  }

Field Documentation

◆ $access

ilAccessHandler ilMediaCastManageTableGUI::$access
protected

Definition at line 48 of file class.ilMediaCastManageTableGUI.php.

Referenced by fillRow().

◆ $action_parameter_token

URLBuilderToken ilMediaCastManageTableGUI::$action_parameter_token
protected

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

Referenced by __construct(), and get().

◆ $ctrl

ilCtrlInterface ilMediaCastManageTableGUI::$ctrl
protected

Definition at line 37 of file class.ilMediaCastManageTableGUI.php.

Referenced by fillRow().

◆ $df

ILIAS Data Factory ilMediaCastManageTableGUI::$df
protected

Definition at line 34 of file class.ilMediaCastManageTableGUI.php.

◆ $downloadable

bool ilMediaCastManageTableGUI::$downloadable = false
protected

Definition at line 49 of file class.ilMediaCastManageTableGUI.php.

◆ $edit_order

bool ilMediaCastManageTableGUI::$edit_order
protected

Definition at line 50 of file class.ilMediaCastManageTableGUI.php.

◆ $http

ILIAS HTTP Services ilMediaCastManageTableGUI::$http
protected

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

◆ $lng

ilLanguage ilMediaCastManageTableGUI::$lng
protected

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

Referenced by fillRow().

◆ $media_type

ILIAS MediaObjects MediaType MediaTypeManager ilMediaCastManageTableGUI::$media_type
protected

Definition at line 45 of file class.ilMediaCastManageTableGUI.php.

◆ $mediacast

ilObjMediaCast ilMediaCastManageTableGUI::$mediacast
protected

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

◆ $parent_cmd

string ilMediaCastManageTableGUI::$parent_cmd
protected

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

Referenced by __construct().

◆ $parent_gui

ilObjMediaCastGUI ilMediaCastManageTableGUI::$parent_gui
protected

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

Referenced by __construct().

◆ $parent_obj

ilMediaCastManageTableGUI::$parent_obj
protected

Definition at line 30 of file class.ilMediaCastManageTableGUI.php.

◆ $playtime

bool ilMediaCastManageTableGUI::$playtime
protected

Definition at line 39 of file class.ilMediaCastManageTableGUI.php.

◆ $presentation_mode

bool ilMediaCastManageTableGUI::$presentation_mode
protected

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

Referenced by fillRow().

◆ $preview

bool ilMediaCastManageTableGUI::$preview
protected

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

◆ $request

StandardGUIRequest ilMediaCastManageTableGUI::$request
protected

Definition at line 47 of file class.ilMediaCastManageTableGUI.php.

◆ $row_id_token

URLBuilderToken ilMediaCastManageTableGUI::$row_id_token
protected

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

Referenced by __construct(), and get().

◆ $tpl

ilTemplate ilMediaCastManageTableGUI::$tpl
protected

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

◆ $ui

ILIAS DI UIServices ilMediaCastManageTableGUI::$ui
protected

Definition at line 51 of file class.ilMediaCastManageTableGUI.php.

Referenced by fillRow().

◆ $url_builder

URLBuilder ilMediaCastManageTableGUI::$url_builder
protected

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

Referenced by __construct(), and get().


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