ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilObjMediaPoolGUI.php
Go to the documentation of this file.
1<?php
2
29
43{
44 protected \ILIAS\MediaPool\InternalDomainService $domain;
45 protected \ILIAS\COPage\Xsl\XslManager $xsl;
49 protected string $mode;
50 protected int $mep_item_id = 0;
52 protected ilTabsGUI $tabs;
53 protected ilHelpGUI $help;
56 protected ilLogger $mep_log;
57 protected ilDBInterface $db;
58 public bool $output_prepared;
59
60 public function __construct(
61 int $a_id = 0,
62 int $a_id_type = self::REPOSITORY_NODE_ID,
63 int $a_parent_node_id = 0
64 ) {
65 global $DIC;
66
67 $this->mep_request = $DIC->mediaPool()
68 ->internal()
69 ->gui()
70 ->standardRequest();
71 $this->mep_item_id = $this->mep_request->getItemId();
72
73 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
74
75 $this->tabs = $DIC->tabs();
76 $this->locator = $DIC["ilLocator"];
77 $this->help = $DIC["ilHelp"];
78
79 $this->main_tpl = $DIC->ui()->mainTemplate();
80
81 $this->upload = $DIC->upload();
82
83 $this->mep_log = ilLoggerFactory::getLogger("mep");
84
85 $this->db = $DIC->database();
86
87 $this->mode = ($this->mep_request->getMode() !== "")
88 ? $this->mep_request->getMode()
89 : "listMedia";
90 $this->gui = $DIC->mediaPool()->internal()->gui();
91 $this->domain = $DIC->mediaPool()->internal()->domain();
92 $this->xsl = $DIC->copage()->internal()->domain()->xsl();
93 }
94
95 protected function getMediaPool(): ilObjMediaPool
96 {
98 $mp = $this->object;
99 return $mp;
100 }
101
105 protected function afterConstructor(): void
106 {
108 if ($this->mep_item_id == 0 && !$this->getCreationMode()) {
109 $tree = $this->object->getTree();
110 $this->mep_item_id = $tree->readRootId();
111 }
112
113 $lng->loadLanguageModule("mep");
114
115 if ($this->ctrl->getCmd() === "explorer") {
116 $this->ctrl->saveParameter($this, array("ref_id"));
117 } else {
118 $this->ctrl->saveParameter($this, array("ref_id", "mepitem_id"));
119 }
120 $this->ctrl->saveParameter($this, array("mep_mode"));
121
122 $lng->loadLanguageModule("content");
123 }
124
125 final public function getType(): string
126 {
127 return "mep";
128 }
129
135 public function executeCommand(): void
136 {
137 $ilTabs = $this->tabs;
139 $ilAccess = $this->access;
141 $ilCtrl = $this->ctrl;
142
143 $tree = null;
144 if ($this->object) {
145 $tree = $this->object->getTree();
146 }
147
148 $next_class = $this->ctrl->getNextClass($this);
149 $cmd = $this->ctrl->getCmd();
150 $new_type = $this->mep_request->getNewType();
151
152
153
154 if ($new_type !== "" && ($cmd !== "confirmRemove" && $cmd !== "copyToClipboard"
155 && $cmd !== "pasteFromClipboard")) {
156 $this->tpl->setPermanentLink("mep", $this->ref_id);
157 $this->setCreationMode(true);
158 }
159
160 if ($cmd === "create") {
161 switch ($this->mep_request->getNewType()) {
162 case "mob":
163 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
164 break;
165
166 case "fold":
167 $this->ctrl->redirectByClass("ilobjfoldergui", "create");
168 break;
169 }
170 }
171
172 switch ($next_class) {
173 case 'ilobjectmetadatagui':
174 $this->checkPermission("write");
175
176 $this->prepareOutput();
177 $this->addHeaderAction();
178
179 $this->tabs_gui->activateTab('meta_data');
180 $md_gui = new ilObjectMetaDataGUI($this->object, ['mob', "mpg"]);
181 $this->ctrl->forwardCommand($md_gui);
182 $this->tpl->printToStdout();
183 break;
184
185 case strtolower(ilRepoStandardUploadHandlerGUI::class):
186 $this->checkPermission("write");
187 $form = $this->getBulkUploadForm();
188 $gui = $form->getRepoStandardUploadHandlerGUI("media_files");
189 $this->ctrl->forwardCommand($gui);
190 break;
191
192 case 'ilmediapoolpagegui':
193 $this->checkPermission("write");
194 $this->prepareOutput();
195 //$this->addHeaderAction();
196 $ilTabs->clearTargets();
197 $ilCtrl->setReturn($this, "returnFromItem");
198 $mep_page_gui = new ilMediaPoolPageGUI(
199 $this->mep_item_id,
200 $this->mep_request->getOldNr()
201 );
202 $mep_page_gui->setPoolGUI($this);
203 $mep_page_gui->setAdvMdRecordObject($this->object->getRefId(), "mep", "mpg");
204
205 if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
206 $mep_page_gui->setEnableEditing(false);
207 }
208 $ret = $this->ctrl->forwardCommand($mep_page_gui);
209 if ($ret != "") {
210 $tpl->setContent($ret);
211 }
212 $this->tpl->printToStdout();
213 break;
214
215 case "ilobjmediaobjectgui":
216 $this->checkPermission("write");
217 if ($cmd === "create" || $cmd === "save" || $cmd === "cancel") {
218 $ret_obj = $this->mep_item_id;
219 $ilObjMediaObjectGUI = new ilObjMediaObjectGUI("", 0, false, false);
220 $ilObjMediaObjectGUI->setWidthPreset((int) $this->getMediaPool()->getDefaultWidth());
221 $ilObjMediaObjectGUI->setHeightPreset((int) $this->getMediaPool()->getDefaultHeight());
222 } else {
223 $ret_obj = $tree->getParentId($this->mep_item_id);
224 $ilObjMediaObjectGUI = new ilObjMediaObjectGUI("", ilMediaPoolItem::lookupForeignId($this->mep_item_id), false, false);
225 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
226 $ilTabs->setBackTarget(
227 $lng->txt("back"),
228 $this->ctrl->getLinkTarget(
229 $this,
230 $this->mode
231 )
232 );
233 }
234 if ($this->ctrl->getCmdClass() === "ilinternallinkgui") {
235 $this->ctrl->setReturn($this, "explorer");
236 } else {
237 $this->ctrl->setParameter($this, "mepitem_id", $ret_obj);
238 $this->ctrl->setReturn(
239 $this,
240 $this->mode
241 );
242 $this->ctrl->setParameter($this, "mepitem_id", $this->mep_item_id);
243 }
244 $this->getTemplate();
245 $ilObjMediaObjectGUI->setTabs();
246 $this->setLocator();
247
248 // set adv metadata record dobject
249 $ilObjMediaObjectGUI->setAdvMdRecordObject($this->object->getRefId(), "mep", "mob");
250
251 $ret = $this->ctrl->forwardCommand($ilObjMediaObjectGUI);
252 if ($cmd === "save") {
253 $object = $ilObjMediaObjectGUI->getObject();
254 if (!is_null($object)) {
255 $mep_item = new ilMediaPoolItem();
256 $mep_item->setTitle($object->getTitle());
257 $mep_item->setType("mob");
258 $mep_item->setForeignId($object->getId());
259 $mep_item->create();
260
261 $parent = $this->mep_item_id;
262 $tree->insertNode($mep_item->getId(), $parent);
264 "ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" .
265 $this->requested_ref_id . "&mepitem_id=" . $this->mep_item_id
266 );
267 }
268 }
269 $this->tpl->printToStdout();
270 break;
271
272 case "ilmediacreationgui":
273 $this->checkPermission("write");
274 $this->prepareOutput();
275 $this->ctrl->setReturn($this, "listMedia");
276 //$ilTabs->activateTab("content");
277 //$this->addContentSubTabs("manage");
278 $med_type = [];
279 $creation = new ilMediaCreationGUI([ilMediaCreationGUI::TYPE_ALL], function ($mob_id) {
280 $this->afterUpload($mob_id);
281 }, function ($mob_id, $long_desc) {
282 $this->afterUrlSaving($mob_id, $long_desc);
283 }, function ($mob_ids) {
284 $this->afterPoolInsert($mob_ids);
285 }, function ($mob_id) {
286 $this->finishSingleUpload($mob_id);
287 }, function ($mob_id) {
288 $this->onMobUpdate($mob_id);
289 });
290 $this->ctrl->forwardCommand($creation);
291 $this->tpl->printToStdout();
292 break;
293
294
295 case "ilobjfoldergui":
296 $this->checkPermission("write");
297 $this->addHeaderAction();
298 $folder_gui = new ilObjFolderGUI("", 0, false, false);
299 $this->ctrl->setReturn($this, "listMedia");
300 $cmd .= "Object";
301 switch ($cmd) {
302 case "createObject":
303 $this->prepareOutput();
304 $folder_gui = new ilObjFolderGUI("", 0, false, false);
305 $folder_gui->setFormAction(
306 "save",
307 $this->ctrl->getFormActionByClass("ilobjfoldergui")
308 );
309 $folder_gui->createObject();
310 $this->tpl->printToStdout();
311 break;
312
313 case "saveObject":
314 $parent = $this->mep_item_id;
315 $folder_gui->setFolderTree($tree);
316 $folder_gui->saveObject();
317 break;
318
319 case "editObject":
320 $this->prepareOutput();
321 $folder_gui = new ilObjFolderGUI(
322 "",
323 ilMediaPoolItem::lookupForeignId($this->mep_item_id),
324 false,
325 false
326 );
327 $this->ctrl->setParameter($this, "foldereditmode", "1");
328 $folder_gui->setFormAction("update", $this->ctrl->getFormActionByClass("ilobjfoldergui"));
329 $folder_gui->editObject();
330 $this->tpl->printToStdout();
331 break;
332
333 case "updateObject":
334 $folder_gui = new ilObjFolderGUI(
335 "",
336 ilMediaPoolItem::lookupForeignId($this->mep_item_id),
337 false,
338 false
339 );
340 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
341 $this->ctrl->setReturn($this, "listMedia");
342 $folder_gui->updateObject(); // this returns to parent
343 break;
344
345 case "cancelObject":
346 if ($this->mep_request->getFolderEditMode()) {
347 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
348 }
349 $this->ctrl->redirect($this, "listMedia");
350 break;
351 }
352 break;
353
354 case "ileditclipboardgui":
355 $this->prepareOutput();
356 $this->addHeaderAction();
357 $this->ctrl->setReturn($this, $this->mode);
358 $clip_gui = new ilEditClipboardGUI();
359 $clip_gui->setMultipleSelections(true);
360 $clip_gui->setInsertButtonTitle($lng->txt("mep_copy_to_mep"));
361 $ilTabs->setTabActive("clipboard");
362 $this->ctrl->forwardCommand($clip_gui);
363 $this->tpl->printToStdout();
364 break;
365
366 case 'ilinfoscreengui':
367 $this->prepareOutput();
368 $this->addHeaderAction();
369 $this->infoScreen();
370 $this->tpl->printToStdout();
371 break;
372
373 case 'ilpermissiongui':
374 $this->checkPermission("edit_permission");
375 $this->prepareOutput();
376 $this->addHeaderAction();
377 $perm_gui = new ilPermissionGUI($this);
378 $ilTabs->activateTab("perm_settings");
379 $this->ctrl->forwardCommand($perm_gui);
380 $this->tpl->printToStdout();
381 break;
382
383 case "ilexportgui":
384 $this->checkPermission("write");
385 $this->prepareOutput();
386 $this->addHeaderAction();
387 $ilTabs->activateTab("export");
388 $exp_gui = new ilExportGUI($this);
389 $this->ctrl->forwardCommand($exp_gui);
390 $this->tpl->printToStdout();
391 break;
392
393 case "ilcommonactiondispatchergui":
395 $this->ctrl->forwardCommand($gui);
396 break;
397
398 case strtolower(TranslationGUI::class):
399 $this->prepareOutput();
400 $this->addHeaderAction();
401 //$this->setTabs("settings");
402 $ilTabs->activateTab("settings");
403 $this->setSettingsSubTabs("obj_multilinguality");
404 $transgui = new TranslationGUI(
405 $this->getObject(),
406 $this->lng,
407 $this->access,
408 $this->user,
409 $this->ctrl,
410 $this->tpl,
411 $this->ui_factory,
412 $this->ui_renderer,
413 $this->http,
414 $this->refinery,
415 $this->toolbar
416 );
417 $transgui->forceContentTranslation();
418 $this->ctrl->forwardCommand($transgui);
419 $this->tpl->printToStdout();
420 break;
421
422 case "ilmediapoolimportgui":
423 $this->prepareOutput();
424 $this->addHeaderAction();
425 $this->checkPermission("write");
426 $ilTabs->activateTab("import");
427 $gui = new ilMediaPoolImportGUI($this->getMediaPool());
428 $this->ctrl->forwardCommand($gui);
429 $this->tpl->printToStdout();
430 break;
431
432 case "ilmobmultisrtuploadgui":
433 $this->checkPermission("write");
434 $this->prepareOutput();
435 $this->addHeaderAction();
436 $this->setContentSubTabs("srt_files");
437 $gui = new ilMobMultiSrtUploadGUI(new ilMepMultiSrt($this->getMediaPool()));
438 $this->ctrl->forwardCommand($gui);
439 $this->tpl->printToStdout();
440 break;
441
442 case strtolower(ilObjectMetaDataGUI::class):
443 $this->checkPermission("write");
444 $this->prepareOutput();
445 $this->addHeaderAction();
446 $ilTabs->activateTab("meta_data");
447 $gui = new ilObjectMetaDataGUI($this->object);
448 $this->ctrl->forwardCommand($gui);
449 break;
450
451 case strtolower(SettingsGUI::class):
452 $this->checkPermission("write");
453 $this->prepareOutput();
454 $this->addHeaderAction();
455 $this->setSettingsSubTabs("settings");
456 $ilTabs->activateTab("settings");
457 $gui = $this->gui->settings()->settingsGUI(
458 $this->object->getId()
459 );
460 $this->ctrl->forwardCommand($gui);
461 $this->tpl->printToStdout();
462 break;
463
464 default:
465 $this->prepareOutput();
466 $this->addHeaderAction();
467 $cmd = $this->ctrl->getCmd("listMedia") ?: "listMedia";
468 $this->$cmd();
469 if (!$this->getCreationMode()) {
470 $this->tpl->printToStdout();
471 }
472 break;
473 }
474 }
475
479 protected function returnFromItem(): void
480 {
482
483 $type = ilMediaPoolItem::lookupType($this->mep_item_id);
484 if ($type !== "fold") {
485 $tree = $this->object->getTree();
486 $fold_id = $tree->getParentId($this->mep_item_id);
487 if ($fold_id > 0) {
488 $ctrl->setParameter($this, "mepitem_id", $fold_id);
489 $ctrl->redirect($this, "listMedia");
490 }
491 }
492 $this->listMedia();
493 }
494
495 public function createMediaObject(): void
496 {
497 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
498 }
499
500 protected function afterSave(ilObject $new_object): void
501 {
502 // always send a message
503 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
504
505 //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
506 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&ref_id=" . $new_object->getRefId() . "&cmd=listMedia");
507 }
508
509 public function edit(): void
510 {
511 $this->ctrl->redirectByClass(SettingsGUI::class);
512 }
513
514
518 public function listMedia(): void
519 {
520 $ilAccess = $this->access;
522 $ilTabs = $this->tabs;
523 $ilCtrl = $this->ctrl;
524 $ilToolbar = $this->toolbar;
526
527 $ilCtrl->setParameter($this, "mep_mode", "listMedia");
528
529 $this->checkPermission("read");
530
531 $ilTabs->setTabActive("content");
532 $this->setContentSubTabs("content");
533
534 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
535 $ilToolbar->addButton(
536 $lng->txt("mep_create_mob"),
537 $ilCtrl->getLinkTargetByClass("ilMediaCreationGUI", "")
538 );
539
540 $mset = new ilSetting("mobs");
541 if ($mset->get("mep_activate_pages")) {
542 $ilToolbar->addButton(
543 $lng->txt("mep_create_content_snippet"),
544 $ilCtrl->getLinkTargetByClass(["ilobjmediapoolgui", "ilmediapoolpagegui"], "createMediaPoolPage")
545 );
546 }
547
548 $ilToolbar->addButton(
549 $lng->txt("mep_create_folder"),
550 $ilCtrl->getLinkTarget($this, "createFolderForm")
551 );
552
553 $ilToolbar->addButton(
554 $lng->txt("mep_bulk_upload"),
555 $ilCtrl->getLinkTarget($this, "bulkUpload")
556 );
557
558 $move_ids = ilSession::get("mep_move_ids");
559 if (is_array($move_ids) && count($move_ids) > 0) {
560 $ilToolbar->addSeparator();
561 $ilToolbar->addButton(
562 $lng->txt("paste"),
563 $ilCtrl->getLinkTarget($this, "paste")
564 );
565 }
566 }
567
568 $mep_table_gui = new ilMediaPoolTableGUI($this, "listMedia", $this->getMediaPool(), "mepitem_id");
569 $tpl->setContent($mep_table_gui->getHTML());
570 }
571
572 protected function toggleExplorerNodeState(): void
573 {
574 $exp = new ilMediaPoolExplorerGUI($this, "listMedia", $this->getMediaPool());
575 $exp->toggleExplorerNodeState();
576 }
577
581 public function allMedia(): void
582 {
584 $ilTabs = $this->tabs;
585 $ilCtrl = $this->ctrl;
586 $ilUser = $this->user;
587
588 $ilCtrl->setParameter($this, "mep_mode", "allMedia");
589
590 $this->checkPermission("read");
591 $ilTabs->setTabActive("content");
592 $this->setContentSubTabs("mep_all_mobs");
593
594 $mep_table_gui = new ilMediaPoolTableGUI(
595 $this,
596 "allMedia",
597 $this->getMediaPool(),
598 "mepitem_id",
600 true
601 );
602
603 if ($this->mep_request->getForceFilter() > 0) {
604 $mep_table_gui->setTitleFilter(
605 ilMediaPoolItem::lookupTitle($this->mep_request->getForceFilter())
606 );
607
608 // Read again
609 $mep_table_gui = new ilMediaPoolTableGUI(
610 $this,
611 "allMedia",
612 $this->getMediaPool(),
613 "mepitem_id",
615 true
616 );
617 }
618
619 $tpl->setContent($mep_table_gui->getHTML());
620 }
621
625 public function applyFilter(): void
626 {
627 $mtab = new ilMediaPoolTableGUI(
628 $this,
629 "allMedia",
630 $this->getMediaPool(),
631 "mepitem_id",
633 true
634 );
635 $mtab->writeFilterToSession();
636 $mtab->resetOffset();
637 $this->allMedia();
638 }
639
640 public function resetFilter(): void
641 {
642 $mtab = new ilMediaPoolTableGUI(
643 $this,
644 "allMedia",
645 $this->getMediaPool(),
646 "mepitem_id",
648 true
649 );
650 $mtab->resetFilter();
651 $mtab->resetOffset();
652 $this->allMedia();
653 }
654
658 public function getTemplate(): void
659 {
660 $this->tpl->loadStandardTemplate();
661 }
662
663
667 public function getParentFolderId(): ?int
668 {
669 if ($this->mep_item_id == 0) {
670 return null;
671 }
672 $par_id = $this->object->getPoolTree()->getParentId($this->mep_item_id);
673 if ($par_id != $this->object->getPoolTree()->getRootId()) {
674 return (int) $par_id;
675 }
676
677 return null;
678 }
679
683 protected function showMedia(): void
684 {
685 $this->checkPermission("read");
686 $link_xml = "";
687 $pg_frame = "";
688
689 $item = new ilMediaPoolItem($this->mep_item_id);
690 $mob_id = $item->getForeignId();
691
692 $this->tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "components/ILIAS/COPage");
693 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
694 $this->tpl->setVariable(
695 "LOCATION_CONTENT_STYLESHEET",
697 );
698
699
701 $media_obj = new ilObjMediaObject($mob_id);
702
703
704 $this->tpl->setVariable("TITLE", " - " . $media_obj->getTitle());
705
706 $xml = "<dummy>";
707 // todo: we get always the first alias now (problem if mob is used multiple
708 // times in page)
709 $xml .= $media_obj->getXML(IL_MODE_ALIAS);
710 $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
711 $xml .= $link_xml;
712 $xml .= "</dummy>";
713 $wb_path = ilFileUtils::getWebspaceDir("output") . "/";
714
715 $mode = ($this->ctrl->getCmd() !== "showPreview")
716 ? "fullscreen"
717 : "media";
718 $enlarge_path = ilUtil::getImagePath("media/enlarge.svg", false, "output");
719 $fullscreen_link =
720 $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
721 $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path,
722 'link_params' => "ref_id=" . $this->requested_ref_id,'fullscreen_link' => $fullscreen_link,
723 'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
724 'ref_id' => $this->requested_ref_id, 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
725 $output = $this->xsl->process($xml, $params);
726
727 // unmask user html
728 $this->tpl->setVariable("MEDIA_CONTENT", $output);
729 }
730
737 public function showPage(): void
738 {
739 //$tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
740 $tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "components/ILIAS/COPage");
741
745
746 // get page object
747 $page_gui = $this->getMediaPoolPageGUI($this->mep_item_id);
748 $page_gui->setTemplate($tpl);
749
750 $page_gui->setTemplateOutput(false);
751 $page_gui->setHeader("");
752 $ret = $page_gui->showPage(true);
753
754 //$tpl->setBodyClass("ilMediaPoolPagePreviewBody");
755 $tpl->setVariable("MEDIA_CONTENT", "<div>" . $ret . "</div>");
756
757
759 exit;
760 }
761
762 protected function getMediaPoolPageGUI($mep_item_id, $old_nr = 0): ilMediaPoolPageGUI
763 {
764 $page_gui = new ilMediaPoolPageGUI($mep_item_id, $old_nr);
765 $page_gui->setPoolGUI($this);
766
767 return $page_gui;
768 }
769
770
774 public function showPreview(): void
775 {
776 $this->checkPermission("read");
777
778 $item = new ilMediaPoolItem($this->mep_item_id);
779
780 switch ($item->getType()) {
781 case "mob":
782 $this->showMedia();
783 break;
784
785 case "pg":
786 $this->showPage();
787 break;
788 }
789 }
790
791
795 public function showFullscreen(): void
796 {
797 $this->showMedia();
798 }
799
803 public function confirmRemove(): void
804 {
805 $ilCtrl = $this->ctrl;
807
808 $this->checkPermission("write");
809
810 $ids = $this->mep_request->getItemIds();
811 if (count($ids) === 0) {
812 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
813 $ilCtrl->redirect($this, "");
814 }
815
816 // display confirmation message
817 $cgui = new ilConfirmationGUI();
818 $cgui->setFormAction($this->ctrl->getFormAction($this));
819 $cgui->setHeaderText($this->lng->txt("info_remove_sure"));
820 $cgui->setCancel($this->lng->txt("cancel"), "cancelRemove");
821 $cgui->setConfirm($this->lng->txt("confirm"), "remove");
822
823 foreach ($ids as $obj_id) {
826
827 // check whether page can be removed
828 $add = "";
829 if ($type === "pg") {
830 $usages = ilPageContentUsage::getUsages("incl", $obj_id, false);
831 if (count($usages) > 0) {
832 $this->main_tpl->setOnScreenMessage('failure', sprintf($lng->txt("mep_content_snippet_in_use"), $title), true);
833 $ilCtrl->redirect($this, "listMedia");
834 } else {
835 // check whether the snippet is used in older versions of pages
836 $usages = ilPageContentUsage::getUsages("incl", $obj_id, true);
837 if (count($usages) > 0) {
838 $add = "<div class='small'>" . $lng->txt("mep_content_snippet_used_in_older_versions") . "</div>";
839 }
840 }
841 }
842
843 $caption =
844 " " . $title . $add;
845
846 $cgui->addItem("id[]", $obj_id, $caption);
847 }
848
849 $this->tpl->setContent($cgui->getHTML());
850 }
851
855 public function openClipboard(): void
856 {
857 $ilCtrl = $this->ctrl;
858
859 $this->checkPermission("write");
860
861 $ilCtrl->setParameterByClass(
862 "ileditclipboardgui",
863 "returnCommand",
864 rawurlencode($ilCtrl->getLinkTarget(
865 $this,
866 "insertFromClipboard",
867 "",
868 false,
869 false
870 ))
871 );
872 $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
873 }
874
875
879 public function insertFromClipboard(): void
880 {
881 $this->checkPermission("write");
882
883 $this->domain->mediapool($this->object->getId())
884 ->copySelectedFromEditClipboard($this->mep_item_id);
885
886 /*
887 if (count($not_inserted) > 0) {
888 $this->main_tpl->setOnScreenMessage('info', $this->lng->txt("mep_not_insert_already_exist") . "<br>" .
889 implode("<br>", $not_inserted), true);
890 }*/
891 $this->ctrl->redirect($this, $this->mode);
892 }
893
894
898 public function cancelRemove(): void
899 {
900 $this->ctrl->redirect($this, $this->mode);
901 }
902
903 public function remove(): void
904 {
905 $this->checkPermission("write");
906
907 $ids = $this->mep_request->getItemIds();
908 foreach ($ids as $obj_id) {
909 $this->object->deleteChild($obj_id);
910 }
911
912 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("cont_obj_removed"), true);
913 $this->ctrl->redirect($this, $this->mode);
914 }
915
916
920 public function copyToClipboard(): void
921 {
922 $ilUser = $this->user;
923
924 $this->checkPermission("write");
925
926 $ids = $this->mep_request->getItemIds();
927 if (count($ids) === 0) {
928 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
929 $this->ctrl->redirect($this, $this->mode);
930 }
931
932 foreach ($ids as $obj_id) {
934 if ($type === "fold") {
935 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("cont_cant_copy_folders"), true);
936 $this->ctrl->redirect($this, $this->mode);
937 }
938 }
939 foreach ($ids as $obj_id) {
942 if ($type === "mob") {
943 $ilUser->addObjectToClipboard($fid, "mob", "");
944 }
945 if ($type === "pg") {
946 $ilUser->addObjectToClipboard($obj_id, "incl", "");
947 }
948 }
949 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("copied_to_clipboard"), true);
950 $this->ctrl->redirect($this, $this->mode);
951 }
952
956 protected function addLocatorItems(): void
957 {
958 $ilLocator = $this->locator;
959 $ilAccess = $this->access;
960 if (!$this->getCreationMode() && $this->ctrl->getCmd() !== "explorer") {
961 $tree = $this->object->getTree();
964 foreach ($path as $node) {
965 if ($node["child"] == $tree->getRootId()) {
966 $this->ctrl->setParameter($this, "mepitem_id", "");
967 $link = "";
968 if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
969 $link = $this->ctrl->getLinkTarget($this, "listMedia");
970 } elseif ($ilAccess->checkAccess("visible", "", $this->object->getRefId())) {
971 $link = $this->ctrl->getLinkTarget($this, "infoScreen");
972 }
973 $title = $this->object->getTitle();
974 $this->ctrl->setParameter($this, "mepitem_id", $this->mep_item_id);
975 $ilLocator->addItem($title, $link, "", $this->requested_ref_id);
976 }
977 }
978 }
979 }
980
984
985 public function createFolderForm(): void
986 {
988
989 $this->checkPermission("write");
990
991 $this->initFolderForm("create");
992 $tpl->setContent($this->form->getHTML());
993 }
994
995 public function editFolder(): void
996 {
998
999 $this->checkPermission("write");
1000
1001 $this->initFolderForm();
1002 $this->getFolderValues();
1003 $tpl->setContent($this->form->getHTML());
1004 }
1005
1009 public function getFolderValues(): void
1010 {
1011 $values = array();
1012
1013 $values["title"] = ilMediaPoolItem::lookupTitle($this->mep_item_id);
1014
1015 $this->form->setValuesByArray($values);
1016 }
1017
1021 public function saveFolder(): void
1022 {
1023 $tpl = $this->tpl;
1024 $lng = $this->lng;
1025 $ilCtrl = $this->ctrl;
1026
1027 $this->checkPermission("write");
1028
1029 $this->initFolderForm("create");
1030 if ($this->form->checkInput()) {
1031 if ($this->object->createFolder($this->form->getInput("title"), $this->mep_item_id)) {
1032 $this->main_tpl->setOnScreenMessage('success', $lng->txt("mep_folder_created"), true);
1033 }
1034 $ilCtrl->redirect($this, "listMedia");
1035 }
1036
1037 $this->form->setValuesByPost();
1038 $tpl->setContent($this->form->getHTML());
1039 }
1040
1041 public function updateFolder(): void
1042 {
1043 $lng = $this->lng;
1044 $ilCtrl = $this->ctrl;
1045 $tpl = $this->tpl;
1046
1047 $this->checkPermission("write");
1048
1049 $this->initFolderForm("edit");
1050 if ($this->form->checkInput()) {
1051 $item = new ilMediaPoolItem($this->mep_item_id);
1052 $item->setTitle($this->form->getInput("title"));
1053 $item->update();
1054 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1055 $ilCtrl->setParameter(
1056 $this,
1057 "mepitem_id",
1058 $this->object->getTree()->getParentId($this->mep_item_id)
1059 );
1060 $ilCtrl->redirect($this, "listMedia");
1061 }
1062
1063 $this->form->setValuesByPost();
1064 $tpl->setContent($this->form->getHTML());
1065 }
1066
1071 public function initFolderForm(string $a_mode = "edit"): void
1072 {
1073 $lng = $this->lng;
1074 $ilCtrl = $this->ctrl;
1075
1076 $this->form = new ilPropertyFormGUI();
1077
1078 // desc
1079 $ti = new ilTextInputGUI($lng->txt("title"), "title");
1080 $ti->setMaxLength(128);
1081 $ti->setRequired(true);
1082 $this->form->addItem($ti);
1083
1084 // save and cancel commands
1085 if ($a_mode === "create") {
1086 $this->form->addCommandButton("saveFolder", $lng->txt("save"));
1087 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1088 $this->form->setTitle($lng->txt("mep_new_folder"));
1089 } else {
1090 $this->form->addCommandButton("updateFolder", $lng->txt("save"));
1091 $this->form->addCommandButton("cancelFolderUpdate", $lng->txt("cancel"));
1092 $this->form->setTitle($lng->txt("mep_edit_folder"));
1093 }
1094
1095 $this->form->setFormAction($ilCtrl->getFormAction($this));
1096 }
1097
1098 public function cancelFolderUpdate(): void
1099 {
1100 $ilCtrl = $this->ctrl;
1101 $ilCtrl->setParameter(
1102 $this,
1103 "mepitem_id",
1104 $this->object->getTree()->getParentId($this->mep_item_id)
1105 );
1106 $ilCtrl->redirect($this, "listMedia");
1107 }
1108
1109 public function cancelSave(): void
1110 {
1111 $ilCtrl = $this->ctrl;
1112 $ilCtrl->redirect($this, "listMedia");
1113 }
1114
1118
1122 public function setContentSubTabs(
1123 string $a_active
1124 ): void {
1125 $ilAccess = $this->access;
1126 $ilTabs = $this->tabs;
1127 $ilCtrl = $this->ctrl;
1128
1129 $ilTabs->addSubTab("content", $this->lng->txt("objs_fold"), $this->ctrl->getLinkTarget($this, ""));
1130
1131 $ilCtrl->setParameter($this, "mepitem_id", "");
1132 $ilTabs->addSubTab("mep_all_mobs", $this->lng->txt("mep_all_mobs"), $this->ctrl->getLinkTarget($this, "allMedia"));
1133 $ilCtrl->setParameter($this, "mepitem_id", $this->mep_item_id);
1134
1135 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
1136 $ilTabs->addSubTab(
1137 "srt_files",
1138 $this->lng->txt("mep_media_subtitles"),
1139 $ilCtrl->getLinkTargetByClass("ilmobmultisrtuploadgui", "")
1140 );
1141 }
1142
1143 $ilTabs->activateSubTab($a_active);
1144 }
1145
1146 protected function setTabs(): void
1147 {
1148 $ilAccess = $this->access;
1149 $ilTabs = $this->tabs;
1150 $ilHelp = $this->help;
1151
1152 $ilHelp->setScreenIdComponent("mep");
1153
1154 if ($ilAccess->checkAccess('read', '', $this->ref_id) ||
1155 $ilAccess->checkAccess('write', '', $this->ref_id)) {
1156 $ilTabs->addTab("content", $this->lng->txt("mep_content"), $this->ctrl->getLinkTarget($this, ""));
1157 }
1158
1159 // info tab
1160 if ($ilAccess->checkAccess('visible', '', $this->ref_id) ||
1161 $ilAccess->checkAccess('read', '', $this->ref_id) ||
1162 $ilAccess->checkAccess('write', '', $this->ref_id)) {
1163 $ilTabs->addTab(
1164 "info_short",
1165 $this->lng->txt("info_short"),
1166 $this->ctrl->getLinkTargetByClass(
1167 array("ilobjmediapoolgui", "ilinfoscreengui"),
1168 "showSummary"
1169 )
1170 );
1171 }
1172
1173 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1174 $ilTabs->addTab(
1175 "settings",
1176 $this->lng->txt("settings"),
1177 $this->ctrl->getLinkTargetByClass(SettingsGUI::class)
1178 );
1179 }
1180 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1181 $ilTabs->addTab(
1182 "clipboard",
1183 $this->lng->txt("clipboard"),
1184 $this->ctrl->getLinkTarget($this, "openClipboard")
1185 );
1186 }
1187
1188 // properties
1189 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1190 // meta data
1191 $mdgui = new ilObjectMetaDataGUI($this->object, ['mob', "mpg"]);
1192 $mdtab = $mdgui->getTab();
1193 if ($mdtab) {
1194 $ilTabs->addTab(
1195 "meta_data",
1196 $this->lng->txt("meta_data"),
1197 $mdtab
1198 );
1199 }
1200 }
1201
1202 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1203 $ilTabs->addTab(
1204 "export",
1205 $this->lng->txt("export"),
1206 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
1207 );
1208
1209 $ilTabs->addTab(
1210 "import",
1211 $this->lng->txt("import"),
1212 $this->ctrl->getLinkTargetByClass("ilmediapoolimportgui", "")
1213 );
1214 }
1215
1216 if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId())) {
1217 $ilTabs->addTab(
1218 "perm_settings",
1219 $this->lng->txt("perm_settings"),
1220 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
1221 );
1222 }
1223 }
1224
1225 public function setSettingsSubTabs(
1226 string $a_active
1227 ): void {
1228 $ilTabs = $this->tabs;
1229 $lng = $this->lng;
1230 $ilAccess = $this->access;
1231
1232 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1233 $ilTabs->addSubTab(
1234 "settings",
1235 $lng->txt("settings"),
1236 $this->ctrl->getLinkTarget($this, "edit")
1237 );
1238
1239 $mset = new ilSetting("mobs");
1240 if ($mset->get("mep_activate_pages")) {
1241 $ilTabs->addSubTabTarget(
1242 "obj_multilinguality",
1243 $this->ctrl->getLinkTargetByClass(TranslationGUI::class, "")
1244 );
1245 }
1246 }
1247
1248 $ilTabs->setSubTabActive($a_active);
1249 }
1250
1251
1252 public static function _goto(string $a_target): void
1253 {
1254 global $DIC;
1255 $main_tpl = $DIC->ui()->mainTemplate();
1256
1257 $ilAccess = $DIC->access();
1258 $lng = $DIC->language();
1259 $ctrl = $DIC->ctrl();
1260
1261 $subitem_id = "";
1262 $targets = explode('_', $a_target);
1263 $ref_id = $targets[0];
1264 if (count((array) $targets) > 1) {
1265 $subitem_id = $targets[1];
1266 }
1267
1268 $ctrl->setParameterByClass("ilMediaPoolPresentationGUI", "ref_id", $ref_id);
1269 if ($ilAccess->checkAccess("read", "", $ref_id)) {
1270 $ctrl->setParameterByClass("ilMediaPoolPresentationGUI", "mepitem_id", $subitem_id);
1271 $ctrl->redirectByClass("ilMediaPoolPresentationGUI", "");
1272 } elseif ($ilAccess->checkAccess("visible", "", $ref_id)) {
1273 $ctrl->redirectByClass("ilMediaPoolPresentationGUI", "infoScreen");
1274 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1275 $main_tpl->setOnScreenMessage('failure', sprintf(
1276 $lng->txt("msg_no_perm_read_item"),
1278 ), true);
1280 }
1281
1282 throw new ilPermissionException($lng->txt("msg_no_perm_read"));
1283 }
1284
1288 public function infoScreenObject(): void
1289 {
1290 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
1291 }
1292
1298 public function infoScreen(): void
1299 {
1300 $this->tabs->activateTab("info_short");
1301 $ilAccess = $this->access;
1302
1303 if (!$ilAccess->checkAccess("visible", "", $this->ref_id) &&
1304 !$ilAccess->checkAccess("read", "", $this->ref_id) &&
1305 !$ilAccess->checkAccess("write", "", $this->ref_id)) {
1306 throw new ilPermissionException($this->lng->txt("msg_no_perm_read"));
1307 }
1308
1309 if ($this->ctrl->getCmd() === "infoScreen") {
1310 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
1311 }
1312
1313 $info = new ilInfoScreenGUI($this);
1314
1315 $info->enablePrivateNotes();
1316
1317
1318 // standard meta data
1319 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1320
1321 // forward the command
1322 $this->ctrl->forwardCommand($info);
1323 }
1324
1325
1329
1333 public function selectUploadDirFiles(
1334 ?array $a_files = null
1335 ): void {
1336 $tpl = $this->tpl;
1337 $ilTabs = $this->tabs;
1338 $lng = $this->lng;
1339 $ilCtrl = $this->ctrl;
1340 $ilToolbar = $this->toolbar;
1341
1342
1343 if (!$a_files) {
1344 $a_files = $this->mep_request->getFiles();
1345 }
1346
1347 $ilTabs->clearTargets();
1348 $ilTabs->setBackTarget(
1349 $lng->txt("back"),
1350 $ilCtrl->getLinkTarget($this, "listMedia")
1351 );
1352
1353 $this->checkPermission("write");
1354
1355 if ($this->rbac_system->checkAccess("visible", SYSTEM_FOLDER_ID)) {
1356 $tb = new ilToolbarGUI();
1357 // action type
1358 $options = array(
1359 "rename" => $lng->txt("mep_up_dir_move"),
1360 "copy" => $lng->txt("mep_up_dir_copy"),
1361 );
1362 $si = new ilSelectInputGUI("", "action");
1363 $si->setOptions($options);
1364 $tb->addInputItem($si);
1365 $tb->setCloseFormTag(false);
1366 $tb->setFormAction($ilCtrl->getFormAction($this));
1367 $tb->setFormName("mep_up_form");
1368
1369 $tab = new ilUploadDirFilesTableGUI(
1370 $this,
1371 "selectUploadDirFiles",
1372 $a_files
1373 );
1374 $tab->setFormName("mep_up_form");
1375 $tpl->setContent($tb->getHTML() . $tab->getHTML());
1376 }
1377 }
1378
1382 public static function getPreviewModalHTML(
1383 int $a_mpool_ref_id,
1385 ): string {
1386 global $DIC;
1387
1388 $tpl = $DIC["tpl"];
1389 $ilCtrl = $DIC->ctrl();
1390 $lng = $DIC->language();
1391 $internal_gui = $DIC->mediaPool()
1392 ->internal()
1393 ->gui();
1394 $request = $internal_gui
1395 ->standardRequest();
1396
1398
1399 $tpl->addJavaScript("assets/js/ilMediaPool.js");
1400
1401 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", "");
1402 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $a_mpool_ref_id);
1403 $tpl->addOnloadCode("il.MediaPool.setPreviewUrl('" . $ilCtrl->getLinkTargetByClass(array("ilmediapoolpresentationgui", "ilobjmediapoolgui"), "showPreview", "", false, false) . "');");
1404 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", $request->getItemId());
1405 $ilCtrl->setParameterByClass(
1406 "ilobjmediapoolgui",
1407 "ref_id",
1408 $request->getRefId()
1409 );
1410
1411 $modal = $internal_gui->ui()->factory()->modal()->roundtrip(
1412 $lng->txt("preview"),
1413 $internal_gui->ui()->factory()->legacy()->content("<iframe id='ilMepPreviewContent'></iframe>")
1414 );
1415 $html = $internal_gui->ui()->renderer()->render($modal);
1416 $html = str_replace(
1417 "<iframe id='ilMepPreviewContent'",
1418 "<iframe data-signal='" . $modal->getShowSignal()->getId() . "' id='ilMepPreviewContent'",
1419 $html
1420 );
1421
1422 return $html;
1423 }
1424
1425 public function export(): void
1426 {
1427 $ot = $this->object->getObjectProperties()->getPropertyTranslations();
1428 $opt = "";
1429 if ($ot->getContentTranslationActivated()) {
1430 $format = explode("_", $this->mep_request->getExportFormat());
1431 $opt = ilUtil::stripSlashes($format[1]);
1432 }
1433
1434 $this->object->exportXML($opt);
1435 }
1436
1437 //
1438 // BULK UPLOAD
1439 //
1440
1441 protected function bulkUpload(): void
1442 {
1443 $this->checkPermission("write");
1444
1445 $main_tpl = $this->main_tpl;
1446
1447 $form = $this->getBulkUploadForm();
1448 $main_tpl->setContent($form->render());
1449 }
1450
1451 protected function getBulkUploadForm(): FormAdapterGUI
1452 {
1453 if (is_null($this->bulk_upload_form)) {
1454 $mep_hash = uniqid();
1455 $this->ctrl->setParameter($this, "mep_hash", $mep_hash);
1456 $this->bulk_upload_form = $this->gui
1457 ->form([self::class], 'performBulkUpload')
1458 ->section("props", $this->lng->txt('mep_bulk_upload'))
1459 ->file(
1460 "media_files",
1461 $this->lng->txt("mep_media_files"),
1462 \Closure::fromCallable([$this, 'handleUploadResult']),
1463 "mep_id",
1464 "",
1465 20
1466 );
1467 // ->meta()->text()->meta()->textarea()
1468 }
1469 return $this->bulk_upload_form;
1470 }
1471
1472 protected function handleUploadResult(
1473 FileUpload $upload,
1474 UploadResult $result
1476 $title = $result->getName();
1477
1478 $mob = new ilObjMediaObject();
1479 $mob->setTitle($title);
1480 $mob->setDescription("");
1481 $mob->create();
1482
1483 $media_item = $mob->addMediaItemFromUpload(
1484 "Standard",
1485 $result,
1486 $this->mep_request->getUploadHash()
1487 );
1488
1489 $mob->update();
1490
1491 /*
1492 $mob->createDirectory();
1493 $media_item = new ilMediaItem();
1494 $mob->addMediaItem($media_item);
1495 $media_item->setPurpose("Standard");
1496
1497 $mob_dir = ilObjMediaObject::_getRelativeDirectory($mob->getId());
1498 $file_name = ilObjMediaObject::fixFilename($title);
1499 $file = $mob_dir . "/" . $file_name;
1500
1501 $upload->moveOneFileTo(
1502 $result,
1503 $mob_dir,
1504 Location::WEB,
1505 $file_name,
1506 true
1507 );*/
1508
1509 // duration
1510 $med_item = $mob->getMediaItem("Standard");
1511 $med_item->determineDuration();
1512 $med_item->update();
1513
1514
1515 $mep_item = new ilMediaPoolItem();
1516 $mep_item->setTitle($title);
1517 $mep_item->setType("mob");
1518 $mep_item->setForeignId($mob->getId());
1519 $mep_item->create();
1520
1521 $tree = $this->object->getTree();
1522 $parent = $this->mep_item_id;
1523 $tree->insertNode($mep_item->getId(), $parent);
1524
1525 // get mime type
1526 /*
1527 $format = ilObjMediaObject::getMimeType($file);
1528 $location = $file_name;
1529
1530 // set real meta and object data
1531 $media_item->setFormat($format);
1532 $media_item->setLocation($location);
1533 $media_item->setLocationType("LocalFile");
1534 $media_item->setUploadHash($this->mep_request->getUploadHash());
1535 $mob->update();*/
1536
1537 $item_ids[] = $mob->getId();
1538
1539 /*
1540 $mob = new ilObjMediaObject($mob->getId());
1541 $mob->generatePreviewPic(320, 240);*/
1542
1543 // duration
1544 /*
1545 $med_item = $mob->getMediaItem("Standard");
1546 $med_item->determineDuration();
1547 $med_item->update();*/
1548
1549 return new BasicHandlerResult(
1550 "mep_id",
1551 HandlerResult::STATUS_OK,
1552 $med_item->getId(),
1553 ''
1554 );
1555 }
1556
1560 public function performBulkUpload(): void
1561 {
1562 $this->checkPermission("write");
1563 $this->ctrl->setParameter($this, "mep_hash", $this->mep_request->getUploadHash());
1564 $this->ctrl->redirect($this, "editTitlesAndDescriptions");
1565 }
1566
1567 protected function editTitlesAndDescriptions(): void
1568 {
1569 $ctrl = $this->ctrl;
1570 $lng = $this->lng;
1571
1572 $this->checkPermission("write");
1573 $ctrl->saveParameter($this, "mep_hash");
1574
1575 $main_tpl = $this->main_tpl;
1576
1578 $this->mep_request->getUploadHash()
1579 );
1580
1581 $tb = new ilToolbarGUI();
1582 $tb->setFormAction($ctrl->getFormAction($this));
1583 $tb->addFormButton($lng->txt("save"), "saveTitlesAndDescriptions");
1584 $tb->setOpenFormTag(true);
1585 $tb->setCloseFormTag(false);
1586 $tb->setId("tb_top");
1587
1588 $html = $tb->getHTML();
1589 foreach ($media_items as $mi) {
1590 $acc = new ilAccordionGUI();
1591 $acc->setBehaviour(ilAccordionGUI::ALL_CLOSED);
1592 $acc->setId("acc_" . $mi["mob_id"]);
1593
1594 $mob = new ilObjMediaObject($mi["mob_id"]);
1595 $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
1596 $acc->addItem($mob->getTitle(), $form->getHTML());
1597
1598 $html .= $acc->getHTML();
1599 }
1600
1601 $html .= $tb->getHTML();
1602 $tb->setOpenFormTag(false);
1603 $tb->setCloseFormTag(true);
1604 $tb->setId("tb_bottom");
1605
1606 $main_tpl->setContent($html);
1607 }
1608
1612 public function initMediaBulkForm(
1613 int $a_id,
1614 string $a_title
1616 $lng = $this->lng;
1617
1618 $form = new ilPropertyFormGUI();
1619 $form->setOpenTag(false);
1620 $form->setCloseTag(false);
1621
1622 // title
1623 $ti = new ilTextInputGUI($lng->txt("title"), "title_" . $a_id);
1624 $ti->setValue($a_title);
1625 $form->addItem($ti);
1626
1627 // description
1628 $ti = new ilTextAreaInputGUI($lng->txt("description"), "description_" . $a_id);
1629 $form->addItem($ti);
1630
1631 return $form;
1632 }
1633
1634 protected function saveTitlesAndDescriptions(): void
1635 {
1636 $lng = $this->lng;
1637 $ctrl = $this->ctrl;
1638
1639 $this->checkPermission("write");
1641 $this->mep_request->getUploadHash()
1642 );
1643
1644 foreach ($media_items as $mi) {
1645 $mob = new ilObjMediaObject($mi["mob_id"]);
1646 $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
1647 $form->checkInput();
1648 $title = $form->getInput("title_" . $mi["mob_id"]);
1649 $desc = $form->getInput("description_" . $mi["mob_id"]);
1650 if (trim($title) !== "") {
1651 $mob->setTitle($title);
1652 }
1653 $mob->setDescription($desc);
1654 $mob->update();
1655 }
1656 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1657 $ctrl->redirect($this, "listMedia");
1658 }
1659
1660 protected function move(): void
1661 {
1662 ilSession::set("mep_move_ids", $this->mep_request->getItemIds());
1663 $this->main_tpl->setOnScreenMessage('info', $this->lng->txt("mep_move_select_insert"), true);
1664 $this->ctrl->redirect($this, "listMedia");
1665 }
1666
1667 protected function paste(): void
1668 {
1669 $target_folder_id = $this->mep_request->getItemId();
1670 $target_tree = $this->domain->tree($this->object->getId());
1671 if (ilMediaPoolItem::lookupType($target_folder_id) !== "fold") {
1672 $target_folder_id = $target_tree->readRootId();
1673 }
1674
1675 try {
1676 $this->domain->mediapool($this->object->getId())->pasteFromClipboard($target_folder_id);
1677 } catch (Exception $e) {
1678 $this->main_tpl->setOnScreenMessage(
1679 'failure',
1680 $this->lng->txt("mep_target_in_source_not_allowed") . " " . $e->getMessage(),
1681 true
1682 );
1683 }
1684
1685 $this->ctrl->redirect($this, "listMedia");
1686 }
1687
1688 protected function afterUpload($mob_ids): void
1689 {
1690 $this->addMobsToPool($mob_ids, "", false);
1691 }
1692
1693 protected function afterUrlSaving(int $mob_id, string $long_desc): void
1694 {
1695 $this->addMobsToPool([$mob_id], $long_desc);
1696 }
1697
1698 protected function addMobsToPool(
1699 array $mob_ids,
1700 string $long_desc = "",
1701 bool $redirect = true,
1702 bool $extract = false
1703 ): void {
1704 $ctrl = $this->ctrl;
1705 $user = $this->user;
1706
1707 $item_ids = [];
1708 foreach ($mob_ids as $mob_id) {
1709 $object = new ilObjMediaObject($mob_id);
1710 if (!is_null($object)) {
1711 $mep_item = new ilMediaPoolItem();
1712 $mep_item->setTitle($object->getTitle());
1713 $mep_item->setType("mob");
1714 $mep_item->setForeignId($object->getId());
1715 $mep_item->create();
1716
1717 $parent = $this->mep_item_id;
1718 $tree = $this->object->getTree();
1719 $tree->insertNode($mep_item->getId(), $parent);
1720 }
1721 }
1722
1723 if ($redirect) {
1724 $ctrl->redirect($this, "listMedia");
1725 }
1726 }
1727
1728 protected function afterPoolInsert(array $mob_ids): void
1729 {
1730 $this->addMobsToPool($mob_ids, "", true, true);
1731 }
1732
1733 public function finishSingleUpload(int $mob_id): void
1734 {
1735 $this->ctrl->redirect($this, "listMedia");
1736 }
1737
1738 protected function onMobUpdate(int $mob_id): void
1739 {
1740 }
1741
1742}
const IL_MODE_ALIAS
const IL_MODE_OUTPUT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Export User Interface Class.
static getWebspaceDir(string $mode="filesystem")
get webspace directory
setCloseTag(bool $a_val)
setOpenTag(bool $a_open)
special template class to simplify handling of ITX/PEAR
Help GUI class.
Class ilInfoScreenGUI.
loadLanguageModule(string $a_module)
Load language module.
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 getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
static getMediaItemsForUploadHash(string $a_hash)
Get media items for upload hash.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Import related features for media pools (currently used for translation imports)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupTitle(int $a_id)
static lookupForeignId(int $a_id)
static lookupType(int $a_id)
Class ilMediaPoolPage GUI class.
TableGUI class for recent changes in wiki.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjFolderGUI.
Editing User Interface for MediaObjects within LMs (see ILIAS DTD)
static includePresentationJS(?ilGlobalTemplateInterface $a_tpl=null)
Include media object presentation JS.
static isTypeAllowed(string $a_type)
User Interface class for media pool objects.
afterSave(ilObject $new_object)
Post (successful) object creation hook.
StandardGUIRequest $mep_request
initMediaBulkForm(int $a_id, string $a_title)
Init media bulk form.
cancelRemove()
cancel deletion of media objects/folders
performBulkUpload()
Save bulk upload form.
getTemplate()
Get standard template.
showMedia()
show media object
setTabs()
create tabs (repository/workspace switch)
addLocatorItems()
add locator items for media pool
getFolderValues()
Get current values for folder from.
showFullscreen()
show media fullscreen
allMedia()
list all media objects
openClipboard()
paste from clipboard
selectUploadDirFiles(?array $a_files=null)
Select files from upload directory.
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
setSettingsSubTabs(string $a_active)
getParentFolderId()
Get folder parent ID.
getMediaPoolPageGUI($mep_item_id, $old_nr=0)
handleUploadResult(FileUpload $upload, UploadResult $result)
confirmRemove()
confirm remove of mobs
static getPreviewModalHTML(int $a_mpool_ref_id, ilGlobalTemplateInterface $a_tpl)
Get preview modal html.
FormAdapterGUI $bulk_upload_form
infoScreenObject()
this one is called from the info button in the repository
ilGlobalTemplateInterface $main_tpl
showPreview()
Show content snippet.
saveFolder()
Save folder form.
static _goto(string $a_target)
ILIAS COPage Xsl XslManager $xsl
infoScreen()
show information screen
addMobsToPool(array $mob_ids, string $long_desc="", bool $redirect=true, bool $extract=false)
ILIAS MediaPool InternalDomainService $domain
returnFromItem()
Return from item editing.
insertFromClipboard()
insert media object from clipboard
afterUrlSaving(int $mob_id, string $long_desc)
copyToClipboard()
copy media objects to clipboard
setContentSubTabs(string $a_active)
Set sub tabs for content tab.
listMedia()
list media objects
getType()
Functions that must be overwritten.
initFolderForm(string $a_mode="edit")
InternalGUIService $gui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
New implementation of ilObjectGUI.
ilAccessHandler $access
ilGlobalTemplateInterface $tpl
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilLocatorGUI $locator
setLocator()
set Locator
prepareOutput(bool $show_sub_objects=true)
ilToolbarGUI $toolbar
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
addHeaderAction()
Add header action menu.
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static getUsages(string $a_pc_type, int $a_pc_id, bool $a_incl_hist=true)
Get usages.
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
This class represents a selection list property in a property form.
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
ILIAS Setting Class.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
insertNode(int $a_node_id, int $a_parent_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deletion_date=false)
insert new node with node_id under parent node with parent_id
getParentId(int $a_node_id)
get parent id of given node
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static redirect(string $a_script)
const SYSTEM_FOLDER_ID
Definition: constants.php:35
const ROOT_FOLDER_ID
Definition: constants.php:32
exit
$info
Definition: entry_point.php:21
Interface Location.
Definition: Location.php:33
setVariable(string $variable, $value='')
Sets the given variable to the given value.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
printToStdout(string $part=self::DEFAULT_BLOCK, bool $has_tabs=true, bool $skip_main_menu=false)
setContent(string $a_html)
Sets content for standard template.
Interface ilDBInterface.
$ref_id
Definition: ltiauth.php:66
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
$path
Definition: ltiservices.php:30
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form(?array $class_path, string $cmd, string $submit_caption="")
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26