ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjMediaPoolGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Object/classes/class.ilObject2GUI.php");
5include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
6include_once("./Services/Table/classes/class.ilTableGUI.php");
7include_once("./Modules/Folder/classes/class.ilObjFolderGUI.php");
8include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
9include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
10include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
11
25{
29 protected $tabs;
30
34 protected $error;
35
39 protected $help;
40
41
45 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
46 {
47 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
48 global $DIC;
49
50 $this->tabs = $DIC->tabs();
51 $this->error = $DIC["ilErr"];
52 $this->locator = $DIC["ilLocator"];
53 $this->help = $DIC["ilHelp"];
54 }
55
57
61 protected function afterConstructor()
62 {
64
65 $lng->loadLanguageModule("mep");
66
67 if ($this->ctrl->getCmd() == "explorer") {
68 $this->ctrl->saveParameter($this, array("ref_id"));
69 } else {
70 $this->ctrl->saveParameter($this, array("ref_id", "mepitem_id"));
71 }
72 $this->ctrl->saveParameter($this, array("mep_mode"));
73
74 $lng->loadLanguageModule("content");
75 }
76
80 final public function getType()
81 {
82 return "mep";
83 }
84
88 public function executeCommand()
89 {
90 $ilTabs = $this->tabs;
92 $ilAccess = $this->access;
95
96 if ($this->ctrl->getRedirectSource() == "ilinternallinkgui") {
97 $this->explorer();
98 return;
99 }
100
101 $next_class = $this->ctrl->getNextClass($this);
102 $cmd = $this->ctrl->getCmd();
103 $new_type = $_POST["new_type"]
104 ? $_POST["new_type"]
105 : $_GET["new_type"];
106
107 if ($new_type != "" && ($cmd != "confirmRemove" && $cmd != "copyToClipboard"
108 && $cmd != "pasteFromClipboard")) {
109 $this->setCreationMode(true);
110 }
111
112 if (!$this->getCreationMode()) {
113 $tree = $this->object->getTree();
114 if ($_GET["mepitem_id"] == "") {
115 $_GET["mepitem_id"] = $tree->getRootId();
116 }
117 }
118 if ($cmd == "create") {
119 switch ($_POST["new_type"]) {
120 case "mob":
121 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
122 break;
123
124 case "fold":
125 $this->ctrl->redirectByClass("ilobjfoldergui", "create");
126 break;
127 }
128 }
129
130 switch ($next_class) {
131 case 'ilmediapoolpagegui':
132 $this->checkPermission("write");
133 $this->prepareOutput();
134 $this->addHeaderAction();
135 $ilTabs->clearTargets();
136 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
137 $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
138
139 if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
140 $mep_page_gui->setEnableEditing(false);
141 }
142 $ret = $this->ctrl->forwardCommand($mep_page_gui);
143 if ($ret != "") {
144 $tpl->setContent($ret);
145 }
146 $this->setMediaPoolPageTabs();
147 $this->tpl->show();
148 break;
149
150 case "ilobjmediaobjectgui":
151 $this->checkPermission("write");
152 //$cmd.="Object";
153 if ($cmd == "create" || $cmd == "save" || $cmd == "cancel") {
154 $ret_obj = $_GET["mepitem_id"];
155 $ilObjMediaObjectGUI = new ilObjMediaObjectGUI("", 0, false, false);
156 $ilObjMediaObjectGUI->setWidthPreset($this->object->getDefaultWidth());
157 $ilObjMediaObjectGUI->setHeightPreset($this->object->getDefaultHeight());
158 } else {
159 $ret_obj = $tree->getParentId($_GET["mepitem_id"]);
160 $ilObjMediaObjectGUI = new ilObjMediaObjectGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
161 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
162 $ilTabs->setBackTarget(
163 $lng->txt("back"),
164 $this->ctrl->getLinkTarget(
165 $this,
166 $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia"
167 )
168 );
169 }
170 if ($this->ctrl->getCmdClass() == "ilinternallinkgui") {
171 $this->ctrl->setReturn($this, "explorer");
172 } else {
173 $this->ctrl->setParameter($this, "mepitem_id", $ret_obj);
174 $this->ctrl->setReturn(
175 $this,
176 $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia"
177 );
178 $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
179 }
180 $this->getTemplate();
181 $ilObjMediaObjectGUI->setTabs();
182 $this->setLocator();
183
184 $ret = $this->ctrl->forwardCommand($ilObjMediaObjectGUI);
185
186 if ($cmd == "save" && $ret != false) {
187 $mep_item = new ilMediaPoolItem();
188 $mep_item->setTitle($ret->getTitle());
189 $mep_item->setType("mob");
190 $mep_item->setForeignId($ret->getId());
191 $mep_item->create();
192
193 $parent = ($_GET["mepitem_id"] == "")
194 ? $tree->getRootId()
195 : $_GET["mepitem_id"];
196 $tree->insertNode($mep_item->getId(), $parent);
197 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" .
198 $_GET["ref_id"] . "&mepitem_id=" . $_GET["mepitem_id"]);
199 } else {
200 $this->tpl->show();
201 }
202 break;
203
204 case "ilobjfoldergui":
205 $this->checkPermission("write");
206 $this->addHeaderAction();
207 $folder_gui = new ilObjFolderGUI("", 0, false, false);
208 $this->ctrl->setReturn($this, "listMedia");
209 $cmd.="Object";
210 switch ($cmd) {
211 case "createObject":
212 $this->prepareOutput();
213 $folder_gui = new ilObjFolderGUI("", 0, false, false);
214 $folder_gui->setFormAction(
215 "save",
216 $this->ctrl->getFormActionByClass("ilobjfoldergui")
217 );
218 $folder_gui->createObject();
219 $this->tpl->show();
220 break;
221
222 case "saveObject":
223 //$folder_gui->setReturnLocation("save", $this->ctrl->getLinkTarget($this, "listMedia"));
224 $parent = ($_GET["mepitem_id"] == "")
225 ? $tree->getRootId()
226 : $_GET["mepitem_id"];
227 $folder_gui->setFolderTree($tree);
228 $folder_gui->saveObject($parent);
229 //$this->ctrl->redirect($this, "listMedia");
230 break;
231
232 case "editObject":
233 $this->prepareOutput();
234 $folder_gui = new ilObjFolderGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
235 $this->ctrl->setParameter($this, "foldereditmode", "1");
236 $folder_gui->setFormAction("update", $this->ctrl->getFormActionByClass("ilobjfoldergui"));
237 $folder_gui->editObject();
238 $this->tpl->show();
239 break;
240
241 case "updateObject":
242 $folder_gui = new ilObjFolderGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
243 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
244 $this->ctrl->setReturn($this, "listMedia");
245 $folder_gui->updateObject(true); // this returns to parent
246 break;
247
248 case "cancelObject":
249 if ($_GET["foldereditmode"]) {
250 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
251 }
252 $this->ctrl->redirect($this, "listMedia");
253 break;
254 }
255 break;
256
257 case "ileditclipboardgui":
258 $this->prepareOutput();
259 $this->addHeaderAction();
260 $this->ctrl->setReturn($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
261 $clip_gui = new ilEditClipboardGUI();
262 $clip_gui->setMultipleSelections(true);
263 $clip_gui->setInsertButtonTitle($lng->txt("mep_copy_to_mep"));
264 $ilTabs->setTabActive("clipboard");
265 $this->ctrl->forwardCommand($clip_gui);
266 $this->tpl->show();
267 break;
268
269 case 'ilinfoscreengui':
270 $this->prepareOutput();
271 $this->addHeaderAction();
272 $this->infoScreen();
273 $this->tpl->show();
274 break;
275
276 case 'ilpermissiongui':
277 $this->checkPermission("edit_permission");
278 $this->prepareOutput();
279 $this->addHeaderAction();
280 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
281 $perm_gui = new ilPermissionGUI($this);
282 $this->ctrl->forwardCommand($perm_gui);
283 $this->tpl->show();
284 break;
285
286 case "ilexportgui":
287 $this->checkPermission("write");
288 $this->prepareOutput();
289 $this->addHeaderAction();
290 include_once("./Services/Export/classes/class.ilExportGUI.php");
291 $exp_gui = new ilExportGUI($this);
292 $exp_gui->addFormat("xml");
293 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
294 $ot = ilObjectTranslation::getInstance($this->object->getId());
295 if ($ot->getContentActivated()) {
296 $exp_gui->addFormat("xml_master", "XML (" . $lng->txt("mep_master_language_only") . ")", $this, "export");
297 $exp_gui->addFormat("xml_masternomedia", "XML (" . $lng->txt("mep_master_language_only_no_media") . ")", $this, "export");
298 }
299 $this->ctrl->forwardCommand($exp_gui);
300 $this->tpl->show();
301 break;
302
303 case "ilfilesystemgui":
304 $this->checkPermission("write");
305 $this->prepareOutput();
306 $this->addHeaderAction();
307 $ilTabs->clearTargets();
308 $ilTabs->setBackTarget(
309 $lng->txt("back"),
310 $ilCtrl->getLinkTarget($this, "listMedia")
311 );
312 $mset = new ilSetting("mobs");
313 if (trim($mset->get("upload_dir")) != "") {
314 include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
315 $fs_gui = new ilFileSystemGUI($mset->get("upload_dir"));
316 $fs_gui->setPostDirPath(true);
317 $fs_gui->setTableId("mepud" . $this->object->getId());
318 $fs_gui->setAllowFileCreation(false);
319 $fs_gui->setAllowDirectoryCreation(false);
320 $fs_gui->clearCommands();
321 $fs_gui->addCommand(
322 $this,
323 "selectUploadDirFiles",
324 $this->lng->txt("mep_sel_upload_dir_files"),
325 false,
326 true
327 );
328 $this->ctrl->forwardCommand($fs_gui);
329 }
330 $this->tpl->show();
331 break;
332
333 case "ilcommonactiondispatchergui":
334 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
336 $this->ctrl->forwardCommand($gui);
337 break;
338
339 case 'ilobjecttranslationgui':
340 $this->prepareOutput();
341 $this->addHeaderAction();
342 //$this->setTabs("settings");
343 $ilTabs->activateTab("settings");
344 $this->setSettingsSubTabs("obj_multilinguality");
345 include_once("./Services/Object/classes/class.ilObjectTranslationGUI.php");
346 $transgui = new ilObjectTranslationGUI($this);
347 $transgui->setTitleDescrOnlyMode(false);
348 $this->ctrl->forwardCommand($transgui);
349 $this->tpl->show();
350 break;
351
352 case "ilmediapoolimportgui":
353 $this->prepareOutput();
354 $this->addHeaderAction();
355 $ilTabs->activateTab("import");
356 include_once("./Modules/MediaPool/classes/class.ilMediaPoolImportGUI.php");
357 $gui = new ilMediaPoolImportGUI($this->object);
358 $this->ctrl->forwardCommand($gui);
359 $this->tpl->show();
360 break;
361
362 case "ilmobmultisrtuploadgui":
363 $this->checkPermission("write");
364 $this->prepareOutput();
365 $this->addHeaderAction();
366 //$this->setTabs("content");
367 $this->setContentSubTabs("srt_files");
368 include_once("./Services/MediaObjects/classes/class.ilMobMultiSrtUploadGUI.php");
369 include_once("./Modules/MediaPool/classes/class.ilMepMultiSrt.php");
370 $gui = new ilMobMultiSrtUploadGUI(new ilMepMultiSrt($this->object));
371 $this->ctrl->forwardCommand($gui);
372 $this->tpl->show();
373 break;
374
375
376 default:
377 $this->prepareOutput();
378 $this->addHeaderAction();
379 $cmd = $this->ctrl->getCmd("listMedia");
380 $this->$cmd();
381 if (!$this->getCreationMode()) {
382 $this->tpl->show();
383 }
384 break;
385 }
386 }
387
391 public function createMediaObject()
392 {
393 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
394 }
395
396 protected function initCreationForms($a_new_type)
397 {
398 $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
399 self::CFORM_IMPORT => $this->initImportForm($a_new_type));
400
401 return $forms;
402 }
403
407 public function afterSave(ilObject $newObj)
408 {
409 // always send a message
410 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
411
412 //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
413 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&ref_id=" . $newObj->getRefId() . "&cmd=listMedia");
414 }
415
416 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
417 {
418 // default width
419 $ni = new ilNumberInputGUI($this->lng->txt("mep_default_width"), "default_width");
420 $ni->setMinValue(0);
421 $ni->setSuffix("px");
422 $ni->setMaxLength(5);
423 $ni->setSize(5);
424 $a_form->addItem($ni);
425
426 // default height
427 $ni = new ilNumberInputGUI($this->lng->txt("mep_default_height"), "default_height");
428 $ni->setSuffix("px");
429 $ni->setMinValue(0);
430 $ni->setMaxLength(5);
431 $ni->setSize(5);
432 $ni->setInfo($this->lng->txt("mep_default_width_height_info"));
433 $a_form->addItem($ni);
434 }
435
442 public function edit()
443 {
444 $this->setSettingsSubTabs("settings");
445 parent::edit();
446 }
447
448
449 protected function getEditFormCustomValues(array &$a_values)
450 {
451 if ($this->object->getDefaultWidth() > 0) {
452 $a_values["default_width"] = $this->object->getDefaultWidth();
453 }
454 if ($this->object->getDefaultHeight() > 0) {
455 $a_values["default_height"] = $this->object->getDefaultHeight();
456 }
457 }
458
459 protected function updateCustom(ilPropertyFormGUI $a_form)
460 {
461 $this->object->setDefaultWidth($a_form->getInput("default_width"));
462 $this->object->setDefaultHeight($a_form->getInput("default_height"));
463 }
464
468 public function listMedia()
469 {
470 $ilAccess = $this->access;
472 $ilTabs = $this->tabs;
474 $ilToolbar = $this->toolbar;
476
477 $ilCtrl->setParameter($this, "mep_mode", "listMedia");
478
479 $this->checkPermission("read");
480
481 $ilTabs->setTabActive("content");
482 $this->setContentSubTabs("content");
483
484 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
485 $ilToolbar->addButton(
486 $lng->txt("mep_create_mob"),
487 $ilCtrl->getLinkTarget($this, "createMediaObject")
488 );
489
490 $mset = new ilSetting("mobs");
491 if ($mset->get("mep_activate_pages")) {
492 $ilToolbar->addButton(
493 $lng->txt("mep_create_content_snippet"),
494 $ilCtrl->getLinkTarget($this, "createMediaPoolPage")
495 );
496 }
497
498 $ilToolbar->addButton(
499 $lng->txt("mep_create_folder"),
500 $ilCtrl->getLinkTarget($this, "createFolderForm")
501 );
502
503 if (trim($mset->get("upload_dir")) != "" && ilMainMenuGUI::_checkAdministrationPermission()) {
504 $ilToolbar->addButton(
505 $lng->txt("mep_create_from_upload_dir"),
506 $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles")
507 );
508 }
509 }
510
511 // tree
512 include_once("./Modules/MediaPool/classes/class.ilMediaPoolExplorerGUI.php");
513 $exp = new ilMediaPoolExplorerGUI($this, "listMedia", $this->object);
514 if (!$exp->handleCommand()) {
515 $this->tpl->setLeftNavContent($exp->getHTML());
516 } else {
517 return;
518 }
519
520 include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
521 $mep_table_gui = new ilMediaPoolTableGUI($this, "listMedia", $this->object, "mepitem_id");
522 $tpl->setContent($mep_table_gui->getHTML());
523 }
524
528 public function allMedia()
529 {
531 $ilTabs = $this->tabs;
534
535 $ilCtrl->setParameter($this, "mep_mode", "allMedia");
536
537 $this->checkPermission("read");
538 $ilTabs->setTabActive("content");
539 $this->setContentSubTabs("mep_all_mobs");
540
541
542 include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
543 $mep_table_gui = new ilMediaPoolTableGUI(
544 $this,
545 "allMedia",
546 $this->object,
547 "mepitem_id",
549 true
550 );
551
552
553 if (isset($_GET['force_filter']) and $_GET['force_filter']) {
554 $_POST['title'] = ilMediaPoolItem::lookupTitle((int) $_GET['force_filter']);
555
556 include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
557 $tprop = new ilTablePropertiesStorage();
558 $tprop->storeProperty(
559 $mep_table_gui->getId(),
560 $ilUser->getId(),
561 'filter',
562 1
563 );
564 $mep_table_gui->resetFilter();
565 $mep_table_gui->resetOffset();
566 $mep_table_gui->writeFilterToSession();
567
568 // Read again
569 $mep_table_gui = new ilMediaPoolTableGUI(
570 $this,
571 "allMedia",
572 $this->object,
573 "mepitem_id",
575 true
576 );
577 }
578
579 $tpl->setContent($mep_table_gui->getHTML());
580 }
581
585 public function applyFilter()
586 {
587 include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
588 $mtab = new ilMediaPoolTableGUI(
589 $this,
590 "allMedia",
591 $this->object,
592 "mepitem_id",
594 true
595 );
596 $mtab->writeFilterToSession();
597 $mtab->resetOffset();
598 $this->allMedia();
599 }
600
604 public function resetFilter()
605 {
606 include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
607 $mtab = new ilMediaPoolTableGUI(
608 $this,
609 "allMedia",
610 $this->object,
611 "mepitem_id",
613 true
614 );
615 $mtab->resetFilter();
616 $mtab->resetOffset();
617 $this->allMedia();
618 }
619
623 public function getTemplate()
624 {
625 $this->tpl->getStandardTemplate();
626 }
627
628
632 public function getParentFolderId()
633 {
634 if ($_GET["mepitem_id"] == "") {
635 return "";
636 }
637 $par_id = $this->object->getPoolTree()->getParentId($_GET["mepitem_id"]);
638 if ($par_id != $this->object->getPoolTree()->getRootId()) {
639 return $par_id;
640 } else {
641 return "";
642 }
643 }
644
648 protected function showMedia()
649 {
650 $this->checkPermission("read");
651
652 $item = new ilMediaPoolItem((int) $_GET["mepitem_id"]);
653 $mob_id = $item->getForeignId();
654
655 $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
656 include_once("Services/Style/Content/classes/class.ilObjStyleSheet.php");
657 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
658 $this->tpl->setVariable(
659 "LOCATION_CONTENT_STYLESHEET",
661 );
662
663
664 require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
665 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
667 $media_obj = new ilObjMediaObject((int) $mob_id);
668
669
670 $this->tpl->setVariable("TITLE", " - " . $media_obj->getTitle());
671
672 $xml = "<dummy>";
673 // todo: we get always the first alias now (problem if mob is used multiple
674 // times in page)
675 $xml.= $media_obj->getXML(IL_MODE_ALIAS);
676 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
677 $xml.= $link_xml;
678 $xml.="</dummy>";
679
680 $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
681 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
682 $xh = xslt_create();
683
684 $wb_path = ilUtil::getWebspaceDir("output") . "/";
685
686 $mode = ($_GET["cmd"] != "showPreview")
687 ? "fullscreen"
688 : "media";
689 $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output");
690 $fullscreen_link =
691 $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
692 $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path,
693 'link_params' => "ref_id=" . $_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
694 'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
695 $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, $params);
696 echo xslt_error($xh);
697 xslt_free($xh);
698 // unmask user html
699 $this->tpl->setVariable("MEDIA_CONTENT", $output);
700 }
701
708 public function showPage()
709 {
711
712 $tpl = new ilTemplate("tpl.main.html", true, true);
713
714 include_once("./Services/Container/classes/class.ilContainerPage.php");
715 include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
716
717 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
718 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
719 $tpl->setVariable(
720 "LOCATION_CONTENT_STYLESHEET",
722 );
723 $tpl->setCurrentBlock("SyntaxStyle");
724 $tpl->setVariable(
725 "LOCATION_SYNTAX_STYLESHEET",
727 );
728 $tpl->parseCurrentBlock();
729
730 // get page object
731 //include_once("./Services/Object/classes/class.ilObjectTranslation.php");
732 //$ot = ilObjectTranslation::getInstance($this->object->getId());
733 //$lang = $ot->getEffectiveContentLang($ilUser->getCurrentLanguage(), "cont");
734 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
735 $page_gui = new ilMediaPoolPageGUI((int) $_GET["mepitem_id"]);
736 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
737 //$page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
738 // $this->object->getStyleSheetId(), $this->object->getType()));
739
740 $page_gui->setTemplateOutput(false);
741 $page_gui->setHeader("");
742 $ret = $page_gui->showPage(true);
743
744 $tpl->setBodyClass("ilMediaPoolPagePreviewBody");
745 $tpl->setVariable("CONTENT", $ret);
746 //$ret = "<div style='background-color: white; padding:5px; margin-bottom: 30px;'>".$ret."</div>";
747
748
749 $tpl->show();
750 exit;
751 }
752
753
757 public function showPreview()
758 {
759 $this->checkPermission("read");
760
761 $item = new ilMediaPoolItem((int) $_GET["mepitem_id"]);
762
763 switch ($item->getType()) {
764 case "mob":
765 $this->showMedia();
766 break;
767
768 case "pg":
769 $this->showPage();
770 break;
771 }
772 }
773
774
778 public function showFullscreen()
779 {
780 $this->showMedia();
781 }
782
786 public function confirmRemove()
787 {
791
792 $this->checkPermission("write");
793
794 if (!isset($_POST["id"])) {
795 $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
796 }
797
798 // display confirmation message
799 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
800 $cgui = new ilConfirmationGUI();
801 $cgui->setFormAction($this->ctrl->getFormAction($this));
802 $cgui->setHeaderText($this->lng->txt("info_remove_sure"));
803 $cgui->setCancel($this->lng->txt("cancel"), "cancelRemove");
804 $cgui->setConfirm($this->lng->txt("confirm"), "remove");
805
806 foreach ($_POST["id"] as $obj_id) {
809
810 // check whether page can be removed
811 $add = "";
812 if ($type == "pg") {
813 include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
814 $usages = ilPageContentUsage::getUsages("incl", $obj_id, false);
815 if (count($usages) > 0) {
816 ilUtil::sendFailure(sprintf($lng->txt("mep_content_snippet_in_use"), $title), true);
817 $ilCtrl->redirect($this, "listMedia");
818 } else {
819 // check whether the snippet is used in older versions of pages
820 $usages = ilPageContentUsage::getUsages("incl", $obj_id, true);
821 if (count($usages) > 0) {
822 $add = "<div class='small'>" . $lng->txt("mep_content_snippet_used_in_older_versions") . "</div>";
823 }
824 }
825 }
826
827 $caption = ilUtil::getImageTagByType($type, $this->tpl->tplPath) .
828 " " . $title . $add;
829
830 $cgui->addItem("id[]", $obj_id, $caption);
831 }
832
833 $this->tpl->setContent($cgui->getHTML());
834 }
835
839 public function openClipboard()
840 {
842 $ilAccess = $this->access;
843
844 $this->checkPermission("write");
845
846 $ilCtrl->setParameterByClass(
847 "ileditclipboardgui",
848 "returnCommand",
849 rawurlencode($ilCtrl->getLinkTarget(
850 $this,
851 "insertFromClipboard",
852 "",
853 false,
854 false
855 ))
856 );
857 $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
858 }
859
860
864 public function insertFromClipboard()
865 {
866 $ilAccess = $this->access;
867
868 $this->checkPermission("write");
869
870 include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
872 $not_inserted = array();
873 if (is_array($ids)) {
874 foreach ($ids as $id2) {
875 $id = explode(":", $id2);
876 $type = $id[0];
877 $id = $id[1];
878
879 if ($type == "mob") { // media object
880 if (ilObjMEdiaPool::isForeignIdInTree($this->object->getId(), $id)) {
881 $not_inserted[] = ilObject::_lookupTitle($id) . " [" .
882 $id . "]";
883 } else {
884 $item = new ilMediaPoolItem();
885 $item->setType("mob");
886 $item->setForeignId($id);
887 $item->setTitle(ilObject::_lookupTitle($id));
888 $item->create();
889 if ($item->getId() > 0) {
890 $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
891 }
892 }
893 }
894 if ($type == "incl") { // content snippet
895 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
896 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
897 if (ilObjMEdiaPool::isItemIdInTree($this->object->getId(), $id)) {
898 $not_inserted[] = ilMediaPoolPage::lookupTitle($id) . " [" .
899 $id . "]";
900 } else {
901 $original = new ilMediaPoolPage($id);
902
903 // copy the page into the pool
904 $item = new ilMediaPoolItem();
905 $item->setType("pg");
906 $item->setTitle(ilMediaPoolItem::lookupTitle($id));
907 $item->create();
908 if ($item->getId() > 0) {
909 $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
910
911 // create page
912 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
913 $page = new ilMediaPoolPage();
914 $page->setId($item->getId());
915 $page->setParentId($this->object->getId());
916 $page->create();
917
918 // copy content
919 $original->copy($page->getId(), $page->getParentType(), $page->getParentId(), true);
920 }
921 }
922 }
923 }
924 }
925 if (count($not_inserted) > 0) {
926 ilUtil::sendInfo($this->lng->txt("mep_not_insert_already_exist") . "<br>" .
927 implode($not_inserted, "<br>"), true);
928 }
929 $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
930 }
931
932
936 public function cancelRemove()
937 {
938 $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
939 }
940
944 public function remove()
945 {
946 $ilAccess = $this->access;
947
948 $this->checkPermission("write");
949
950 foreach ($_POST["id"] as $obj_id) {
951 $this->object->deleteChild($obj_id);
952 }
953
954 ilUtil::sendSuccess($this->lng->txt("cont_obj_removed"), true);
955 $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
956 }
957
958
962 public function copyToClipboard()
963 {
965 $ilAccess = $this->access;
966
967 $this->checkPermission("write");
968
969 if (!isset($_POST["id"])) {
970 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
971 $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
972 }
973
974 foreach ($_POST["id"] as $obj_id) {
976 if ($type == "fold") {
977 ilUtil::sendFailure($this->lng->txt("cont_cant_copy_folders"), true);
978 $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
979 }
980 }
981 foreach ($_POST["id"] as $obj_id) {
984 if ($type == "mob") {
985 $ilUser->addObjectToClipboard($fid, "mob", "");
986 }
987 if ($type == "pg") {
988 $ilUser->addObjectToClipboard($obj_id, "incl", "");
989 }
990 }
991 ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
992 $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
993 }
994
998 public function addLocatorItems()
999 {
1000 $ilLocator = $this->locator;
1001 $ilAccess = $this->access;
1002
1003 if (!$this->getCreationMode() && $this->ctrl->getCmd() != "explorer") {
1004 $tree = $this->object->getTree();
1005 $obj_id = ($_GET["mepitem_id"] == "")
1006 ? $tree->getRootId()
1007 : $_GET["mepitem_id"];
1008 $path = $tree->getPathFull($obj_id);
1009 foreach ($path as $node) {
1010 if ($node["child"] == $tree->getRootId()) {
1011 $this->ctrl->setParameter($this, "mepitem_id", "");
1012 if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
1013 $link = $this->ctrl->getLinkTarget($this, "listMedia");
1014 } elseif ($ilAccess->checkAccess("visible", "", $this->object->getRefId())) {
1015 $link = $this->ctrl->getLinkTarget($this, "infoScreen");
1016 }
1017 $title = $this->object->getTitle();
1018 $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1019 $ilLocator->addItem($title, $link, "", $_GET["ref_id"]);
1020 }
1021 }
1022 }
1023 }
1024
1028
1032 public function createFolderForm()
1033 {
1034 $ilAccess = $this->access;
1035 $tpl = $this->tpl;
1036
1037 $this->checkPermission("write");
1038
1039 $this->initFolderForm("create");
1040 $tpl->setContent($this->form->getHTML());
1041 }
1042
1049 public function editFolder()
1050 {
1051 $tpl = $this->tpl;
1052
1053 $this->checkPermission("write");
1054
1055 $this->initFolderForm();
1056 $this->getFolderValues();
1057 $tpl->setContent($this->form->getHTML());
1058 }
1059
1063 public function getFolderValues()
1064 {
1065 $values = array();
1066
1067 $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1068
1069 $this->form->setValuesByArray($values);
1070 }
1071
1075 public function saveFolder()
1076 {
1077 $tpl = $this->tpl;
1078 $lng = $this->lng;
1080
1081 $this->checkPermission("write");
1082
1083 $this->initFolderForm("create");
1084 if ($this->form->checkInput()) {
1085 if ($this->object->createFolder($_POST["title"], (int) $_GET["mepitem_id"])) {
1086 ilUtil::sendSuccess($lng->txt("mep_folder_created"), true);
1087 }
1088 $ilCtrl->redirect($this, "listMedia");
1089 }
1090
1091 $this->form->setValuesByPost();
1092 $tpl->setContent($this->form->getHtml());
1093 }
1094
1098 public function updateFolder()
1099 {
1100 $lng = $this->lng;
1102 $tpl = $this->tpl;
1103
1104 $this->checkPermission("write");
1105
1106 $this->initFolderForm("edit");
1107 if ($this->form->checkInput()) {
1108 $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1109 $item->setTitle($_POST["title"]);
1110 $item->update();
1111 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1112 $ilCtrl->setParameter(
1113 $this,
1114 "mepitem_id",
1115 $this->object->getTree()->getParentId($_GET["mepitem_id"])
1116 );
1117 $ilCtrl->redirect($this, "listMedia");
1118 }
1119
1120 $this->form->setValuesByPost();
1121 $tpl->setContent($this->form->getHtml());
1122 }
1123
1129 public function initFolderForm($a_mode = "edit")
1130 {
1131 $lng = $this->lng;
1133
1134 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1135 $this->form = new ilPropertyFormGUI();
1136
1137 // desc
1138 $ti = new ilTextInputGUI($lng->txt("title"), "title");
1139 $ti->setMaxLength(128);
1140 $ti->setRequired(true);
1141 $this->form->addItem($ti);
1142
1143 // save and cancel commands
1144 if ($a_mode == "create") {
1145 $this->form->addCommandButton("saveFolder", $lng->txt("save"));
1146 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1147 $this->form->setTitle($lng->txt("mep_new_folder"));
1148 } else {
1149 $this->form->addCommandButton("updateFolder", $lng->txt("save"));
1150 $this->form->addCommandButton("cancelFolderUpdate", $lng->txt("cancel"));
1151 $this->form->setTitle($lng->txt("mep_edit_folder"));
1152 }
1153
1154 $this->form->setFormAction($ilCtrl->getFormAction($this));
1155 }
1156
1160 public function cancelFolderUpdate()
1161 {
1163 $ilCtrl->setParameter(
1164 $this,
1165 "mepitem_id",
1166 $this->object->getTree()->getParentId($_GET["mepitem_id"])
1167 );
1168 $ilCtrl->redirect($this, "listMedia");
1169 }
1170
1174 public function cancelSave()
1175 {
1177 $ilCtrl->redirect($this, "listMedia");
1178 }
1179
1183
1187 public function createMediaPoolPage()
1188 {
1189 $tpl = $this->tpl;
1190
1191 $this->checkPermission("write");
1192
1193 $this->initMediaPoolPageForm("create");
1194 $tpl->setContent($this->form->getHTML());
1195 }
1196
1203 public function editMediaPoolPage()
1204 {
1205 $tpl = $this->tpl;
1206 $ilTabs = $this->tabs;
1207
1208 $this->checkPermission("write");
1209
1210 $ilTabs->clearTargets();
1211
1212 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1213 $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1214 $mep_page_gui->getTabs();
1215
1216 $this->setMediaPoolPageTabs();
1217
1218 $this->initMediaPoolPageForm("edit");
1219 $this->getMediaPoolPageValues();
1220 $tpl->setContent($this->form->getHTML());
1221 }
1222
1226 public function saveMediaPoolPage()
1227 {
1228 $tpl = $this->tpl;
1229 $lng = $this->lng;
1231
1232 $this->checkPermission("write");
1233
1234 $this->initMediaPoolPageForm("create");
1235 if ($this->form->checkInput()) {
1236 // create media pool item
1237 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1238 $item = new ilMediaPoolItem();
1239 $item->setTitle($_POST["title"]);
1240 $item->setType("pg");
1241 $item->create();
1242
1243 if ($item->getId() > 0) {
1244 // put in tree
1245 $tree = $this->object->getTree();
1246 $parent = $_GET["mepitem_id"] > 0
1247 ? $_GET["mepitem_id"]
1248 : $tree->getRootId();
1249 $this->object->insertInTree($item->getId(), $parent);
1250
1251 // create page
1252 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1253 $page = new ilMediaPoolPage();
1254 $page->setId($item->getId());
1255 $page->setParentId($this->object->getId());
1256 $page->create();
1257
1258 $ilCtrl->setParameterByClass("ilmediapoolpagegui", "mepitem_id", $item->getId());
1259 $ilCtrl->redirectByClass("ilmediapoolpagegui", "edit");
1260 }
1261 $ilCtrl->redirect($this, "listMedia");
1262 }
1263
1264 $this->form->setValuesByPost();
1265 $tpl->setContent($this->form->getHtml());
1266 }
1267
1271 public function updateMediaPoolPage()
1272 {
1273 $lng = $this->lng;
1275 $tpl = $this->tpl;
1276
1277 $this->checkPermission("write");
1278
1279 $this->initMediaPoolPageForm("edit");
1280 if ($this->form->checkInput()) {
1281 $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1282 $item->setTitle($_POST["title"]);
1283 $item->update();
1284 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1285 $ilCtrl->redirect($this, "editMediaPoolPage");
1286 }
1287
1288 $this->form->setValuesByPost();
1289 $tpl->setContent($this->form->getHtml());
1290 }
1296 public function initMediaPoolPageForm($a_mode = "edit")
1297 {
1298 $lng = $this->lng;
1300
1301 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1302 $this->form = new ilPropertyFormGUI();
1303
1304 // title
1305 $ti = new ilTextInputGUI($lng->txt("title"), "title");
1306 $ti->setMaxLength(128);
1307 $ti->setRequired(true);
1308 $this->form->addItem($ti);
1309
1310 // save and cancel commands
1311 if ($a_mode == "create") {
1312 $this->form->addCommandButton("saveMediaPoolPage", $lng->txt("save"));
1313 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1314 $this->form->setTitle($lng->txt("mep_new_content_snippet"));
1315 } else {
1316 $this->form->addCommandButton("updateMediaPoolPage", $lng->txt("save"));
1317 $this->form->setTitle($lng->txt("mep_edit_content_snippet"));
1318 }
1319
1320 $this->form->setFormAction($ilCtrl->getFormAction($this));
1321 }
1322
1326 public function getMediaPoolPageValues()
1327 {
1328 $values = array();
1329
1330 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1331 $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1332
1333 $this->form->setValuesByArray($values);
1334 }
1335
1342 public function setMediaPoolPageTabs()
1343 {
1344 $ilTabs = $this->tabs;
1346 $lng = $this->lng;
1347
1348 // $ilTabs->clearTargets();
1349 //$ilTabs->addTab("mep_pg_prop", $lng->txt("mep_page_properties"),
1350 // $ilCtrl->getLinkTarget($this, "editMediaPoolPage"));
1351 $ilTabs->addTarget(
1352 "cont_usage",
1353 $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages"),
1354 array("showMediaPoolPageUsages", "showAllMediaPoolPageUsages"),
1355 get_class($this)
1356 );
1357 $ilTabs->addTarget(
1358 "settings",
1359 $ilCtrl->getLinkTarget($this, "editMediaPoolPage"),
1360 "editMediaPoolPage",
1361 get_class($this)
1362 );
1363 $ilCtrl->setParameter($this, "mepitem_id", $this->object->getPoolTree()->getParentId($_GET["mepitem_id"]));
1364 $ilTabs->setBackTarget($lng->txt("mep_folder"), $ilCtrl->getLinkTarget($this, "listMedia"));
1365 $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1366 }
1367
1372 {
1373 $this->showMediaPoolPageUsages(true);
1374 }
1375
1376
1380 public function showMediaPoolPageUsages($a_all = false)
1381 {
1382 $ilTabs = $this->tabs;
1384 $lng = $this->lng;
1385 $tpl = $this->tpl;
1386
1387 $this->checkPermission("write");
1388
1389 $ilTabs->clearTargets();
1390
1391 $ilTabs->addSubTab(
1392 "current_usages",
1393 $lng->txt("cont_current_usages"),
1394 $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages")
1395 );
1396
1397 $ilTabs->addSubTab(
1398 "all_usages",
1399 $lng->txt("cont_all_usages"),
1400 $ilCtrl->getLinkTarget($this, "showAllMediaPoolPageUsages")
1401 );
1402
1403 if ($a_all) {
1404 $ilTabs->activateSubTab("all_usages");
1405 $cmd = "showAllMediaPoolPageUsages";
1406 } else {
1407 $ilTabs->activateSubTab("current_usages");
1408 $cmd = "showMediaPoolPageUsages";
1409 }
1410
1411
1412 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1413 $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1414 $mep_page_gui->getTabs();
1415
1416 $this->setMediaPoolPageTabs();
1417
1418 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1419 $page = new ilMediaPoolPage((int) $_GET["mepitem_id"]);
1420
1421 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageUsagesTableGUI.php");
1422 $table = new ilMediaPoolPageUsagesTableGUI($this, $cmd, $page, $a_all);
1423
1424 $tpl->setContent($table->getHTML());
1425 }
1426
1427
1431
1437 public function setContentSubTabs($a_active)
1438 {
1439 $ilAccess = $this->access;
1440 $ilTabs = $this->tabs;
1442
1443 $ilTabs->addSubTab("content", $this->lng->txt("objs_fold"), $this->ctrl->getLinkTarget($this, ""));
1444
1445 $ilCtrl->setParameter($this, "mepitem_id", "");
1446 $ilTabs->addSubTab("mep_all_mobs", $this->lng->txt("mep_all_mobs"), $this->ctrl->getLinkTarget($this, "allMedia"));
1447 $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1448
1449 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
1450 $ilTabs->addSubtab(
1451 "srt_files",
1452 $this->lng->txt("mep_media_subtitles"),
1453 $ilCtrl->getLinkTargetByClass("ilmobmultisrtuploadgui", "")
1454 );
1455 }
1456
1457 $ilTabs->activateSubTab($a_active);
1458 }
1459
1460
1464 public function setTabs()
1465 {
1466 $ilAccess = $this->access;
1467 $ilTabs = $this->tabs;
1469 $ilHelp = $this->help;
1470
1471 $ilHelp->setScreenIdComponent("mep");
1472
1473 if ($ilAccess->checkAccess('read', '', $this->ref_id) ||
1474 $ilAccess->checkAccess('write', '', $this->ref_id)) {
1475 $ilTabs->addTab("content", $this->lng->txt("mep_content"), $this->ctrl->getLinkTarget($this, ""));
1476 //$ilTabs->addTarget("objs_fold", $this->ctrl->getLinkTarget($this, ""),
1477 // "listMedia", "", "_top");
1478
1479 //$ilCtrl->setParameter($this, "mepitem_id", "");
1480 //$ilTabs->addTarget("mep_all_mobs", $this->ctrl->getLinkTarget($this, "allMedia"),
1481 // "allMedia", "", "_top");
1482 //$ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1483 }
1484
1485 // info tab
1486 if ($ilAccess->checkAccess('visible', '', $this->ref_id) ||
1487 $ilAccess->checkAccess('read', '', $this->ref_id) ||
1488 $ilAccess->checkAccess('write', '', $this->ref_id)) {
1489 $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
1490 || strtolower($_GET["cmdClass"]) == "ilnotegui")
1491 ? true
1492 : false;
1493 //echo "-$force_active-";
1494 $ilTabs->addTarget(
1495 "info_short",
1496 $this->ctrl->getLinkTargetByClass(
1497 array("ilobjmediapoolgui", "ilinfoscreengui"),
1498 "showSummary"
1499 ),
1500 array("showSummary", "infoScreen"),
1501 "",
1502 "",
1503 $force_active
1504 );
1505 }
1506
1507 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1508 $ilTabs->addTarget(
1509 "settings",
1510 $this->ctrl->getLinkTarget($this, "edit"),
1511 "edit",
1512 array("", "ilobjmediapoolgui")
1513 );
1514 }
1515
1516 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1517 $ilTabs->addTarget(
1518 "clipboard",
1519 $this->ctrl->getLinkTarget($this, "openClipboard"),
1520 "view",
1521 "ileditclipboardgui"
1522 );
1523 }
1524
1525 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1526 $ilTabs->addTarget(
1527 "export",
1528 $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1529 "",
1530 "ilexportgui"
1531 );
1532
1533 $ilTabs->addTarget(
1534 "import",
1535 $this->ctrl->getLinkTargetByClass("ilmediapoolimportgui", ""),
1536 "",
1537 "ilmediapoolimportgui"
1538 );
1539 }
1540
1541 if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId())) {
1542 $ilTabs->addTarget(
1543 "perm_settings",
1544 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1545 array("perm","info","owner"),
1546 'ilpermissiongui'
1547 );
1548 }
1549 }
1550
1557 public function setSettingsSubTabs($a_active)
1558 {
1559 $ilTabs = $this->tabs;
1560 $lng = $this->lng;
1561 $ilAccess = $this->access;
1562
1563 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1564 $ilTabs->addSubTab(
1565 "settings",
1566 $lng->txt("settings"),
1567 $this->ctrl->getLinkTarget($this, "edit")
1568 );
1569
1570 $mset = new ilSetting("mobs");
1571 if ($mset->get("mep_activate_pages")) {
1572 $ilTabs->addSubTabTarget(
1573 "obj_multilinguality",
1574 $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
1575 );
1576 }
1577 }
1578
1579 $ilTabs->setSubTabActive($a_active);
1580 }
1581
1582
1586 public static function _goto($a_target)
1587 {
1588 global $DIC;
1589
1590 $ilAccess = $DIC->access();
1591 $ilErr = $DIC["ilErr"];
1592 $lng = $DIC->language();
1593
1594 $targets = explode('_', $a_target);
1595 if (count((array) $targets) > 1) {
1596 $ref_id = $targets[0];
1597 $subitem_id = $targets[1];
1598 } else {
1599 $ref_id = $targets[0];
1600 }
1601
1602 if ($ilAccess->checkAccess("read", "", $ref_id)) {
1603 $_GET["baseClass"] = "ilMediaPoolPresentationGUI";
1604 $_GET["ref_id"] = $ref_id;
1605 $_GET['mepitem_id'] = $subitem_id;
1606 include("ilias.php");
1607 exit;
1608 } elseif ($ilAccess->checkAccess("visible", "", $ref_id)) {
1609 $_GET["baseClass"] = "ilMediaPoolPresentationGUI";
1610 $_GET["ref_id"] = $ref_id;
1611 $_GET["cmd"] = "infoScreen";
1612 include("ilias.php");
1613 exit;
1614 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1616 $lng->txt("msg_no_perm_read_item"),
1618 ), true);
1620 }
1621
1622 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1623 }
1624
1630 public function infoScreenObject()
1631 {
1632 $this->ctrl->setCmd("showSummary");
1633 $this->ctrl->setCmdClass("ilinfoscreengui");
1634 $this->infoScreen();
1635 }
1636
1640 public function infoScreen()
1641 {
1642 $ilAccess = $this->access;
1644
1645 if (!$ilAccess->checkAccess("visible", "", $this->ref_id) &&
1646 !$ilAccess->checkAccess("read", "", $this->ref_id) &&
1647 !$ilAccess->checkAccess("write", "", $this->ref_id)) {
1648 $ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
1649 }
1650
1651 if ($this->ctrl->getCmd() == "infoScreen") {
1652 $this->ctrl->setCmd("showSummary");
1653 $this->ctrl->setCmdClass("ilinfoscreengui");
1654 }
1655
1656 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1657 $info = new ilInfoScreenGUI($this);
1658
1659 $info->enablePrivateNotes();
1660
1661
1662 // standard meta data
1663 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1664
1665 // forward the command
1666 $this->ctrl->forwardCommand($info);
1667 }
1668
1669
1673
1677 public function selectUploadDirFiles($a_files = null)
1678 {
1679 $tpl = $this->tpl;
1680 $ilTabs = $this->tabs;
1681 $lng = $this->lng;
1683 $ilToolbar = $this->toolbar;
1684
1685 if (!$a_files) {
1686 $a_files = $_POST["file"];
1687 }
1688
1689 $ilTabs->clearTargets();
1690 $ilTabs->setBackTarget(
1691 $lng->txt("back"),
1692 $ilCtrl->getLinkTarget($this, "listMedia")
1693 );
1694
1695 $this->checkPermission("write");
1696
1698
1699 // action type
1700 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1701 $options = array(
1702 "rename" => $lng->txt("mep_up_dir_move"),
1703 "copy" => $lng->txt("mep_up_dir_copy"),
1704 );
1705 $si = new ilSelectInputGUI("", "action");
1706 $si->setOptions($options);
1707 $ilToolbar->addInputItem($si);
1708 $ilToolbar->setCloseFormTag(false);
1709 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1710 $ilToolbar->setFormName("mep_up_form");
1711
1712 include_once("./Modules/MediaPool/classes/class.ilUploadDirFilesTableGUI.php");
1714 $this,
1715 "selectUploadDirFiles",
1716 $a_files
1717 );
1718 $tab->setFormName("mep_up_form");
1719 $tpl->setContent($tab->getHTML());
1720 }
1721 }
1722
1727 {
1728 $this->checkPermission("write");
1729
1730 $mset = new ilSetting("mobs");
1731 $upload_dir = trim($mset->get("upload_dir"));
1732
1733 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1734
1735 if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission()) {
1736 foreach ($_POST["file"] as $f) {
1737 $f = str_replace("..", "", $f);
1738 $fullpath = $upload_dir . "/" . $f;
1739 $mob = new ilObjMediaObject();
1740 $mob->setTitle(basename($fullpath));
1741 $mob->setDescription("");
1742 $mob->create();
1743
1744 // determine and create mob directory, move uploaded file to directory
1745 //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
1746 $mob->createDirectory();
1747 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1748
1749 $media_item = new ilMediaItem();
1750 $mob->addMediaItem($media_item);
1751 $media_item->setPurpose("Standard");
1752
1753 $file = $mob_dir . "/" . basename($fullpath);
1754
1755 // virus handling
1756 $vir = ilUtil::virusHandling($fullpath, basename($fullpath));
1757 if (!$vir[0]) {
1758 ilUtil::sendFailure($this->lng->txt("file_is_infected") . "<br />" . $vir[1], true);
1759 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" .
1760 $_GET["ref_id"] . "&mepitem_id=" . $_GET["mepitem_id"]);
1761 }
1762
1763 switch ($_POST["action"]) {
1764 case "rename":
1765 rename($fullpath, $file);
1766 break;
1767
1768 case "copy":
1769 copy($fullpath, $file);
1770 break;
1771 }
1772
1773 // get mime type
1775 $location = basename($fullpath);
1776
1777 // set real meta and object data
1778 $media_item->setFormat($format);
1779 $media_item->setLocation($location);
1780 $media_item->setLocationType("LocalFile");
1781
1782 $mob->setDescription($format);
1783
1784 // determine width and height of known image types
1786 $format,
1787 "File",
1788 $mob_dir . "/" . $location,
1789 $media_item->getLocation(),
1790 true,
1791 true,
1792 "",
1793 ""
1794 );
1795 $media_item->setWidth($wh["width"]);
1796 $media_item->setHeight($wh["height"]);
1797 if ($wh["info"] != "") {
1798 // ilUtil::sendInfo($wh["info"], true);
1799 }
1800
1801 $media_item->setHAlign("Left");
1802 ilUtil::renameExecutables($mob_dir);
1803 $mob->update();
1804
1805
1806 // put it into current folder
1807 $mep_item = new ilMediaPoolItem();
1808 $mep_item->setTitle($mob->getTitle());
1809 $mep_item->setType("mob");
1810 $mep_item->setForeignId($mob->getId());
1811 $mep_item->create();
1812
1813 $tree = $this->object->getTree();
1814 $parent = ($_GET["mepitem_id"] == "")
1815 ? $tree->getRootId()
1816 : $_GET["mepitem_id"];
1817 $tree->insertNode($mep_item->getId(), $parent);
1818 }
1819 }
1820 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" .
1821 $_GET["ref_id"] . "&mepitem_id=" . $_GET["mepitem_id"]);
1822 }
1823
1827 public static function getPreviewModalHTML($a_mpool_ref_id, $a_tpl)
1828 {
1829 global $DIC;
1830
1831 $tpl = $DIC["tpl"];
1832 $ilCtrl = $DIC->ctrl();
1833 $lng = $DIC->language();
1834
1835 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1837
1838 $tpl->addJavaScript("./Modules/MediaPool/js/ilMediaPool.js");
1839
1840 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", "");
1841 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $a_mpool_ref_id);
1842 $tpl->addOnloadCode("il.MediaPool.setPreviewUrl('" . $ilCtrl->getLinkTargetByClass(array("ilmediapoolpresentationgui", "ilobjmediapoolgui"), "showPreview", "", false, false) . "');");
1843 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", $_GET["mepitem_id"]);
1844 $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $_GET["red_id"]);
1845
1846 include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1847 $modal = ilModalGUI::getInstance();
1848 $modal->setHeading($lng->txt("preview"));
1849 $modal->setId("ilMepPreview");
1850 $modal->setType(ilModalGUI::TYPE_LARGE);
1851 $modal->setBody("<iframe id='ilMepPreviewContent'></iframe>");
1852
1853 return $modal->getHTML();
1854 }
1855
1859 public function export()
1860 {
1861 $ot = ilObjectTranslation::getInstance($this->object->getId());
1862 $opt = "";
1863 if ($ot->getContentActivated()) {
1864 $format = explode("_", $_POST["format"]);
1865 $opt = ilUtil::stripSlashes($format[1]);
1866 }
1867
1868 $this->object->exportXML($opt);
1869 }
1870}
sprintf('%.4f', $callTime)
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
const IL_MODE_ALIAS
const IL_MODE_OUTPUT
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
Class ilEditClipboardGUI.
Export User Interface Class.
File System Explorer GUI class.
Class ilInfoScreenGUI.
static _checkAdministrationPermission()
Class ilMediaItem.
Media pool explorer GUI class.
Import related features for media pools (currently used for translation imports)
static lookupForeignId($a_id)
Lookup Foreign Id.
static lookupType($a_id)
Lookup type.
static lookupTitle($a_id)
Lookup title.
Class ilMediaPoolPage GUI class.
TableGUI class for media pool page usages listing.
Class ilMediaPoolPage.
static lookupTitle($a_page_id)
Lookup title.
TableGUI class for recent changes in wiki.
Handler class for multi srt upload in learning modules.
Upload SRT files to a set of media objects.
static getInstance()
Get instance.
This class represents a number property in a property form.
Class ilObjFolderGUI.
Class ilObjMediaObjectGUI.
static includePresentationJS($a_tpl=null)
Include media object presentation JS.
Class ilObjMediaObject.
static getMimeType($a_file, $a_external=null)
get mime type for file
static _getDirectory($a_mob_id)
get directory for files of media object (static)
static _determineWidthHeight( $a_format, $a_type, $a_file, $a_reference, $a_constrain_proportions, $a_use_original, $a_user_width, $a_user_height)
Determine width and height.
User Interface class for media pool objects.
cancelRemove()
cancel deletion of media objects/folders
getTemplate()
Get standard template.
showMedia()
show media object
afterSave(ilObject $newObj)
save object
addLocatorItems()
add locator items for media pool
getFolderValues()
Get current values for folder from.
showFullscreen()
show fullscreen
executeCommand()
execute command
setContentSubTabs($a_active)
Set sub tabs for content tab.
allMedia()
list all objects
openClipboard()
paste from clipboard
createMediaFromUploadDir()
Create media object from upload directory.
getParentFolderId()
Get folder parent ID.
setSettingsSubTabs($a_active)
Set setting sub tabs.
confirmRemove()
confirm remove of mobs
saveMediaPoolPage()
Save media pool page.
getMediaPoolPageValues()
Get current values for media pool page from.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
initMediaPoolPageForm($a_mode="edit")
Init page form.
static _goto($a_target)
goto target media pool
showMediaPoolPageUsages($a_all=false)
List usages of the contnet snippet.
showPreview()
Show content snippet.
saveFolder()
Save folder form.
initFolderForm($a_mode="edit")
Init folder form.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
setMediaPoolPageTabs()
Set media pool page tabs.
editMediaPoolPage()
Edit media pool page.
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($a_new_type)
Init creation froms.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
createFolderForm()
create folder form
export()
export content object
showAllMediaPoolPageUsages()
List usages of the contnet snippet.
selectUploadDirFiles($a_files=null)
Select files from upload directory.
static getPreviewModalHTML($a_mpool_ref_id, $a_tpl)
Get preview modal html.
insertFromClipboard()
insert media object from clipboard
copyToClipboard()
copy media objects to clipboard
updateMediaPoolPage()
Update media pool page.
listMedia()
list media objects
afterConstructor()
Initialisation.
createMediaPoolPage()
Create new content snippet.
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true)
get content style path
New implementation of ilObjectGUI.
prepareOutput($a_show_subobjects=true)
prepare output
setCreationMode($a_mode=true)
if true, a creation screen is displayed the current $_GET[ref_id] don't belong to the current class!...
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getCreationMode()
get creation mode
setLocator()
set Locator
initImportForm($a_new_type)
Init object import form.
initCreateForm($a_new_type)
Init object creation form.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
addHeaderAction()
Add header action menu.
GUI class for object translation handling.
static getInstance($a_obj_id)
Get instance.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
static getUsages($a_pc_type, $a_pc_id, $a_incl_hist=true)
Get usages.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
This class represents a selection list property in a property form.
ILIAS Setting Class.
Saves (mostly asynchronously) user properties of tables (e.g.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getImageTagByType($a_type, $a_path, $a_big=false)
Builds an html image tag TODO: function still in use, but in future use getImagePath and move HTML-Co...
static getWebspaceDir($mode="filesystem")
get webspace directory
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
if(!array_key_exists('StateId', $_REQUEST)) $id
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
global $ilCtrl
Definition: ilias.php:18
xslt_error(&$proc)
xslt_free(&$proc)
xslt_create()
$format
Definition: metadata.php:141
$xml
Definition: metadata.php:240
$info
Definition: index.php:5
$ret
Definition: parser.php:6
$type
if(empty($password)) $table
Definition: pwgen.php:24
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$params
Definition: disable.php:11