ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilMediaCreationGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
28 
34 {
35  public const TYPE_VIDEO = 1;
36  public const TYPE_AUDIO = 2;
37  public const TYPE_IMAGE = 3;
38  public const TYPE_OTHER = 4;
39  public const TYPE_ALL = 5;
40  public const POOL_VIEW_FOLDER = "fold";
41  public const POOL_VIEW_ALL = "all";
42  protected \ILIAS\MediaObjects\MediaType\MediaTypeManager $type_manager;
44  protected ?FormAdapterGUI $bulk_upload_form = null;
46 
47  protected array $accept_types = [1,2,3,4];
48  protected ilLanguage $lng;
49  protected ilCtrl $ctrl;
60  protected array $all_suffixes = [];
64  protected array $all_mime_types = [];
65  protected \ILIAS\DI\UIServices $ui;
66  protected int $requested_mep;
67  protected string $pool_view = self::POOL_VIEW_FOLDER;
68  protected \ILIAS\FileUpload\FileUpload $upload;
69  protected ilLogger $mob_log;
70 
71  public function __construct(
72  array $accept_types,
73  Closure $after_upload,
74  Closure $after_url_saving,
75  Closure $after_pool_insert,
76  Closure $finish_single_upload = null,
77  Closure $on_mob_update = null
78  ) {
79  global $DIC;
80 
81  $this->lng = $DIC->language();
82  $this->lng->loadLanguageModule("mob");
83  $this->lng->loadLanguageModule("content");
84  $this->access = $DIC->access();
85 
86  $this->ctrl = $DIC->ctrl();
87  $this->main_tpl = $DIC->ui()->mainTemplate();
88  $this->ui = $DIC->ui();
89  $this->upload = $DIC->upload();
90  $this->mob_log = $DIC->logger()->mob();
91 
92  $this->accept_types = $accept_types;
93  $this->after_upload = $after_upload;
94  $this->after_url_saving = $after_url_saving;
95  $this->after_pool_insert = $after_pool_insert;
96  $this->finish_single_upload = $finish_single_upload;
97  $this->on_mob_update = $on_mob_update;
98  $this->type_manager = $DIC->mediaObjects()
99  ->internal()
100  ->domain()
101  ->mediaType();
102 
103  $this->ctrl->saveParameter($this, ["mep", "pool_view"]);
104 
105  $this->request = $DIC->mediaObjects()
106  ->internal()
107  ->gui()
108  ->creation()
109  ->request();
110 
111  $this->requested_mep = $this->request->getMediaPoolId();
112  $this->ctrl->setParameter($this, "mep", $this->requested_mep);
113 
114  $pv = $this->request->getPoolView();
115  $this->pool_view = (in_array($pv, [self::POOL_VIEW_FOLDER, self::POOL_VIEW_ALL]))
116  ? $pv
117  : self::POOL_VIEW_FOLDER;
118  $this->gui = $DIC->mediaObjects()->internal()->gui();
119  }
120 
121  public function setAllSuffixes(
122  array $a_val
123  ): void {
124  $this->all_suffixes = $a_val;
125  }
126 
127  public function getAllSuffixes(): array
128  {
129  return $this->all_suffixes;
130  }
131 
132  public function setAllMimeTypes(
133  array $a_val
134  ): void {
135  $this->all_mime_types = $a_val;
136  }
137 
141  public function getAllMimeTypes(): array
142  {
143  return $this->all_mime_types;
144  }
145 
149  protected function getSuffixes(): array
150  {
151  $suffixes = [];
152  if (in_array(self::TYPE_ALL, $this->accept_types, true)) {
153  $suffixes = iterator_to_array($this->type_manager->getAllowedSuffixes());
154  }
155  if (in_array(self::TYPE_VIDEO, $this->accept_types, true)) {
156  $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedVideoSuffixes()));
157  }
158  if (in_array(self::TYPE_AUDIO, $this->accept_types, true)) {
159  $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedAudioSuffixes()));
160  }
161  if (in_array(self::TYPE_IMAGE, $this->accept_types, true)) {
162  $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedImageSuffixes()));
163  }
164  return $suffixes;
165  }
166 
170  protected function getMimeTypes($local_only = false): array
171  {
172  $mimes = [];
173  if (in_array(self::TYPE_ALL, $this->accept_types)) {
174  $mimes = iterator_to_array($this->type_manager->getAllowedMimeTypes());
175  }
176  if (in_array(self::TYPE_VIDEO, $this->accept_types)) {
177  $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedVideoMimeTypes($local_only)));
178  }
179  if (in_array(self::TYPE_AUDIO, $this->accept_types)) {
180  $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedAudioMimeTypes()));
181  }
182  if (in_array(self::TYPE_IMAGE, $this->accept_types)) {
183  $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedImageMimeTypes()));
184  }
185  return $mimes;
186  }
187 
188  public function executeCommand(): void
189  {
190  $ctrl = $this->ctrl;
191 
192  $next_class = $ctrl->getNextClass($this);
193  $cmd = $ctrl->getCmd("creationSelection");
194 
195  switch ($next_class) {
196  case "ilpropertyformgui":
197  $form = $this->initPoolSelection();
198  $ctrl->forwardCommand($form);
199  break;
200 
201  case strtolower(ilRepoStandardUploadHandlerGUI::class):
202  $form = $this->getUploadForm();
203  $gui = $form->getRepoStandardUploadHandlerGUI("media_files");
204  $this->ctrl->forwardCommand($gui);
205  break;
206 
207  default:
208  if (in_array($cmd, ["creationSelection", "uploadFile", "saveUrl", "cancel", "cancelCreate", "listPoolItems",
209  "insertFromPool", "poolSelection", "selectPool", "applyFilter", "resetFilter", "performBulkUpload",
210  "editTitlesAndDescriptions", "saveTitlesAndDescriptions"])) {
211  $this->$cmd();
212  }
213  }
214  }
215 
216  protected function creationSelection(): void
217  {
218  $main_tpl = $this->main_tpl;
219 
220  $acc = new \ilAccordionGUI();
221  $acc->setBehaviour(\ilAccordionGUI::FIRST_OPEN);
222  $cnt = 1;
223  $forms = [
224  $this->getUploadForm(),
225  $this->initUrlForm(),
226  $this->initPoolSelection()
227  ];
228  foreach ($forms as $form_type => $cf) {
229  $htpl = new \ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
230 
231  // using custom form titles (used for repository plugins)
232  $form_title = "";
233  if (method_exists($this, "getCreationFormTitle")) {
234  $form_title = $this->getCreationFormTitle($form_type);
235  }
236  if (!$form_title) {
237  $form_title = $cf->getTitle();
238  }
239 
240  // move title from form to accordion
241  $htpl->setVariable("TITLE", $this->lng->txt("option") . " " . $cnt . ": " .
242  $form_title);
243  if (!($cf instanceof FormAdapterGUI)) {
244  $cf->setTitle("");
245  $cf->setTitleIcon("");
246  $cf->setTableWidth("100%");
247 
248  $acc->addItem($htpl->get(), $cf->getHTML());
249  } else {
250  $acc->addItem($htpl->get(), $cf->render());
251  }
252 
253  $cnt++;
254  }
255  $main_tpl->setContent($acc->getHTML());
256  }
257 
258  public function getUploadForm(): FormAdapterGUI
259  {
260  // $item->setSuffixes($this->getSuffixes());
261  if (is_null($this->bulk_upload_form)) {
262  $mep_hash = uniqid();
263  $this->ctrl->setParameter($this, "mep_hash", $mep_hash);
264  $this->bulk_upload_form = $this->gui
265  ->form(self::class, 'performBulkUpload')
266  ->section("props", $this->lng->txt('mob_upload_file'))
267  ->file(
268  "media_files",
269  $this->lng->txt("files"),
270  \Closure::fromCallable([$this, 'handleUploadResult']),
271  "mep_id",
272  "",
273  20,
274  $this->getMimeTypes(true)
275  )->required();
276  // ->meta()->text()->meta()->textarea()
277  }
279  }
280 
281  public function initUrlForm(): ilPropertyFormGUI
282  {
283  $ctrl = $this->ctrl;
284  $lng = $this->lng;
285 
286  $form = new \ilPropertyFormGUI();
287 
288  //
289  $ti = new \ilTextInputGUI($lng->txt("mob_url"), "url");
290  $info = $lng->txt("mob_url_info1") . " " . implode(", ", $this->getSuffixes()) . ".";
291  if (in_array(self::TYPE_VIDEO, $this->accept_types)) {
292  $info .= " " . $lng->txt("mob_url_info_video");
293  }
294  $ti->setInfo($info);
295  $ti->setRequired(true);
296  $form->addItem($ti);
297 
298  $form->addCommandButton("saveUrl", $lng->txt("save"));
299  $form->addCommandButton("cancel", $lng->txt("cancel"));
300 
301  $form->setTitle($lng->txt("mob_external_url"));
302  $form->setFormAction($ctrl->getFormAction($this));
303 
304  return $form;
305  }
306 
308  {
309  $ctrl = $this->ctrl;
310  $lng = $this->lng;
311 
312  $form = new \ilPropertyFormGUI();
313 
314  $mcst = new ilRepositorySelector2InputGUI(
315  $lng->txt("obj_mep"),
316  "mep",
317  false,
318  $form
319  );
320  $exp = $mcst->getExplorerGUI();
321  $exp->setSelectableTypes(["mep"]);
322  $exp->setTypeWhiteList(["root", "mep", "cat", "crs", "grp", "fold"]);
323  $mcst->setRequired(true);
324  $form->addItem($mcst);
325 
326  $form->addCommandButton("listPoolItems", $lng->txt("continue"));
327  $form->addCommandButton("cancel", $lng->txt("cancel"));
328 
329  $form->setTitle($lng->txt("mob_choose_from_pool"));
330  $form->setFormAction($ctrl->getFormAction($this));
331 
332  return $form;
333  }
334 
335  /*
336  protected function uploadFile() : void
337  {
338  $form = $this->initUploadForm();
339 
340  if (!$form->checkInput()) {
341  $form->setValuesByPost();
342  $this->main_tpl->setContent($form->getHTML());
343  //$this->creationSelection();
344  } else {
345  $mob = new ilObjMediaObject();
346  $mob->create();
347 
348  //handle standard purpose
349  $mediaItem = new ilMediaItem();
350  $mob->addMediaItem($mediaItem);
351  $mediaItem->setPurpose("Standard");
352 
353  // determine and create mob directory, move uploaded file to directory
354  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
355  if (!is_dir($mob_dir)) {
356  $mob->createDirectory();
357  }
358  $file_name = ilFileUtils::getASCIIFilename($_FILES['file']["name"]);
359  $file_name = str_replace(" ", "_", $file_name);
360 
361  $file = $mob_dir . "/" . $file_name;
362  $title = $file_name;
363  $locationType = "LocalFile";
364  $location = $title;
365  ilFileUtils::moveUploadedFile($_FILES['file']['tmp_name'], $file_name, $file);
366  ilFileUtils::renameExecutables($mob_dir);
367 
368  // get mime type, if not already set!
369  $format = ilObjMediaObject::getMimeType($file, false);
370 
371  // set real meta and object data
372  $mediaItem->setFormat($format);
373  $mediaItem->setLocation($location);
374  $mediaItem->setLocationType($locationType);
375  $mediaItem->setHAlign("Left");
376  $mob->setTitle($title);
377 
378  $mob->update();
379 
380  // preview pic
381  $mob = new ilObjMediaObject($mob->getId());
382  $mob->generatePreviewPic(320, 240);
383 
384  // duration
385  $med_item = $mob->getMediaItem("Standard");
386  $med_item->determineDuration();
387  $med_item->update();
388 
389  //
390  // @todo: save usage
391  //
392 
393  ($this->after_upload)($mob->getId());
394  }
395  }*/
396 
397  protected function handleUploadResult(
398  FileUpload $upload,
399  UploadResult $result
400  ): BasicHandlerResult {
401  $title = $result->getName();
402 
403  $mob = new ilObjMediaObject();
404  $mob->setTitle($title);
405  $mob->setDescription("");
406  $mob->create();
407 
408  $mob->createDirectory();
409  $media_item = new ilMediaItem();
410  $mob->addMediaItem($media_item);
411  $media_item->setPurpose("Standard");
412 
413  $mob_dir = ilObjMediaObject::_getRelativeDirectory($mob->getId());
414  $file_name = ilObjMediaObject::fixFilename($title);
415  $file = $mob_dir . "/" . $file_name;
416 
417  $upload->moveOneFileTo(
418  $result,
419  $mob_dir,
420  Location::WEB,
421  $file_name,
422  true
423  );
424 
425  // get mime type
426  $format = ilObjMediaObject::getMimeType($file);
427  $location = $file_name;
428 
429  // set real meta and object data
430  $media_item->setFormat($format);
431  $media_item->setLocation($location);
432  $media_item->setLocationType("LocalFile");
433  $media_item->setUploadHash($this->request->getUploadHash());
434  $mob->update();
435  $item_ids[] = $mob->getId();
436 
437  $mob = new ilObjMediaObject($mob->getId());
438  $mob->generatePreviewPic(320, 240);
439 
440  // duration
441  $med_item = $mob->getMediaItem("Standard");
442  $med_item->determineDuration();
443  $med_item->update();
444 
445  ($this->after_upload)([$mob->getId()]);
446 
447  return new BasicHandlerResult(
448  "mep_id",
449  HandlerResult::STATUS_OK,
450  $med_item->getId(),
451  ''
452  );
453  }
454 
458  public function performBulkUpload(): void
459  {
460  $form = $this->getUploadForm();
461  if (!$form->isValid()) {
462  $this->main_tpl->setContent($form->render());
463  return;
464  }
465 
466  $this->ctrl->setParameter($this, "mep_hash", $this->request->getUploadHash());
467  $this->ctrl->redirect($this, "editTitlesAndDescriptions");
468  }
469 
470 
471  protected function editTitlesAndDescriptions(): void
472  {
473  $ctrl = $this->ctrl;
474  $lng = $this->lng;
475 
476  $ctrl->saveParameter($this, "mep_hash");
477 
478  $main_tpl = $this->main_tpl;
479 
480  $media_items = ilMediaItem::getMediaItemsForUploadHash($this->request->getUploadHash());
481 
482  $tb = new ilToolbarGUI();
483  $tb->setFormAction($ctrl->getFormAction($this));
484  $tb->addFormButton($lng->txt("save"), "saveTitlesAndDescriptions");
485  $tb->setOpenFormTag(true);
486  $tb->setCloseFormTag(false);
487  $tb->setId("tb_top");
488 
489  if (count($media_items) == 1 && $this->finish_single_upload) {
490  $mi = current($media_items);
491  ($this->finish_single_upload)($mi["mob_id"]);
492  return;
493  }
494 
495  $html = $tb->getHTML();
496  foreach ($media_items as $mi) {
497  $acc = new ilAccordionGUI();
498  $acc->setBehaviour(ilAccordionGUI::ALL_CLOSED);
499  $acc->setId("acc_" . $mi["mob_id"]);
500 
501  $mob = new ilObjMediaObject($mi["mob_id"]);
502  $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
503  $acc->addItem($mob->getTitle(), $form->getHTML());
504 
505  $html .= $acc->getHTML();
506  }
507 
508  $html .= $tb->getHTML();
509  $tb->setOpenFormTag(false);
510  $tb->setCloseFormTag(true);
511  $tb->setId("tb_bottom");
512 
513  $main_tpl->setContent($html);
514  }
515 
516  public function initMediaBulkForm(string $a_id, string $a_title): ilPropertyFormGUI
517  {
518  $lng = $this->lng;
519 
520  $form = new ilPropertyFormGUI();
521  $form->setOpenTag(false);
522  $form->setCloseTag(false);
523 
524  // title
525  $ti = new ilTextInputGUI($lng->txt("title"), "title_" . $a_id);
526  $ti->setValue($a_title);
527  $form->addItem($ti);
528 
529  // description
530  $ti = new ilTextAreaInputGUI($lng->txt("description"), "description_" . $a_id);
531  $form->addItem($ti);
532 
533  return $form;
534  }
535 
536  protected function saveTitlesAndDescriptions(): void
537  {
538  $lng = $this->lng;
539  $ctrl = $this->ctrl;
540 
541  $media_items = ilMediaItem::getMediaItemsForUploadHash($this->request->getUploadHash());
542 
543  foreach ($media_items as $mi) {
544  $mob = new ilObjMediaObject($mi["mob_id"]);
545  $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
546  $form->checkInput();
547  $title = $form->getInput("title_" . $mi["mob_id"]);
548  $desc = $form->getInput("description_" . $mi["mob_id"]);
549  if (trim($title) != "") {
550  $mob->setTitle($title);
551  }
552  $mob->setDescription($desc);
553  $mob->update();
554  ($this->on_mob_update)($mob->getId());
555  }
556  $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
557  $ctrl->returnToParent($this);
558  }
559 
560  protected function cancel(): void
561  {
562  $ctrl = $this->ctrl;
563  $ctrl->returnToParent($this);
564  }
565 
566  protected function cancelCreate(): void
567  {
568  $ctrl = $this->ctrl;
569  $ctrl->returnToParent($this);
570  }
571 
572  protected function saveUrl(): void
573  {
574  $form = $this->initUrlForm();
575 
576  if (!$form->checkInput()) {
577  $form->setValuesByPost();
578  $this->main_tpl->setContent($form->getHTML());
579  } else {
580  $mob = new ilObjMediaObject();
581  $mob->create();
582 
583  //handle standard purpose
584  $mediaItem = new ilMediaItem();
585  $mob->addMediaItem($mediaItem);
586  $mediaItem->setPurpose("Standard");
587 
588  // determine and create mob directory, move uploaded file to directory
589  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
590  if (!is_dir($mob_dir)) {
591  $mob->createDirectory();
592  }
593  $locationType = "Reference";
594  $url = $form->getInput("url");
595  $url_pi = pathinfo(basename($url));
596  $title = str_replace("_", " ", $url_pi["filename"]);
597 
598  // get mime type, if not already set!
599  $format = ilObjMediaObject::getMimeType($url, true);
600  if (!in_array($format, $this->getMimeTypes())) {
601  $this->main_tpl->setOnScreenMessage(
602  "failure",
603  $this->lng->txt("mob_type_not_supported") . " " . $format
604  );
605  $form->setValuesByPost();
606  $this->main_tpl->setContent($form->getHTML());
607  return;
608  }
609  // set real meta and object data
610  $mediaItem->setFormat($format);
611  $mediaItem->setLocation($url);
612  $mediaItem->setLocationType("Reference");
613  $mediaItem->setHAlign("Left");
614  $mob->setTitle($title);
615  try {
616  $mob->getExternalMetadata();
617  } catch (Exception $e) {
618  $this->main_tpl->setOnScreenMessage('failure', $e->getMessage(), true);
619  $form->setValuesByPost();
620  $this->main_tpl->setContent($form->getHTML());
621  return;
622  }
623 
624  $long_desc = $mob->getLongDescription();
625  $mob->update();
626 
627  $mob = new ilObjMediaObject($mob->getId());
628  $mob->generatePreviewPic(320, 240);
629 
630  // duration
631  $med_item = $mob->getMediaItem("Standard");
632  $med_item->determineDuration();
633  $med_item->update();
634 
635  //
636  // @todo: save usage
637  //
638 
639  ($this->after_url_saving)($mob->getId(), $long_desc);
640  }
641  }
642 
646  public function listPoolItems(): void
647  {
648  $ctrl = $this->ctrl;
649  $access = $this->access;
650  $lng = $this->lng;
651  $ui = $this->ui;
652  $main_tpl = $this->main_tpl;
653 
654  $form = $this->initPoolSelection();
655  if ($this->requested_mep === 0) {
656  $this->main_tpl->setOnScreenMessage("failure", $this->lng->txt("mob_please_select_pool"));
657  $form->setValuesByPost();
658  $this->main_tpl->setContent($form->getHTML());
659  return;
660  }
661 
662  if ($this->requested_mep > 0 &&
663  $access->checkAccess("write", "", $this->requested_mep)
664  && ilObject::_lookupType(ilObject::_lookupObjId($this->requested_mep)) == "mep") {
665  $tb = new ilToolbarGUI();
666 
667  // button: select pool
668  $tb->addButton(
669  $lng->txt("cont_switch_to_media_pool"),
670  $ctrl->getLinkTarget($this, "poolSelection")
671  );
672 
673  // view mode: pool view (folders/all media objects)
674  $f = $ui->factory();
675  $lng->loadLanguageModule("mep");
676  $ctrl->setParameter($this, "pool_view", self::POOL_VIEW_FOLDER);
677  $actions[$lng->txt("folders")] = $ctrl->getLinkTarget($this, "listPoolItems");
678  $ctrl->setParameter($this, "pool_view", self::POOL_VIEW_ALL);
679  $actions[$lng->txt("mep_all_mobs")] = $ctrl->getLinkTarget($this, "listPoolItems");
680  $ctrl->setParameter($this, "pool_view", $this->pool_view);
681  $aria_label = $lng->txt("cont_change_pool_view");
682  $view_control = $f->viewControl()->mode($actions, $aria_label)->withActive(($this->pool_view == self::POOL_VIEW_FOLDER)
683  ? $lng->txt("folders") : $lng->txt("mep_all_mobs"));
684  $tb->addSeparator();
685  $tb->addComponent($view_control);
686 
687  $html = $tb->getHTML();
688 
689  $pool_table = $this->getPoolTable();
690 
691  $html .= $pool_table->getHTML();
692 
693  $main_tpl->setContent($html);
694  }
695  }
696 
697  protected function applyFilter(): void
698  {
699  $mpool_table = $this->getPoolTable();
700  $mpool_table->resetOffset();
701  $mpool_table->writeFilterToSession();
702  $this->ctrl->redirect($this, "listPoolItems");
703  }
704 
705  protected function resetFilter(): void
706  {
707  $mpool_table = $this->getPoolTable();
708  $mpool_table->resetOffset();
709  $mpool_table->resetFilter();
710  $this->ctrl->redirect($this, "listPoolItems");
711  }
712 
713  protected function getPoolTable(): ilMediaPoolTableGUI
714  {
715  $pool = new ilObjMediaPool($this->requested_mep);
716  $mpool_table = new ilMediaPoolTableGUI(
717  $this,
718  "listPoolItems",
719  $pool,
720  "mep_folder",
722  $this->pool_view == self::POOL_VIEW_ALL
723  );
724  $mpool_table->setFilterCommand("applyFilter");
725  $mpool_table->setResetCommand("resetFilter");
726  $mpool_table->setInsertCommand("insertFromPool");
727  return $mpool_table;
728  }
729 
733  public function selectPool(): void
734  {
735  $ctrl = $this->ctrl;
736 
737  $ctrl->setParameter($this, "mep", $this->request->getSelectedMediaPoolRefId());
738  $ctrl->redirect($this, "listPoolItems");
739  }
740 
741  public function poolSelection(): void
742  {
743  $main_tpl = $this->main_tpl;
744  $exp = new ilPoolSelectorGUI(
745  $this,
746  "poolSelection",
747  null,
748  "selectPool",
749  "",
750  "mep_ref_id"
751  );
752  $exp->setTypeWhiteList(array("root", "cat", "grp", "fold", "crs", "mep"));
753  $exp->setClickableTypes(array('mep'));
754  if (!$exp->handleCommand()) {
755  $main_tpl->setContent($exp->getHTML());
756  }
757  }
758 
762  protected function insertFromPool(): void
763  {
764  $ids = $this->request->getIds();
765  if (count($ids) == 0) {
766  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"));
767  $this->listPoolItems();
768  return;
769  }
770  $mob_ids = [];
771  foreach ($ids as $pool_entry_id) {
772  $id = ilMediaPoolItem::lookupForeignId($pool_entry_id);
773  $mob = new ilObjMediaObject((int) $id);
774  if (!in_array($mob->getMediaItem("Standard")->getFormat(), $this->getMimeTypes())) {
775  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("mob_mime_type_not_allowed") . ": " .
776  $mob->getMediaItem("Standard")->getFormat());
777  $this->listPoolItems();
778  return;
779  }
780  $mob_ids[] = $id;
781  }
782  ($this->after_pool_insert)($mob_ids);
783  }
784 }
ilGlobalTemplateInterface $main_tpl
static _getRelativeDirectory(int $a_mob_id)
Get relative (to webspace dir) directory.
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...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
getCmd(string $fallback_command=null)
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
static lookupForeignId(int $a_id)
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
initMediaBulkForm(string $a_id, string $a_title)
__construct(array $accept_types, Closure $after_upload, Closure $after_url_saving, Closure $after_pool_insert, Closure $finish_single_upload=null, Closure $on_mob_update=null)
loadLanguageModule(string $a_module)
Load language module.
ILIAS FileUpload FileUpload $upload
CreationGUIRequest $request
returnToParent(object $a_gui_obj, string $a_anchor=null)
forwardCommand(object $a_gui_object)
selectPool()
Select concrete pool.
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
ILIAS MediaObjects MediaType MediaTypeManager $type_manager
getNextClass($a_gui_class=null)
static _getDirectory(int $a_mob_id)
Get absolute directory.
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
setContent(string $a_html)
Sets content for standard template.
getMimeTypes($local_only=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getMediaItemsForUploadHash(string $a_hash)
Get media items for upload hash.
moveOneFileTo(UploadResult $uploadResult, string $destination, int $location=Location::STORAGE, string $file_name='', bool $override_existing=false)
Moves a single File (the attributes, metadata and upload-status of which are contained in UploadResul...
getMediaItem(string $a_purpose)
get item for media purpose
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$url
Definition: ltiregstart.php:35
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class FileUpload.
Definition: FileUpload.php:34
setRequired(bool $a_required)
static fixFilename(string $a_name)
Fix filename of uploaded file.
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
performBulkUpload()
Save bulk upload form.
This class represents a text area property in a property form.
saveParameter(object $a_gui_obj, $a_parameter)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handleUploadResult(FileUpload $upload, UploadResult $result)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
static _lookupType(int $id, bool $reference=false)
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insertFromPool()
Insert media from pool.
listPoolItems()
Insert media object from pool.
TableGUI class for recent changes in wiki.