65 protected \ILIAS\DI\UIServices
$ui;
68 protected \ILIAS\FileUpload\FileUpload
$upload;
81 $this->
lng = $DIC->language();
82 $this->
lng->loadLanguageModule(
"mob");
83 $this->
lng->loadLanguageModule(
"content");
84 $this->
access = $DIC->access();
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();
98 $this->type_manager =
$DIC->mediaObjects()
103 $this->
ctrl->saveParameter($this, [
"mep",
"pool_view"]);
105 $this->request =
$DIC->mediaObjects()
111 $this->requested_mep = $this->request->getMediaPoolId();
112 $this->
ctrl->setParameter($this,
"mep", $this->requested_mep);
114 $pv = $this->request->getPoolView();
115 $this->pool_view = (in_array($pv, [self::POOL_VIEW_FOLDER, self::POOL_VIEW_ALL]))
117 : self::POOL_VIEW_FOLDER;
118 $this->gui =
$DIC->mediaObjects()->internal()->gui();
124 $this->all_suffixes = $a_val;
129 return $this->all_suffixes;
135 $this->all_mime_types = $a_val;
143 return $this->all_mime_types;
152 if (in_array(self::TYPE_ALL, $this->accept_types,
true)) {
153 $suffixes = iterator_to_array($this->type_manager->getAllowedSuffixes());
155 if (in_array(self::TYPE_VIDEO, $this->accept_types,
true)) {
156 $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedVideoSuffixes()));
158 if (in_array(self::TYPE_AUDIO, $this->accept_types,
true)) {
159 $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedAudioSuffixes()));
161 if (in_array(self::TYPE_IMAGE, $this->accept_types,
true)) {
162 $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedImageSuffixes()));
173 if (in_array(self::TYPE_ALL, $this->accept_types)) {
174 $mimes = iterator_to_array($this->type_manager->getAllowedMimeTypes());
176 if (in_array(self::TYPE_VIDEO, $this->accept_types)) {
177 $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedVideoMimeTypes($local_only)));
179 if (in_array(self::TYPE_AUDIO, $this->accept_types)) {
180 $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedAudioMimeTypes()));
182 if (in_array(self::TYPE_IMAGE, $this->accept_types)) {
183 $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedImageMimeTypes()));
193 $cmd = $ctrl->
getCmd(
"creationSelection");
195 switch ($next_class) {
196 case "ilpropertyformgui":
197 $form = $this->initPoolSelection();
201 case strtolower(ilRepoStandardUploadHandlerGUI::class):
202 $form = $this->getUploadForm();
203 $gui = $form->getRepoStandardUploadHandlerGUI(
"media_files");
204 $this->
ctrl->forwardCommand($gui);
208 if (in_array($cmd, [
"creationSelection",
"uploadFile",
"saveUrl",
"cancel",
"cancelCreate",
"listPoolItems",
209 "insertFromPool",
"poolSelection",
"selectPool",
"applyFilter",
"resetFilter",
"performBulkUpload",
210 "editTitlesAndDescriptions",
"saveTitlesAndDescriptions"])) {
218 $main_tpl = $this->main_tpl;
220 $acc = new \ilAccordionGUI();
224 $this->getUploadForm(),
225 $this->initUrlForm(),
226 $this->initPoolSelection()
228 foreach ($forms as $form_type => $cf) {
229 $htpl = new \ilTemplate(
"tpl.creation_acc_head.html",
true,
true,
"components/ILIAS/ILIASObject");
233 if (method_exists($this,
"getCreationFormTitle")) {
234 $form_title = $this->getCreationFormTitle($form_type);
237 $form_title = $cf->getTitle();
241 $htpl->setVariable(
"TITLE", $this->
lng->txt(
"option") .
" " . $cnt .
": " .
245 $cf->setTitleIcon(
"");
246 $cf->setTableWidth(
"100%");
248 $acc->addItem($htpl->get(), $cf->getHTML());
250 $acc->addItem($htpl->get(), $cf->render());
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'))
269 $this->
lng->txt(
"files"),
270 \Closure::fromCallable([$this,
'handleUploadResult']),
274 $this->getMimeTypes(
true)
278 return $this->bulk_upload_form;
286 $form = new \ilPropertyFormGUI();
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");
295 $ti->setRequired(
true);
298 $form->addCommandButton(
"saveUrl",
$lng->txt(
"save"));
299 $form->addCommandButton(
"cancel",
$lng->txt(
"cancel"));
301 $form->setTitle(
$lng->txt(
"mob_external_url"));
312 $form = new \ilPropertyFormGUI();
315 $lng->txt(
"obj_mep"),
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);
326 $form->addCommandButton(
"listPoolItems",
$lng->txt(
"continue"));
327 $form->addCommandButton(
"cancel",
$lng->txt(
"cancel"));
329 $form->setTitle(
$lng->txt(
"mob_choose_from_pool"));
401 $title = $result->getName();
404 $mob->setTitle($title);
405 $mob->setDescription(
"");
408 $media_item = $mob->addMediaItemFromUpload(
411 $this->request->getUploadHash()
442 $item_ids[] = $mob->getId();
445 $med_item = $mob->getMediaItem(
"Standard");
446 $med_item->determineDuration();
449 ($this->after_upload)([$mob->getId()]);
453 HandlerResult::STATUS_OK,
464 $form = $this->getUploadForm();
465 if (!$form->isValid()) {
466 $this->main_tpl->setContent($form->render());
470 $this->
ctrl->setParameter($this,
"mep_hash", $this->request->getUploadHash());
471 $this->
ctrl->redirect($this,
"editTitlesAndDescriptions");
482 $main_tpl = $this->main_tpl;
488 $tb->addFormButton(
$lng->txt(
"save"),
"saveTitlesAndDescriptions");
489 $tb->setOpenFormTag(
true);
490 $tb->setCloseFormTag(
false);
491 $tb->setId(
"tb_top");
493 if (count($media_items) == 1 && $this->finish_single_upload) {
494 $mi = current($media_items);
495 ($this->finish_single_upload)($mi[
"mob_id"]);
499 $html = $tb->getHTML();
500 foreach ($media_items as $mi) {
503 $acc->setId(
"acc_" . $mi[
"mob_id"]);
506 $form = $this->initMediaBulkForm($mi[
"mob_id"], $mob->getTitle());
507 $acc->addItem($mob->getTitle(), $form->getHTML());
509 $html .= $acc->getHTML();
512 $html .= $tb->getHTML();
513 $tb->setOpenFormTag(
false);
514 $tb->setCloseFormTag(
true);
515 $tb->setId(
"tb_bottom");
525 $form->setOpenTag(
false);
526 $form->setCloseTag(
false);
530 $ti->setValue($a_title);
547 foreach ($media_items as $mi) {
549 $form = $this->initMediaBulkForm($mi[
"mob_id"], $mob->getTitle());
551 $title = $form->getInput(
"title_" . $mi[
"mob_id"]);
552 $desc = $form->getInput(
"description_" . $mi[
"mob_id"]);
553 if (trim($title) !=
"") {
554 $mob->setTitle($title);
556 $mob->setDescription($desc);
558 ($this->on_mob_update)($mob->getId());
560 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"msg_obj_modified"),
true);
578 $form = $this->initUrlForm();
580 if (!$form->checkInput()) {
581 $form->setValuesByPost();
582 $this->main_tpl->setContent($form->getHTML());
584 $locationType =
"Reference";
585 $url = $form->getInput(
"url");
586 $url_pi = pathinfo(basename(
$url));
587 $title = str_replace(
"_",
" ", $url_pi[
"filename"]);
594 $mob->setTitle($title);
599 $mob->addMediaItem($mediaItem);
600 $mediaItem->setPurpose(
"Standard");
604 if (!is_dir($mob_dir)) {
605 $mob->createDirectory();
610 if (!in_array($format, $this->getMimeTypes())) {
611 $this->main_tpl->setOnScreenMessage(
613 $this->
lng->txt(
"mob_type_not_supported") .
" " . $format
615 $form->setValuesByPost();
616 $this->main_tpl->setContent($form->getHTML());
620 $mediaItem->setFormat($format);
621 $mediaItem->setLocation(
$url);
622 $mediaItem->setLocationType(
"Reference");
623 $mediaItem->setHAlign(
"Left");
625 $mob->getExternalMetadata();
626 }
catch (Exception
$e) {
627 $this->main_tpl->setOnScreenMessage(
'failure',
$e->getMessage(),
true);
628 $form->setValuesByPost();
629 $this->main_tpl->setContent($form->getHTML());
633 $long_desc = $mob->getLongDescription();
637 $mob->generatePreviewPic(320, 240);
640 $med_item = $mob->getMediaItem(
"Standard");
641 $med_item->determineDuration();
648 ($this->after_url_saving)($mob->getId(), $long_desc);
658 $access = $this->access;
661 $main_tpl = $this->main_tpl;
663 $form = $this->initPoolSelection();
664 if ($this->requested_mep === 0) {
665 $this->main_tpl->setOnScreenMessage(
"failure", $this->
lng->txt(
"mob_please_select_pool"));
666 $form->setValuesByPost();
667 $this->main_tpl->setContent($form->getHTML());
671 if ($this->requested_mep > 0 &&
672 $access->
checkAccess(
"write",
"", $this->requested_mep)
678 $lng->txt(
"cont_switch_to_media_pool"),
684 $lng->loadLanguageModule(
"mep");
685 $ctrl->
setParameter($this,
"pool_view", self::POOL_VIEW_FOLDER);
687 $ctrl->
setParameter($this,
"pool_view", self::POOL_VIEW_ALL);
688 $actions[
$lng->txt(
"mep_all_mobs")] = $ctrl->
getLinkTarget($this,
"listPoolItems");
689 $ctrl->
setParameter($this,
"pool_view", $this->pool_view);
690 $aria_label =
$lng->txt(
"cont_change_pool_view");
691 $view_control =
$f->viewControl()->mode($actions, $aria_label)->withActive(($this->pool_view == self::POOL_VIEW_FOLDER)
692 ?
$lng->txt(
"folders") :
$lng->txt(
"mep_all_mobs"));
694 $tb->addComponent($view_control);
696 $html = $tb->getHTML();
698 $pool_table = $this->getPoolTable();
700 $html .= $pool_table->getHTML();
708 $mpool_table = $this->getPoolTable();
709 $mpool_table->resetOffset();
710 $mpool_table->writeFilterToSession();
711 $this->
ctrl->redirect($this,
"listPoolItems");
716 $mpool_table = $this->getPoolTable();
717 $mpool_table->resetOffset();
718 $mpool_table->resetFilter();
719 $this->
ctrl->redirect($this,
"listPoolItems");
731 $this->pool_view == self::POOL_VIEW_ALL
733 $mpool_table->setFilterCommand(
"applyFilter");
734 $mpool_table->setResetCommand(
"resetFilter");
735 $mpool_table->setInsertCommand(
"insertFromPool");
746 $ctrl->
setParameter($this,
"mep", $this->request->getSelectedMediaPoolRefId());
747 $ctrl->
redirect($this,
"listPoolItems");
752 $main_tpl = $this->main_tpl;
761 $exp->setTypeWhiteList(array(
"root",
"cat",
"grp",
"fold",
"crs",
"mep"));
762 $exp->setClickableTypes(array(
'mep'));
763 if (!$exp->handleCommand()) {
773 $ids = $this->request->getIds();
774 if (count($ids) == 0) {
775 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"select_one"));
776 $this->listPoolItems();
780 foreach ($ids as $pool_entry_id) {
783 if (!in_array($mob->getMediaItem(
"Standard")->getFormat(), $this->getMimeTypes())) {
784 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"mob_mime_type_not_allowed") .
": " .
785 $mob->getMediaItem(
"Standard")->getFormat());
786 $this->listPoolItems();
791 ($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)