ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjMediaPoolGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObject2GUI.php");
5 include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
6 include_once("./Services/Table/classes/class.ilTableGUI.php");
7 include_once("./Modules/Folder/classes/class.ilObjFolderGUI.php");
8 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
9 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
10 include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
11 
26 {
28 
32  protected function afterConstructor()
33  {
34  global $lng;
35 
36  $lng->loadLanguageModule("mep");
37 
38  if ($this->ctrl->getCmd() == "explorer")
39  {
40  $this->ctrl->saveParameter($this, array("ref_id"));
41  }
42  else
43  {
44  $this->ctrl->saveParameter($this, array("ref_id", "mepitem_id"));
45  }
46  $this->ctrl->saveParameter($this, array("mep_mode"));
47 
48  $lng->loadLanguageModule("content");
49  }
50 
54  final function getType()
55  {
56  return "mep";
57  }
58 
62  function executeCommand()
63  {
64  global $ilTabs, $lng, $ilAccess, $tpl, $ilCtrl;
65 
66  if ($this->ctrl->getRedirectSource() == "ilinternallinkgui")
67  {
68  $this->explorer();
69  return;
70  }
71 
72  $next_class = $this->ctrl->getNextClass($this);
73  $cmd = $this->ctrl->getCmd();
74  $new_type = $_POST["new_type"]
75  ? $_POST["new_type"]
76  : $_GET["new_type"];
77 
78  if ($new_type != "" && ($cmd != "confirmRemove" && $cmd != "copyToClipboard"
79  && $cmd != "pasteFromClipboard"))
80  {
81  $this->setCreationMode(true);
82  }
83 
84  if (!$this->getCreationMode())
85  {
86  $tree = $this->object->getTree();
87  if ($_GET["mepitem_id"] == "")
88  {
89  $_GET["mepitem_id"] = $tree->getRootId();
90  }
91  }
92  if ($cmd == "create")
93  {
94  switch($_POST["new_type"])
95  {
96  case "mob":
97  $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
98  break;
99 
100  case "fold":
101  $this->ctrl->redirectByClass("ilobjfoldergui", "create");
102  break;
103  }
104  }
105 
106  switch($next_class)
107  {
108  case 'ilmediapoolpagegui':
109  $this->checkPermission("write");
110  $this->prepareOutput();
111  $this->addHeaderAction();
112  $this->setMediaPoolPageTabs();
113  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
114  $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
115 
116  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
117  {
118  $mep_page_gui->setEnableEditing(false);
119  }
120  $ret = $this->ctrl->forwardCommand($mep_page_gui);
121  if ($ret != "")
122  {
123  $tpl->setContent($ret);
124  }
125  $this->tpl->show();
126  break;
127 
128  case "ilobjmediaobjectgui":
129  $this->checkPermission("write");
130  //$cmd.="Object";
131  if ($cmd == "create" || $cmd == "save" || $cmd == "cancel")
132  {
133  $ret_obj = $_GET["mepitem_id"];
134  $ilObjMediaObjectGUI = new ilObjMediaObjectGUI("", 0, false, false);
135  $ilObjMediaObjectGUI->setWidthPreset($this->object->getDefaultWidth());
136  $ilObjMediaObjectGUI->setHeightPreset($this->object->getDefaultHeight());
137  }
138  else
139  {
140  $ret_obj = $tree->getParentId($_GET["mepitem_id"]);
141  $ilObjMediaObjectGUI = new ilObjMediaObjectGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
142  $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
143  $ilTabs->setBackTarget($lng->txt("back"),
144  $this->ctrl->getLinkTarget($this,
145  $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia"));
146  }
147  if ($this->ctrl->getCmdClass() == "ilinternallinkgui")
148  {
149  $this->ctrl->setReturn($this, "explorer");
150  }
151  else
152  {
153  $this->ctrl->setParameter($this, "mepitem_id", $ret_obj);
154  $this->ctrl->setReturn($this,
155  $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
156  $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
157  }
158  $this->getTemplate();
159  $ilObjMediaObjectGUI->setTabs();
160  $this->setLocator();
161 
162  $ret = $this->ctrl->forwardCommand($ilObjMediaObjectGUI);
163 
164  if ($cmd == "save" && $ret != false)
165  {
166  $mep_item = new ilMediaPoolItem();
167  $mep_item->setTitle($ret->getTitle());
168  $mep_item->setType("mob");
169  $mep_item->setForeignId($ret->getId());
170  $mep_item->create();
171 
172  $parent = ($_GET["mepitem_id"] == "")
173  ? $tree->getRootId()
174  : $_GET["mepitem_id"];
175  $tree->insertNode($mep_item->getId(), $parent);
176  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=".
177  $_GET["ref_id"]."&mepitem_id=".$_GET["mepitem_id"]);
178  }
179  else
180  {
181  $this->tpl->show();
182  }
183  break;
184 
185  case "ilobjfoldergui":
186  $this->checkPermission("write");
187  $this->addHeaderAction();
188  $folder_gui = new ilObjFolderGUI("", 0, false, false);
189  $this->ctrl->setReturn($this, "listMedia");
190  $cmd.="Object";
191  switch($cmd)
192  {
193  case "createObject":
194  $this->prepareOutput();
195  $folder_gui = new ilObjFolderGUI("", 0, false, false);
196  $folder_gui->setFormAction("save",
197  $this->ctrl->getFormActionByClass("ilobjfoldergui"));
198  $folder_gui->createObject();
199  $this->tpl->show();
200  break;
201 
202  case "saveObject":
203  //$folder_gui->setReturnLocation("save", $this->ctrl->getLinkTarget($this, "listMedia"));
204  $parent = ($_GET["mepitem_id"] == "")
205  ? $tree->getRootId()
206  : $_GET["mepitem_id"];
207  $folder_gui->setFolderTree($tree);
208  $folder_gui->saveObject($parent);
209  //$this->ctrl->redirect($this, "listMedia");
210  break;
211 
212  case "editObject":
213  $this->prepareOutput();
214  $folder_gui = new ilObjFolderGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
215  $this->ctrl->setParameter($this, "foldereditmode", "1");
216  $folder_gui->setFormAction("update", $this->ctrl->getFormActionByClass("ilobjfoldergui"));
217  $folder_gui->editObject();
218  $this->tpl->show();
219  break;
220 
221  case "updateObject":
222  $folder_gui = new ilObjFolderGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
223  $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
224  $this->ctrl->setReturn($this, "listMedia");
225  $folder_gui->updateObject(true); // this returns to parent
226  break;
227 
228  case "cancelObject":
229  if ($_GET["foldereditmode"])
230  {
231  $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
232  }
233  $this->ctrl->redirect($this, "listMedia");
234  break;
235  }
236  break;
237 
238  case "ileditclipboardgui":
239  $this->prepareOutput();
240  $this->addHeaderAction();
241  $this->ctrl->setReturn($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
242  $clip_gui = new ilEditClipboardGUI();
243  $clip_gui->setMultipleSelections(true);
244  $clip_gui->setInsertButtonTitle($lng->txt("mep_copy_to_mep"));
245  $ilTabs->setTabActive("clipboard");
246  $this->ctrl->forwardCommand($clip_gui);
247  $this->tpl->show();
248  break;
249 
250  case 'ilinfoscreengui':
251  $this->prepareOutput();
252  $this->addHeaderAction();
253  $this->infoScreen();
254  $this->tpl->show();
255  break;
256 
257  case 'ilpermissiongui':
258  $this->checkPermission("edit_permission");
259  $this->prepareOutput();
260  $this->addHeaderAction();
261  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
262  $perm_gui = new ilPermissionGUI($this);
263  $this->ctrl->forwardCommand($perm_gui);
264  $this->tpl->show();
265  break;
266 
267  case "ilexportgui":
268  $this->checkPermission("write");
269  $this->prepareOutput();
270  $this->addHeaderAction();
271  include_once("./Services/Export/classes/class.ilExportGUI.php");
272  $exp_gui = new ilExportGUI($this);
273  $exp_gui->addFormat("xml");
274  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
275  $ot = ilObjectTranslation::getInstance($this->object->getId());
276  if ($ot->getContentActivated())
277  {
278  $exp_gui->addFormat("xml_master", "XML (".$lng->txt("mep_master_language_only").")", $this, "export");
279  }
280  $this->ctrl->forwardCommand($exp_gui);
281  $this->tpl->show();
282  break;
283 
284  case "ilfilesystemgui":
285  $this->checkPermission("write");
286  $this->prepareOutput();
287  $this->addHeaderAction();
288  $ilTabs->clearTargets();
289  $ilTabs->setBackTarget($lng->txt("back"),
290  $ilCtrl->getLinkTarget($this, "listMedia"));
291  $mset = new ilSetting("mobs");
292  if (trim($mset->get("upload_dir")) != "")
293  {
294  include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
295  $fs_gui = new ilFileSystemGUI($mset->get("upload_dir"));
296  $fs_gui->setPostDirPath(true);
297  $fs_gui->setTableId("mepud".$this->object->getId());
298  $fs_gui->setAllowFileCreation(false);
299  $fs_gui->setAllowDirectoryCreation(false);
300  $fs_gui->clearCommands();
301  $fs_gui->addCommand($this, "selectUploadDirFiles", $this->lng->txt("mep_sel_upload_dir_files"),
302  false, true);
303  $this->ctrl->forwardCommand($fs_gui);
304  }
305  $this->tpl->show();
306  break;
307 
308  case "ilcommonactiondispatchergui":
309  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
311  $this->ctrl->forwardCommand($gui);
312  break;
313 
314  case 'ilobjecttranslationgui':
315  $this->prepareOutput();
316  $this->addHeaderAction();
317  //$this->setTabs("settings");
318  $ilTabs->activateTab("settings");
319  $this->setSettingsSubTabs("obj_multilinguality");
320  include_once("./Services/Object/classes/class.ilObjectTranslationGUI.php");
321  $transgui = new ilObjectTranslationGUI($this);
322  $transgui->setTitleDescrOnlyMode(false);
323  $this->ctrl->forwardCommand($transgui);
324  $this->tpl->show();
325  break;
326 
327  case "ilmediapoolimportgui":
328  $this->prepareOutput();
329  $this->addHeaderAction();
330  $ilTabs->activateTab("import");
331  include_once("./Modules/MediaPool/classes/class.ilMediaPoolImportGUI.php");
332  $gui = new ilMediaPoolImportGUI($this->object);
333  $this->ctrl->forwardCommand($gui);
334  $this->tpl->show();
335  break;
336 
337  default:
338  $this->prepareOutput();
339  $this->addHeaderAction();
340  $cmd = $this->ctrl->getCmd("listMedia");
341  $this->$cmd();
342  if (!$this->getCreationMode())
343  {
344  $this->tpl->show();
345  }
346  break;
347  }
348  }
349 
353  function createMediaObject()
354  {
355  $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
356  }
357 
358  protected function initCreationForms($a_new_type)
359  {
360  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
361  self::CFORM_IMPORT => $this->initImportForm($a_new_type));
362 
363  return $forms;
364  }
365 
369  function afterSave(ilObject $newObj)
370  {
371  // always send a message
372  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
373 
374  //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
375  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&ref_id=".$newObj->getRefId()."&cmd=listMedia");
376  }
377 
378  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
379  {
380  // default width
381  $ni = new ilNumberInputGUI($this->lng->txt("mep_default_width"), "default_width");
382  $ni->setMinValue(0);
383  $ni->setSuffix("px");
384  $ni->setMaxLength(5);
385  $ni->setSize(5);
386  $a_form->addItem($ni);
387 
388  // default height
389  $ni = new ilNumberInputGUI($this->lng->txt("mep_default_height"), "default_height");
390  $ni->setSuffix("px");
391  $ni->setMinValue(0);
392  $ni->setMaxLength(5);
393  $ni->setSize(5);
394  $ni->setInfo($this->lng->txt("mep_default_width_height_info"));
395  $a_form->addItem($ni);
396  }
397 
404  function edit()
405  {
406  $this->setSettingsSubTabs("settings");
407  parent::edit();
408  }
409 
410 
411  protected function getEditFormCustomValues(array &$a_values)
412  {
413  if ($this->object->getDefaultWidth() > 0)
414  {
415  $a_values["default_width"] = $this->object->getDefaultWidth();
416  }
417  if ($this->object->getDefaultHeight() > 0)
418  {
419  $a_values["default_height"] = $this->object->getDefaultHeight();
420  }
421  }
422 
423  protected function updateCustom(ilPropertyFormGUI $a_form)
424  {
425  $this->object->setDefaultWidth($a_form->getInput("default_width"));
426  $this->object->setDefaultHeight($a_form->getInput("default_height"));
427  }
428 
432  function listMedia()
433  {
434  global $tree, $ilAccess, $tpl, $ilTabs, $ilCtrl, $ilToolbar, $lng, $ilErr;
435 
436  $ilCtrl->setParameter($this, "mep_mode", "listMedia");
437 
438  $this->checkPermission("read");
439 
440  $ilTabs->setTabActive("objs_fold");
441 
442  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
443  {
444  $ilToolbar->addButton($lng->txt("mep_create_mob"),
445  $ilCtrl->getLinkTarget($this, "createMediaObject"));
446 
447  $mset = new ilSetting("mobs");
448  if ($mset->get("mep_activate_pages"))
449  {
450  $ilToolbar->addButton($lng->txt("mep_create_content_snippet"),
451  $ilCtrl->getLinkTarget($this, "createMediaPoolPage"));
452  }
453 
454  $ilToolbar->addButton($lng->txt("mep_create_folder"),
455  $ilCtrl->getLinkTarget($this, "createFolderForm"));
456 
457  if (trim($mset->get("upload_dir")) != "" && ilMainMenuGUI::_checkAdministrationPermission())
458  {
459  $ilToolbar->addButton($lng->txt("mep_create_from_upload_dir"),
460  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
461  }
462  }
463 
464  // tree
465  include_once("./Modules/MediaPool/classes/class.ilMediaPoolExplorerGUI.php");
466  $exp = new ilMediaPoolExplorerGUI($this, "listMedia", $this->object);
467  if (!$exp->handleCommand())
468  {
469  $this->tpl->setLeftNavContent($exp->getHTML());
470  }
471  else
472  {
473  return;
474  }
475 
476  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
477  $mep_table_gui = new ilMediaPoolTableGUI($this, "listMedia", $this->object, "mepitem_id");
478  $tpl->setContent($mep_table_gui->getHTML());
479 // $this->tpl->show();
480  }
481 
485  function allMedia()
486  {
487  global $tree, $ilAccess, $tpl, $ilTabs, $ilCtrl,$ilUser;
488 
489  $ilCtrl->setParameter($this, "mep_mode", "allMedia");
490 
491  $this->checkPermission("read");
492  $ilTabs->setTabActive("mep_all_mobs");
493 
494 
495  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
496  $mep_table_gui = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
497  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
498 
499 
500  if(isset($_GET['force_filter']) and $_GET['force_filter'])
501  {
502  $_POST['title'] = ilMediaPoolItem::lookupTitle((int) $_GET['force_filter']);
503 
504  include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
505  $tprop = new ilTablePropertiesStorage();
506  $tprop->storeProperty(
507  $mep_table_gui->getId(),
508  $ilUser->getId(),
509  'filter',
510  1
511  );
512  $mep_table_gui->resetFilter();
513  $mep_table_gui->resetOffset();
514  $mep_table_gui->writeFilterToSession();
515 
516  // Read again
517  $mep_table_gui = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
518  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
519  }
520 
521  $tpl->setContent($mep_table_gui->getHTML());
522 // $this->tpl->show();
523  }
524 
528  function applyFilter()
529  {
530  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
531  $mtab = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
532  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
533  $mtab->writeFilterToSession();
534  $mtab->resetOffset();
535  $this->allMedia();
536  }
537 
541  function resetFilter()
542  {
543  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
544  $mtab = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
545  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
546  $mtab->resetFilter();
547  $mtab->resetOffset();
548  $this->allMedia();
549  }
550 
554  function getTemplate()
555  {
556  $this->tpl->getStandardTemplate();
557  }
558 
559 
563  function getParentFolderId()
564  {
565  if ($_GET["mepitem_id"] == "")
566  {
567  return "";
568  }
569  $par_id = $this->object->tree->getParentId($_GET["mepitem_id"]);
570  if ($par_id != $this->object->tree->getRootId())
571  {
572  return $par_id;
573  }
574  else
575  {
576  return "";
577  }
578  }
579 
583  protected function showMedia()
584  {
585  global $ilAccess;
586 
587  $this->checkPermission("read");
588 
589  $item = new ilMediaPoolItem((int) $_GET["mepitem_id"]);
590  $mob_id = $item->getForeignId();
591 
592  $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
593  include_once("Services/Style/Content/classes/class.ilObjStyleSheet.php");
594  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
595  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
597 
598 
599  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
600  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
602  $media_obj = new ilObjMediaObject((int) $mob_id);
603 
604 
605  $this->tpl->setVariable("TITLE", " - ".$media_obj->getTitle());
606 
607  $xml = "<dummy>";
608  // todo: we get always the first alias now (problem if mob is used multiple
609  // times in page)
610  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
611  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
612  $xml.= $link_xml;
613  $xml.="</dummy>";
614 
615  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
616  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
617  $xh = xslt_create();
618 
619  $wb_path = ilUtil::getWebspaceDir("output")."/";
620 
621  $mode = ($_GET["cmd"] != "showPreview")
622  ? "fullscreen"
623  : "media";
624  $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output");
625  $fullscreen_link =
626  $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
627  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
628  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
629  'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
630  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
631  echo xslt_error($xh);
632  xslt_free($xh);
633  // unmask user html
634  $this->tpl->setVariable("MEDIA_CONTENT", $output);
635  }
636 
643  function showPage()
644  {
645  global $tpl;
646 
647  $tpl = new ilTemplate("tpl.main.html", true, true);
648 
649  include_once("./Services/Container/classes/class.ilContainerPage.php");
650  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
651 
652  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
653  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
654  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
656  $tpl->setCurrentBlock("SyntaxStyle");
657  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
659  $tpl->parseCurrentBlock();
660 
661  // get page object
662  //include_once("./Services/Object/classes/class.ilObjectTranslation.php");
663  //$ot = ilObjectTranslation::getInstance($this->object->getId());
664  //$lang = $ot->getEffectiveContentLang($ilUser->getCurrentLanguage(), "cont");
665  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
666  $page_gui = new ilMediaPoolPageGUI((int) $_GET["mepitem_id"]);
667  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
668  //$page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
669  // $this->object->getStyleSheetId(), $this->object->getType()));
670 
671  $page_gui->setTemplateOutput(false);
672  $page_gui->setHeader("");
673  $ret = $page_gui->showPage(true);
674 
675  $tpl->setBodyClass("ilMediaPoolPagePreviewBody");
676  $tpl->setVariable("CONTENT", $ret);
677  //$ret = "<div style='background-color: white; padding:5px; margin-bottom: 30px;'>".$ret."</div>";
678 
679 
680  $tpl->show();
681  exit;
682  }
683 
684 
688  function showPreview()
689  {
690  $this->checkPermission("read");
691 
692  $item = new ilMediaPoolItem((int) $_GET["mepitem_id"]);
693 
694  switch ($item->getType())
695  {
696  case "mob":
697  $this->showMedia();
698  break;
699 
700  case "pg":
701  $this->showPage();
702  break;
703  }
704  }
705 
706 
710  function showFullscreen()
711  {
712  $this->showMedia();
713  }
714 
718  function confirmRemove()
719  {
720  global $ilAccess, $ilCtrl, $lng, $ilErr;
721 
722 
723  $this->checkPermission("write");
724 
725  if(!isset($_POST["id"]))
726  {
727  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
728  }
729 
730  // display confirmation message
731  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
732  $cgui = new ilConfirmationGUI();
733  $cgui->setFormAction($this->ctrl->getFormAction($this));
734  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
735  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemove");
736  $cgui->setConfirm($this->lng->txt("confirm"), "remove");
737 
738  foreach($_POST["id"] as $obj_id)
739  {
740  $type = ilMediaPoolItem::lookupType($obj_id);
742 
743  // check whether page can be removed
744  $add = "";
745  if ($type == "pg")
746  {
747  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
748  $usages = ilPageContentUsage::getUsages("incl", $obj_id, false);
749  if (count($usages) > 0)
750  {
751  ilUtil::sendFailure(sprintf($lng->txt("mep_content_snippet_in_use"), $title), true);
752  $ilCtrl->redirect($this, "listMedia");
753  }
754  else
755  {
756  // check whether the snippet is used in older versions of pages
757  $usages = ilPageContentUsage::getUsages("incl", $obj_id, true);
758  if (count($usages) > 0)
759  {
760  $add = "<div class='small'>".$lng->txt("mep_content_snippet_used_in_older_versions")."</div>";
761  }
762  }
763  }
764 
765  $caption = ilUtil::getImageTagByType($type, $this->tpl->tplPath).
766  " ".$title.$add;
767 
768  $cgui->addItem("id[]", $obj_id, $caption);
769  }
770 
771  $this->tpl->setContent($cgui->getHTML());
772  }
773 
777  function openClipboard()
778  {
779  global $ilCtrl, $ilAccess;
780 
781  $this->checkPermission("write");
782 
783  $ilCtrl->setParameterByClass("ileditclipboardgui", "returnCommand",
784  rawurlencode($ilCtrl->getLinkTarget($this,
785  "insertFromClipboard", "", false, false)));
786  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
787  }
788 
789 
794  {
795  global $ilAccess;
796 
797  $this->checkPermission("write");
798 
799  include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
801  $not_inserted = array();
802  if (is_array($ids))
803  {
804  foreach ($ids as $id2)
805  {
806  $id = explode(":", $id2);
807  $type = $id[0];
808  $id = $id[1];
809 
810  if ($type == "mob") // media object
811  {
812  if (ilObjMEdiaPool::isForeignIdInTree($this->object->getId(), $id))
813  {
814  $not_inserted[] = ilObject::_lookupTitle($id)." [".
815  $id."]";
816  }
817  else
818  {
819  $item = new ilMediaPoolItem();
820  $item->setType("mob");
821  $item->setForeignId($id);
822  $item->setTitle(ilObject::_lookupTitle($id));
823  $item->create();
824  if ($item->getId() > 0)
825  {
826  $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
827  }
828  }
829  }
830  if ($type == "incl") // content snippet
831  {
832  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
833  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
834  if (ilObjMEdiaPool::isItemIdInTree($this->object->getId(), $id))
835  {
836  $not_inserted[] = ilMediaPoolPage::lookupTitle($id)." [".
837  $id."]";
838  }
839  else
840  {
841  $original = new ilMediaPoolPage($id);
842 
843  // copy the page into the pool
844  $item = new ilMediaPoolItem();
845  $item->setType("pg");
846  $item->setTitle(ilMediaPoolItem::lookupTitle($id));
847  $item->create();
848  if ($item->getId() > 0)
849  {
850  $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
851 
852  // create page
853  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
854  $page = new ilMediaPoolPage();
855  $page->setId($item->getId());
856  $page->setParentId($this->object->getId());
857  $page->create();
858 
859  // copy content
860  $original->copy($page->getId(), $page->getParentType(), $page->getParentId(), true);
861 
862  //$page->setXMLContent($original->copyXMLContent());
863  //$page->buildDom();
864  //$page->update();
865  }
866  }
867  }
868  }
869  }
870  if (count($not_inserted) > 0)
871  {
872  ilUtil::sendInfo($this->lng->txt("mep_not_insert_already_exist")."<br>".
873  implode($not_inserted,"<br>"), true);
874  }
875  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
876  }
877 
878 
882  function cancelRemove()
883  {
884  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
885  }
886 
890  function remove()
891  {
892  global $ilAccess;
893 
894  $this->checkPermission("write");
895 
896  foreach($_POST["id"] as $obj_id)
897  {
898  $this->object->deleteChild($obj_id);
899  }
900 
901  ilUtil::sendSuccess($this->lng->txt("cont_obj_removed"),true);
902  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
903  }
904 
905 
909  function copyToClipboard()
910  {
911  global $ilUser, $ilAccess;
912 
913  $this->checkPermission("write");
914 
915  if(!isset($_POST["id"]))
916  {
917  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
918  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
919  }
920 
921  foreach ($_POST["id"] as $obj_id)
922  {
923  $type = ilMediaPoolItem::lookupType($obj_id);
924  if ($type == "fold")
925  {
926  ilUtil::sendFailure($this->lng->txt("cont_cant_copy_folders"), true);
927  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
928  }
929  }
930  foreach ($_POST["id"] as $obj_id)
931  {
932  $fid = ilMediaPoolItem::lookupForeignId($obj_id);
933  $type = ilMediaPoolItem::lookupType($obj_id);
934  if ($type == "mob")
935  {
936  $ilUser->addObjectToClipboard($fid, "mob", "");
937  }
938  if ($type == "pg")
939  {
940  $ilUser->addObjectToClipboard($obj_id, "incl", "");
941  }
942  }
943  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"),true);
944  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
945  }
946 
950  function addLocatorItems()
951  {
952  global $ilLocator, $ilAccess;
953 
954  if (!$this->getCreationMode() && $this->ctrl->getCmd() != "explorer")
955  {
956  $tree = $this->object->getTree();
957  $obj_id = ($_GET["mepitem_id"] == "")
958  ? $tree->getRootId()
959  : $_GET["mepitem_id"];
960  $path = $tree->getPathFull($obj_id);
961  foreach($path as $node)
962  {
963  if ($node["child"] == $tree->getRootId())
964  {
965  $this->ctrl->setParameter($this, "mepitem_id", "");
966  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
967  {
968  $link = $this->ctrl->getLinkTarget($this, "listMedia");
969  }
970  else if ($ilAccess->checkAccess("visible", "", $this->object->getRefId()))
971  {
972  $link = $this->ctrl->getLinkTarget($this, "infoScreen");
973  }
974  $title = $this->object->getTitle();
975  $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
976  $ilLocator->addItem($title, $link, "", $_GET["ref_id"]);
977  }
978  }
979  }
980  }
981 
985 
989  function createFolderForm()
990  {
991  global $ilAccess, $tpl;
992 
993  $this->checkPermission("write");
994 
995  $this->initFolderForm("create");
996  $tpl->setContent($this->form->getHTML());
997 
998 /* $folder_gui = new ilObjFolderGUI("", 0, false, false);
999  $this->ctrl->setParameterByClass("ilobjfoldergui", "obj_id", $_GET["obj_id"]);
1000  $folder_gui->setFormAction("save",
1001  $this->ctrl->getFormActionByClass("ilobjfoldergui"));
1002  $folder_gui->createObject();*/
1003 // $this->tpl->show();
1004  }
1005 
1012  function editFolder()
1013  {
1014  global $tpl;
1015 
1016  $this->checkPermission("write");
1017 
1018  $this->initFolderForm();
1019  $this->getFolderValues();
1020  $tpl->setContent($this->form->getHTML());
1021  }
1022 
1026  public function getFolderValues()
1027  {
1028  $values = array();
1029 
1030  $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1031 
1032  $this->form->setValuesByArray($values);
1033  }
1034 
1038  public function saveFolder()
1039  {
1040  global $tpl, $lng, $ilCtrl;
1041 
1042  $this->checkPermission("write");
1043 
1044  $this->initFolderForm("create");
1045  if ($this->form->checkInput())
1046  {
1047  if ($this->object->createFolder($_POST["title"], (int) $_GET["mepitem_id"]))
1048  {
1049  ilUtil::sendSuccess($lng->txt("mep_folder_created"), true);
1050  }
1051  $ilCtrl->redirect($this, "listMedia");
1052  }
1053 
1054  $this->form->setValuesByPost();
1055  $tpl->setContent($this->form->getHtml());
1056  }
1057 
1061  function updateFolder()
1062  {
1063  global $lng, $ilCtrl, $tpl;
1064 
1065  $this->checkPermission("write");
1066 
1067  $this->initFolderForm("edit");
1068  if ($this->form->checkInput())
1069  {
1070  $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1071  $item->setTitle($_POST["title"]);
1072  $item->update();
1073  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1074  $ilCtrl->setParameter($this, "mepitem_id",
1075  $this->object->getTree()->getParentId($_GET["mepitem_id"]));
1076  $ilCtrl->redirect($this, "listMedia");
1077  }
1078 
1079  $this->form->setValuesByPost();
1080  $tpl->setContent($this->form->getHtml());
1081  }
1082 
1088  public function initFolderForm($a_mode = "edit")
1089  {
1090  global $lng, $ilCtrl;
1091 
1092  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1093  $this->form = new ilPropertyFormGUI();
1094 
1095  // desc
1096  $ti = new ilTextInputGUI($lng->txt("title"), "title");
1097  $ti->setMaxLength(128);
1098  $ti->setRequired(true);
1099  $this->form->addItem($ti);
1100 
1101  // save and cancel commands
1102  if ($a_mode == "create")
1103  {
1104  $this->form->addCommandButton("saveFolder", $lng->txt("save"));
1105  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1106  $this->form->setTitle($lng->txt("mep_new_folder"));
1107  }
1108  else
1109  {
1110  $this->form->addCommandButton("updateFolder", $lng->txt("save"));
1111  $this->form->addCommandButton("cancelFolderUpdate", $lng->txt("cancel"));
1112  $this->form->setTitle($lng->txt("mep_edit_folder"));
1113  }
1114 
1115  $this->form->setFormAction($ilCtrl->getFormAction($this));
1116  }
1117 
1122  {
1123  global $ilCtrl;
1124  $ilCtrl->setParameter($this, "mepitem_id",
1125  $this->object->getTree()->getParentId($_GET["mepitem_id"]));
1126  $ilCtrl->redirect($this, "listMedia");
1127  }
1128 
1132  function cancelSave()
1133  {
1134  global $ilCtrl;
1135  $ilCtrl->redirect($this, "listMedia");
1136  }
1137 
1141 
1146  {
1147  global $tpl;
1148 
1149  $this->checkPermission("write");
1150 
1151  $this->initMediaPoolPageForm("create");
1152  $tpl->setContent($this->form->getHTML());
1153  }
1154 
1162  {
1163  global $tpl;
1164 
1165  $this->checkPermission("write");
1166 
1167  $this->setMediaPoolPageTabs();
1168 
1169  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1170  $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1171  $mep_page_gui->getTabs();
1172 
1173  $this->initMediaPoolPageForm("edit");
1174  $this->getMediaPoolPageValues();
1175  $tpl->setContent($this->form->getHTML());
1176  }
1177 
1181  public function saveMediaPoolPage()
1182  {
1183  global $tpl, $lng, $ilCtrl;
1184 
1185  $this->checkPermission("write");
1186 
1187  $this->initMediaPoolPageForm("create");
1188  if ($this->form->checkInput())
1189  {
1190  // create media pool item
1191  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1192  $item = new ilMediaPoolItem();
1193  $item->setTitle($_POST["title"]);
1194  $item->setType("pg");
1195  $item->create();
1196 
1197  if ($item->getId() > 0)
1198  {
1199  // put in tree
1200  $tree = $this->object->getTree();
1201  $parent = $_GET["mepitem_id"] > 0
1202  ? $_GET["mepitem_id"]
1203  : $tree->getRootId();
1204  $this->object->insertInTree($item->getId(), $parent);
1205 
1206  // create page
1207  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1208  $page = new ilMediaPoolPage();
1209  $page->setId($item->getId());
1210  $page->setParentId($this->object->getId());
1211  $page->create();
1212 
1213  $ilCtrl->setParameterByClass("ilmediapoolpagegui", "mepitem_id", $item->getId());
1214  $ilCtrl->redirectByClass("ilmediapoolpagegui", "edit");
1215 
1216  }
1217  $ilCtrl->redirect($this, "listMedia");
1218  }
1219 
1220  $this->form->setValuesByPost();
1221  $tpl->setContent($this->form->getHtml());
1222  }
1223 
1228  {
1229  global $lng, $ilCtrl, $tpl;
1230 
1231  $this->checkPermission("write");
1232 
1233  $this->initMediaPoolPageForm("edit");
1234  if ($this->form->checkInput())
1235  {
1236  $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1237  $item->setTitle($_POST["title"]);
1238  $item->update();
1239  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1240  $ilCtrl->redirect($this, "editMediaPoolPage");
1241  }
1242 
1243  $this->form->setValuesByPost();
1244  $tpl->setContent($this->form->getHtml());
1245  }
1251  public function initMediaPoolPageForm($a_mode = "edit")
1252  {
1253  global $lng, $ilCtrl;
1254 
1255  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1256  $this->form = new ilPropertyFormGUI();
1257 
1258  // title
1259  $ti = new ilTextInputGUI($lng->txt("title"), "title");
1260  $ti->setMaxLength(128);
1261  $ti->setRequired(true);
1262  $this->form->addItem($ti);
1263 
1264  // save and cancel commands
1265  if ($a_mode == "create")
1266  {
1267  $this->form->addCommandButton("saveMediaPoolPage", $lng->txt("save"));
1268  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1269  $this->form->setTitle($lng->txt("mep_new_content_snippet"));
1270  }
1271  else
1272  {
1273  $this->form->addCommandButton("updateMediaPoolPage", $lng->txt("save"));
1274  $this->form->setTitle($lng->txt("mep_edit_content_snippet"));
1275  }
1276 
1277  $this->form->setFormAction($ilCtrl->getFormAction($this));
1278  }
1279 
1283  public function getMediaPoolPageValues()
1284  {
1285  $values = array();
1286 
1287  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1288  $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1289 
1290  $this->form->setValuesByArray($values);
1291  }
1292 
1300  {
1301  global $ilTabs, $ilCtrl, $lng;
1302 
1303  $ilTabs->clearTargets();
1304  //$ilTabs->addTab("mep_pg_prop", $lng->txt("mep_page_properties"),
1305  // $ilCtrl->getLinkTarget($this, "editMediaPoolPage"));
1306  $ilTabs->addTarget("mep_page_properties", $ilCtrl->getLinkTarget($this, "editMediaPoolPage"),
1307  "editMediaPoolPage", get_class($this));
1308  $ilTabs->addTarget("cont_usage", $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages"),
1309  array("showMediaPoolPageUsages", "showAllMediaPoolPageUsages"), get_class($this));
1310  $ilCtrl->setParameter($this, "mepitem_id", $this->object->tree->getParentId($_GET["mepitem_id"]));
1311  $ilTabs->setBackTarget($lng->txt("mep_folder"), $ilCtrl->getLinkTarget($this, "listMedia"));
1312  $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1313  }
1314 
1319  {
1320  $this->showMediaPoolPageUsages(true);
1321  }
1322 
1323 
1327  function showMediaPoolPageUsages($a_all = false)
1328  {
1329  global $ilTabs, $ilCtrl, $lng, $tpl;
1330 
1331  $this->checkPermission("write");
1332 
1333  $this->setMediaPoolPageTabs();
1334 
1335  $ilTabs->addSubTab("current_usages", $lng->txt("cont_current_usages"),
1336  $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages"));
1337 
1338  $ilTabs->addSubTab("all_usages", $lng->txt("cont_all_usages"),
1339  $ilCtrl->getLinkTarget($this, "showAllMediaPoolPageUsages"));
1340 
1341  if ($a_all)
1342  {
1343  $ilTabs->activateSubTab("all_usages");
1344  $cmd = "showAllMediaPoolPageUsages";
1345  }
1346  else
1347  {
1348  $ilTabs->activateSubTab("current_usages");
1349  $cmd = "showMediaPoolPageUsages";
1350  }
1351 
1352 
1353  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1354  $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1355  $mep_page_gui->getTabs();
1356 
1357  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1358  $page = new ilMediaPoolPage((int) $_GET["mepitem_id"]);
1359 
1360  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageUsagesTableGUI.php");
1361  $table = new ilMediaPoolPageUsagesTableGUI($this, $cmd, $page, $a_all);
1362 
1363  $tpl->setContent($table->getHTML());
1364 
1365  }
1366 
1367 
1371 
1375  function setTabs()
1376  {
1377  global $ilAccess, $ilTabs, $ilCtrl, $ilHelp;
1378 
1379  $ilHelp->setScreenIdComponent("mep");
1380 
1381  if ($ilAccess->checkAccess('read', '', $this->ref_id) ||
1382  $ilAccess->checkAccess('write', '', $this->ref_id))
1383  {
1384  $ilTabs->addTarget("objs_fold", $this->ctrl->getLinkTarget($this, ""),
1385  "listMedia", "", "_top");
1386 
1387  $ilCtrl->setParameter($this, "mepitem_id", "");
1388  $ilTabs->addTarget("mep_all_mobs", $this->ctrl->getLinkTarget($this, "allMedia"),
1389  "allMedia", "", "_top");
1390  $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1391  }
1392 
1393  // info tab
1394  if ($ilAccess->checkAccess('visible', '', $this->ref_id) ||
1395  $ilAccess->checkAccess('read', '', $this->ref_id) ||
1396  $ilAccess->checkAccess('write', '', $this->ref_id))
1397  {
1398  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
1399  || strtolower($_GET["cmdClass"]) == "ilnotegui")
1400  ? true
1401  : false;
1402  //echo "-$force_active-";
1403  $ilTabs->addTarget("info_short",
1404  $this->ctrl->getLinkTargetByClass(
1405  array("ilobjmediapoolgui", "ilinfoscreengui"), "showSummary"),
1406  array("showSummary", "infoScreen"),
1407  "", "", $force_active);
1408  }
1409 
1410  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1411  {
1412  $ilTabs->addTarget("settings", $this->ctrl->getLinkTarget($this, "edit"),
1413  "edit", array("", "ilobjmediapoolgui"));
1414  }
1415 
1416  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1417  {
1418  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTarget($this, "openClipboard"),
1419  "view", "ileditclipboardgui");
1420  }
1421 
1422  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1423  {
1424  $ilTabs->addTarget("export", $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1425  "", "ilexportgui");
1426 
1427  $ilTabs->addTarget("import", $this->ctrl->getLinkTargetByClass("ilmediapoolimportgui", ""),
1428  "", "ilmediapoolimportgui");
1429  }
1430 
1431  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
1432  {
1433  $ilTabs->addTarget("perm_settings",
1434  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1435  }
1436 
1437  }
1438 
1445  function setSettingsSubTabs($a_active)
1446  {
1447  global $ilTabs, $lng, $ilAccess;
1448 
1449  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1450  {
1451  $ilTabs->addSubTab("settings",
1452  $lng->txt("settings"),
1453  $this->ctrl->getLinkTarget($this, "edit"));
1454 
1455  $mset = new ilSetting("mobs");
1456  if ($mset->get("mep_activate_pages"))
1457  {
1458  $ilTabs->addSubTabTarget("obj_multilinguality",
1459  $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", ""));
1460  }
1461  }
1462 
1463  $ilTabs->setSubTabActive($a_active);
1464  }
1465 
1466 
1470  public static function _goto($a_target)
1471  {
1472  global $ilAccess, $ilErr, $lng;
1473 
1474  $targets = explode('_',$a_target);
1475  if(count((array) $targets) > 1)
1476  {
1477  $ref_id = $targets[0];
1478  $subitem_id = $targets[1];
1479  }
1480  else
1481  {
1482  $ref_id = $targets[0];
1483  }
1484 
1485  if ($ilAccess->checkAccess("read", "", $ref_id))
1486  {
1487  $_GET["baseClass"] = "ilMediaPoolPresentationGUI";
1488  $_GET["ref_id"] = $ref_id;
1489  $_GET['mepitem_id'] = $subitem_id;
1490  include("ilias.php");
1491  exit;
1492  } else if ($ilAccess->checkAccess("visible", "", $ref_id))
1493  {
1494  $_GET["baseClass"] = "ilMediaPoolPresentationGUI";
1495  $_GET["ref_id"] = $ref_id;
1496  $_GET["cmd"] = "infoScreen";
1497  include("ilias.php");
1498  exit;
1499  }
1500  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1501  {
1502  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1503  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1505  }
1506 
1507  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1508  }
1509 
1515  function infoScreenObject()
1516  {
1517  $this->ctrl->setCmd("showSummary");
1518  $this->ctrl->setCmdClass("ilinfoscreengui");
1519  $this->infoScreen();
1520  }
1521 
1525  function infoScreen()
1526  {
1527  global $ilAccess;
1528 
1529  if (!$ilAccess->checkAccess("visible", "", $this->ref_id) &&
1530  !$ilAccess->checkAccess("read", "", $this->ref_id) &&
1531  !$ilAccess->checkAccess("write", "", $this->ref_id))
1532  {
1533  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1534  }
1535 
1536  if ($this->ctrl->getCmd() == "infoScreen")
1537  {
1538  $this->ctrl->setCmd("showSummary");
1539  $this->ctrl->setCmdClass("ilinfoscreengui");
1540  }
1541 
1542  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1543  $info = new ilInfoScreenGUI($this);
1544 
1545  $info->enablePrivateNotes();
1546 
1547  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1548  {
1549  //$info->enableNews();
1550  }
1551 
1552  // no news editing for files, just notifications
1553 // $info->enableNewsEditing(false);
1554  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1555  {
1556 // $news_set = new ilSetting("news");
1557 // $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1558 
1559 // if ($enable_internal_rss)
1560 // {
1561 // $info->setBlockProperty("news", "settings", true);
1562 // $info->setBlockProperty("news", "public_notifications_option", true);
1563 // }
1564  }
1565 
1566 
1567  // standard meta data
1568  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1569 
1570  // forward the command
1571  $this->ctrl->forwardCommand($info);
1572 
1573 // $this->tpl->show();
1574  }
1575 
1576 
1580 
1584  function selectUploadDirFiles($a_files = null)
1585  {
1586  global $tpl, $ilTabs, $lng, $ilCtrl, $ilToolbar;
1587 
1588  if(!$a_files)
1589  {
1590  $a_files = $_POST["file"];
1591  }
1592 
1593  $ilTabs->clearTargets();
1594  $ilTabs->setBackTarget($lng->txt("back"),
1595  $ilCtrl->getLinkTarget($this, "listMedia"));
1596 
1597  $this->checkPermission("write");
1598 
1600  {
1601 
1602  // action type
1603  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1604  $options = array(
1605  "rename" => $lng->txt("mep_up_dir_move"),
1606  "copy" => $lng->txt("mep_up_dir_copy"),
1607  );
1608  $si = new ilSelectInputGUI("", "action");
1609  $si->setOptions($options);
1610  $ilToolbar->addInputItem($si);
1611  $ilToolbar->setCloseFormTag(false);
1612  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1613  $ilToolbar->setFormName("mep_up_form");
1614 
1615  include_once("./Modules/MediaPool/classes/class.ilUploadDirFilesTableGUI.php");
1616  $tab = new ilUploadDirFilesTableGUI($this, "selectUploadDirFiles",
1617  $a_files);
1618  $tab->setFormName("mep_up_form");
1619  $tpl->setContent($tab->getHTML());
1620  }
1621  }
1622 
1627  {
1628  $this->checkPermission("write");
1629 
1630  $mset = new ilSetting("mobs");
1631  $upload_dir = trim($mset->get("upload_dir"));
1632 
1633  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1634 
1635  if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission())
1636  {
1637  foreach ($_POST["file"] as $f)
1638  {
1639  $f = str_replace("..", "", $f);
1640  $fullpath = $upload_dir."/".$f;
1641  $mob = new ilObjMediaObject();
1642  $mob->setTitle(basename($fullpath));
1643  $mob->setDescription("");
1644  $mob->create();
1645 
1646  // determine and create mob directory, move uploaded file to directory
1647  //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
1648  $mob->createDirectory();
1649  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1650 
1651  $media_item = new ilMediaItem();
1652  $mob->addMediaItem($media_item);
1653  $media_item->setPurpose("Standard");
1654 
1655  $file = $mob_dir."/".basename($fullpath);
1656  ilUtil::moveUploadedFile($fullpath,
1657  basename($fullpath), $file, false, $_POST["action"]);
1658 
1659  // get mime type
1661  $location = basename($fullpath);
1662 
1663  // set real meta and object data
1664  $media_item->setFormat($format);
1665  $media_item->setLocation($location);
1666  $media_item->setLocationType("LocalFile");
1667 
1668  $mob->setDescription($format);
1669 
1670  // determine width and height of known image types
1672  "File", $mob_dir."/".$location, $media_item->getLocation(),
1673  true, true, "", "");
1674  $media_item->setWidth($wh["width"]);
1675  $media_item->setHeight($wh["height"]);
1676  if ($wh["info"] != "")
1677  {
1678  // ilUtil::sendInfo($wh["info"], true);
1679  }
1680 
1681  $media_item->setHAlign("Left");
1682  ilUtil::renameExecutables($mob_dir);
1683  $mob->update();
1684 
1685 
1686  // put it into current folder
1687  $mep_item = new ilMediaPoolItem();
1688  $mep_item->setTitle($mob->getTitle());
1689  $mep_item->setType("mob");
1690  $mep_item->setForeignId($mob->getId());
1691  $mep_item->create();
1692 
1693  $tree = $this->object->getTree();
1694  $parent = ($_GET["mepitem_id"] == "")
1695  ? $tree->getRootId()
1696  : $_GET["mepitem_id"];
1697  $tree->insertNode($mep_item->getId(), $parent);
1698  }
1699  }
1700  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=".
1701  $_GET["ref_id"]."&mepitem_id=".$_GET["mepitem_id"]);
1702 
1703  }
1704 
1708  static function getPreviewModalHTML($a_mpool_ref_id, $a_tpl)
1709  {
1710  global $tpl, $ilCtrl, $lng;
1711 
1712  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1714 
1715  $tpl->addJavaScript("./Modules/MediaPool/js/ilMediaPool.js");
1716 
1717  $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", "");
1718  $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $a_mpool_ref_id);
1719  $tpl->addOnloadCode("il.MediaPool.setPreviewUrl('".$ilCtrl->getLinkTargetByClass(array("ilmediapoolpresentationgui", "ilobjmediapoolgui"), "showPreview", "", false, false)."');");
1720  $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", $_GET["mepitem_id"]);
1721  $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $_GET["red_id"]);
1722 
1723  include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1724  $modal = ilModalGUI::getInstance();
1725  $modal->setHeading($lng->txt("preview"));
1726  $modal->setId("ilMepPreview");
1727  $modal->setType(ilModalGUI::TYPE_LARGE);
1728  $modal->setBody("<iframe id='ilMepPreviewContent'></iframe>");
1729 
1730  return $modal->getHTML();
1731  }
1732 
1736  function export()
1737  {
1738  $ot = ilObjectTranslation::getInstance($this->object->getId());
1739  $opt = "";
1740  if ($ot->getContentActivated())
1741  {
1742  $format = explode("_", $_POST["format"]);
1743  $opt = ilUtil::stripSlashes($format[1]);
1744  }
1745 
1746  $this->object->exportXML(($opt == "master"));
1747  }
1748 
1749 }
1750 ?>
showFullscreen()
show fullscreen
getFolderValues()
Get current values for folder from.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
setLocator()
set Locator
xslt_create()
updateCustom(ilPropertyFormGUI $a_form)
global $ilErr
Definition: raiseError.php:16
initEditCustomForm(ilPropertyFormGUI $a_form)
ILIAS Setting Class.
static lookupType($a_id)
Lookup type.
$path
Definition: aliased.php:25
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Class ilObjFolderGUI.
Class ilInfoScreenGUI.
Class ilEditClipboardGUI.
executeCommand()
execute command
This class represents a selection list property in a property form.
static _goto($a_target)
goto target media pool
openClipboard()
paste from clipboard
This class represents a property form user interface.
New implementation of ilObjectGUI.
setSettingsSubTabs($a_active)
Set setting sub tabs.
setPostDirPath($a_val)
Set post dir path.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
$location
Definition: buildRTE.php:44
infoScreen()
show information screen
xslt_free(&$proc)
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...
Class ilObject Basic functions for all objects.
saveMediaPoolPage()
Save media pool page.
allMedia()
list all objects
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
$cmd
Definition: sahs_server.php:35
insertFromClipboard()
insert media object from clipboard
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static _lookupTitle($a_id)
lookup object title
static includePresentationJS($a_tpl=null)
Include media object presentation JS.
addItem($a_item)
Add Item (Property, SectionHeader).
Saves (mostly asynchronously) user properties of tables (e.g.
initFolderForm($a_mode="edit")
Init folder form.
Class ilMediaPoolPage.
getTemplate()
Get standard template.
createMediaFromUploadDir()
Create media object from upload directory.
Media pool explorer GUI class.
static lookupTitle($a_page_id)
Lookup title.
static _getDirectory($a_mob_id)
get directory for files of media object (static)
TableGUI class for media pool page usages listing.
showPreview()
Show content snippet.
afterSave(ilObject $newObj)
save object
initMediaPoolPageForm($a_mode="edit")
Init page form.
setMediaPoolPageTabs()
Set media pool page tabs.
global $ilCtrl
Definition: ilias.php:18
getEditFormCustomValues(array &$a_values)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setCreationMode($a_mode=true)
showMediaPoolPageUsages($a_all=false)
List usages of the contnet snippet.
static lookupForeignId($a_id)
Lookup Foreign Id.
xslt_error(&$proc)
Export User Interface Class.
initImportForm($a_new_type)
Init object import form.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
$info
Definition: example_052.php:80
selectUploadDirFiles($a_files=null)
Select files from upload directory.
saveFolder()
Save folder form.
editMediaPoolPage()
Edit media pool page.
afterConstructor()
Initialisation.
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.
setMinValue($a_minvalue, $a_display_always=false)
Set Minimum Value.
setSuffix($a_value)
Set suffix.
showAllMediaPoolPageUsages()
List usages of the contnet snippet.
if(!is_array($argv)) $options
static getPreviewModalHTML($a_mpool_ref_id, $a_tpl)
Get preview modal html.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static _lookupObjId($a_id)
static getUsages($a_pc_type, $a_pc_id, $a_incl_hist=true)
Get usages.
special template class to simplify handling of ITX/PEAR
cancelRemove()
cancel deletion of media objects/folders
Class ilMediaItem.
This class represents a text property in a property form.
listMedia()
list media objects
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
Import related features for media pools (currently used for translation imports)
Class ilObjMediaObject.
setMaxLength($a_maxlength)
Set Max Length.
initCreateForm($a_new_type)
Init object creation form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getSyntaxStylePath()
get syntax style path
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
copyToClipboard()
copy media objects to clipboard
const IL_MODE_ALIAS
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getContentStylePath($a_style_id)
get content style path
getMediaPoolPageValues()
Get current values for media pool page from.
static getInstance()
Get instance.
Media Pool Item.
Class ilObjMediaObjectGUI.
static lookupTitle($a_id)
Lookup title.
export()
export content object
static getMimeType($a_file, $a_external=false)
get mime type for file
getParentFolderId()
Get folder parent ID.
addLocatorItems()
add locator items for media pool
Create new PHPExcel object
obj_idprivate
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
User Interface class for media pool objects.
static getInstance($a_obj_id)
Get instance.
createMediaPoolPage()
Create new content snippet.
showMedia()
show media object
$ret
Definition: parser.php:6
static _checkAdministrationPermission()
getRefId()
get reference id public
prepareOutput($a_show_subobjects=true)
const IL_MODE_OUTPUT
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
createFolderForm()
create folder form
File System Explorer GUI class.
updateMediaPoolPage()
Update media pool page.
static redirect($a_script)
http redirect to other script
addHeaderAction()
Add header action menu.
static getWebspaceDir($mode="filesystem")
get webspace directory
$_POST["username"]
Class ilMediaPoolPage GUI class.
$params
Definition: example_049.php:96
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
GUI class for object translation handling.
confirmRemove()
confirm remove of mobs
TableGUI class for recent changes in wiki.
Confirmation screen class.