ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilObjMediaPoolGUI.php
Go to the documentation of this file.
1<?php
2
27
39{
43 protected string $mode;
44 protected int $mep_item_id = 0;
46 protected ilTabsGUI $tabs;
47 protected ilHelpGUI $help;
50 protected ilLogger $mep_log;
51 public bool $output_prepared;
52
53 public function __construct(
54 int $a_id = 0,
55 int $a_id_type = self::REPOSITORY_NODE_ID,
56 int $a_parent_node_id = 0
57 ) {
58 global $DIC;
59
60 $this->mep_request = $DIC->mediaPool()
61 ->internal()
62 ->gui()
63 ->standardRequest();
64 $this->mep_item_id = $this->mep_request->getItemId();
65
66 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
67
68 $this->tabs = $DIC->tabs();
69 $this->locator = $DIC["ilLocator"];
70 $this->help = $DIC["ilHelp"];
71
72 $this->main_tpl = $DIC->ui()->mainTemplate();
73
74 $this->upload = $DIC->upload();
75
76 $this->mep_log = ilLoggerFactory::getLogger("mep");
77
78
79 $this->mode = ($this->mep_request->getMode() !== "")
80 ? $this->mep_request->getMode()
81 : "listMedia";
82 $this->gui = $DIC->mediaPool()->internal()->gui();
83 }
84
85 protected function getMediaPool(): ilObjMediaPool
86 {
88 $mp = $this->object;
89 return $mp;
90 }
91
95 protected function afterConstructor(): void
96 {
98 if ($this->mep_item_id == 0 && !$this->getCreationMode()) {
99 $tree = $this->object->getTree();
100 $this->mep_item_id = $tree->readRootId();
101 }
102
103 $lng->loadLanguageModule("mep");
104
105 if ($this->ctrl->getCmd() === "explorer") {
106 $this->ctrl->saveParameter($this, array("ref_id"));
107 } else {
108 $this->ctrl->saveParameter($this, array("ref_id", "mepitem_id"));
109 }
110 $this->ctrl->saveParameter($this, array("mep_mode"));
111
112 $lng->loadLanguageModule("content");
113 }
114
115 final public function getType(): string
116 {
117 return "mep";
118 }
119
125 public function executeCommand(): void
126 {
127 $ilTabs = $this->tabs;
129 $ilAccess = $this->access;
131 $ilCtrl = $this->ctrl;
132
133 $tree = null;
134 if ($this->object) {
135 $tree = $this->object->getTree();
136 }
137
138 $next_class = $this->ctrl->getNextClass($this);
139 $cmd = $this->ctrl->getCmd();
140 $new_type = $this->mep_request->getNewType();
141
142
143
144 if ($new_type !== "" && ($cmd !== "confirmRemove" && $cmd !== "copyToClipboard"
145 && $cmd !== "pasteFromClipboard")) {
146 $this->tpl->setPermanentLink("mep", $this->ref_id);
147 $this->setCreationMode(true);
148 }
149
150 if ($cmd === "create") {
151 switch ($this->mep_request->getNewType()) {
152 case "mob":
153 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
154 break;
155
156 case "fold":
157 $this->ctrl->redirectByClass("ilobjfoldergui", "create");
158 break;
159 }
160 }
161
162 switch ($next_class) {
163 case 'ilobjectmetadatagui':
164 $this->checkPermission("write");
165
166 $this->prepareOutput();
167 $this->addHeaderAction();
168
169 $this->tabs_gui->activateTab('meta_data');
170 $md_gui = new ilObjectMetaDataGUI($this->object, ['mob', "mpg"]);
171 $this->ctrl->forwardCommand($md_gui);
172 $this->tpl->printToStdout();
173 break;
174
175 case strtolower(ilRepoStandardUploadHandlerGUI::class):
176 $this->checkPermission("write");
177 $form = $this->getBulkUploadForm();
178 $gui = $form->getRepoStandardUploadHandlerGUI("media_files");
179 $this->ctrl->forwardCommand($gui);
180 break;
181
182 case 'ilmediapoolpagegui':
183 $this->checkPermission("write");
184 $this->prepareOutput();
185 //$this->addHeaderAction();
186 $ilTabs->clearTargets();
187 $ilCtrl->setReturn($this, "returnFromItem");
188 $mep_page_gui = new ilMediaPoolPageGUI(
189 $this->mep_item_id,
190 $this->mep_request->getOldNr()
191 );
192 $mep_page_gui->setPoolGUI($this);
193 $mep_page_gui->setAdvMdRecordObject($this->object->getRefId(), "mep", "mpg");
194
195 if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
196 $mep_page_gui->setEnableEditing(false);
197 }
198 $ret = $this->ctrl->forwardCommand($mep_page_gui);
199 if ($ret != "") {
200 $tpl->setContent($ret);
201 }
202 $this->tpl->printToStdout();
203 break;
204
205 case "ilobjmediaobjectgui":
206 $this->checkPermission("write");
207 if ($cmd === "create" || $cmd === "save" || $cmd === "cancel") {
208 $ret_obj = $this->mep_item_id;
209 $ilObjMediaObjectGUI = new ilObjMediaObjectGUI("", 0, false, false);
210 $ilObjMediaObjectGUI->setWidthPreset((int) $this->getMediaPool()->getDefaultWidth());
211 $ilObjMediaObjectGUI->setHeightPreset((int) $this->getMediaPool()->getDefaultHeight());
212 } else {
213 $ret_obj = $tree->getParentId($this->mep_item_id);
214 $ilObjMediaObjectGUI = new ilObjMediaObjectGUI("", ilMediaPoolItem::lookupForeignId($this->mep_item_id), false, false);
215 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
216 $ilTabs->setBackTarget(
217 $lng->txt("back"),
218 $this->ctrl->getLinkTarget(
219 $this,
220 $this->mode
221 )
222 );
223 }
224 if ($this->ctrl->getCmdClass() === "ilinternallinkgui") {
225 $this->ctrl->setReturn($this, "explorer");
226 } else {
227 $this->ctrl->setParameter($this, "mepitem_id", $ret_obj);
228 $this->ctrl->setReturn(
229 $this,
230 $this->mode
231 );
232 $this->ctrl->setParameter($this, "mepitem_id", $this->mep_item_id);
233 }
234 $this->getTemplate();
235 $ilObjMediaObjectGUI->setTabs();
236 $this->setLocator();
237
238 // set adv metadata record dobject
239 $ilObjMediaObjectGUI->setAdvMdRecordObject($this->object->getRefId(), "mep", "mob");
240
241 $ret = $this->ctrl->forwardCommand($ilObjMediaObjectGUI);
242 if ($cmd === "save") {
243 $object = $ilObjMediaObjectGUI->getObject();
244 if (!is_null($object)) {
245 $mep_item = new ilMediaPoolItem();
246 $mep_item->setTitle($object->getTitle());
247 $mep_item->setType("mob");
248 $mep_item->setForeignId($object->getId());
249 $mep_item->create();
250
251 $parent = $this->mep_item_id;
252 $tree->insertNode($mep_item->getId(), $parent);
254 "ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" .
255 $this->requested_ref_id . "&mepitem_id=" . $this->mep_item_id
256 );
257 }
258 }
259 $this->tpl->printToStdout();
260 break;
261
262 case "ilobjfoldergui":
263 $this->checkPermission("write");
264 $this->addHeaderAction();
265 $folder_gui = new ilObjFolderGUI("", 0, false, false);
266 $this->ctrl->setReturn($this, "listMedia");
267 $cmd .= "Object";
268 switch ($cmd) {
269 case "createObject":
270 $this->prepareOutput();
271 $folder_gui = new ilObjFolderGUI("", 0, false, false);
272 $folder_gui->setFormAction(
273 "save",
274 $this->ctrl->getFormActionByClass("ilobjfoldergui")
275 );
276 $folder_gui->createObject();
277 $this->tpl->printToStdout();
278 break;
279
280 case "saveObject":
281 $parent = $this->mep_item_id;
282 $folder_gui->setFolderTree($tree);
283 $folder_gui->saveObject();
284 break;
285
286 case "editObject":
287 $this->prepareOutput();
288 $folder_gui = new ilObjFolderGUI(
289 "",
290 ilMediaPoolItem::lookupForeignId($this->mep_item_id),
291 false,
292 false
293 );
294 $this->ctrl->setParameter($this, "foldereditmode", "1");
295 $folder_gui->setFormAction("update", $this->ctrl->getFormActionByClass("ilobjfoldergui"));
296 $folder_gui->editObject();
297 $this->tpl->printToStdout();
298 break;
299
300 case "updateObject":
301 $folder_gui = new ilObjFolderGUI(
302 "",
303 ilMediaPoolItem::lookupForeignId($this->mep_item_id),
304 false,
305 false
306 );
307 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
308 $this->ctrl->setReturn($this, "listMedia");
309 $folder_gui->updateObject(); // this returns to parent
310 break;
311
312 case "cancelObject":
313 if ($this->mep_request->getFolderEditMode()) {
314 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
315 }
316 $this->ctrl->redirect($this, "listMedia");
317 break;
318 }
319 break;
320
321 case "ileditclipboardgui":
322 $this->prepareOutput();
323 $this->addHeaderAction();
324 $this->ctrl->setReturn($this, $this->mode);
325
326 $return_cmd = $ilCtrl->getLinkTarget(
327 $this,
328 "insertFromClipboard"
329 );
330
331 $clip_gui = new ilEditClipboardGUI($return_cmd);
332 $clip_gui->setMultipleSelections(true);
333 $clip_gui->setInsertButtonTitle($lng->txt("mep_copy_to_mep"));
334 $ilTabs->setTabActive("clipboard");
335 $this->ctrl->forwardCommand($clip_gui);
336 $this->tpl->printToStdout();
337 break;
338
339 case 'ilinfoscreengui':
340 $this->prepareOutput();
341 $this->addHeaderAction();
342 $this->infoScreen();
343 $this->tpl->printToStdout();
344 break;
345
346 case 'ilpermissiongui':
347 $this->checkPermission("edit_permission");
348 $this->prepareOutput();
349 $this->addHeaderAction();
350 $perm_gui = new ilPermissionGUI($this);
351 $ilTabs->activateTab("perm_settings");
352 $this->ctrl->forwardCommand($perm_gui);
353 $this->tpl->printToStdout();
354 break;
355
356 case "ilexportgui":
357 $this->checkPermission("write");
358 $this->prepareOutput();
359 $this->addHeaderAction();
360 $ilTabs->activateTab("export");
361 $exp_gui = new ilExportGUI($this);
362 $exp_gui->addFormat("xml");
363 $ot = ilObjectTranslation::getInstance($this->object->getId());
364 if ($ot->getContentActivated()) {
365 $exp_gui->addFormat("xml_master", "XML (" . $lng->txt("mep_master_language_only") . ")", $this, "export");
366 $exp_gui->addFormat("xml_masternomedia", "XML (" . $lng->txt("mep_master_language_only_no_media") . ")", $this, "export");
367 }
368 $this->ctrl->forwardCommand($exp_gui);
369 $this->tpl->printToStdout();
370 break;
371
372 case "ilfilesystemgui":
373 $this->checkPermission("write");
374 $this->prepareOutput();
375 $this->addHeaderAction();
376 $ilTabs->clearTargets();
377 $ilTabs->setBackTarget(
378 $lng->txt("back"),
379 $ilCtrl->getLinkTarget($this, "listMedia")
380 );
381 $mset = new ilSetting("mobs");
382 $import_directory_factory = new ilImportDirectoryFactory();
383 $mob_import_directory = $import_directory_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_MOB);
384 if ($mob_import_directory->exists()) {
385 $fs_gui = new ilFileSystemGUI($mob_import_directory->getAbsolutePath());
386 $fs_gui->setPostDirPath(true);
387 $fs_gui->setTableId("mepud" . $this->object->getId());
388 $fs_gui->setAllowFileCreation(false);
389 $fs_gui->setAllowDirectoryCreation(false);
390 $fs_gui->clearCommands();
391 $fs_gui->addCommand(
392 $this,
393 "selectUploadDirFiles",
394 $this->lng->txt("mep_sel_upload_dir_files"),
395 false,
396 true
397 );
398 $this->ctrl->forwardCommand($fs_gui);
399 }
400 $this->tpl->printToStdout();
401 break;
402
403 case "ilcommonactiondispatchergui":
405 $this->ctrl->forwardCommand($gui);
406 break;
407
408 case 'ilobjecttranslationgui':
409 $this->prepareOutput();
410 $this->addHeaderAction();
411 //$this->setTabs("settings");
412 $ilTabs->activateTab("settings");
413 $this->setSettingsSubTabs("obj_multilinguality");
414 $transgui = new ilObjectTranslationGUI($this);
415 $transgui->setTitleDescrOnlyMode(false);
416 $this->ctrl->forwardCommand($transgui);
417 $this->tpl->printToStdout();
418 break;
419
420 case "ilmediapoolimportgui":
421 $this->prepareOutput();
422 $this->addHeaderAction();
423 $this->checkPermission("write");
424 $ilTabs->activateTab("import");
425 $gui = new ilMediaPoolImportGUI($this->getMediaPool());
426 $this->ctrl->forwardCommand($gui);
427 $this->tpl->printToStdout();
428 break;
429
430 case "ilmobmultisrtuploadgui":
431 $this->checkPermission("write");
432 $this->prepareOutput();
433 $this->addHeaderAction();
434 $this->setContentSubTabs("srt_files");
435 $gui = new ilMobMultiSrtUploadGUI(new ilMepMultiSrt($this->getMediaPool()));
436 $this->ctrl->forwardCommand($gui);
437 $this->tpl->printToStdout();
438 break;
439
440
441 default:
442 $this->prepareOutput();
443 $this->addHeaderAction();
444 $cmd = $this->ctrl->getCmd("listMedia") ?: "listMedia";
445 $this->$cmd();
446 if (!$this->getCreationMode()) {
447 $this->tpl->printToStdout();
448 }
449 break;
450 }
451 }
452
456 protected function returnFromItem(): void
457 {
459
460 $type = ilMediaPoolItem::lookupType($this->mep_item_id);
461 if ($type !== "fold") {
462 $tree = $this->object->getTree();
463 $fold_id = $tree->getParentId($this->mep_item_id);
464 if ($fold_id > 0) {
465 $ctrl->setParameter($this, "mepitem_id", $fold_id);
466 $ctrl->redirect($this, "listMedia");
467 }
468 }
469 $this->listMedia();
470 }
471
472 public function createMediaObject(): void
473 {
474 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
475 }
476
477 protected function initCreationForms(string $new_type): array
478 {
479 $forms = array(self::CFORM_NEW => $this->initCreateForm($new_type),
480 self::CFORM_IMPORT => $this->initImportForm($new_type));
481
482 return $forms;
483 }
484
485 protected function afterSave(ilObject $new_object): void
486 {
487 // always send a message
488 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
489
490 //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
491 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&ref_id=" . $new_object->getRefId() . "&cmd=listMedia");
492 }
493
494 protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
495 {
496 $obj_service = $this->object_service;
497
498 // default width
499 $ni = new ilNumberInputGUI($this->lng->txt("mep_default_width"), "default_width");
500 $ni->setMinValue(0);
501 $ni->setSuffix("px");
502 $ni->setMaxLength(5);
503 $ni->setSize(5);
504 $a_form->addItem($ni);
505
506 // default height
507 $ni = new ilNumberInputGUI($this->lng->txt("mep_default_height"), "default_height");
508 $ni->setSuffix("px");
509 $ni->setMinValue(0);
510 $ni->setMaxLength(5);
511 $ni->setSize(5);
512 $ni->setInfo($this->lng->txt("mep_default_width_height_info"));
513 $a_form->addItem($ni);
514
515 // presentation
516 $pres = new ilFormSectionHeaderGUI();
517 $pres->setTitle($this->lng->txt('obj_presentation'));
518 $a_form->addItem($pres);
519
520 // tile image
521 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
522
523 // additional features
524 $feat = new ilFormSectionHeaderGUI();
525 $feat->setTitle($this->lng->txt('obj_features'));
526 $a_form->addItem($feat);
527
529 $this->object->getId(),
530 $a_form,
531 array(
533 )
534 );
535 }
536
540 public function edit(): void
541 {
543 $ilTabs = $this->tabs_gui;
544
545 $this->setSettingsSubTabs("settings");
546
547 if (!$this->checkPermissionBool("write")) {
548 throw new ilPermissionException($this->lng->txt("msg_no_perm_write"));
549 }
550
551 $ilTabs->activateTab("settings");
552
553 $form = $this->initEditForm();
554 $values = $this->getEditFormValues();
555 if ($values) {
556 $form->setValuesByArray($values, true);
557 }
558
559 $this->addExternalEditFormCustom($form);
560
562 }
563
564
565 protected function getEditFormCustomValues(array &$a_values): void
566 {
567 $ot = ilObjectTranslation::getInstance($this->getMediaPool()->getId());
568 if ($ot->getContentActivated()) {
569 $a_values["title"] = $ot->getDefaultTitle();
570 $a_values["desc"] = $ot->getDefaultDescription();
571 }
572 if ($this->getMediaPool()->getDefaultWidth() > 0) {
573 $a_values["default_width"] = $this->object->getDefaultWidth();
574 }
575 if ($this->getMediaPool()->getDefaultHeight() > 0) {
576 $a_values["default_height"] = $this->object->getDefaultHeight();
577 }
578 }
579
580 protected function updateCustom(ilPropertyFormGUI $form): void
581 {
582 $obj_service = $this->object_service;
583
584 $ot = ilObjectTranslation::getInstance($this->getMediaPool()->getId());
585 if ($ot->getContentActivated()) {
586 $ot->setDefaultTitle($form->getInput('title'));
587 $ot->setDefaultDescription($form->getInput('desc'));
588 $ot->save();
589 }
590
591 $this->getMediaPool()->setDefaultWidth($form->getInput("default_width"));
592 $this->object->setDefaultHeight($form->getInput("default_height"));
593
594 // additional features
596 $this->object->getId(),
597 $form,
598 array(
600 )
601 );
602
603 // tile image
604 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
605 }
606
610 public function listMedia(): void
611 {
612 $ilAccess = $this->access;
614 $ilTabs = $this->tabs;
615 $ilCtrl = $this->ctrl;
616 $ilToolbar = $this->toolbar;
618
619 $ilCtrl->setParameter($this, "mep_mode", "listMedia");
620
621 $this->checkPermission("read");
622
623 $ilTabs->setTabActive("content");
624 $this->setContentSubTabs("content");
625
626 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
627 $ilToolbar->addButton(
628 $lng->txt("mep_create_mob"),
629 $ilCtrl->getLinkTarget($this, "createMediaObject")
630 );
631
632 $mset = new ilSetting("mobs");
633 if ($mset->get("mep_activate_pages")) {
634 $ilToolbar->addButton(
635 $lng->txt("mep_create_content_snippet"),
636 $ilCtrl->getLinkTargetByClass(["ilobjmediapoolgui", "ilmediapoolpagegui"], "createMediaPoolPage")
637 );
638 }
639
640 $ilToolbar->addButton(
641 $lng->txt("mep_create_folder"),
642 $ilCtrl->getLinkTarget($this, "createFolderForm")
643 );
644
645 $upload_factory = new ilImportDirectoryFactory();
646 $media_upload = $upload_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_MOB);
647 if ($media_upload->exists() && $this->rbac_system->checkAccess("visible", SYSTEM_FOLDER_ID)) {
648 $ilToolbar->addButton(
649 $lng->txt("mep_create_from_upload_dir"),
650 $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles")
651 );
652 }
653
654 $ilToolbar->addButton(
655 $lng->txt("mep_bulk_upload"),
656 $ilCtrl->getLinkTarget($this, "bulkUpload")
657 );
658
659 $move_ids = ilSession::get("mep_move_ids");
660 if (is_array($move_ids) && count($move_ids) > 0) {
661 $ilToolbar->addSeparator();
662 $ilToolbar->addButton(
663 $lng->txt("paste"),
664 $ilCtrl->getLinkTarget($this, "paste")
665 );
666 }
667 }
668
669 $mep_table_gui = new ilMediaPoolTableGUI($this, "listMedia", $this->getMediaPool(), "mepitem_id");
670 $tpl->setContent($mep_table_gui->getHTML());
671 }
672
673 protected function toggleExplorerNodeState(): void
674 {
675 $exp = new ilMediaPoolExplorerGUI($this, "listMedia", $this->getMediaPool());
676 $exp->toggleExplorerNodeState();
677 }
678
682 public function allMedia(): void
683 {
685 $ilTabs = $this->tabs;
686 $ilCtrl = $this->ctrl;
688
689 $ilCtrl->setParameter($this, "mep_mode", "allMedia");
690
691 $this->checkPermission("read");
692 $ilTabs->setTabActive("content");
693 $this->setContentSubTabs("mep_all_mobs");
694
695 $mep_table_gui = new ilMediaPoolTableGUI(
696 $this,
697 "allMedia",
698 $this->getMediaPool(),
699 "mepitem_id",
701 true
702 );
703
704 if ($this->mep_request->getForceFilter() > 0) {
705 $mep_table_gui->setTitleFilter(
706 ilMediaPoolItem::lookupTitle($this->mep_request->getForceFilter())
707 );
708
709 // Read again
710 $mep_table_gui = new ilMediaPoolTableGUI(
711 $this,
712 "allMedia",
713 $this->getMediaPool(),
714 "mepitem_id",
716 true
717 );
718 }
719
720 $tpl->setContent($mep_table_gui->getHTML());
721 }
722
726 public function applyFilter(): void
727 {
728 $mtab = new ilMediaPoolTableGUI(
729 $this,
730 "allMedia",
731 $this->getMediaPool(),
732 "mepitem_id",
734 true
735 );
736 $mtab->writeFilterToSession();
737 $mtab->resetOffset();
738 $this->allMedia();
739 }
740
741 public function resetFilter(): void
742 {
743 $mtab = new ilMediaPoolTableGUI(
744 $this,
745 "allMedia",
746 $this->getMediaPool(),
747 "mepitem_id",
749 true
750 );
751 $mtab->resetFilter();
752 $mtab->resetOffset();
753 $this->allMedia();
754 }
755
759 public function getTemplate(): void
760 {
761 $this->tpl->loadStandardTemplate();
762 }
763
764
768 public function getParentFolderId(): ?int
769 {
770 if ($this->mep_item_id == 0) {
771 return null;
772 }
773 $par_id = $this->object->getPoolTree()->getParentId($this->mep_item_id);
774 if ($par_id != $this->object->getPoolTree()->getRootId()) {
775 return (int) $par_id;
776 }
777
778 return null;
779 }
780
784 protected function showMedia(): void
785 {
786 $this->checkPermission("read");
787 $link_xml = "";
788 $pg_frame = "";
789
790 $item = new ilMediaPoolItem($this->mep_item_id);
791 $mob_id = $item->getForeignId();
792
793 $this->tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
794 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
795 $this->tpl->setVariable(
796 "LOCATION_CONTENT_STYLESHEET",
798 );
799
800
802 $media_obj = new ilObjMediaObject($mob_id);
803
804
805 $this->tpl->setVariable("TITLE", " - " . $media_obj->getTitle());
806
807 $xml = "<dummy>";
808 // todo: we get always the first alias now (problem if mob is used multiple
809 // times in page)
810 $xml .= $media_obj->getXML(IL_MODE_ALIAS);
811 $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
812 $xml .= $link_xml;
813 $xml .= "</dummy>";
814
815 $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
816 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
817 $xh = xslt_create();
818
819 $wb_path = ilFileUtils::getWebspaceDir("output") . "/";
820
821 $mode = ($this->ctrl->getCmd() !== "showPreview")
822 ? "fullscreen"
823 : "media";
824 $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output");
825 $fullscreen_link =
826 $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
827 $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path,
828 'link_params' => "ref_id=" . $this->requested_ref_id,'fullscreen_link' => $fullscreen_link,
829 'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
830 'ref_id' => $this->requested_ref_id, 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
831 $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, $params);
832 xslt_free($xh);
833 // unmask user html
834 $this->tpl->setVariable("MEDIA_CONTENT", $output);
835 }
836
843 public function showPage(): void
844 {
845 //$tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
846 $tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
847
851
852 // get page object
853 $page_gui = $this->getMediaPoolPageGUI($this->mep_item_id);
854 $page_gui->setTemplate($tpl);
855
856 $page_gui->setTemplateOutput(false);
857 $page_gui->setHeader("");
858 $ret = $page_gui->showPage(true);
859
860 //$tpl->setBodyClass("ilMediaPoolPagePreviewBody");
861 $tpl->setVariable("MEDIA_CONTENT", "<div>" . $ret . "</div>");
862
863
865 exit;
866 }
867
873 protected function getMediaPoolPageGUI($mep_item_id, $old_nr = 0)
874 {
875 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
876 $page_gui = new ilMediaPoolPageGUI($mep_item_id, $old_nr);
877 $page_gui->setPoolGUI($this);
878
879 return $page_gui;
880 }
881
882
886 public function showPreview(): void
887 {
888 $this->checkPermission("read");
889
890 $item = new ilMediaPoolItem($this->mep_item_id);
891
892 switch ($item->getType()) {
893 case "mob":
894 $this->showMedia();
895 break;
896
897 case "pg":
898 $this->showPage();
899 break;
900 }
901 }
902
903
907 public function showFullscreen(): void
908 {
909 $this->showMedia();
910 }
911
915 public function confirmRemove(): void
916 {
917 $ilCtrl = $this->ctrl;
919
920 $this->checkPermission("write");
921
922 $ids = $this->mep_request->getItemIds();
923 if (count($ids) === 0) {
924 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
925 $ilCtrl->redirect($this, "");
926 }
927
928 // display confirmation message
929 $cgui = new ilConfirmationGUI();
930 $cgui->setFormAction($this->ctrl->getFormAction($this));
931 $cgui->setHeaderText($this->lng->txt("info_remove_sure"));
932 $cgui->setCancel($this->lng->txt("cancel"), "cancelRemove");
933 $cgui->setConfirm($this->lng->txt("confirm"), "remove");
934
935 foreach ($ids as $obj_id) {
938
939 // check whether page can be removed
940 $add = "";
941 if ($type === "pg") {
942 $usages = ilPageContentUsage::getUsages("incl", $obj_id, false);
943 if (count($usages) > 0) {
944 $this->main_tpl->setOnScreenMessage('failure', sprintf($lng->txt("mep_content_snippet_in_use"), $title), true);
945 $ilCtrl->redirect($this, "listMedia");
946 } else {
947 // check whether the snippet is used in older versions of pages
948 $usages = ilPageContentUsage::getUsages("incl", $obj_id, true);
949 if (count($usages) > 0) {
950 $add = "<div class='small'>" . $lng->txt("mep_content_snippet_used_in_older_versions") . "</div>";
951 }
952 }
953 }
954
955 $caption =
956 " " . $title . $add;
957
958 $cgui->addItem("id[]", $obj_id, $caption);
959 }
960
961 $this->tpl->setContent($cgui->getHTML());
962 }
963
967 public function openClipboard(): void
968 {
969 $ilCtrl = $this->ctrl;
970
971 $this->checkPermission("write");
972
973 $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
974 }
975
976
980 public function insertFromClipboard(): void
981 {
982 $this->checkPermission("write");
983
985 $not_inserted = array();
986 foreach ($ids as $id2) {
987 $id = explode(":", $id2);
988 $type = $id[0];
989 $id = $id[1];
990
991 if ($type === "mob") { // media object
992 if (ilObjMediaPool::isForeignIdInTree($this->object->getId(), $id)) {
993 $not_inserted[] = ilObject::_lookupTitle($id) . " [" .
994 $id . "]";
995 } else {
996 $item = new ilMediaPoolItem();
997 $item->setType("mob");
998 $item->setForeignId($id);
999 $item->setTitle(ilObject::_lookupTitle($id));
1000 $item->create();
1001 if ($item->getId() > 0) {
1002 $this->object->insertInTree($item->getId(), $this->mep_item_id);
1003 }
1004 }
1005 }
1006 if ($type === "incl") { // content snippet
1007 if (ilObjMediaPool::isItemIdInTree($this->object->getId(), $id)) {
1008 $not_inserted[] = ilMediaPoolPage::lookupTitle($id) . " [" .
1009 $id . "]";
1010 } else {
1011 $original = new ilMediaPoolPage($id);
1012
1013 // copy the page into the pool
1014 $item = new ilMediaPoolItem();
1015 $item->setType("pg");
1016 $item->setTitle(ilMediaPoolItem::lookupTitle($id));
1017 $item->create();
1018 if ($item->getId() > 0) {
1019 $this->object->insertInTree($item->getId(), $this->mep_item_id);
1020
1021 // create page
1022 $page = new ilMediaPoolPage();
1023 $page->setId($item->getId());
1024 $page->setParentId($this->object->getId());
1025 $page->create(false);
1026
1027 // copy content
1028 $original->copy($page->getId(), $page->getParentType(), $page->getParentId(), true);
1029 }
1030 }
1031 }
1032 }
1033 if (count($not_inserted) > 0) {
1034 $this->main_tpl->setOnScreenMessage('info', $this->lng->txt("mep_not_insert_already_exist") . "<br>" .
1035 implode("<br>", $not_inserted), true);
1036 }
1037 $this->ctrl->redirect($this, $this->mode);
1038 }
1039
1040
1044 public function cancelRemove(): void
1045 {
1046 $this->ctrl->redirect($this, $this->mode);
1047 }
1048
1049 public function remove(): void
1050 {
1051 $this->checkPermission("write");
1052
1053 $ids = $this->mep_request->getItemIds();
1054 foreach ($ids as $obj_id) {
1055 $this->object->deleteChild($obj_id);
1056 }
1057
1058 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("cont_obj_removed"), true);
1059 $this->ctrl->redirect($this, $this->mode);
1060 }
1061
1062
1066 public function copyToClipboard(): void
1067 {
1069
1070 $this->checkPermission("write");
1071
1072 $ids = $this->mep_request->getItemIds();
1073 if (count($ids) === 0) {
1074 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1075 $this->ctrl->redirect($this, $this->mode);
1076 }
1077
1078 foreach ($ids as $obj_id) {
1080 if ($type === "fold") {
1081 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("cont_cant_copy_folders"), true);
1082 $this->ctrl->redirect($this, $this->mode);
1083 }
1084 }
1085 foreach ($ids as $obj_id) {
1088 if ($type === "mob") {
1089 $ilUser->addObjectToClipboard($fid, "mob", "");
1090 }
1091 if ($type === "pg") {
1092 $ilUser->addObjectToClipboard($obj_id, "incl", "");
1093 }
1094 }
1095 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("copied_to_clipboard"), true);
1096 $this->ctrl->redirect($this, $this->mode);
1097 }
1098
1102 protected function addLocatorItems(): void
1103 {
1104 $ilLocator = $this->locator;
1105 $ilAccess = $this->access;
1106 if (!$this->getCreationMode() && $this->ctrl->getCmd() !== "explorer") {
1107 $tree = $this->object->getTree();
1110 foreach ($path as $node) {
1111 if ($node["child"] == $tree->getRootId()) {
1112 $this->ctrl->setParameter($this, "mepitem_id", "");
1113 $link = "";
1114 if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
1115 $link = $this->ctrl->getLinkTarget($this, "listMedia");
1116 } elseif ($ilAccess->checkAccess("visible", "", $this->object->getRefId())) {
1117 $link = $this->ctrl->getLinkTarget($this, "infoScreen");
1118 }
1119 $title = $this->object->getTitle();
1120 $this->ctrl->setParameter($this, "mepitem_id", $this->mep_item_id);
1121 $ilLocator->addItem($title, $link, "", $this->requested_ref_id);
1122 }
1123 }
1124 }
1125 }
1126
1130
1131 public function createFolderForm(): void
1132 {
1133 $tpl = $this->tpl;
1134
1135 $this->checkPermission("write");
1136
1137 $this->initFolderForm("create");
1138 $tpl->setContent($this->form->getHTML());
1139 }
1140
1141 public function editFolder(): void
1142 {
1143 $tpl = $this->tpl;
1144
1145 $this->checkPermission("write");
1146
1147 $this->initFolderForm();
1148 $this->getFolderValues();
1149 $tpl->setContent($this->form->getHTML());
1150 }
1151
1155 public function getFolderValues(): void
1156 {
1157 $values = array();
1158
1159 $values["title"] = ilMediaPoolItem::lookupTitle($this->mep_item_id);
1160
1161 $this->form->setValuesByArray($values);
1162 }
1163
1167 public function saveFolder(): void
1168 {
1169 $tpl = $this->tpl;
1170 $lng = $this->lng;
1171 $ilCtrl = $this->ctrl;
1172
1173 $this->checkPermission("write");
1174
1175 $this->initFolderForm("create");
1176 if ($this->form->checkInput()) {
1177 if ($this->object->createFolder($this->form->getInput("title"), $this->mep_item_id)) {
1178 $this->main_tpl->setOnScreenMessage('success', $lng->txt("mep_folder_created"), true);
1179 }
1180 $ilCtrl->redirect($this, "listMedia");
1181 }
1182
1183 $this->form->setValuesByPost();
1184 $tpl->setContent($this->form->getHTML());
1185 }
1186
1187 public function updateFolder(): void
1188 {
1189 $lng = $this->lng;
1190 $ilCtrl = $this->ctrl;
1191 $tpl = $this->tpl;
1192
1193 $this->checkPermission("write");
1194
1195 $this->initFolderForm("edit");
1196 if ($this->form->checkInput()) {
1197 $item = new ilMediaPoolItem($this->mep_item_id);
1198 $item->setTitle($this->form->getInput("title"));
1199 $item->update();
1200 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1201 $ilCtrl->setParameter(
1202 $this,
1203 "mepitem_id",
1204 $this->object->getTree()->getParentId($this->mep_item_id)
1205 );
1206 $ilCtrl->redirect($this, "listMedia");
1207 }
1208
1209 $this->form->setValuesByPost();
1210 $tpl->setContent($this->form->getHTML());
1211 }
1212
1217 public function initFolderForm(string $a_mode = "edit"): void
1218 {
1219 $lng = $this->lng;
1220 $ilCtrl = $this->ctrl;
1221
1222 $this->form = new ilPropertyFormGUI();
1223
1224 // desc
1225 $ti = new ilTextInputGUI($lng->txt("title"), "title");
1226 $ti->setMaxLength(128);
1227 $ti->setRequired(true);
1228 $this->form->addItem($ti);
1229
1230 // save and cancel commands
1231 if ($a_mode === "create") {
1232 $this->form->addCommandButton("saveFolder", $lng->txt("save"));
1233 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1234 $this->form->setTitle($lng->txt("mep_new_folder"));
1235 } else {
1236 $this->form->addCommandButton("updateFolder", $lng->txt("save"));
1237 $this->form->addCommandButton("cancelFolderUpdate", $lng->txt("cancel"));
1238 $this->form->setTitle($lng->txt("mep_edit_folder"));
1239 }
1240
1241 $this->form->setFormAction($ilCtrl->getFormAction($this));
1242 }
1243
1244 public function cancelFolderUpdate(): void
1245 {
1246 $ilCtrl = $this->ctrl;
1247 $ilCtrl->setParameter(
1248 $this,
1249 "mepitem_id",
1250 $this->object->getTree()->getParentId($this->mep_item_id)
1251 );
1252 $ilCtrl->redirect($this, "listMedia");
1253 }
1254
1255 public function cancelSave(): void
1256 {
1257 $ilCtrl = $this->ctrl;
1258 $ilCtrl->redirect($this, "listMedia");
1259 }
1260
1264
1268 public function setContentSubTabs(
1269 string $a_active
1270 ): void {
1271 $ilAccess = $this->access;
1272 $ilTabs = $this->tabs;
1273 $ilCtrl = $this->ctrl;
1274
1275 $ilTabs->addSubTab("content", $this->lng->txt("objs_fold"), $this->ctrl->getLinkTarget($this, ""));
1276
1277 $ilCtrl->setParameter($this, "mepitem_id", "");
1278 $ilTabs->addSubTab("mep_all_mobs", $this->lng->txt("mep_all_mobs"), $this->ctrl->getLinkTarget($this, "allMedia"));
1279 $ilCtrl->setParameter($this, "mepitem_id", $this->mep_item_id);
1280
1281 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
1282 $ilTabs->addSubTab(
1283 "srt_files",
1284 $this->lng->txt("mep_media_subtitles"),
1285 $ilCtrl->getLinkTargetByClass("ilmobmultisrtuploadgui", "")
1286 );
1287 }
1288
1289 $ilTabs->activateSubTab($a_active);
1290 }
1291
1292 protected function setTabs(): void
1293 {
1294 $ilAccess = $this->access;
1295 $ilTabs = $this->tabs;
1296 $ilHelp = $this->help;
1297
1298 $ilHelp->setScreenIdComponent("mep");
1299
1300 if ($ilAccess->checkAccess('read', '', $this->ref_id) ||
1301 $ilAccess->checkAccess('write', '', $this->ref_id)) {
1302 $ilTabs->addTab("content", $this->lng->txt("mep_content"), $this->ctrl->getLinkTarget($this, ""));
1303 }
1304
1305 // info tab
1306 if ($ilAccess->checkAccess('visible', '', $this->ref_id) ||
1307 $ilAccess->checkAccess('read', '', $this->ref_id) ||
1308 $ilAccess->checkAccess('write', '', $this->ref_id)) {
1309 $force_active = $this->ctrl->getNextClass() === "ilinfoscreengui"
1310 || strtolower($this->ctrl->getCmdClass()) === "ilnotegui";
1311 $ilTabs->addTarget(
1312 "info_short",
1313 $this->ctrl->getLinkTargetByClass(
1314 array("ilobjmediapoolgui", "ilinfoscreengui"),
1315 "showSummary"
1316 ),
1317 array("showSummary", "infoScreen"),
1318 "",
1319 "",
1320 $force_active
1321 );
1322 }
1323
1324 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1325 $ilTabs->addTarget(
1326 "settings",
1327 $this->ctrl->getLinkTarget($this, "edit"),
1328 "edit",
1329 array("", "ilobjmediapoolgui")
1330 );
1331 }
1332 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1333 $ilTabs->addTarget(
1334 "clipboard",
1335 $this->ctrl->getLinkTarget($this, "openClipboard"),
1336 "view",
1337 "ileditclipboardgui"
1338 );
1339 }
1340
1341 // properties
1342 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1343 // meta data
1344 $mdgui = new ilObjectMetaDataGUI($this->object, ['mob', "mpg"]);
1345 $mdtab = $mdgui->getTab();
1346 if ($mdtab) {
1347 $ilTabs->addTarget(
1348 "meta_data",
1349 $mdtab,
1350 "",
1351 "ilobjectmetadatagui"
1352 );
1353 }
1354 }
1355
1356 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1357 $ilTabs->addTarget(
1358 "export",
1359 $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1360 "",
1361 "ilexportgui"
1362 );
1363
1364 $ilTabs->addTarget(
1365 "import",
1366 $this->ctrl->getLinkTargetByClass("ilmediapoolimportgui", ""),
1367 "",
1368 "ilmediapoolimportgui"
1369 );
1370 }
1371
1372 if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId())) {
1373 $ilTabs->addTarget(
1374 "perm_settings",
1375 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1376 array("perm","info","owner"),
1377 'ilpermissiongui'
1378 );
1379 }
1380 }
1381
1382 public function setSettingsSubTabs(
1383 string $a_active
1384 ): void {
1385 $ilTabs = $this->tabs;
1386 $lng = $this->lng;
1387 $ilAccess = $this->access;
1388
1389 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1390 $ilTabs->addSubTab(
1391 "settings",
1392 $lng->txt("settings"),
1393 $this->ctrl->getLinkTarget($this, "edit")
1394 );
1395
1396 $mset = new ilSetting("mobs");
1397 if ($mset->get("mep_activate_pages")) {
1398 $ilTabs->addSubTabTarget(
1399 "obj_multilinguality",
1400 $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
1401 );
1402 }
1403 }
1404
1405 $ilTabs->setSubTabActive($a_active);
1406 }
1407
1408
1409 public static function _goto(string $a_target): void
1410 {
1411 global $DIC;
1412 $main_tpl = $DIC->ui()->mainTemplate();
1413
1414 $ilAccess = $DIC->access();
1415 $lng = $DIC->language();
1416 $ctrl = $DIC->ctrl();
1417
1418 $subitem_id = "";
1419 $targets = explode('_', $a_target);
1420 $ref_id = $targets[0];
1421 if (count((array) $targets) > 1) {
1422 $subitem_id = $targets[1];
1423 }
1424
1425 $ctrl->setParameterByClass("ilMediaPoolPresentationGUI", "ref_id", $ref_id);
1426 if ($ilAccess->checkAccess("read", "", $ref_id)) {
1427 $ctrl->setParameterByClass("ilMediaPoolPresentationGUI", "mepitem_id", $subitem_id);
1428 $ctrl->redirectByClass("ilMediaPoolPresentationGUI", "");
1429 } elseif ($ilAccess->checkAccess("visible", "", $ref_id)) {
1430 $ctrl->redirectByClass("ilMediaPoolPresentationGUI", "infoScreen");
1431 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1432 $main_tpl->setOnScreenMessage('failure', sprintf(
1433 $lng->txt("msg_no_perm_read_item"),
1435 ), true);
1437 }
1438
1439 throw new ilPermissionException($lng->txt("msg_no_perm_read"));
1440 }
1441
1445 public function infoScreenObject(): void
1446 {
1447 $this->ctrl->setCmd("showSummary");
1448 $this->ctrl->setCmdClass("ilinfoscreengui");
1449 $this->infoScreen();
1450 }
1451
1457 public function infoScreen(): void
1458 {
1459 $this->tabs->activateTab("info_short");
1460 $ilAccess = $this->access;
1461
1462 if (!$ilAccess->checkAccess("visible", "", $this->ref_id) &&
1463 !$ilAccess->checkAccess("read", "", $this->ref_id) &&
1464 !$ilAccess->checkAccess("write", "", $this->ref_id)) {
1465 throw new ilPermissionException($this->lng->txt("msg_no_perm_read"));
1466 }
1467
1468 if ($this->ctrl->getCmd() === "infoScreen") {
1469 $this->ctrl->setCmd("showSummary");
1470 $this->ctrl->setCmdClass("ilinfoscreengui");
1471 }
1472
1473 $info = new ilInfoScreenGUI($this);
1474
1475 $info->enablePrivateNotes();
1476
1477
1478 // standard meta data
1479 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1480
1481 // forward the command
1482 $this->ctrl->forwardCommand($info);
1483 }
1484
1485
1489
1493 public function selectUploadDirFiles(
1494 ?array $a_files = null
1495 ): void {
1496 $tpl = $this->tpl;
1497 $ilTabs = $this->tabs;
1498 $lng = $this->lng;
1499 $ilCtrl = $this->ctrl;
1500 $ilToolbar = $this->toolbar;
1501
1502
1503 if (!$a_files) {
1504 $a_files = $this->mep_request->getFiles();
1505 }
1506
1507 $ilTabs->clearTargets();
1508 $ilTabs->setBackTarget(
1509 $lng->txt("back"),
1510 $ilCtrl->getLinkTarget($this, "listMedia")
1511 );
1512
1513 $this->checkPermission("write");
1514
1515 if ($this->rbac_system->checkAccess("visible", SYSTEM_FOLDER_ID)) {
1516 $tb = new ilToolbarGUI();
1517 // action type
1518 $options = array(
1519 "rename" => $lng->txt("mep_up_dir_move"),
1520 "copy" => $lng->txt("mep_up_dir_copy"),
1521 );
1522 $si = new ilSelectInputGUI("", "action");
1523 $si->setOptions($options);
1524 $tb->addInputItem($si);
1525 $tb->setCloseFormTag(false);
1526 $tb->setFormAction($ilCtrl->getFormAction($this));
1527 $tb->setFormName("mep_up_form");
1528
1529 $tab = new ilUploadDirFilesTableGUI(
1530 $this,
1531 "selectUploadDirFiles",
1532 $a_files
1533 );
1534 $tab->setFormName("mep_up_form");
1535 $tpl->setContent($tb->getHTML() . $tab->getHTML());
1536 }
1537 }
1538
1542 public function createMediaFromUploadDir(): void
1543 {
1544 $this->checkPermission("write");
1545
1546 $import_directory_factory = new ilImportDirectoryFactory();
1547 $mob_import_directory = $import_directory_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_MOB);
1548 $upload_dir = $mob_import_directory->getAbsolutePath();
1549
1550 $files = $this->mep_request->getFiles();
1551 if ($this->rbac_system->checkAccess("visible", SYSTEM_FOLDER_ID)) {
1552 foreach ($files as $f) {
1553 $f = str_replace("..", "", $f);
1554 $fullpath = $upload_dir . "/" . $f;
1555 $mob = new ilObjMediaObject();
1556 $mob->setTitle(basename($fullpath));
1557 $mob->setDescription("");
1558 $mob->create();
1559
1560 // determine and create mob directory, move uploaded file to directory
1561 //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
1562 $mob->createDirectory();
1563 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1564
1565 $media_item = new ilMediaItem();
1566 $mob->addMediaItem($media_item);
1567 $media_item->setPurpose("Standard");
1568
1569 $file = $mob_dir . "/" . basename($fullpath);
1570
1571 // virus handling
1572 $vir = ilVirusScanner::virusHandling($fullpath, basename($fullpath));
1573 if (!$vir[0]) {
1574 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("file_is_infected") . "<br />" . $vir[1], true);
1575 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" .
1576 $this->requested_ref_id . "&mepitem_id=" . $this->mep_item_id);
1577 }
1578
1579 switch ($this->mep_request->getFileAction()) {
1580 case "rename":
1581 rename($fullpath, $file);
1582 break;
1583
1584 case "copy":
1585 copy($fullpath, $file);
1586 break;
1587 }
1588
1589 // get mime type
1591 $location = basename($fullpath);
1592
1593 // set real meta and object data
1594 $media_item->setFormat($format);
1595 $media_item->setLocation($location);
1596 $media_item->setLocationType("LocalFile");
1597
1598 $mob->setDescription($format);
1599
1600 // determine width and height of known image types
1602 $format,
1603 "File",
1604 $mob_dir . "/" . $location,
1605 $media_item->getLocation(),
1606 true,
1607 true,
1608 null,
1609 null
1610 );
1611 $media_item->setWidth($wh["width"]);
1612 $media_item->setHeight($wh["height"]);
1613
1614 $media_item->setHAlign("Left");
1616 $mob->update();
1617
1618
1619 // put it into current folder
1620 $mep_item = new ilMediaPoolItem();
1621 $mep_item->setTitle($mob->getTitle());
1622 $mep_item->setType("mob");
1623 $mep_item->setForeignId($mob->getId());
1624 $mep_item->create();
1625
1626 $tree = $this->object->getTree();
1627 $parent = $this->mep_item_id;
1628 $tree->insertNode($mep_item->getId(), $parent);
1629 }
1630 }
1631 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" .
1632 $this->requested_ref_id . "&mepitem_id=" . $this->mep_item_id);
1633 }
1634
1638 public static function getPreviewModalHTML(
1639 int $a_mpool_ref_id,
1641 ): string {
1642 global $DIC;
1643
1644 $tpl = $DIC["tpl"];
1645 $ilCtrl = $DIC->ctrl();
1646 $lng = $DIC->language();
1647 $request = $DIC->mediaPool()
1648 ->internal()
1649 ->gui()
1650 ->standardRequest();
1651
1653
1654 $tpl->addJavaScript("./Modules/MediaPool/js/ilMediaPool.js");
1655
1656 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", "");
1657 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $a_mpool_ref_id);
1658 $tpl->addOnloadCode("il.MediaPool.setPreviewUrl('" . $ilCtrl->getLinkTargetByClass(array("ilmediapoolpresentationgui", "ilobjmediapoolgui"), "showPreview", "", false, false) . "');");
1659 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", $request->getItemId());
1660 $ilCtrl->setParameterByClass(
1661 "ilobjmediapoolgui",
1662 "ref_id",
1663 $request->getRefId()
1664 );
1665
1666 $modal = ilModalGUI::getInstance();
1667 $modal->setHeading($lng->txt("preview"));
1668 $modal->setId("ilMepPreview");
1669 $modal->setType(ilModalGUI::TYPE_LARGE);
1670 $modal->setBody("<iframe id='ilMepPreviewContent'></iframe>");
1671
1672 return $modal->getHTML();
1673 }
1674
1675 public function export(): void
1676 {
1677 $ot = ilObjectTranslation::getInstance($this->object->getId());
1678 $opt = "";
1679 if ($ot->getContentActivated()) {
1680 $format = explode("_", $this->mep_request->getExportFormat());
1681 $opt = ilUtil::stripSlashes($format[1]);
1682 }
1683
1684 $this->object->exportXML($opt);
1685 }
1686
1687 //
1688 // BULK UPLOAD
1689 //
1690
1691 protected function bulkUpload(): void
1692 {
1693 $this->checkPermission("write");
1694
1695 $main_tpl = $this->main_tpl;
1696
1697 $form = $this->getBulkUploadForm();
1698 $main_tpl->setContent($form->render());
1699 }
1700
1701 protected function getBulkUploadForm(): FormAdapterGUI
1702 {
1703 if (is_null($this->bulk_upload_form)) {
1704 $mep_hash = uniqid();
1705 $this->ctrl->setParameter($this, "mep_hash", $mep_hash);
1706 $this->bulk_upload_form = $this->gui
1707 ->form(self::class, 'performBulkUpload')
1708 ->section("props", $this->lng->txt('mep_bulk_upload'))
1709 ->file(
1710 "media_files",
1711 $this->lng->txt("mep_media_files"),
1712 \Closure::fromCallable([$this, 'handleUploadResult']),
1713 "mep_id",
1714 "",
1715 20
1716 );
1717 // ->meta()->text()->meta()->textarea()
1718 }
1719 return $this->bulk_upload_form;
1720 }
1721
1722 protected function handleUploadResult(
1723 FileUpload $upload,
1724 UploadResult $result
1726 $title = $result->getName();
1727
1728 $mob = new ilObjMediaObject();
1729 $mob->setTitle($title);
1730 $mob->setDescription("");
1731 $mob->create();
1732
1733 $mob->createDirectory();
1734 $media_item = new ilMediaItem();
1735 $mob->addMediaItem($media_item);
1736 $media_item->setPurpose("Standard");
1737
1738 $mob_dir = ilObjMediaObject::_getRelativeDirectory($mob->getId());
1739 $file_name = ilObjMediaObject::fixFilename($title);
1740 $file = $mob_dir . "/" . $file_name;
1741
1742 $upload->moveOneFileTo(
1743 $result,
1744 $mob_dir,
1745 Location::WEB,
1746 $file_name,
1747 true
1748 );
1749
1750 $mep_item = new ilMediaPoolItem();
1751 $mep_item->setTitle($title);
1752 $mep_item->setType("mob");
1753 $mep_item->setForeignId($mob->getId());
1754 $mep_item->create();
1755
1756 $tree = $this->object->getTree();
1757 $parent = $this->mep_item_id;
1758 $tree->insertNode($mep_item->getId(), $parent);
1759
1760 // get mime type
1762 $location = $file_name;
1763
1764 // set real meta and object data
1765 $media_item->setFormat($format);
1766 $media_item->setLocation($location);
1767 $media_item->setLocationType("LocalFile");
1768 $media_item->setUploadHash($this->mep_request->getUploadHash());
1769 $mob->update();
1770
1771 $item_ids[] = $mob->getId();
1772
1773 $mob = new ilObjMediaObject($mob->getId());
1774 $mob->generatePreviewPic(320, 240);
1775
1776 // duration
1777 $med_item = $mob->getMediaItem("Standard");
1778 $med_item->determineDuration();
1779 $med_item->update();
1780
1781 return new BasicHandlerResult(
1782 "mep_id",
1783 HandlerResult::STATUS_OK,
1784 $med_item->getId(),
1785 ''
1786 );
1787 }
1788
1792 public function performBulkUpload(): void
1793 {
1794 $this->checkPermission("write");
1795 $this->ctrl->setParameter($this, "mep_hash", $this->mep_request->getUploadHash());
1796 $this->ctrl->redirect($this, "editTitlesAndDescriptions");
1797 }
1798
1799 protected function editTitlesAndDescriptions(): void
1800 {
1801 $ctrl = $this->ctrl;
1802 $lng = $this->lng;
1803
1804 $this->checkPermission("write");
1805 $ctrl->saveParameter($this, "mep_hash");
1806
1807 $main_tpl = $this->main_tpl;
1808
1810 $this->mep_request->getUploadHash()
1811 );
1812
1813 $tb = new ilToolbarGUI();
1814 $tb->setFormAction($ctrl->getFormAction($this));
1815 $tb->addFormButton($lng->txt("save"), "saveTitlesAndDescriptions");
1816 $tb->setOpenFormTag(true);
1817 $tb->setCloseFormTag(false);
1818 $tb->setId("tb_top");
1819
1820 $html = $tb->getHTML();
1821 foreach ($media_items as $mi) {
1822 $acc = new ilAccordionGUI();
1823 $acc->setBehaviour(ilAccordionGUI::ALL_CLOSED);
1824 $acc->setId("acc_" . $mi["mob_id"]);
1825
1826 $mob = new ilObjMediaObject($mi["mob_id"]);
1827 $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
1828 $acc->addItem($mob->getTitle(), $form->getHTML());
1829
1830 $html .= $acc->getHTML();
1831 }
1832
1833 $html .= $tb->getHTML();
1834 $tb->setOpenFormTag(false);
1835 $tb->setCloseFormTag(true);
1836 $tb->setId("tb_bottom");
1837
1838 $main_tpl->setContent($html);
1839 }
1840
1844 public function initMediaBulkForm(
1845 int $a_id,
1846 string $a_title
1848 $lng = $this->lng;
1849
1850 $form = new ilPropertyFormGUI();
1851 $form->setOpenTag(false);
1852 $form->setCloseTag(false);
1853
1854 // title
1855 $ti = new ilTextInputGUI($lng->txt("title"), "title_" . $a_id);
1856 $ti->setValue($a_title);
1857 $form->addItem($ti);
1858
1859 // description
1860 $ti = new ilTextAreaInputGUI($lng->txt("description"), "description_" . $a_id);
1861 $form->addItem($ti);
1862
1863 return $form;
1864 }
1865
1866 protected function saveTitlesAndDescriptions(): void
1867 {
1868 $lng = $this->lng;
1869 $ctrl = $this->ctrl;
1870
1871 $this->checkPermission("write");
1873 $this->mep_request->getUploadHash()
1874 );
1875
1876 foreach ($media_items as $mi) {
1877 $mob = new ilObjMediaObject($mi["mob_id"]);
1878 $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
1879 $form->checkInput();
1880 $title = $form->getInput("title_" . $mi["mob_id"]);
1881 $desc = $form->getInput("description_" . $mi["mob_id"]);
1882 if (trim($title) !== "") {
1883 $mob->setTitle($title);
1884 }
1885 $mob->setDescription($desc);
1886 $mob->update();
1887 }
1888 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1889 $ctrl->redirect($this, "listMedia");
1890 }
1891
1892 protected function move(): void
1893 {
1894 ilSession::set("mep_move_ids", $this->mep_request->getItemIds());
1895 $this->main_tpl->setOnScreenMessage('info', $this->lng->txt("mep_move_select_insert"), true);
1896 $this->ctrl->redirect($this, "listMedia");
1897 }
1898
1899 protected function paste(): void
1900 {
1902 $target_tree = $this->object->getTree();
1903
1904 // sanity check
1905 $move_ids = ilSession::get("mep_move_ids");
1906 if (is_array($move_ids)) {
1907 foreach ($move_ids as $id) {
1909
1910 $parent_id = $this->mep_request->getItemId();
1911 if (ilMediaPoolItem::lookupType($parent_id) !== "fold") {
1912 $parent_id = $target_tree->readRootId();
1913 }
1914
1915 $subnodes = [];
1916 foreach ($pool_ids as $pool_id) {
1917 $pool = new ilObjMediaPool($pool_id, false);
1918 $source_tree = $pool->getTree();
1919
1920 // if source tree == target tree, check if target is within source tree
1921 $subnodes = $source_tree->getSubtree($source_tree->getNodeData($id));
1922 if ($pool_id == $target_tree->getTreeId()) {
1923 // check, if target is within subtree
1924 foreach ($subnodes as $subnode) {
1925 if ($subnode["child"] == $parent_id) {
1926 $this->main_tpl->setOnScreenMessage(
1927 'failure',
1928 $this->lng->txt("mep_target_in_source_not_allowed"),
1929 true
1930 );
1931
1932 $this->ctrl->redirect($this, "listMedia");
1933 }
1934 }
1935 }
1936 $source_tree->deleteTree($source_tree->getNodeData($id));
1937 }
1938
1939 $target_tree->insertNode($id, $parent_id);
1940 foreach ($subnodes as $node) {
1941 if ($node["child"] != $id) {
1942 $target_tree->insertNode($node["child"], $node["parent"]);
1943 }
1944 }
1945 }
1946 }
1947 ilSession::clear("mep_move_ids");
1948 $this->ctrl->redirect($this, "listMedia");
1949 }
1950}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
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...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
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...
File System Explorer GUI class.
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static renameExecutables(string $a_dir)
setCloseTag(bool $a_val)
setOpenTag(bool $a_open)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getMediaItemsForUploadHash(string $a_hash)
Get media items for upload hash.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPoolForItemId(int $a_id)
static lookupTitle(int $a_id)
static lookupForeignId(int $a_id)
static lookupType(int $a_id)
Class ilMediaPoolPage GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupTitle(int $a_page_id)
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...
static getInstance()
This class represents a number property in a property form.
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)
static _determineWidthHeight(string $a_format, string $a_type, string $a_file, string $a_reference, bool $a_constrain_proportions, bool $a_use_original, ?int $a_user_width=null, ?int $a_user_height=null)
static fixFilename(string $a_name)
Fix filename of uploaded file.
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
static _getRelativeDirectory(int $a_mob_id)
Get relative (to webspace dir) directory.
static _getDirectory(int $a_mob_id)
Get absolute directory.
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
updateCustom(ilPropertyFormGUI $form)
Insert custom update form values into object.
allMedia()
list all media objects
openClipboard()
paste from clipboard
selectUploadDirFiles(?array $a_files=null)
Select files from upload directory.
createMediaFromUploadDir()
Create media object 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)
Get media pool page.
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)
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
infoScreen()
show information screen
initCreationForms(string $new_type)
Init creation forms.
returnFromItem()
Return from item editing.
insertFromClipboard()
insert media object from clipboard
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 isItemIdInTree(int $a_pool_id, int $a_item_id)
Check whether a mep item id is in the media pool.
static isForeignIdInTree(int $a_pool_id, int $a_foreign_id)
Check whether foreign id is in tree.
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] don't belong to the current class!...
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
ilLocatorGUI $locator
setLocator()
set Locator
ilObjectService $object_service
prepareOutput(bool $show_sub_objects=true)
checkPermission(string $perm, string $cmd="", string $type="", int $ref_id=null)
ilToolbarGUI $toolbar
initImportForm(string $new_type)
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
addExternalEditFormCustom(ilPropertyFormGUI $form)
addHeaderAction()
Add header action menu.
initCreateForm(string $new_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
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 clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
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...
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 getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static redirect(string $a_script)
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
const SYSTEM_FOLDER_ID
Definition: constants.php:35
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
xslt_free(&$proc)
xslt_create()
moveOneFileTo(UploadResult $uploadResult, string $destination, int $location=Location::STORAGE, string $file_name='', bool $override_existing=false)
Moves a single File (the attributes, metadata and upload-status of which are contained in UploadResul...
Interface Location.
Definition: Location.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
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)
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.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
exit
Definition: login.php:28
$ref_id
Definition: ltiauth.php:67
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$path
Definition: ltiservices.php:32
$format
Definition: metadata.php:235
$xml
Definition: metadata.php:351
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd)
$lng