64 protected \ILIAS\DI\UIServices
$ui;
67 protected \ILIAS\FileUpload\FileUpload
$upload;
80 $this->
lng = $DIC->language();
81 $this->
lng->loadLanguageModule(
"mob");
82 $this->
lng->loadLanguageModule(
"content");
83 $this->
access = $DIC->access();
85 $this->
ctrl = $DIC->ctrl();
86 $this->main_tpl =
$DIC->ui()->mainTemplate();
87 $this->
ui = $DIC->ui();
88 $this->
upload = $DIC->upload();
89 $this->mob_log =
$DIC->logger()->mob();
97 $this->type_manager =
$DIC->mediaObjects()
102 $this->
ctrl->saveParameter($this, [
"mep",
"pool_view"]);
104 $this->request =
$DIC->mediaObjects()
110 $this->requested_mep = $this->request->getMediaPoolId();
111 $this->
ctrl->setParameter($this,
"mep", $this->requested_mep);
113 $pv = $this->request->getPoolView();
114 $this->pool_view = (in_array($pv, [self::POOL_VIEW_FOLDER, self::POOL_VIEW_ALL]))
116 : self::POOL_VIEW_FOLDER;
117 $this->gui =
$DIC->mediaObjects()->internal()->gui();
123 $this->all_suffixes = $a_val;
128 return $this->all_suffixes;
134 $this->all_mime_types = $a_val;
142 return $this->all_mime_types;
151 if (in_array(self::TYPE_ALL, $this->accept_types,
true)) {
152 $suffixes = iterator_to_array($this->type_manager->getAllowedSuffixes());
154 if (in_array(self::TYPE_VIDEO, $this->accept_types,
true)) {
155 $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedVideoSuffixes()));
157 if (in_array(self::TYPE_AUDIO, $this->accept_types,
true)) {
158 $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedAudioSuffixes()));
160 if (in_array(self::TYPE_IMAGE, $this->accept_types,
true)) {
161 $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedImageSuffixes()));
172 if (in_array(self::TYPE_ALL, $this->accept_types)) {
173 $mimes = iterator_to_array($this->type_manager->getAllowedMimeTypes());
175 if (in_array(self::TYPE_VIDEO, $this->accept_types)) {
176 $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedVideoMimeTypes($local_only)));
178 if (in_array(self::TYPE_AUDIO, $this->accept_types)) {
179 $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedAudioMimeTypes()));
181 if (in_array(self::TYPE_IMAGE, $this->accept_types)) {
182 $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedImageMimeTypes()));
192 $cmd = $ctrl->
getCmd(
"creationSelection");
194 switch ($next_class) {
195 case "ilpropertyformgui":
196 $form = $this->initPoolSelection();
200 case strtolower(ilRepoStandardUploadHandlerGUI::class):
201 $form = $this->getUploadForm();
202 $gui = $form->getRepoStandardUploadHandlerGUI(
"media_files");
203 $this->
ctrl->forwardCommand($gui);
207 if (in_array($cmd, [
"creationSelection",
"uploadFile",
"saveUrl",
"cancel",
"cancelCreate",
"listPoolItems",
208 "insertFromPool",
"poolSelection",
"selectPool",
"applyFilter",
"resetFilter",
"performBulkUpload",
209 "editTitlesAndDescriptions",
"saveTitlesAndDescriptions"])) {
217 $main_tpl = $this->main_tpl;
219 $acc = new \ilAccordionGUI();
223 $this->getUploadForm(),
224 $this->initUrlForm(),
225 $this->initPoolSelection()
227 foreach ($forms as $form_type => $cf) {
228 $htpl = new \ilTemplate(
"tpl.creation_acc_head.html",
true,
true,
"components/ILIAS/ILIASObject");
232 if (method_exists($this,
"getCreationFormTitle")) {
233 $form_title = $this->getCreationFormTitle($form_type);
236 $form_title = $cf->getTitle();
240 $htpl->setVariable(
"TITLE", $this->
lng->txt(
"option") .
" " . $cnt .
": " .
244 $cf->setTitleIcon(
"");
245 $cf->setTableWidth(
"100%");
247 $acc->addItem($htpl->get(), $cf->getHTML());
249 $acc->addItem($htpl->get(), $cf->render());
260 if (is_null($this->bulk_upload_form)) {
261 $mep_hash = uniqid();
262 $this->
ctrl->setParameter($this,
"mep_hash", $mep_hash);
263 $this->bulk_upload_form = $this->gui
264 ->form([self::class],
'performBulkUpload')
265 ->section(
"props", $this->
lng->txt(
'mob_upload_file'))
268 $this->
lng->txt(
"files"),
269 \Closure::fromCallable([$this,
'handleUploadResult']),
273 $this->getMimeTypes(
true)
277 return $this->bulk_upload_form;
285 $form = new \ilPropertyFormGUI();
288 $ti = new \ilTextInputGUI(
$lng->txt(
"mob_url"),
"url");
289 $info =
$lng->txt(
"mob_url_info1") .
" " . implode(
", ", $this->getSuffixes()) .
".";
290 if (in_array(self::TYPE_VIDEO, $this->accept_types)) {
291 $info .=
" " .
$lng->txt(
"mob_url_info_video");
294 $ti->setRequired(
true);
297 $form->addCommandButton(
"saveUrl",
$lng->txt(
"save"));
298 $form->addCommandButton(
"cancel",
$lng->txt(
"cancel"));
300 $form->setTitle(
$lng->txt(
"mob_external_url"));
311 $form = new \ilPropertyFormGUI();
314 $lng->txt(
"obj_mep"),
319 $exp = $mcst->getExplorerGUI();
320 $exp->setSelectableTypes([
"mep"]);
321 $exp->setTypeWhiteList([
"root",
"mep",
"cat",
"crs",
"grp",
"fold"]);
322 $mcst->setRequired(
true);
323 $form->addItem($mcst);
325 $form->addCommandButton(
"listPoolItems",
$lng->txt(
"continue"));
326 $form->addCommandButton(
"cancel",
$lng->txt(
"cancel"));
328 $form->setTitle(
$lng->txt(
"mob_choose_from_pool"));
400 $title = $result->getName();
403 $mob->setTitle($title);
404 $mob->setDescription(
"");
407 $media_item = $mob->addMediaItemFromUpload(
410 $this->request->getUploadHash()
441 $item_ids[] = $mob->getId();
444 $med_item = $mob->getMediaItem(
"Standard");
445 $med_item->determineDuration();
448 ($this->after_upload)([$mob->getId()]);
452 HandlerResult::STATUS_OK,
463 $form = $this->getUploadForm();
464 if (!$form->isValid()) {
465 $this->main_tpl->setContent($form->render());
469 $this->
ctrl->setParameter($this,
"mep_hash", $this->request->getUploadHash());
470 $this->
ctrl->redirect($this,
"editTitlesAndDescriptions");
481 $main_tpl = $this->main_tpl;
487 $tb->addFormButton(
$lng->txt(
"save"),
"saveTitlesAndDescriptions");
488 $tb->setOpenFormTag(
true);
489 $tb->setCloseFormTag(
false);
490 $tb->setId(
"tb_top");
492 if (count($media_items) == 1 && $this->finish_single_upload) {
493 $mi = current($media_items);
494 ($this->finish_single_upload)($mi[
"mob_id"]);
498 $html = $tb->getHTML();
499 foreach ($media_items as $mi) {
502 $acc->setId(
"acc_" . $mi[
"mob_id"]);
505 $form = $this->initMediaBulkForm($mi[
"mob_id"], $mob->getTitle());
506 $acc->addItem($mob->getTitle(), $form->getHTML());
508 $html .= $acc->getHTML();
511 $html .= $tb->getHTML();
512 $tb->setOpenFormTag(
false);
513 $tb->setCloseFormTag(
true);
514 $tb->setId(
"tb_bottom");
524 $form->setOpenTag(
false);
525 $form->setCloseTag(
false);
529 $ti->setValue($a_title);
546 foreach ($media_items as $mi) {
548 $form = $this->initMediaBulkForm($mi[
"mob_id"], $mob->getTitle());
550 $title = $form->getInput(
"title_" . $mi[
"mob_id"]);
551 $desc = $form->getInput(
"description_" . $mi[
"mob_id"]);
552 if (trim($title) !=
"") {
553 $mob->setTitle($title);
555 $mob->setDescription($desc);
557 ($this->on_mob_update)($mob->getId());
559 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"msg_obj_modified"),
true);
577 $form = $this->initUrlForm();
579 if (!$form->checkInput()) {
580 $form->setValuesByPost();
581 $this->main_tpl->setContent($form->getHTML());
583 $locationType =
"Reference";
584 $url = $form->getInput(
"url");
585 $url_pi = pathinfo(basename(
$url));
586 $title = str_replace(
"_",
" ", $url_pi[
"filename"]);
593 $mob->setTitle($title);
598 $mob->addMediaItem($mediaItem);
599 $mediaItem->setPurpose(
"Standard");
603 if (!is_dir($mob_dir)) {
604 $mob->createDirectory();
609 if (!in_array($format, $this->getMimeTypes())) {
610 $this->main_tpl->setOnScreenMessage(
612 $this->
lng->txt(
"mob_type_not_supported") .
" " . $format
614 $form->setValuesByPost();
615 $this->main_tpl->setContent($form->getHTML());
619 $mediaItem->setFormat($format);
620 $mediaItem->setLocation(
$url);
621 $mediaItem->setLocationType(
"Reference");
622 $mediaItem->setHAlign(
"Left");
624 $mob->getExternalMetadata();
625 }
catch (Exception
$e) {
626 $this->main_tpl->setOnScreenMessage(
'failure',
$e->getMessage(),
true);
627 $form->setValuesByPost();
628 $this->main_tpl->setContent($form->getHTML());
632 $long_desc = $mob->getLongDescription();
636 $mob->generatePreviewPic(320, 240);
639 $med_item = $mob->getMediaItem(
"Standard");
640 $med_item->determineDuration();
647 ($this->after_url_saving)($mob->getId(), $long_desc);
657 $access = $this->access;
660 $main_tpl = $this->main_tpl;
662 $form = $this->initPoolSelection();
663 if ($this->requested_mep === 0) {
664 $this->main_tpl->setOnScreenMessage(
"failure", $this->
lng->txt(
"mob_please_select_pool"));
665 $form->setValuesByPost();
666 $this->main_tpl->setContent($form->getHTML());
670 if ($this->requested_mep > 0 &&
671 $access->
checkAccess(
"write",
"", $this->requested_mep)
677 $lng->txt(
"cont_switch_to_media_pool"),
683 $lng->loadLanguageModule(
"mep");
684 $ctrl->
setParameter($this,
"pool_view", self::POOL_VIEW_FOLDER);
686 $ctrl->
setParameter($this,
"pool_view", self::POOL_VIEW_ALL);
687 $actions[
$lng->txt(
"mep_all_mobs")] = $ctrl->
getLinkTarget($this,
"listPoolItems");
688 $ctrl->
setParameter($this,
"pool_view", $this->pool_view);
689 $aria_label =
$lng->txt(
"cont_change_pool_view");
690 $view_control =
$f->viewControl()->mode($actions, $aria_label)->withActive(($this->pool_view == self::POOL_VIEW_FOLDER)
691 ?
$lng->txt(
"folders") :
$lng->txt(
"mep_all_mobs"));
693 $tb->addComponent($view_control);
695 $html = $tb->getHTML();
697 $pool_table = $this->getPoolTable();
699 $html .= $pool_table->getHTML();
707 $mpool_table = $this->getPoolTable();
708 $mpool_table->resetOffset();
709 $mpool_table->writeFilterToSession();
710 $this->
ctrl->redirect($this,
"listPoolItems");
715 $mpool_table = $this->getPoolTable();
716 $mpool_table->resetOffset();
717 $mpool_table->resetFilter();
718 $this->
ctrl->redirect($this,
"listPoolItems");
730 $this->pool_view == self::POOL_VIEW_ALL
732 $mpool_table->setFilterCommand(
"applyFilter");
733 $mpool_table->setResetCommand(
"resetFilter");
734 $mpool_table->setInsertCommand(
"insertFromPool");
745 $ctrl->
setParameter($this,
"mep", $this->request->getSelectedMediaPoolRefId());
746 $ctrl->
redirect($this,
"listPoolItems");
751 $main_tpl = $this->main_tpl;
760 $exp->setTypeWhiteList(array(
"root",
"cat",
"grp",
"fold",
"crs",
"mep"));
761 $exp->setClickableTypes(array(
'mep'));
762 if (!$exp->handleCommand()) {
772 $ids = $this->request->getIds();
773 if (count($ids) == 0) {
774 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"select_one"));
775 $this->listPoolItems();
779 foreach ($ids as $pool_entry_id) {
782 if (!in_array($mob->getMediaItem(
"Standard")->getFormat(), $this->getMimeTypes())) {
783 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"mob_mime_type_not_allowed") .
": " .
784 $mob->getMediaItem(
"Standard")->getFormat());
785 $this->listPoolItems();
790 ($this->after_pool_insert)($mob_ids);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class BasicHandlerResult.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getNextClass($a_gui_class=null)
@inheritDoc
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
saveParameter(object $a_gui_obj, $a_parameter)
@inheritDoc
returnToParent(object $a_gui_obj, ?string $a_anchor=null)
@inheritDoc
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
forwardCommand(object $a_gui_object)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
Component logger with individual log levels by component id.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
setContent(string $a_html)
Sets content for standard template.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
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)