ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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":
394 $this->prepareOutput();
396 $this->ctrl->forwardCommand($gui);
397 break;
398
399 case strtolower(TranslationGUI::class):
400 $this->prepareOutput();
401 $this->addHeaderAction();
402 //$this->setTabs("settings");
403 $ilTabs->activateTab("settings");
404 $this->setSettingsSubTabs("obj_multilinguality");
405 $transgui = new TranslationGUI(
406 $this->getObject(),
407 $this->lng,
408 $this->access,
409 $this->user,
410 $this->ctrl,
411 $this->tpl,
412 $this->ui_factory,
413 $this->ui_renderer,
414 $this->http,
415 $this->refinery,
416 $this->toolbar
417 );
418 $transgui->forceContentTranslation();
419 $this->ctrl->forwardCommand($transgui);
420 $this->tpl->printToStdout();
421 break;
422
423 case "ilmediapoolimportgui":
424 $this->prepareOutput();
425 $this->addHeaderAction();
426 $this->checkPermission("write");
427 $ilTabs->activateTab("import");
428 $gui = new ilMediaPoolImportGUI($this->getMediaPool());
429 $this->ctrl->forwardCommand($gui);
430 $this->tpl->printToStdout();
431 break;
432
433 case "ilmobmultisrtuploadgui":
434 $this->checkPermission("write");
435 $this->prepareOutput();
436 $this->addHeaderAction();
437 $this->setContentSubTabs("srt_files");
438 $gui = new ilMobMultiSrtUploadGUI(new ilMepMultiSrt($this->getMediaPool()));
439 $this->ctrl->forwardCommand($gui);
440 $this->tpl->printToStdout();
441 break;
442
443 case strtolower(ilObjectMetaDataGUI::class):
444 $this->checkPermission("write");
445 $this->prepareOutput();
446 $this->addHeaderAction();
447 $ilTabs->activateTab("meta_data");
448 $gui = new ilObjectMetaDataGUI($this->object);
449 $this->ctrl->forwardCommand($gui);
450 break;
451
452 case strtolower(SettingsGUI::class):
453 $this->checkPermission("write");
454 $this->prepareOutput();
455 $this->addHeaderAction();
456 $this->setSettingsSubTabs("settings");
457 $ilTabs->activateTab("settings");
458 $gui = $this->gui->settings()->settingsGUI(
459 $this->object->getId()
460 );
461 $this->ctrl->forwardCommand($gui);
462 $this->tpl->printToStdout();
463 break;
464
465 default:
466 $this->prepareOutput();
467 $this->addHeaderAction();
468 $cmd = $this->ctrl->getCmd("listMedia") ?: "listMedia";
469 $this->$cmd();
470 if (!$this->getCreationMode()) {
471 $this->tpl->printToStdout();
472 }
473 break;
474 }
475 }
476
480 protected function returnFromItem(): void
481 {
483
484 $type = ilMediaPoolItem::lookupType($this->mep_item_id);
485 if ($type !== "fold") {
486 $tree = $this->object->getTree();
487 $fold_id = $tree->getParentId($this->mep_item_id);
488 if ($fold_id > 0) {
489 $ctrl->setParameter($this, "mepitem_id", $fold_id);
490 $ctrl->redirect($this, "listMedia");
491 }
492 }
493 $this->listMedia();
494 }
495
496 public function createMediaObject(): void
497 {
498 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
499 }
500
501 protected function afterSave(ilObject $new_object): void
502 {
503 // always send a message
504 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
505
506 //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
507 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&ref_id=" . $new_object->getRefId() . "&cmd=listMedia");
508 }
509
510 public function edit(): void
511 {
512 $this->ctrl->redirectByClass(SettingsGUI::class);
513 }
514
515
519 public function listMedia(): void
520 {
521 $ilAccess = $this->access;
523 $ilTabs = $this->tabs;
524 $ilCtrl = $this->ctrl;
525 $ilToolbar = $this->toolbar;
527
528 $ilCtrl->setParameter($this, "mep_mode", "listMedia");
529
530 $this->checkPermission("read");
531
532 $ilTabs->setTabActive("content");
533 $this->setContentSubTabs("content");
534
535 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
536 $ilToolbar->addButton(
537 $lng->txt("mep_create_mob"),
538 $ilCtrl->getLinkTargetByClass("ilMediaCreationGUI", "")
539 );
540
541 $mset = new ilSetting("mobs");
542 if ($mset->get("mep_activate_pages")) {
543 $ilToolbar->addButton(
544 $lng->txt("mep_create_content_snippet"),
545 $ilCtrl->getLinkTargetByClass(["ilobjmediapoolgui", "ilmediapoolpagegui"], "createMediaPoolPage")
546 );
547 }
548
549 $ilToolbar->addButton(
550 $lng->txt("mep_create_folder"),
551 $ilCtrl->getLinkTarget($this, "createFolderForm")
552 );
553
554 $ilToolbar->addButton(
555 $lng->txt("mep_bulk_upload"),
556 $ilCtrl->getLinkTarget($this, "bulkUpload")
557 );
558
559 $move_ids = ilSession::get("mep_move_ids");
560 if (is_array($move_ids) && count($move_ids) > 0) {
561 $ilToolbar->addSeparator();
562 $ilToolbar->addButton(
563 $lng->txt("paste"),
564 $ilCtrl->getLinkTarget($this, "paste")
565 );
566 }
567 }
568
569 $mep_table_gui = new ilMediaPoolTableGUI($this, "listMedia", $this->getMediaPool(), "mepitem_id");
570 $tpl->setContent($mep_table_gui->getHTML());
571 }
572
573 protected function toggleExplorerNodeState(): void
574 {
575 $exp = new ilMediaPoolExplorerGUI($this, "listMedia", $this->getMediaPool());
576 $exp->toggleExplorerNodeState();
577 }
578
582 public function allMedia(): void
583 {
585 $ilTabs = $this->tabs;
586 $ilCtrl = $this->ctrl;
587 $ilUser = $this->user;
588
589 $ilCtrl->setParameter($this, "mep_mode", "allMedia");
590
591 $this->checkPermission("read");
592 $ilTabs->setTabActive("content");
593 $this->setContentSubTabs("mep_all_mobs");
594
595 $mep_table_gui = new ilMediaPoolTableGUI(
596 $this,
597 "allMedia",
598 $this->getMediaPool(),
599 "mepitem_id",
601 true
602 );
603
604 if ($this->mep_request->getForceFilter() > 0) {
605 $mep_table_gui->setTitleFilter(
606 ilMediaPoolItem::lookupTitle($this->mep_request->getForceFilter())
607 );
608
609 // Read again
610 $mep_table_gui = new ilMediaPoolTableGUI(
611 $this,
612 "allMedia",
613 $this->getMediaPool(),
614 "mepitem_id",
616 true
617 );
618 }
619
620 $tpl->setContent($mep_table_gui->getHTML());
621 }
622
626 public function applyFilter(): void
627 {
628 $mtab = new ilMediaPoolTableGUI(
629 $this,
630 "allMedia",
631 $this->getMediaPool(),
632 "mepitem_id",
634 true
635 );
636 $mtab->writeFilterToSession();
637 $mtab->resetOffset();
638 $this->allMedia();
639 }
640
641 public function resetFilter(): void
642 {
643 $mtab = new ilMediaPoolTableGUI(
644 $this,
645 "allMedia",
646 $this->getMediaPool(),
647 "mepitem_id",
649 true
650 );
651 $mtab->resetFilter();
652 $mtab->resetOffset();
653 $this->allMedia();
654 }
655
659 public function getTemplate(): void
660 {
661 $this->tpl->loadStandardTemplate();
662 }
663
664
668 public function getParentFolderId(): ?int
669 {
670 if ($this->mep_item_id == 0) {
671 return null;
672 }
673 $par_id = $this->object->getPoolTree()->getParentId($this->mep_item_id);
674 if ($par_id != $this->object->getPoolTree()->getRootId()) {
675 return (int) $par_id;
676 }
677
678 return null;
679 }
680
684 protected function showMedia(): void
685 {
686 $this->checkPermission("read");
687 $link_xml = "";
688 $pg_frame = "";
689
690 $item = new ilMediaPoolItem($this->mep_item_id);
691 $mob_id = $item->getForeignId();
692
693 $this->tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "components/ILIAS/COPage");
694 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
695 $this->tpl->setVariable(
696 "LOCATION_CONTENT_STYLESHEET",
698 );
699
700
702 $media_obj = new ilObjMediaObject($mob_id);
703
704
705 $this->tpl->setVariable("TITLE", " - " . $media_obj->getTitle());
706
707 $xml = "<dummy>";
708 // todo: we get always the first alias now (problem if mob is used multiple
709 // times in page)
710 $xml .= $media_obj->getXML(IL_MODE_ALIAS);
711 $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
712 $xml .= $link_xml;
713 $xml .= "</dummy>";
714 $wb_path = ilFileUtils::getWebspaceDir("output") . "/";
715
716 $mode = ($this->ctrl->getCmd() !== "showPreview")
717 ? "fullscreen"
718 : "media";
719 $enlarge_path = ilUtil::getImagePath("media/enlarge.svg", false, "output");
720 $fullscreen_link =
721 $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
722 $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path,
723 'link_params' => "ref_id=" . $this->requested_ref_id,'fullscreen_link' => $fullscreen_link,
724 'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
725 'ref_id' => $this->requested_ref_id, 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
726 $output = $this->xsl->process($xml, $params);
727
728 // unmask user html
729 $this->tpl->setVariable("MEDIA_CONTENT", $output);
730 }
731
738 public function showPage(): void
739 {
740 //$tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
741 $tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "components/ILIAS/COPage");
742
746
747 // get page object
748 $page_gui = $this->getMediaPoolPageGUI($this->mep_item_id);
749 $page_gui->setTemplate($tpl);
750
751 $page_gui->setTemplateOutput(false);
752 $page_gui->setHeader("");
753 $ret = $page_gui->showPage(true);
754
755 //$tpl->setBodyClass("ilMediaPoolPagePreviewBody");
756 $tpl->setVariable("MEDIA_CONTENT", "<div>" . $ret . "</div>");
757
758
760 exit;
761 }
762
763 protected function getMediaPoolPageGUI($mep_item_id, $old_nr = 0): ilMediaPoolPageGUI
764 {
765 $page_gui = new ilMediaPoolPageGUI($mep_item_id, $old_nr);
766 $page_gui->setPoolGUI($this);
767
768 return $page_gui;
769 }
770
771
775 public function showPreview(): void
776 {
777 $this->checkPermission("read");
778
779 $item = new ilMediaPoolItem($this->mep_item_id);
780
781 switch ($item->getType()) {
782 case "mob":
783 $this->showMedia();
784 break;
785
786 case "pg":
787 $this->showPage();
788 break;
789 }
790 }
791
792
796 public function showFullscreen(): void
797 {
798 $this->showMedia();
799 }
800
804 public function confirmRemove(): void
805 {
806 $ilCtrl = $this->ctrl;
808
809 $this->checkPermission("write");
810
811 $ids = $this->mep_request->getItemIds();
812 if (count($ids) === 0) {
813 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
814 $ilCtrl->redirect($this, "");
815 }
816
817 // display confirmation message
818 $cgui = new ilConfirmationGUI();
819 $cgui->setFormAction($this->ctrl->getFormAction($this));
820 $cgui->setHeaderText($this->lng->txt("info_remove_sure"));
821 $cgui->setCancel($this->lng->txt("cancel"), "cancelRemove");
822 $cgui->setConfirm($this->lng->txt("confirm"), "remove");
823
824 foreach ($ids as $obj_id) {
827
828 // check whether page can be removed
829 $add = "";
830 if ($type === "pg") {
831 $usages = ilPageContentUsage::getUsages("incl", $obj_id, false);
832 if (count($usages) > 0) {
833 $this->main_tpl->setOnScreenMessage('failure', sprintf($lng->txt("mep_content_snippet_in_use"), $title), true);
834 $ilCtrl->redirect($this, "listMedia");
835 } else {
836 // check whether the snippet is used in older versions of pages
837 $usages = ilPageContentUsage::getUsages("incl", $obj_id, true);
838 if (count($usages) > 0) {
839 $add = "<div class='small'>" . $lng->txt("mep_content_snippet_used_in_older_versions") . "</div>";
840 }
841 }
842 }
843
844 $caption =
845 " " . $title . $add;
846
847 $cgui->addItem("id[]", $obj_id, $caption);
848 }
849
850 $this->tpl->setContent($cgui->getHTML());
851 }
852
856 public function openClipboard(): void
857 {
858 $ilCtrl = $this->ctrl;
859
860 $this->checkPermission("write");
861
862 $ilCtrl->setParameterByClass(
863 "ileditclipboardgui",
864 "returnCommand",
865 rawurlencode($ilCtrl->getLinkTarget(
866 $this,
867 "insertFromClipboard",
868 "",
869 false,
870 false
871 ))
872 );
873 $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
874 }
875
876
880 public function insertFromClipboard(): void
881 {
882 $this->checkPermission("write");
883
884 $this->domain->mediapool($this->object->getId())
885 ->copySelectedFromEditClipboard($this->mep_item_id);
886
887 /*
888 if (count($not_inserted) > 0) {
889 $this->main_tpl->setOnScreenMessage('info', $this->lng->txt("mep_not_insert_already_exist") . "<br>" .
890 implode("<br>", $not_inserted), true);
891 }*/
892 $this->ctrl->redirect($this, $this->mode);
893 }
894
895
899 public function cancelRemove(): void
900 {
901 $this->ctrl->redirect($this, $this->mode);
902 }
903
904 public function remove(): void
905 {
906 $this->checkPermission("write");
907
908 $ids = $this->mep_request->getItemIds();
909 foreach ($ids as $obj_id) {
910 $this->object->deleteChild($obj_id);
911 }
912
913 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("cont_obj_removed"), true);
914 $this->ctrl->redirect($this, $this->mode);
915 }
916
917
921 public function copyToClipboard(): void
922 {
923 $ilUser = $this->user;
924
925 $this->checkPermission("write");
926
927 $ids = $this->mep_request->getItemIds();
928 if (count($ids) === 0) {
929 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
930 $this->ctrl->redirect($this, $this->mode);
931 }
932
933 foreach ($ids as $obj_id) {
935 if ($type === "fold") {
936 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("cont_cant_copy_folders"), true);
937 $this->ctrl->redirect($this, $this->mode);
938 }
939 }
940 foreach ($ids as $obj_id) {
943 if ($type === "mob") {
944 $ilUser->addObjectToClipboard($fid, "mob", "");
945 }
946 if ($type === "pg") {
947 $ilUser->addObjectToClipboard($obj_id, "incl", "");
948 }
949 }
950 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("copied_to_clipboard"), true);
951 $this->ctrl->redirect($this, $this->mode);
952 }
953
957 protected function addLocatorItems(): void
958 {
959 $ilLocator = $this->locator;
960 $ilAccess = $this->access;
961 if (!$this->getCreationMode() && $this->ctrl->getCmd() !== "explorer") {
962 $tree = $this->object->getTree();
965 foreach ($path as $node) {
966 if ($node["child"] == $tree->getRootId()) {
967 $this->ctrl->setParameter($this, "mepitem_id", "");
968 $link = "";
969 if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
970 $link = $this->ctrl->getLinkTarget($this, "listMedia");
971 } elseif ($ilAccess->checkAccess("visible", "", $this->object->getRefId())) {
972 $link = $this->ctrl->getLinkTarget($this, "infoScreen");
973 }
974 $title = $this->object->getTitle();
975 $this->ctrl->setParameter($this, "mepitem_id", $this->mep_item_id);
976 $ilLocator->addItem($title, $link, "", $this->requested_ref_id);
977 }
978 }
979 }
980 }
981
985
986 public function createFolderForm(): void
987 {
989
990 $this->checkPermission("write");
991
992 $this->initFolderForm("create");
993 $tpl->setContent($this->form->getHTML());
994 }
995
996 public function editFolder(): void
997 {
999
1000 $this->checkPermission("write");
1001
1002 $this->initFolderForm();
1003 $this->getFolderValues();
1004 $tpl->setContent($this->form->getHTML());
1005 }
1006
1010 public function getFolderValues(): void
1011 {
1012 $values = array();
1013
1014 $values["title"] = ilMediaPoolItem::lookupTitle($this->mep_item_id);
1015
1016 $this->form->setValuesByArray($values);
1017 }
1018
1022 public function saveFolder(): void
1023 {
1024 $tpl = $this->tpl;
1025 $lng = $this->lng;
1026 $ilCtrl = $this->ctrl;
1027
1028 $this->checkPermission("write");
1029
1030 $this->initFolderForm("create");
1031 if ($this->form->checkInput()) {
1032 if ($this->object->createFolder($this->form->getInput("title"), $this->mep_item_id)) {
1033 $this->main_tpl->setOnScreenMessage('success', $lng->txt("mep_folder_created"), true);
1034 }
1035 $ilCtrl->redirect($this, "listMedia");
1036 }
1037
1038 $this->form->setValuesByPost();
1039 $tpl->setContent($this->form->getHTML());
1040 }
1041
1042 public function updateFolder(): void
1043 {
1044 $lng = $this->lng;
1045 $ilCtrl = $this->ctrl;
1046 $tpl = $this->tpl;
1047
1048 $this->checkPermission("write");
1049
1050 $this->initFolderForm("edit");
1051 if ($this->form->checkInput()) {
1052 $item = new ilMediaPoolItem($this->mep_item_id);
1053 $item->setTitle($this->form->getInput("title"));
1054 $item->update();
1055 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1056 $ilCtrl->setParameter(
1057 $this,
1058 "mepitem_id",
1059 $this->object->getTree()->getParentId($this->mep_item_id)
1060 );
1061 $ilCtrl->redirect($this, "listMedia");
1062 }
1063
1064 $this->form->setValuesByPost();
1065 $tpl->setContent($this->form->getHTML());
1066 }
1067
1072 public function initFolderForm(string $a_mode = "edit"): void
1073 {
1074 $lng = $this->lng;
1075 $ilCtrl = $this->ctrl;
1076
1077 $this->form = new ilPropertyFormGUI();
1078
1079 // desc
1080 $ti = new ilTextInputGUI($lng->txt("title"), "title");
1081 $ti->setMaxLength(128);
1082 $ti->setRequired(true);
1083 $this->form->addItem($ti);
1084
1085 // save and cancel commands
1086 if ($a_mode === "create") {
1087 $this->form->addCommandButton("saveFolder", $lng->txt("save"));
1088 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1089 $this->form->setTitle($lng->txt("mep_new_folder"));
1090 } else {
1091 $this->form->addCommandButton("updateFolder", $lng->txt("save"));
1092 $this->form->addCommandButton("cancelFolderUpdate", $lng->txt("cancel"));
1093 $this->form->setTitle($lng->txt("mep_edit_folder"));
1094 }
1095
1096 $this->form->setFormAction($ilCtrl->getFormAction($this));
1097 }
1098
1099 public function cancelFolderUpdate(): void
1100 {
1101 $ilCtrl = $this->ctrl;
1102 $ilCtrl->setParameter(
1103 $this,
1104 "mepitem_id",
1105 $this->object->getTree()->getParentId($this->mep_item_id)
1106 );
1107 $ilCtrl->redirect($this, "listMedia");
1108 }
1109
1110 public function cancelSave(): void
1111 {
1112 $ilCtrl = $this->ctrl;
1113 $ilCtrl->redirect($this, "listMedia");
1114 }
1115
1119
1123 public function setContentSubTabs(
1124 string $a_active
1125 ): void {
1126 $ilAccess = $this->access;
1127 $ilTabs = $this->tabs;
1128 $ilCtrl = $this->ctrl;
1129
1130 $ilTabs->addSubTab("content", $this->lng->txt("objs_fold"), $this->ctrl->getLinkTarget($this, ""));
1131
1132 $ilCtrl->setParameter($this, "mepitem_id", "");
1133 $ilTabs->addSubTab("mep_all_mobs", $this->lng->txt("mep_all_mobs"), $this->ctrl->getLinkTarget($this, "allMedia"));
1134 $ilCtrl->setParameter($this, "mepitem_id", $this->mep_item_id);
1135
1136 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
1137 $ilTabs->addSubTab(
1138 "srt_files",
1139 $this->lng->txt("mep_media_subtitles"),
1140 $ilCtrl->getLinkTargetByClass("ilmobmultisrtuploadgui", "")
1141 );
1142 }
1143
1144 $ilTabs->activateSubTab($a_active);
1145 }
1146
1147 protected function setTabs(): void
1148 {
1149 $ilAccess = $this->access;
1150 $ilTabs = $this->tabs;
1151 $ilHelp = $this->help;
1152
1153 $ilHelp->setScreenIdComponent("mep");
1154
1155 if ($ilAccess->checkAccess('read', '', $this->ref_id) ||
1156 $ilAccess->checkAccess('write', '', $this->ref_id)) {
1157 $ilTabs->addTab("content", $this->lng->txt("mep_content"), $this->ctrl->getLinkTarget($this, ""));
1158 }
1159
1160 // info tab
1161 if ($ilAccess->checkAccess('visible', '', $this->ref_id) ||
1162 $ilAccess->checkAccess('read', '', $this->ref_id) ||
1163 $ilAccess->checkAccess('write', '', $this->ref_id)) {
1164 $ilTabs->addTab(
1165 "info_short",
1166 $this->lng->txt("info_short"),
1167 $this->ctrl->getLinkTargetByClass(
1168 array("ilobjmediapoolgui", "ilinfoscreengui"),
1169 "showSummary"
1170 )
1171 );
1172 }
1173
1174 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1175 $ilTabs->addTab(
1176 "settings",
1177 $this->lng->txt("settings"),
1178 $this->ctrl->getLinkTargetByClass(SettingsGUI::class)
1179 );
1180 }
1181 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1182 $ilTabs->addTab(
1183 "clipboard",
1184 $this->lng->txt("clipboard"),
1185 $this->ctrl->getLinkTarget($this, "openClipboard")
1186 );
1187 }
1188
1189 // properties
1190 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1191 // meta data
1192 $mdgui = new ilObjectMetaDataGUI($this->object, ['mob', "mpg"]);
1193 $mdtab = $mdgui->getTab();
1194 if ($mdtab) {
1195 $ilTabs->addTab(
1196 "meta_data",
1197 $this->lng->txt("meta_data"),
1198 $mdtab
1199 );
1200 }
1201 }
1202
1203 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1204 $ilTabs->addTab(
1205 "export",
1206 $this->lng->txt("export"),
1207 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
1208 );
1209
1210 $ilTabs->addTab(
1211 "import",
1212 $this->lng->txt("import"),
1213 $this->ctrl->getLinkTargetByClass("ilmediapoolimportgui", "")
1214 );
1215 }
1216
1217 if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId())) {
1218 $ilTabs->addTab(
1219 "perm_settings",
1220 $this->lng->txt("perm_settings"),
1221 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
1222 );
1223 }
1224 }
1225
1226 public function setSettingsSubTabs(
1227 string $a_active
1228 ): void {
1229 $ilTabs = $this->tabs;
1230 $lng = $this->lng;
1231 $ilAccess = $this->access;
1232
1233 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1234 $ilTabs->addSubTab(
1235 "settings",
1236 $lng->txt("settings"),
1237 $this->ctrl->getLinkTarget($this, "edit")
1238 );
1239
1240 $mset = new ilSetting("mobs");
1241 if ($mset->get("mep_activate_pages")) {
1242 $ilTabs->addSubTabTarget(
1243 "obj_multilinguality",
1244 $this->ctrl->getLinkTargetByClass(TranslationGUI::class, "")
1245 );
1246 }
1247 }
1248
1249 $ilTabs->setSubTabActive($a_active);
1250 }
1251
1252
1253 public static function _goto(string $a_target): void
1254 {
1255 global $DIC;
1256 $main_tpl = $DIC->ui()->mainTemplate();
1257
1258 $ilAccess = $DIC->access();
1259 $lng = $DIC->language();
1260 $ctrl = $DIC->ctrl();
1261
1262 $subitem_id = "";
1263 $targets = explode('_', $a_target);
1264 $ref_id = $targets[0];
1265 if (count((array) $targets) > 1) {
1266 $subitem_id = $targets[1];
1267 }
1268
1269 $ctrl->setParameterByClass("ilMediaPoolPresentationGUI", "ref_id", $ref_id);
1270 if ($ilAccess->checkAccess("read", "", $ref_id)) {
1271 $ctrl->setParameterByClass("ilMediaPoolPresentationGUI", "mepitem_id", $subitem_id);
1272 $ctrl->redirectByClass("ilMediaPoolPresentationGUI", "");
1273 } elseif ($ilAccess->checkAccess("visible", "", $ref_id)) {
1274 $ctrl->redirectByClass("ilMediaPoolPresentationGUI", "infoScreen");
1275 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1276 $main_tpl->setOnScreenMessage('failure', sprintf(
1277 $lng->txt("msg_no_perm_read_item"),
1279 ), true);
1281 }
1282
1283 throw new ilPermissionException($lng->txt("msg_no_perm_read"));
1284 }
1285
1289 public function infoScreenObject(): void
1290 {
1291 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
1292 }
1293
1299 public function infoScreen(): void
1300 {
1301 $this->tabs->activateTab("info_short");
1302 $ilAccess = $this->access;
1303
1304 if (!$ilAccess->checkAccess("visible", "", $this->ref_id) &&
1305 !$ilAccess->checkAccess("read", "", $this->ref_id) &&
1306 !$ilAccess->checkAccess("write", "", $this->ref_id)) {
1307 throw new ilPermissionException($this->lng->txt("msg_no_perm_read"));
1308 }
1309
1310 if ($this->ctrl->getCmd() === "infoScreen") {
1311 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
1312 }
1313
1314 $info = new ilInfoScreenGUI($this);
1315
1316 $info->enablePrivateNotes();
1317
1318
1319 // standard meta data
1320 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1321
1322 // forward the command
1323 $this->ctrl->forwardCommand($info);
1324 }
1325
1326
1330
1334 public function selectUploadDirFiles(
1335 ?array $a_files = null
1336 ): void {
1337 $tpl = $this->tpl;
1338 $ilTabs = $this->tabs;
1339 $lng = $this->lng;
1340 $ilCtrl = $this->ctrl;
1341 $ilToolbar = $this->toolbar;
1342
1343
1344 if (!$a_files) {
1345 $a_files = $this->mep_request->getFiles();
1346 }
1347
1348 $ilTabs->clearTargets();
1349 $ilTabs->setBackTarget(
1350 $lng->txt("back"),
1351 $ilCtrl->getLinkTarget($this, "listMedia")
1352 );
1353
1354 $this->checkPermission("write");
1355
1356 if ($this->rbac_system->checkAccess("visible", SYSTEM_FOLDER_ID)) {
1357 $tb = new ilToolbarGUI();
1358 // action type
1359 $options = array(
1360 "rename" => $lng->txt("mep_up_dir_move"),
1361 "copy" => $lng->txt("mep_up_dir_copy"),
1362 );
1363 $si = new ilSelectInputGUI("", "action");
1364 $si->setOptions($options);
1365 $tb->addInputItem($si);
1366 $tb->setCloseFormTag(false);
1367 $tb->setFormAction($ilCtrl->getFormAction($this));
1368 $tb->setFormName("mep_up_form");
1369
1370 $tab = new ilUploadDirFilesTableGUI(
1371 $this,
1372 "selectUploadDirFiles",
1373 $a_files
1374 );
1375 $tab->setFormName("mep_up_form");
1376 $tpl->setContent($tb->getHTML() . $tab->getHTML());
1377 }
1378 }
1379
1383 public static function getPreviewModalHTML(
1384 int $a_mpool_ref_id,
1386 ): string {
1387 global $DIC;
1388
1389 $tpl = $DIC["tpl"];
1390 $ilCtrl = $DIC->ctrl();
1391 $lng = $DIC->language();
1392 $internal_gui = $DIC->mediaPool()
1393 ->internal()
1394 ->gui();
1395 $request = $internal_gui
1396 ->standardRequest();
1397
1399
1400 $tpl->addJavaScript("assets/js/ilMediaPool.js");
1401
1402 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", "");
1403 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $a_mpool_ref_id);
1404 $tpl->addOnloadCode("il.MediaPool.setPreviewUrl('" . $ilCtrl->getLinkTargetByClass(array("ilmediapoolpresentationgui", "ilobjmediapoolgui"), "showPreview", "", false, false) . "');");
1405 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", $request->getItemId());
1406 $ilCtrl->setParameterByClass(
1407 "ilobjmediapoolgui",
1408 "ref_id",
1409 $request->getRefId()
1410 );
1411
1412 $modal = $internal_gui->ui()->factory()->modal()->roundtrip(
1413 $lng->txt("preview"),
1414 $internal_gui->ui()->factory()->legacy()->content("<iframe id='ilMepPreviewContent'></iframe>")
1415 );
1416 $html = $internal_gui->ui()->renderer()->render($modal);
1417 $html = str_replace(
1418 "<iframe id='ilMepPreviewContent'",
1419 "<iframe data-signal='" . $modal->getShowSignal()->getId() . "' id='ilMepPreviewContent'",
1420 $html
1421 );
1422
1423 return $html;
1424 }
1425
1426 public function export(): void
1427 {
1428 $ot = $this->object->getObjectProperties()->getPropertyTranslations();
1429 $opt = "";
1430 if ($ot->getContentTranslationActivated()) {
1431 $format = explode("_", $this->mep_request->getExportFormat());
1432 $opt = ilUtil::stripSlashes($format[1]);
1433 }
1434
1435 $this->object->exportXML($opt);
1436 }
1437
1438 //
1439 // BULK UPLOAD
1440 //
1441
1442 protected function bulkUpload(): void
1443 {
1444 $this->checkPermission("write");
1445
1446 $main_tpl = $this->main_tpl;
1447
1448 $form = $this->getBulkUploadForm();
1449 $main_tpl->setContent($form->render());
1450 }
1451
1452 protected function getBulkUploadForm(): FormAdapterGUI
1453 {
1454 if (is_null($this->bulk_upload_form)) {
1455 $mep_hash = uniqid();
1456 $this->ctrl->setParameter($this, "mep_hash", $mep_hash);
1457 $this->bulk_upload_form = $this->gui
1458 ->form([self::class], 'performBulkUpload')
1459 ->section("props", $this->lng->txt('mep_bulk_upload'))
1460 ->file(
1461 "media_files",
1462 $this->lng->txt("mep_media_files"),
1463 \Closure::fromCallable([$this, 'handleUploadResult']),
1464 "mep_id",
1465 "",
1466 20
1467 );
1468 // ->meta()->text()->meta()->textarea()
1469 }
1470 return $this->bulk_upload_form;
1471 }
1472
1473 protected function handleUploadResult(
1474 FileUpload $upload,
1475 UploadResult $result
1477 $title = $result->getName();
1478
1479 $mob = new ilObjMediaObject();
1480 $mob->setTitle($title);
1481 $mob->setDescription("");
1482 $mob->create();
1483
1484 $media_item = $mob->addMediaItemFromUpload(
1485 "Standard",
1486 $result,
1487 $this->mep_request->getUploadHash()
1488 );
1489
1490 $mob->update();
1491
1492 /*
1493 $mob->createDirectory();
1494 $media_item = new ilMediaItem();
1495 $mob->addMediaItem($media_item);
1496 $media_item->setPurpose("Standard");
1497
1498 $mob_dir = ilObjMediaObject::_getRelativeDirectory($mob->getId());
1499 $file_name = ilObjMediaObject::fixFilename($title);
1500 $file = $mob_dir . "/" . $file_name;
1501
1502 $upload->moveOneFileTo(
1503 $result,
1504 $mob_dir,
1505 Location::WEB,
1506 $file_name,
1507 true
1508 );*/
1509
1510 // duration
1511 $med_item = $mob->getMediaItem("Standard");
1512 $med_item->determineDuration();
1513 $med_item->update();
1514
1515
1516 $mep_item = new ilMediaPoolItem();
1517 $mep_item->setTitle($title);
1518 $mep_item->setType("mob");
1519 $mep_item->setForeignId($mob->getId());
1520 $mep_item->create();
1521
1522 $tree = $this->object->getTree();
1523 $parent = $this->mep_item_id;
1524 $tree->insertNode($mep_item->getId(), $parent);
1525
1526 // get mime type
1527 /*
1528 $format = ilObjMediaObject::getMimeType($file);
1529 $location = $file_name;
1530
1531 // set real meta and object data
1532 $media_item->setFormat($format);
1533 $media_item->setLocation($location);
1534 $media_item->setLocationType("LocalFile");
1535 $media_item->setUploadHash($this->mep_request->getUploadHash());
1536 $mob->update();*/
1537
1538 $item_ids[] = $mob->getId();
1539
1540 /*
1541 $mob = new ilObjMediaObject($mob->getId());
1542 $mob->generatePreviewPic(320, 240);*/
1543
1544 // duration
1545 /*
1546 $med_item = $mob->getMediaItem("Standard");
1547 $med_item->determineDuration();
1548 $med_item->update();*/
1549
1550 return new BasicHandlerResult(
1551 "mep_id",
1552 HandlerResult::STATUS_OK,
1553 $med_item->getId(),
1554 ''
1555 );
1556 }
1557
1561 public function performBulkUpload(): void
1562 {
1563 $this->checkPermission("write");
1564 $this->ctrl->setParameter($this, "mep_hash", $this->mep_request->getUploadHash());
1565 $this->ctrl->redirect($this, "editTitlesAndDescriptions");
1566 }
1567
1568 protected function editTitlesAndDescriptions(): void
1569 {
1570 $ctrl = $this->ctrl;
1571 $lng = $this->lng;
1572
1573 $this->checkPermission("write");
1574 $ctrl->saveParameter($this, "mep_hash");
1575
1576 $main_tpl = $this->main_tpl;
1577
1579 $this->mep_request->getUploadHash()
1580 );
1581
1582 $tb = new ilToolbarGUI();
1583 $tb->setFormAction($ctrl->getFormAction($this));
1584 $tb->addFormButton($lng->txt("save"), "saveTitlesAndDescriptions");
1585 $tb->setOpenFormTag(true);
1586 $tb->setCloseFormTag(false);
1587 $tb->setId("tb_top");
1588
1589 $html = $tb->getHTML();
1590 foreach ($media_items as $mi) {
1591 $acc = new ilAccordionGUI();
1592 $acc->setBehaviour(ilAccordionGUI::ALL_CLOSED);
1593 $acc->setId("acc_" . $mi["mob_id"]);
1594
1595 $mob = new ilObjMediaObject($mi["mob_id"]);
1596 $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
1597 $acc->addItem($mob->getTitle(), $form->getHTML());
1598
1599 $html .= $acc->getHTML();
1600 }
1601
1602 $html .= $tb->getHTML();
1603 $tb->setOpenFormTag(false);
1604 $tb->setCloseFormTag(true);
1605 $tb->setId("tb_bottom");
1606
1607 $main_tpl->setContent($html);
1608 }
1609
1613 public function initMediaBulkForm(
1614 int $a_id,
1615 string $a_title
1617 $lng = $this->lng;
1618
1619 $form = new ilPropertyFormGUI();
1620 $form->setOpenTag(false);
1621 $form->setCloseTag(false);
1622
1623 // title
1624 $ti = new ilTextInputGUI($lng->txt("title"), "title_" . $a_id);
1625 $ti->setValue($a_title);
1626 $form->addItem($ti);
1627
1628 // description
1629 $ti = new ilTextAreaInputGUI($lng->txt("description"), "description_" . $a_id);
1630 $form->addItem($ti);
1631
1632 return $form;
1633 }
1634
1635 protected function saveTitlesAndDescriptions(): void
1636 {
1637 $lng = $this->lng;
1638 $ctrl = $this->ctrl;
1639
1640 $this->checkPermission("write");
1642 $this->mep_request->getUploadHash()
1643 );
1644
1645 foreach ($media_items as $mi) {
1646 $mob = new ilObjMediaObject($mi["mob_id"]);
1647 $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
1648 $form->checkInput();
1649 $title = $form->getInput("title_" . $mi["mob_id"]);
1650 $desc = $form->getInput("description_" . $mi["mob_id"]);
1651 if (trim($title) !== "") {
1652 $mob->setTitle($title);
1653 }
1654 $mob->setDescription($desc);
1655 $mob->update();
1656 }
1657 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1658 $ctrl->redirect($this, "listMedia");
1659 }
1660
1661 protected function move(): void
1662 {
1663 ilSession::set("mep_move_ids", $this->mep_request->getItemIds());
1664 $this->main_tpl->setOnScreenMessage('info', $this->lng->txt("mep_move_select_insert"), true);
1665 $this->ctrl->redirect($this, "listMedia");
1666 }
1667
1668 protected function paste(): void
1669 {
1670 $target_folder_id = $this->mep_request->getItemId();
1671 $target_tree = $this->domain->tree($this->object->getId());
1672 if (ilMediaPoolItem::lookupType($target_folder_id) !== "fold") {
1673 $target_folder_id = $target_tree->readRootId();
1674 }
1675
1676 try {
1677 $this->domain->mediapool($this->object->getId())->pasteFromClipboard($target_folder_id);
1678 } catch (Exception $e) {
1679 $this->main_tpl->setOnScreenMessage(
1680 'failure',
1681 $this->lng->txt("mep_target_in_source_not_allowed") . " " . $e->getMessage(),
1682 true
1683 );
1684 }
1685
1686 $this->ctrl->redirect($this, "listMedia");
1687 }
1688
1689 protected function afterUpload($mob_ids): void
1690 {
1691 $this->addMobsToPool($mob_ids, "", false);
1692 }
1693
1694 protected function afterUrlSaving(int $mob_id, string $long_desc): void
1695 {
1696 $this->addMobsToPool([$mob_id], $long_desc);
1697 }
1698
1699 protected function addMobsToPool(
1700 array $mob_ids,
1701 string $long_desc = "",
1702 bool $redirect = true,
1703 bool $extract = false
1704 ): void {
1705 $ctrl = $this->ctrl;
1706 $user = $this->user;
1707
1708 $item_ids = [];
1709 foreach ($mob_ids as $mob_id) {
1710 $object = new ilObjMediaObject($mob_id);
1711 if (!is_null($object)) {
1712 $mep_item = new ilMediaPoolItem();
1713 $mep_item->setTitle($object->getTitle());
1714 $mep_item->setType("mob");
1715 $mep_item->setForeignId($object->getId());
1716 $mep_item->create();
1717
1718 $parent = $this->mep_item_id;
1719 $tree = $this->object->getTree();
1720 $tree->insertNode($mep_item->getId(), $parent);
1721 }
1722 }
1723
1724 if ($redirect) {
1725 $ctrl->redirect($this, "listMedia");
1726 }
1727 }
1728
1729 protected function afterPoolInsert(array $mob_ids): void
1730 {
1731 $this->addMobsToPool($mob_ids, "", true, true);
1732 }
1733
1734 public function finishSingleUpload(int $mob_id): void
1735 {
1736 $this->ctrl->redirect($this, "listMedia");
1737 }
1738
1739 protected function onMobUpdate(int $mob_id): void
1740 {
1741 }
1742
1743}
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