ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 // todo
102  $this->ctrl->redirectByClass("ilobjfoldergui", "create");
103  break;
104  }
105  }
106 
107  switch($next_class)
108  {
109  case 'ilmediapoolpagegui':
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  //$cmd.="Object";
130  if ($cmd == "create" || $cmd == "save" || $cmd == "cancel")
131  {
132  $ret_obj = $_GET["mepitem_id"];
133  $ilObjMediaObjectGUI =& new ilObjMediaObjectGUI("", 0, false, false);
134  $ilObjMediaObjectGUI->setWidthPreset($this->object->getDefaultWidth());
135  $ilObjMediaObjectGUI->setHeightPreset($this->object->getDefaultHeight());
136  }
137  else
138  {
139  $ret_obj = $tree->getParentId($_GET["mepitem_id"]);
140  $ilObjMediaObjectGUI =& new ilObjMediaObjectGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
141  $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
142  $ilTabs->setBackTarget($lng->txt("back"),
143  $this->ctrl->getLinkTarget($this,
144  $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia"));
145  }
146  if ($this->ctrl->getCmdClass() == "ilinternallinkgui")
147  {
148  $this->ctrl->setReturn($this, "explorer");
149  }
150  else
151  {
152  $this->ctrl->setParameter($this, "mepitem_id", $ret_obj);
153  $this->ctrl->setReturn($this,
154  $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
155  $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
156  }
157  $this->getTemplate();
158  $ilObjMediaObjectGUI->setTabs();
159  $this->setLocator();
160 
161  //$ret =& $ilObjMediaObjectGUI->executeCommand();
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 // todo
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  //$ret =& $clip_gui->executeCommand();
247  $ret =& $this->ctrl->forwardCommand($clip_gui);
248  $this->tpl->show();
249  break;
250 
251  case 'ilinfoscreengui':
252  $this->prepareOutput();
253  $this->addHeaderAction();
254  $this->infoScreen();
255  $this->tpl->show();
256  break;
257 
258  case 'ilpermissiongui':
259  $this->prepareOutput();
260  $this->addHeaderAction();
261  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
262  $perm_gui =& new ilPermissionGUI($this);
263  $ret =& $this->ctrl->forwardCommand($perm_gui);
264  $this->tpl->show();
265  break;
266 
267  case "ilexportgui":
268  $this->prepareOutput();
269  $this->addHeaderAction();
270  include_once("./Services/Export/classes/class.ilExportGUI.php");
271  $exp_gui = new ilExportGUI($this);
272  $exp_gui->addFormat("xml");
273  $ret = $this->ctrl->forwardCommand($exp_gui);
274  $this->tpl->show();
275  break;
276 
277  case "ilfilesystemgui":
278  $this->prepareOutput();
279  $this->addHeaderAction();
280  $ilTabs->clearTargets();
281  $ilTabs->setBackTarget($lng->txt("back"),
282  $ilCtrl->getLinkTarget($this, "listMedia"));
283  $mset = new ilSetting("mobs");
284  if (trim($mset->get("upload_dir")) != "")
285  {
286  include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
287  $fs_gui = new ilFileSystemGUI($mset->get("upload_dir"));
288  $fs_gui->setPostDirPath(true);
289  $fs_gui->setTableId("mepud".$this->object->getId());
290  $fs_gui->setAllowFileCreation(false);
291  $fs_gui->setAllowDirectoryCreation(false);
292  $fs_gui->clearCommands();
293  $fs_gui->addCommand($this, "selectUploadDirFiles", $this->lng->txt("mep_sel_upload_dir_files"),
294  false, true);
295  //$fs_gui->addCommand($this, "assignFullscreenObject", $this->lng->txt("cont_assign_full"));
296  $ret =& $this->ctrl->forwardCommand($fs_gui);
297  }
298  $this->tpl->show();
299  break;
300 
301  case "ilcommonactiondispatchergui":
302  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
304  $this->ctrl->forwardCommand($gui);
305  break;
306 
307  default:
308  $this->prepareOutput();
309  $this->addHeaderAction();
310  $cmd = $this->ctrl->getCmd("frameset");
311  $this->$cmd();
312  if (!$this->getCreationMode())
313  {
314  $this->tpl->show();
315  }
316  break;
317  }
318  }
319 
323  function createMediaObject()
324  {
325  $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
326  }
327 
328  protected function initCreationForms($a_new_type)
329  {
330  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
331  self::CFORM_IMPORT => $this->initImportForm($a_new_type));
332 
333  return $forms;
334  }
335 
339  function afterSave($newObj)
340  {
341  // always send a message
342  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
343 
344  //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
345  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&ref_id=".$newObj->getRefId()."&cmd=edit");
346  }
347 
348  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
349  {
350  // default width
351  $ni = new ilNumberInputGUI($this->lng->txt("mep_default_width"), "default_width");
352  $ni->setMinValue(0);
353  $ni->setMaxLength(5);
354  $ni->setSize(5);
355  $a_form->addItem($ni);
356 
357  // default height
358  $ni = new ilNumberInputGUI($this->lng->txt("mep_default_height"), "default_height");
359  $ni->setMinValue(0);
360  $ni->setMaxLength(5);
361  $ni->setSize(5);
362  $ni->setInfo($this->lng->txt("mep_default_width_height_info"));
363  $a_form->addItem($ni);
364  }
365 
366  protected function getEditFormCustomValues(array &$a_values)
367  {
368  if ($this->object->getDefaultWidth() > 0)
369  {
370  $a_values["default_width"] = $this->object->getDefaultWidth();
371  }
372  if ($this->object->getDefaultHeight() > 0)
373  {
374  $a_values["default_height"] = $this->object->getDefaultHeight();
375  }
376  }
377 
378  protected function updateCustom(ilPropertyFormGUI $a_form)
379  {
380  $this->object->setDefaultWidth($a_form->getInput("default_width"));
381  $this->object->setDefaultHeight($a_form->getInput("default_height"));
382  }
383 
387  function listMedia()
388  {
389  global $tree, $ilAccess, $tpl, $ilTabs, $ilCtrl, $ilToolbar, $lng;
390 
391  $ilCtrl->setParameter($this, "mep_mode", "listMedia");
392 
393  if (!$ilAccess->checkAccess("read", "", $this->object->getRefId()))
394  {
395  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
396  }
397  $ilTabs->setTabActive("objs_fold");
398 
399  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
400  {
401  $ilToolbar->addButton($lng->txt("mep_create_mob"),
402  $ilCtrl->getLinkTarget($this, "createMediaObject"));
403 
404  $mset = new ilSetting("mobs");
405  if ($mset->get("mep_activate_pages"))
406  {
407  $ilToolbar->addButton($lng->txt("mep_create_content_snippet"),
408  $ilCtrl->getLinkTarget($this, "createMediaPoolPage"));
409  }
410 
411  $ilToolbar->addButton($lng->txt("mep_create_folder"),
412  $ilCtrl->getLinkTarget($this, "createFolderForm"));
413 
414  if (trim($mset->get("upload_dir")) != "" && ilMainMenuGUI::_checkAdministrationPermission())
415  {
416  $ilToolbar->addButton($lng->txt("mep_create_from_upload_dir"),
417  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
418  }
419  }
420 
421  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
422  $mep_table_gui = new ilMediaPoolTableGUI($this, "listMedia", $this->object, "mepitem_id");
423  $tpl->setContent($mep_table_gui->getHTML());
424 // $this->tpl->show();
425  }
426 
430  function allMedia()
431  {
432  global $tree, $ilAccess, $tpl, $ilTabs, $ilCtrl,$ilUser;
433 
434  $ilCtrl->setParameter($this, "mep_mode", "allMedia");
435 
436  if (!$ilAccess->checkAccess("read", "", $this->object->getRefId()))
437  {
438  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
439  }
440  $ilTabs->setTabActive("mep_all_mobs");
441 
442 
443  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
444  $mep_table_gui = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
445  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
446 
447 
448  if(isset($_GET['force_filter']) and $_GET['force_filter'])
449  {
450  $_POST['title'] = ilMediaPoolItem::lookupTitle((int) $_GET['force_filter']);
451 
452  include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
453  $tprop = new ilTablePropertiesStorage();
454  $tprop->storeProperty(
455  $mep_table_gui->getId(),
456  $ilUser->getId(),
457  'filter',
458  1
459  );
460  $mep_table_gui->resetFilter();
461  $mep_table_gui->resetOffset();
462  $mep_table_gui->writeFilterToSession();
463 
464  // Read again
465  $mep_table_gui = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
466  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
467  }
468 
469  $tpl->setContent($mep_table_gui->getHTML());
470 // $this->tpl->show();
471  }
472 
476  function applyFilter()
477  {
478  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
479  $mtab = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
480  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
481  $mtab->writeFilterToSession();
482  $mtab->resetOffset();
483  $this->allMedia();
484  }
485 
489  function resetFilter()
490  {
491  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
492  $mtab = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
493  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
494  $mtab->resetFilter();
495  $mtab->resetOffset();
496  $this->allMedia();
497  }
498 
502  function getTemplate()
503  {
504  $this->tpl->getStandardTemplate();
505  }
506 
507 
511  function getParentFolderId()
512  {
513  if ($_GET["mepitem_id"] == "")
514  {
515  return "";
516  }
517  $par_id = $this->object->tree->getParentId($_GET["mepitem_id"]);
518  if ($par_id != $this->object->tree->getRootId())
519  {
520  return $par_id;
521  }
522  else
523  {
524  return "";
525  }
526  }
527 
528 
534  function frameset()
535  {
536  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
537  $fs_gui = new ilFramesetGUI();
538  $fs_gui->setMainFrameName("content");
539  $fs_gui->setSideFrameName("tree");
540  $fs_gui->setMainFrameSource(
541  $this->ctrl->getLinkTarget($this, "listMedia"));
542  $this->ctrl->setParameter($this, "expand", "1");
543  $fs_gui->setSideFrameSource(
544  $this->ctrl->getLinkTarget($this, "explorer"));
545  $fs_gui->setFramesetTitle($this->object->getTitle());
546  $fs_gui->show();
547  exit;
548  }
549 
556  {
557  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
558  $fs_gui = new ilFramesetGUI();
559  $fs_gui->setMainFrameName("content");
560  $fs_gui->setSideFrameName("tree");
561  $fs_gui->setMainFrameSource(
562  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
563  $this->ctrl->setParameter($this, "expand", "1");
564  $fs_gui->setSideFrameSource(
565  $this->ctrl->getLinkTarget($this, "explorer"));
566  $fs_gui->setFramesetTitle($this->object->getTitle());
567  $fs_gui->show();
568  exit;
569  }
570 
574  function explorer()
575  {
576  global $ilAccess, $ilCtrl;
577 
578  $ilCtrl->setParameter($this, "obj_id", "");
579  $ilCtrl->setParameter($this, "mepitem_id", "");
580 
581  if (!$ilAccess->checkAccess("read", "", $this->object->getRefId()) &&
582  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
583  {
584  return;
585  }
586 
587  require_once ("./Modules/MediaPool/classes/class.ilMediaPoolExplorer.php");
588  $exp = new ilMediaPoolExplorer($this->ctrl->getLinkTarget($this, "listMedia"), $this->object);
589  $exp->setUseStandardFrame(true);
590  $exp->setTargetGet("mepitem_id");
591  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "explorer"));
592  $exp->setTitle($this->lng->txt("cont_mep_structure"));
593 
594  $exp->addFilter("dummy");
595  $exp->addFilter("fold");
596  $exp->setFiltered(true);
597  $exp->setFilterMode(IL_FM_POSITIVE);
598 
599 
600  if ($_GET["mepexpand"] == "")
601  {
602  $mep_tree =& $this->object->getTree();
603  $expanded = $mep_tree->readRootId();
604  }
605  else
606  {
607  $expanded = $_GET["mepexpand"];
608  }
609 
610  $exp->setExpand($expanded);
611 
612  // build html-output
613  $exp->setOutput(0);
614  $output = $exp->getOutput();
615  echo $output;
616  exit;
617 /* $this->tpl->setCurrentBlock("content");
618  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_mep_structure"));
619  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
620  $this->tpl->setVariable("EXPLORER",$output);
621  $this->ctrl->setParameter($this, "mepexpand", $_GET["mepexpand"]);
622  $this->tpl->setVariable("ACTION",
623  $this->ctrl->getLinkTarget($this, "explorer"));
624  $this->tpl->parseCurrentBlock();
625  $this->tpl->show(false);
626 */
627  }
628 
632  function showMedia()
633  {
634  global $ilAccess;
635 
636  if (!$ilAccess->checkAccess("read", "", $this->object->getRefId()))
637  {
638  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
639  }
640 
641  $this->tpl =& new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
642  include_once("Services/Style/classes/class.ilObjStyleSheet.php");
643  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
644  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
646 
647  //$int_links = $page_object->getInternalLinks();
648  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
649 
650  // later
651  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
652 
653  $link_xlm = "";
654 
655  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
656  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
658  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
659 
660  $xml = "<dummy>";
661  // todo: we get always the first alias now (problem if mob is used multiple
662  // times in page)
663  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
664  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
665  $xml.= $link_xml;
666  $xml.="</dummy>";
667 
668  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
669  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
670  $xh = xslt_create();
671 
672  $wb_path = ilUtil::getWebspaceDir("output")."/";
673 
674  $mode = ($_GET["cmd"] != "showMedia")
675  ? "fullscreen"
676  : "media";
677  $enlarge_path = ilUtil::getImagePath("enlarge.png", false, "output");
678  $fullscreen_link =
679  $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
680  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
681  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
682  'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
683  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
684  echo xslt_error($xh);
685  xslt_free($xh);
686  // unmask user html
687  $this->tpl->setVariable("MEDIA_CONTENT", $output);
688  }
689 
693  function showFullscreen()
694  {
695  $this->showMedia();
696  }
697 
701  function confirmRemove()
702  {
703  global $ilAccess, $ilCtrl, $lng;
704 
705  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
706  {
707  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
708  }
709 
710  if(!isset($_POST["id"]))
711  {
712  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
713  }
714 
715  // display confirmation message
716  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
717  $cgui = new ilConfirmationGUI();
718  $cgui->setFormAction($this->ctrl->getFormAction($this));
719  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
720  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemove");
721  $cgui->setConfirm($this->lng->txt("confirm"), "remove");
722 
723  foreach($_POST["id"] as $obj_id)
724  {
725  $type = ilMediaPoolItem::lookupType($obj_id);
727 
728  // check whether page can be removed
729  $add = "";
730  if ($type == "pg")
731  {
732  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
733  $usages = ilPageContentUsage::getUsages("incl", $obj_id, false);
734  if (count($usages) > 0)
735  {
736  ilUtil::sendFailure(sprintf($lng->txt("mep_content_snippet_in_use"), $title), true);
737  $ilCtrl->redirect($this, "listMedia");
738  }
739  else
740  {
741  // check whether the snippet is used in older versions of pages
742  $usages = ilPageContentUsage::getUsages("incl", $obj_id, true);
743  if (count($usages) > 0)
744  {
745  $add = "<div class='small'>".$lng->txt("mep_content_snippet_used_in_older_versions")."</div>";
746  }
747  }
748  }
749 
750  $caption = ilUtil::getImageTagByType($type, $this->tpl->tplPath).
751  " ".$title.$add;
752 
753  $cgui->addItem("id[]", $obj_id, $caption);
754  }
755 
756  $this->tpl->setContent($cgui->getHTML());
757  }
758 
762  function openClipboard()
763  {
764  global $ilCtrl, $ilAccess;
765 
766  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
767  {
768  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
769  }
770 
771  $ilCtrl->setParameterByClass("ileditclipboardgui", "returnCommand",
772  rawurlencode($ilCtrl->getLinkTarget($this,
773  "insertFromClipboard", "", false, false)));
774  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
775  }
776 
777 
782  {
783  global $ilAccess;
784 
785  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
786  {
787  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
788  }
789 
790  include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
792  $not_inserted = array();
793  if (is_array($ids))
794  {
795  foreach ($ids as $id2)
796  {
797  $id = explode(":", $id2);
798  $type = $id[0];
799  $id = $id[1];
800 
801  if ($type == "mob") // media object
802  {
803  if (ilObjMEdiaPool::isForeignIdInTree($this->object->getId(), $id))
804  {
805  $not_inserted[] = ilObject::_lookupTitle($id)." [".
806  $id."]";
807  }
808  else
809  {
810  $item = new ilMediaPoolItem();
811  $item->setType("mob");
812  $item->setForeignId($id);
813  $item->setTitle(ilObject::_lookupTitle($id));
814  $item->create();
815  if ($item->getId() > 0)
816  {
817  $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
818  }
819  }
820  }
821  if ($type == "incl") // content snippet
822  {
823  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
824  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
825  if (ilObjMEdiaPool::isItemIdInTree($this->object->getId(), $id))
826  {
827  $not_inserted[] = ilMediaPoolPage::lookupTitle($id)." [".
828  $id."]";
829  }
830  else
831  {
832  $original = new ilMediaPoolPage($id);
833 
834  // copy the page into the pool
835  $item = new ilMediaPoolItem();
836  $item->setType("pg");
837  $item->setTitle(ilMediaPoolItem::lookupTitle($id));
838  $item->create();
839  if ($item->getId() > 0)
840  {
841  $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
842 
843  // create page
844  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
845  $page = new ilMediaPoolPage();
846  $page->setId($item->getId());
847  $page->create();
848 
849  // copy content
850  $page->setXMLContent($original->copyXMLContent());
851  $page->buildDom();
852  $page->update();
853  }
854  }
855  }
856  }
857  }
858  if (count($not_inserted) > 0)
859  {
860  ilUtil::sendInfo($this->lng->txt("mep_not_insert_already_exist")."<br>".
861  implode($not_inserted,"<br>"), true);
862  }
863  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
864  }
865 
866 
870  function cancelRemove()
871  {
872  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
873  }
874 
878  function remove()
879  {
880  global $ilAccess;
881 
882  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
883  {
884  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
885  }
886 
887  foreach($_POST["id"] as $obj_id)
888  {
889  $this->object->deleteChild($obj_id);
890  }
891 
892  ilUtil::sendSuccess($this->lng->txt("cont_obj_removed"),true);
893  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
894  }
895 
896 
900  function copyToClipboard()
901  {
902  global $ilUser, $ilAccess;
903 
904  $this->checkPermission("write");
905 
906  if(!isset($_POST["id"]))
907  {
908  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
909  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
910  }
911 
912  foreach ($_POST["id"] as $obj_id)
913  {
914  $type = ilMediaPoolItem::lookupType($obj_id);
915  if ($type == "fold")
916  {
917  ilUtil::sendFailure($this->lng->txt("cont_cant_copy_folders"), true);
918  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
919  }
920  }
921  foreach ($_POST["id"] as $obj_id)
922  {
923  $fid = ilMediaPoolItem::lookupForeignId($obj_id);
924  $type = ilMediaPoolItem::lookupType($obj_id);
925  if ($type == "mob")
926  {
927  $ilUser->addObjectToClipboard($fid, "mob", "");
928  }
929  if ($type == "pg")
930  {
931  $ilUser->addObjectToClipboard($obj_id, "incl", "");
932  }
933  }
934  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"),true);
935  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
936  }
937 
941  function addLocatorItems()
942  {
943  global $ilLocator;
944 
945  if (!$this->getCreationMode() && $this->ctrl->getCmd() != "explorer")
946  {
947  $tree =& $this->object->getTree();
948  $obj_id = ($_GET["mepitem_id"] == "")
949  ? $tree->getRootId()
950  : $_GET["mepitem_id"];
951  $path = $tree->getPathFull($obj_id);
952  foreach($path as $node)
953  {
954  if ($node["child"] == $tree->getRootId())
955  {
956  $this->ctrl->setParameter($this, "mepitem_id", "");
957  $link = $this->ctrl->getLinkTarget($this, "listMedia");
958  $title = $this->object->getTitle();
959  $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
960  $ilLocator->addItem($title, $link, "", $_GET["ref_id"]);
961  }
962  else
963  {
964  $this->ctrl->setParameter($this, "mepitem_id", $node["child"]);
965  $link = $this->ctrl->getLinkTarget($this, "listMedia");
966  $title = $node["title"];
967  $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
968  $ilLocator->addItem($title, $link);
969  }
970  }
971  }
972  }
973 
977 
981  function createFolderForm()
982  {
983  global $ilAccess, $tpl;
984 
985  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
986  {
987  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
988  }
989 
990  $this->initFolderForm("create");
991  $tpl->setContent($this->form->getHTML());
992 
993 /* $folder_gui =& new ilObjFolderGUI("", 0, false, false);
994  $this->ctrl->setParameterByClass("ilobjfoldergui", "obj_id", $_GET["obj_id"]);
995  $folder_gui->setFormAction("save",
996  $this->ctrl->getFormActionByClass("ilobjfoldergui"));
997  $folder_gui->createObject();*/
998 // $this->tpl->show();
999  }
1000 
1007  function editFolder()
1008  {
1009  global $tpl;
1010 
1011  $this->initFolderForm();
1012  $this->getFolderValues();
1013  $tpl->setContent($this->form->getHTML());
1014  }
1015 
1019  public function getFolderValues()
1020  {
1021  $values = array();
1022 
1023  $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1024 
1025  $this->form->setValuesByArray($values);
1026  }
1027 
1031  public function saveFolder()
1032  {
1033  global $tpl, $lng, $ilCtrl;
1034 
1035  $this->initFolderForm("create");
1036  if ($this->form->checkInput())
1037  {
1038  if ($this->object->createFolder($_POST["title"], (int) $_GET["mepitem_id"]))
1039  {
1040  ilUtil::sendSuccess($lng->txt("mep_folder_created"), true);
1041  }
1042  $ilCtrl->redirect($this, "listMedia");
1043  }
1044 
1045  $this->form->setValuesByPost();
1046  $tpl->setContent($this->form->getHtml());
1047  }
1048 
1052  function updateFolder()
1053  {
1054  global $lng, $ilCtrl, $tpl;
1055 
1056  $this->initFolderForm("edit");
1057  if ($this->form->checkInput())
1058  {
1059  $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1060  $item->setTitle($_POST["title"]);
1061  $item->update();
1062  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1063  $ilCtrl->setParameter($this, "mepitem_id",
1064  $this->object->getTree()->getParentId($_GET["mepitem_id"]));
1065  $ilCtrl->redirect($this, "listMedia");
1066  }
1067 
1068  $this->form->setValuesByPost();
1069  $tpl->setContent($this->form->getHtml());
1070  }
1071 
1077  public function initFolderForm($a_mode = "edit")
1078  {
1079  global $lng, $ilCtrl;
1080 
1081  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1082  $this->form = new ilPropertyFormGUI();
1083 
1084  // desc
1085  $ti = new ilTextInputGUI($lng->txt("title"), "title");
1086  $ti->setMaxLength(128);
1087  $ti->setRequired(true);
1088  $this->form->addItem($ti);
1089 
1090  // save and cancel commands
1091  if ($a_mode == "create")
1092  {
1093  $this->form->addCommandButton("saveFolder", $lng->txt("save"));
1094  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1095  $this->form->setTitle($lng->txt("mep_new_folder"));
1096  }
1097  else
1098  {
1099  $this->form->addCommandButton("updateFolder", $lng->txt("save"));
1100  $this->form->addCommandButton("cancelFolderUpdate", $lng->txt("cancel"));
1101  $this->form->setTitle($lng->txt("mep_edit_folder"));
1102  }
1103 
1104  $this->form->setFormAction($ilCtrl->getFormAction($this));
1105  }
1106 
1111  {
1112  global $ilCtrl;
1113  $ilCtrl->setParameter($this, "mepitem_id",
1114  $this->object->getTree()->getParentId($_GET["mepitem_id"]));
1115  $ilCtrl->redirect($this, "listMedia");
1116  }
1117 
1121  function cancelSave()
1122  {
1123  global $ilCtrl;
1124  $ilCtrl->redirect($this, "listMedia");
1125  }
1126 
1130 
1135  {
1136  global $tpl;
1137  $this->initMediaPoolPageForm("create");
1138  $tpl->setContent($this->form->getHTML());
1139  }
1140 
1148  {
1149  global $tpl;
1150 
1151  $this->setMediaPoolPageTabs();
1152 
1153  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1154  $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1155  $mep_page_gui->getTabs();
1156 
1157  $this->initMediaPoolPageForm("edit");
1158  $this->getMediaPoolPageValues();
1159  $tpl->setContent($this->form->getHTML());
1160  }
1161 
1165  public function saveMediaPoolPage()
1166  {
1167  global $tpl, $lng, $ilCtrl;
1168 
1169  $this->initMediaPoolPageForm("create");
1170  if ($this->form->checkInput())
1171  {
1172  // create media pool item
1173  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1174  $item = new ilMediaPoolItem();
1175  $item->setTitle($_POST["title"]);
1176  $item->setType("pg");
1177  $item->create();
1178 
1179  if ($item->getId() > 0)
1180  {
1181  // put in tree
1182  $tree = $this->object->getTree();
1183  $parent = $_GET["mepitem_id"] > 0
1184  ? $_GET["mepitem_id"]
1185  : $tree->getRootId();
1186  $this->object->insertInTree($item->getId(), $parent);
1187 
1188  // create page
1189  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1190  $page = new ilMediaPoolPage();
1191  $page->setId($item->getId());
1192  $page->create();
1193 
1194  ilUtil::sendSuccess($lng->txt("mep_page_created"), true);
1195  }
1196  $ilCtrl->redirect($this, "listMedia");
1197  }
1198 
1199  $this->form->setValuesByPost();
1200  $tpl->setContent($this->form->getHtml());
1201  }
1202 
1207  {
1208  global $lng, $ilCtrl, $tpl;
1209 
1210  $this->initMediaPoolPageForm("edit");
1211  if ($this->form->checkInput())
1212  {
1213  $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1214  $item->setTitle($_POST["title"]);
1215  $item->update();
1216  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1217  $ilCtrl->redirect($this, "editMediaPoolPage");
1218  }
1219 
1220  $this->form->setValuesByPost();
1221  $tpl->setContent($this->form->getHtml());
1222  }
1228  public function initMediaPoolPageForm($a_mode = "edit")
1229  {
1230  global $lng, $ilCtrl;
1231 
1232  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1233  $this->form = new ilPropertyFormGUI();
1234 
1235  // title
1236  $ti = new ilTextInputGUI($lng->txt("title"), "title");
1237  $ti->setMaxLength(128);
1238  $ti->setRequired(true);
1239  $this->form->addItem($ti);
1240 
1241  // save and cancel commands
1242  if ($a_mode == "create")
1243  {
1244  $this->form->addCommandButton("saveMediaPoolPage", $lng->txt("save"));
1245  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1246  $this->form->setTitle($lng->txt("mep_new_content_snippet"));
1247  }
1248  else
1249  {
1250  $this->form->addCommandButton("updateMediaPoolPage", $lng->txt("save"));
1251  $this->form->setTitle($lng->txt("mep_edit_content_snippet"));
1252  }
1253 
1254  $this->form->setFormAction($ilCtrl->getFormAction($this));
1255  }
1256 
1260  public function getMediaPoolPageValues()
1261  {
1262  $values = array();
1263 
1264  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1265  $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1266 
1267  $this->form->setValuesByArray($values);
1268  }
1269 
1277  {
1278  global $ilTabs, $ilCtrl, $lng;
1279 
1280  $ilTabs->clearTargets();
1281  //$ilTabs->addTab("mep_pg_prop", $lng->txt("mep_page_properties"),
1282  // $ilCtrl->getLinkTarget($this, "editMediaPoolPage"));
1283  $ilTabs->addTarget("mep_page_properties", $ilCtrl->getLinkTarget($this, "editMediaPoolPage"),
1284  "editMediaPoolPage", get_class($this));
1285  $ilTabs->addTarget("cont_usage", $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages"),
1286  array("showMediaPoolPageUsages", "showAllMediaPoolPageUsages"), get_class($this));
1287  $ilCtrl->setParameter($this, "mepitem_id", $this->object->tree->getParentId($_GET["mepitem_id"]));
1288  $ilTabs->setBackTarget($lng->txt("mep_folder"), $ilCtrl->getLinkTarget($this, "listMedia"));
1289  $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1290  }
1291 
1296  {
1297  $this->showMediaPoolPageUsages(true);
1298  }
1299 
1300 
1304  function showMediaPoolPageUsages($a_all = false)
1305  {
1306  global $ilTabs, $ilCtrl, $lng, $tpl;
1307 
1308  $this->setMediaPoolPageTabs();
1309 
1310  $ilTabs->addSubTab("current_usages", $lng->txt("cont_current_usages"),
1311  $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages"));
1312 
1313  $ilTabs->addSubTab("all_usages", $lng->txt("cont_all_usages"),
1314  $ilCtrl->getLinkTarget($this, "showAllMediaPoolPageUsages"));
1315 
1316  if ($a_all)
1317  {
1318  $ilTabs->activateSubTab("all_usages");
1319  $cmd = "showAllMediaPoolPageUsages";
1320  }
1321  else
1322  {
1323  $ilTabs->activateSubTab("current_usages");
1324  $cmd = "showMediaPoolPageUsages";
1325  }
1326 
1327 
1328  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1329  $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1330  $mep_page_gui->getTabs();
1331 
1332  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1333  $page = new ilMediaPoolPage((int) $_GET["mepitem_id"]);
1334 
1335  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageUsagesTableGUI.php");
1336  $table = new ilMediaPoolPageUsagesTableGUI($this, $cmd, $page, $a_all);
1337 
1338  $tpl->setContent($table->getHTML());
1339 
1340  }
1341 
1342 
1346 
1350  function setTabs()
1351  {
1352  global $ilAccess, $ilTabs, $ilCtrl, $ilHelp;
1353 
1354  $ilHelp->setScreenIdComponent("mep");
1355 
1356  if ($ilAccess->checkAccess('read', '', $this->ref_id) ||
1357  $ilAccess->checkAccess('write', '', $this->ref_id))
1358  {
1359  $ilTabs->addTarget("objs_fold", $this->ctrl->getLinkTarget($this, ""),
1360  "listMedia", "", "_top");
1361 
1362  $ilCtrl->setParameter($this, "mepitem_id", "");
1363  $ilTabs->addTarget("mep_all_mobs", $this->ctrl->getLinkTarget($this, "allMedia"),
1364  "allMedia", "", "_top");
1365  $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1366  }
1367 
1368  // info tab
1369  if ($ilAccess->checkAccess('visible', '', $this->ref_id))
1370  {
1371  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
1372  || strtolower($_GET["cmdClass"]) == "ilnotegui")
1373  ? true
1374  : false;
1375  //echo "-$force_active-";
1376  $ilTabs->addTarget("info_short",
1377  $this->ctrl->getLinkTargetByClass(
1378  array("ilobjmediapoolgui", "ilinfoscreengui"), "showSummary"),
1379  array("showSummary", "infoScreen"),
1380  "", "", $force_active);
1381  }
1382 
1383  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1384  {
1385  $ilTabs->addTarget("settings", $this->ctrl->getLinkTarget($this, "edit"),
1386  "edit", array("", "ilobjmediapoolgui"));
1387  }
1388 
1389  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1390  {
1391  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTarget($this, "openClipboard"),
1392  "view", "ileditclipboardgui");
1393  }
1394 
1395  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1396  {
1397  $ilTabs->addTarget("export", $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1398  "", "ilexportgui");
1399  }
1400 
1401  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
1402  {
1403  $ilTabs->addTarget("perm_settings",
1404  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1405  }
1406 
1407  }
1408 
1409 
1413  function _goto($a_target)
1414  {
1415  global $ilAccess, $ilErr, $lng;
1416 
1417  $targets = explode('_',$a_target);
1418  if(count((array) $targets) > 1)
1419  {
1420  $ref_id = $targets[0];
1421  $subitem_id = $targets[1];
1422  }
1423  else
1424  {
1425  $ref_id = $targets[0];
1426  }
1427 
1428  if ($ilAccess->checkAccess("read", "", $ref_id))
1429  {
1430  $_GET["cmd"] = "frameset";
1431  $_GET["baseClass"] = "ilMediaPoolPresentationGUI";
1432  $_GET["ref_id"] = $ref_id;
1433  $_GET['mepitem_id'] = $subitem_id;
1434  include("ilias.php");
1435  exit;
1436  }
1437  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1438  {
1439  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1440  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1442  }
1443 
1444  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1445  }
1446 
1452  function infoScreenObject()
1453  {
1454  $this->ctrl->setCmd("showSummary");
1455  $this->ctrl->setCmdClass("ilinfoscreengui");
1456  $this->infoScreen();
1457  }
1458 
1462  function infoScreen()
1463  {
1464  global $ilAccess;
1465 
1466  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
1467  {
1468  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1469  }
1470 
1471  if ($this->ctrl->getCmd() == "infoScreen")
1472  {
1473  $this->ctrl->setCmd("showSummary");
1474  $this->ctrl->setCmdClass("ilinfoscreengui");
1475  }
1476 
1477  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1478  $info = new ilInfoScreenGUI($this);
1479 
1480  $info->enablePrivateNotes();
1481 
1482  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1483  {
1484  //$info->enableNews();
1485  }
1486 
1487  // no news editing for files, just notifications
1488 // $info->enableNewsEditing(false);
1489  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1490  {
1491 // $news_set = new ilSetting("news");
1492 // $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1493 
1494 // if ($enable_internal_rss)
1495 // {
1496 // $info->setBlockProperty("news", "settings", true);
1497 // $info->setBlockProperty("news", "public_notifications_option", true);
1498 // }
1499  }
1500 
1501 
1502  // standard meta data
1503  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1504 
1505  // forward the command
1506  $this->ctrl->forwardCommand($info);
1507 
1508 // $this->tpl->show();
1509  }
1510 
1511 
1515 
1520  {
1521  global $tpl, $ilTabs, $lng, $ilCtrl, $ilToolbar;
1522 
1523  $ilTabs->clearTargets();
1524  $ilTabs->setBackTarget($lng->txt("back"),
1525  $ilCtrl->getLinkTarget($this, "listMedia"));
1526 
1528  {
1529 
1530  // action type
1531  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1532  $options = array(
1533  "rename" => $lng->txt("mep_up_dir_move"),
1534  "copy" => $lng->txt("mep_up_dir_copy"),
1535  );
1536  $si = new ilSelectInputGUI("", "action");
1537  $si->setOptions($options);
1538  $ilToolbar->addInputItem($si);
1539  $ilToolbar->setCloseFormTag(false);
1540  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1541  $ilToolbar->setFormName("mep_up_form");
1542 
1543  include_once("./Modules/MediaPool/classes/class.ilUploadDirFilesTableGUI.php");
1544  $tab = new ilUploadDirFilesTableGUI($this, "selectUploadDirFiles",
1545  $_POST["file"]);
1546  $tab->setFormName("mep_up_form");
1547  $tpl->setContent($tab->getHTML());
1548  }
1549  }
1550 
1555  {
1556  $mset = new ilSetting("mobs");
1557  $upload_dir = trim($mset->get("upload_dir"));
1558 
1559  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1560 
1561  if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission())
1562  {
1563  foreach ($_POST["file"] as $f)
1564  {
1565  $f = str_replace("..", "", $f);
1566  $fullpath = $upload_dir."/".$f;
1567  $mob = new ilObjMediaObject();
1568  $mob->setTitle(basename($fullpath));
1569  $mob->setDescription("");
1570  $mob->create();
1571 
1572  // determine and create mob directory, move uploaded file to directory
1573  //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
1574  $mob->createDirectory();
1575  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1576 
1577  $media_item = new ilMediaItem();
1578  $mob->addMediaItem($media_item);
1579  $media_item->setPurpose("Standard");
1580 
1581  $file = $mob_dir."/".basename($fullpath);
1582  ilUtil::moveUploadedFile($fullpath,
1583  basename($fullpath), $file, false, $_POST["action"]);
1584 
1585  // get mime type
1587  $location = basename($fullpath);
1588 
1589  // set real meta and object data
1590  $media_item->setFormat($format);
1591  $media_item->setLocation($location);
1592  $media_item->setLocationType("LocalFile");
1593 
1594  $mob->setDescription($format);
1595 
1596  // determine width and height of known image types
1597  $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format,
1598  "File", $mob_dir."/".$location, $media_item->getLocation(),
1599  true, true, "", "");
1600  $media_item->setWidth($wh["width"]);
1601  $media_item->setHeight($wh["height"]);
1602  if ($wh["info"] != "")
1603  {
1604  // ilUtil::sendInfo($wh["info"], true);
1605  }
1606 
1607  $media_item->setHAlign("Left");
1608  ilUtil::renameExecutables($mob_dir);
1609  $mob->update();
1610 
1611 
1612  // put it into current folder
1613  $mep_item = new ilMediaPoolItem();
1614  $mep_item->setTitle($mob->getTitle());
1615  $mep_item->setType("mob");
1616  $mep_item->setForeignId($mob->getId());
1617  $mep_item->create();
1618 
1619  $tree = $this->object->getTree();
1620  $parent = ($_GET["mepitem_id"] == "")
1621  ? $tree->getRootId()
1622  : $_GET["mepitem_id"];
1623  $tree->insertNode($mep_item->getId(), $parent);
1624  }
1625  }
1626  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=".
1627  $_GET["ref_id"]."&mepitem_id=".$_GET["mepitem_id"]);
1628 
1629  }
1630 }
1631 ?>