ILIAS  Release_4_2_x_branch Revision 61807
 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("./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  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
657 
658  $xml = "<dummy>";
659  // todo: we get always the first alias now (problem if mob is used multiple
660  // times in page)
661  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
662  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
663  $xml.= $link_xml;
664  $xml.="</dummy>";
665 
666  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
667  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
668  $xh = xslt_create();
669 
670  $wb_path = ilUtil::getWebspaceDir("output")."/";
671 
672  $mode = ($_GET["cmd"] != "showMedia")
673  ? "fullscreen"
674  : "media";
675  $enlarge_path = ilUtil::getImagePath("enlarge.gif", false, "output");
676  $fullscreen_link =
677  $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
678  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
679  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
680  'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
681  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
682  echo xslt_error($xh);
683  xslt_free($xh);
684  // unmask user html
685  $this->tpl->setVariable("MEDIA_CONTENT", $output);
686 
687  $this->tpl->parseCurrentBlock();
688 // $this->tpl->show();
689  }
690 
694  function showFullscreen()
695  {
696  $this->showMedia();
697  }
698 
702  function confirmRemove()
703  {
704  global $ilAccess, $ilCtrl, $lng;
705 
706  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
707  {
708  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
709  }
710 
711  if(!isset($_POST["id"]))
712  {
713  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
714  }
715 
716  //$this->prepareOutput();
717 
718  // SAVE POST VALUES
719  $_SESSION["ilMepRemove"] = $_POST["id"];
720 
721  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/MediaPool");
722 
723  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
724 
725  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
726 
727  // BEGIN TABLE HEADER
728  $this->tpl->setCurrentBlock("table_header");
729  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
730  $this->tpl->parseCurrentBlock();
731 
732  // BEGIN TABLE DATA
733  $counter = 0;
734  foreach($_POST["id"] as $obj_id)
735  {
736  $type = ilMediaPoolItem::lookupType($obj_id);
738 
739  // check whether page can be removed
740  $add = "";
741  if ($type == "pg")
742  {
743  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
744  $usages = ilPageContentUsage::getUsages("incl", $obj_id, false);
745  if (count($usages) > 0)
746  {
747  ilUtil::sendFailure(sprintf($lng->txt("mep_content_snippet_in_use"), $title), true);
748  $ilCtrl->redirect($this, "listMedia");
749  }
750  else
751  {
752  // check whether the snippet is used in older versions of pages
753  $usages = ilPageContentUsage::getUsages("incl", $obj_id, true);
754  if (count($usages) > 0)
755  {
756  $add = "<div class='small'>".$lng->txt("mep_content_snippet_used_in_older_versions")."</div>";
757  }
758  }
759  }
760 
761  $this->tpl->setCurrentBlock("table_row");
762  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
763  $this->tpl->setVariable("TEXT_CONTENT", $title.$add);
764  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_".$type.".gif"));
765  $this->tpl->parseCurrentBlock();
766  }
767 
768  // cancel/confirm button
769  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
770  $buttons = array( "cancelRemove" => $this->lng->txt("cancel"),
771  "remove" => $this->lng->txt("confirm"));
772  foreach ($buttons as $name => $value)
773  {
774  $this->tpl->setCurrentBlock("operation_btn");
775  $this->tpl->setVariable("BTN_NAME",$name);
776  $this->tpl->setVariable("BTN_VALUE",$value);
777  $this->tpl->parseCurrentBlock();
778  }
779 // $this->tpl->show();
780  }
781 
785  function openClipboard()
786  {
787  global $ilCtrl, $ilAccess;
788 
789  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
790  {
791  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
792  }
793 
794  $ilCtrl->setParameterByClass("ileditclipboardgui", "returnCommand",
795  rawurlencode($ilCtrl->getLinkTarget($this,
796  "insertFromClipboard", "", false, false)));
797  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
798  }
799 
800 
805  {
806  global $ilAccess;
807 
808  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
809  {
810  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
811  }
812 
813  include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
815  $not_inserted = array();
816  if (is_array($ids))
817  {
818  foreach ($ids as $id2)
819  {
820  $id = explode(":", $id2);
821  $type = $id[0];
822  $id = $id[1];
823 
824  if ($type == "mob") // media object
825  {
826  if (ilObjMEdiaPool::isForeignIdInTree($this->object->getId(), $id))
827  {
828  $not_inserted[] = ilObject::_lookupTitle($id)." [".
829  $id."]";
830  }
831  else
832  {
833  $item = new ilMediaPoolItem();
834  $item->setType("mob");
835  $item->setForeignId($id);
836  $item->setTitle(ilObject::_lookupTitle($id));
837  $item->create();
838  if ($item->getId() > 0)
839  {
840  $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
841  }
842  }
843  }
844  if ($type == "incl") // content snippet
845  {
846  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
847  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
848  if (ilObjMEdiaPool::isItemIdInTree($this->object->getId(), $id))
849  {
850  $not_inserted[] = ilMediaPoolPage::lookupTitle($id)." [".
851  $id."]";
852  }
853  else
854  {
855  $original = new ilMediaPoolPage($id);
856 
857  // copy the page into the pool
858  $item = new ilMediaPoolItem();
859  $item->setType("pg");
860  $item->setTitle(ilMediaPoolItem::lookupTitle($id));
861  $item->create();
862  if ($item->getId() > 0)
863  {
864  $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
865 
866  // create page
867  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
868  $page = new ilMediaPoolPage();
869  $page->setId($item->getId());
870  $page->create();
871 
872  // copy content
873  $page->setXMLContent($original->copyXMLContent());
874  $page->buildDom();
875  $page->update();
876  }
877  }
878  }
879  }
880  }
881  if (count($not_inserted) > 0)
882  {
883  ilUtil::sendInfo($this->lng->txt("mep_not_insert_already_exist")."<br>".
884  implode($not_inserted,"<br>"), true);
885  }
886  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
887  }
888 
889 
893  function cancelRemove()
894  {
895  session_unregister("ilMepRemove");
896  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
897  }
898 
902  function remove()
903  {
904  global $ilAccess;
905 
906  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
907  {
908  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
909  }
910 
911  foreach($_SESSION["ilMepRemove"] as $obj_id)
912  {
913  $this->object->deleteChild($obj_id);
914  }
915 
916  ilUtil::sendSuccess($this->lng->txt("cont_obj_removed"),true);
917  session_unregister("ilMepRemove");
918  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
919  }
920 
921 
925  function copyToClipboard()
926  {
927  global $ilUser, $ilAccess;
928 
929  $this->checkPermission("write");
930 
931  if(!isset($_POST["id"]))
932  {
933  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
934  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
935  }
936 
937  foreach ($_POST["id"] as $obj_id)
938  {
939  $type = ilMediaPoolItem::lookupType($obj_id);
940  if ($type == "fold")
941  {
942  ilUtil::sendFailure($this->lng->txt("cont_cant_copy_folders"), true);
943  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
944  }
945  }
946  foreach ($_POST["id"] as $obj_id)
947  {
948  $fid = ilMediaPoolItem::lookupForeignId($obj_id);
949  $type = ilMediaPoolItem::lookupType($obj_id);
950  if ($type == "mob")
951  {
952  $ilUser->addObjectToClipboard($fid, "mob", "");
953  }
954  if ($type == "pg")
955  {
956  $ilUser->addObjectToClipboard($obj_id, "incl", "");
957  }
958  }
959  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"),true);
960  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
961  }
962 
966  function addLocatorItems()
967  {
968  global $ilLocator;
969 
970  if (!$this->getCreationMode() && $this->ctrl->getCmd() != "explorer")
971  {
972  $tree =& $this->object->getTree();
973  $obj_id = ($_GET["mepitem_id"] == "")
974  ? $tree->getRootId()
975  : $_GET["mepitem_id"];
976  $path = $tree->getPathFull($obj_id);
977  foreach($path as $node)
978  {
979  if ($node["child"] == $tree->getRootId())
980  {
981  $this->ctrl->setParameter($this, "mepitem_id", "");
982  $link = $this->ctrl->getLinkTarget($this, "listMedia");
983  $title = $this->object->getTitle();
984  $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
985  $ilLocator->addItem($title, $link, "", $_GET["ref_id"]);
986  }
987  else
988  {
989  $this->ctrl->setParameter($this, "mepitem_id", $node["child"]);
990  $link = $this->ctrl->getLinkTarget($this, "listMedia");
991  $title = $node["title"];
992  $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
993  $ilLocator->addItem($title, $link);
994  }
995  }
996  }
997  }
998 
1002 
1006  function createFolderForm()
1007  {
1008  global $ilAccess, $tpl;
1009 
1010  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
1011  {
1012  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1013  }
1014 
1015  $this->initFolderForm("create");
1016  $tpl->setContent($this->form->getHTML());
1017 
1018 /* $folder_gui =& new ilObjFolderGUI("", 0, false, false);
1019  $this->ctrl->setParameterByClass("ilobjfoldergui", "obj_id", $_GET["obj_id"]);
1020  $folder_gui->setFormAction("save",
1021  $this->ctrl->getFormActionByClass("ilobjfoldergui"));
1022  $folder_gui->createObject();*/
1023 // $this->tpl->show();
1024  }
1025 
1032  function editFolder()
1033  {
1034  global $tpl;
1035 
1036  $this->initFolderForm();
1037  $this->getFolderValues();
1038  $tpl->setContent($this->form->getHTML());
1039  }
1040 
1044  public function getFolderValues()
1045  {
1046  $values = array();
1047 
1048  $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1049 
1050  $this->form->setValuesByArray($values);
1051  }
1052 
1056  public function saveFolder()
1057  {
1058  global $tpl, $lng, $ilCtrl;
1059 
1060  $this->initFolderForm("create");
1061  if ($this->form->checkInput())
1062  {
1063  if ($this->object->createFolder($_POST["title"], (int) $_GET["mepitem_id"]))
1064  {
1065  ilUtil::sendSuccess($lng->txt("mep_folder_created"), true);
1066  }
1067  $ilCtrl->redirect($this, "listMedia");
1068  }
1069 
1070  $this->form->setValuesByPost();
1071  $tpl->setContent($this->form->getHtml());
1072  }
1073 
1077  function updateFolder()
1078  {
1079  global $lng, $ilCtrl, $tpl;
1080 
1081  $this->initFolderForm("edit");
1082  if ($this->form->checkInput())
1083  {
1084  $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1085  $item->setTitle($_POST["title"]);
1086  $item->update();
1087  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1088  $ilCtrl->setParameter($this, "mepitem_id",
1089  $this->object->getTree()->getParentId($_GET["mepitem_id"]));
1090  $ilCtrl->redirect($this, "listMedia");
1091  }
1092 
1093  $this->form->setValuesByPost();
1094  $tpl->setContent($this->form->getHtml());
1095  }
1096 
1102  public function initFolderForm($a_mode = "edit")
1103  {
1104  global $lng, $ilCtrl;
1105 
1106  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1107  $this->form = new ilPropertyFormGUI();
1108 
1109  // desc
1110  $ti = new ilTextInputGUI($lng->txt("title"), "title");
1111  $ti->setMaxLength(128);
1112  $ti->setRequired(true);
1113  $this->form->addItem($ti);
1114 
1115  // save and cancel commands
1116  if ($a_mode == "create")
1117  {
1118  $this->form->addCommandButton("saveFolder", $lng->txt("save"));
1119  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1120  $this->form->setTitle($lng->txt("mep_new_folder"));
1121  }
1122  else
1123  {
1124  $this->form->addCommandButton("updateFolder", $lng->txt("save"));
1125  $this->form->addCommandButton("cancelFolderUpdate", $lng->txt("cancel"));
1126  $this->form->setTitle($lng->txt("mep_edit_folder"));
1127  }
1128 
1129  $this->form->setFormAction($ilCtrl->getFormAction($this));
1130  }
1131 
1136  {
1137  global $ilCtrl;
1138  $ilCtrl->setParameter($this, "mepitem_id",
1139  $this->object->getTree()->getParentId($_GET["mepitem_id"]));
1140  $ilCtrl->redirect($this, "listMedia");
1141  }
1142 
1146  function cancelSave()
1147  {
1148  global $ilCtrl;
1149  $ilCtrl->redirect($this, "listMedia");
1150  }
1151 
1155 
1160  {
1161  global $tpl;
1162  $this->initMediaPoolPageForm("create");
1163  $tpl->setContent($this->form->getHTML());
1164  }
1165 
1173  {
1174  global $tpl;
1175 
1176  $this->setMediaPoolPageTabs();
1177 
1178  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1179  $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1180  $mep_page_gui->getTabs();
1181 
1182  $this->initMediaPoolPageForm("edit");
1183  $this->getMediaPoolPageValues();
1184  $tpl->setContent($this->form->getHTML());
1185  }
1186 
1190  public function saveMediaPoolPage()
1191  {
1192  global $tpl, $lng, $ilCtrl;
1193 
1194  $this->initMediaPoolPageForm("create");
1195  if ($this->form->checkInput())
1196  {
1197  // create media pool item
1198  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1199  $item = new ilMediaPoolItem();
1200  $item->setTitle($_POST["title"]);
1201  $item->setType("pg");
1202  $item->create();
1203 
1204  if ($item->getId() > 0)
1205  {
1206  // put in tree
1207  $tree = $this->object->getTree();
1208  $parent = $_GET["mepitem_id"] > 0
1209  ? $_GET["mepitem_id"]
1210  : $tree->getRootId();
1211  $this->object->insertInTree($item->getId(), $parent);
1212 
1213  // create page
1214  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1215  $page = new ilMediaPoolPage();
1216  $page->setId($item->getId());
1217  $page->create();
1218 
1219  ilUtil::sendSuccess($lng->txt("mep_page_created"), true);
1220  }
1221  $ilCtrl->redirect($this, "listMedia");
1222  }
1223 
1224  $this->form->setValuesByPost();
1225  $tpl->setContent($this->form->getHtml());
1226  }
1227 
1232  {
1233  global $lng, $ilCtrl, $tpl;
1234 
1235  $this->initMediaPoolPageForm("edit");
1236  if ($this->form->checkInput())
1237  {
1238  $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1239  $item->setTitle($_POST["title"]);
1240  $item->update();
1241  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1242  $ilCtrl->redirect($this, "editMediaPoolPage");
1243  }
1244 
1245  $this->form->setValuesByPost();
1246  $tpl->setContent($this->form->getHtml());
1247  }
1253  public function initMediaPoolPageForm($a_mode = "edit")
1254  {
1255  global $lng, $ilCtrl;
1256 
1257  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1258  $this->form = new ilPropertyFormGUI();
1259 
1260  // title
1261  $ti = new ilTextInputGUI($lng->txt("title"), "title");
1262  $ti->setMaxLength(128);
1263  $ti->setRequired(true);
1264  $this->form->addItem($ti);
1265 
1266  // save and cancel commands
1267  if ($a_mode == "create")
1268  {
1269  $this->form->addCommandButton("saveMediaPoolPage", $lng->txt("save"));
1270  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1271  $this->form->setTitle($lng->txt("mep_new_content_snippet"));
1272  }
1273  else
1274  {
1275  $this->form->addCommandButton("updateMediaPoolPage", $lng->txt("save"));
1276  $this->form->setTitle($lng->txt("mep_edit_content_snippet"));
1277  }
1278 
1279  $this->form->setFormAction($ilCtrl->getFormAction($this));
1280  }
1281 
1285  public function getMediaPoolPageValues()
1286  {
1287  $values = array();
1288 
1289  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1290  $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1291 
1292  $this->form->setValuesByArray($values);
1293  }
1294 
1302  {
1303  global $ilTabs, $ilCtrl, $lng;
1304 
1305  $ilTabs->clearTargets();
1306  //$ilTabs->addTab("mep_pg_prop", $lng->txt("mep_page_properties"),
1307  // $ilCtrl->getLinkTarget($this, "editMediaPoolPage"));
1308  $ilTabs->addTarget("mep_page_properties", $ilCtrl->getLinkTarget($this, "editMediaPoolPage"),
1309  "editMediaPoolPage", get_class($this));
1310  $ilTabs->addTarget("cont_usage", $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages"),
1311  array("showMediaPoolPageUsages", "showAllMediaPoolPageUsages"), get_class($this));
1312  $ilCtrl->setParameter($this, "mepitem_id", $this->object->tree->getParentId($_GET["mepitem_id"]));
1313  $ilTabs->setBackTarget($lng->txt("mep_folder"), $ilCtrl->getLinkTarget($this, "listMedia"));
1314  $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1315  }
1316 
1321  {
1322  $this->showMediaPoolPageUsages(true);
1323  }
1324 
1325 
1329  function showMediaPoolPageUsages($a_all = false)
1330  {
1331  global $ilTabs, $ilCtrl, $lng, $tpl;
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;
1378 
1379  if ($ilAccess->checkAccess('read', '', $this->ref_id) ||
1380  $ilAccess->checkAccess('write', '', $this->ref_id))
1381  {
1382  $ilTabs->addTarget("objs_fold", $this->ctrl->getLinkTarget($this, ""),
1383  "listMedia", "", "_top");
1384 
1385  $ilCtrl->setParameter($this, "mepitem_id", "");
1386  $ilTabs->addTarget("mep_all_mobs", $this->ctrl->getLinkTarget($this, "allMedia"),
1387  "allMedia", "", "_top");
1388  $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1389  }
1390 
1391  // info tab
1392  if ($ilAccess->checkAccess('visible', '', $this->ref_id))
1393  {
1394  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
1395  || strtolower($_GET["cmdClass"]) == "ilnotegui")
1396  ? true
1397  : false;
1398  //echo "-$force_active-";
1399  $ilTabs->addTarget("info_short",
1400  $this->ctrl->getLinkTargetByClass(
1401  array("ilobjmediapoolgui", "ilinfoscreengui"), "showSummary"),
1402  array("showSummary", "infoScreen"),
1403  "", "", $force_active);
1404  }
1405 
1406  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1407  {
1408  $ilTabs->addTarget("settings", $this->ctrl->getLinkTarget($this, "edit"),
1409  "edit", array("", "ilobjmediapoolgui"));
1410  }
1411 
1412  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1413  {
1414  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTarget($this, "openClipboard"),
1415  "view", "ileditclipboardgui");
1416  }
1417 
1418  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1419  {
1420  $ilTabs->addTarget("export", $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1421  "", "ilexportgui");
1422  }
1423 
1424  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
1425  {
1426  $ilTabs->addTarget("perm_settings",
1427  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1428  }
1429 
1430  }
1431 
1432 
1436  function _goto($a_target)
1437  {
1438  global $ilAccess, $ilErr, $lng;
1439 
1440  $targets = explode('_',$a_target);
1441  if(count((array) $targets) > 1)
1442  {
1443  $ref_id = $targets[0];
1444  $subitem_id = $targets[1];
1445  }
1446  else
1447  {
1448  $ref_id = $targets[0];
1449  }
1450 
1451  if ($ilAccess->checkAccess("read", "", $ref_id))
1452  {
1453  $_GET["cmd"] = "frameset";
1454  $_GET["baseClass"] = "ilMediaPoolPresentationGUI";
1455  $_GET["ref_id"] = $ref_id;
1456  $_GET['mepitem_id'] = $subitem_id;
1457  include("ilias.php");
1458  exit;
1459  }
1460  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1461  {
1462  $_GET["cmd"] = "frameset";
1463  $_GET["target"] = "";
1464  $_GET["ref_id"] = ROOT_FOLDER_ID;
1465  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1466  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1467  include("repository.php");
1468  exit;
1469  }
1470 
1471  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1472  }
1473 
1479  function infoScreenObject()
1480  {
1481  $this->ctrl->setCmd("showSummary");
1482  $this->ctrl->setCmdClass("ilinfoscreengui");
1483  $this->infoScreen();
1484  }
1485 
1489  function infoScreen()
1490  {
1491  global $ilAccess;
1492 
1493  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
1494  {
1495  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1496  }
1497 
1498  if ($this->ctrl->getCmd() == "infoScreen")
1499  {
1500  $this->ctrl->setCmd("showSummary");
1501  $this->ctrl->setCmdClass("ilinfoscreengui");
1502  }
1503 
1504  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1505  $info = new ilInfoScreenGUI($this);
1506 
1507  $info->enablePrivateNotes();
1508 
1509  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1510  {
1511  //$info->enableNews();
1512  }
1513 
1514  // no news editing for files, just notifications
1515 // $info->enableNewsEditing(false);
1516  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1517  {
1518 // $news_set = new ilSetting("news");
1519 // $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1520 
1521 // if ($enable_internal_rss)
1522 // {
1523 // $info->setBlockProperty("news", "settings", true);
1524 // $info->setBlockProperty("news", "public_notifications_option", true);
1525 // }
1526  }
1527 
1528 
1529  // standard meta data
1530  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1531 
1532  // forward the command
1533  $this->ctrl->forwardCommand($info);
1534 
1535 // $this->tpl->show();
1536  }
1537 
1538 
1542 
1547  {
1548  global $tpl, $ilTabs, $lng, $ilCtrl, $ilToolbar;
1549 
1550  $ilTabs->clearTargets();
1551  $ilTabs->setBackTarget($lng->txt("back"),
1552  $ilCtrl->getLinkTarget($this, "listMedia"));
1553 
1555  {
1556 
1557  // action type
1558  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1559  $options = array(
1560  "rename" => $lng->txt("mep_up_dir_move"),
1561  "copy" => $lng->txt("mep_up_dir_copy"),
1562  );
1563  $si = new ilSelectInputGUI("", "action");
1564  $si->setOptions($options);
1565  $ilToolbar->addInputItem($si);
1566  $ilToolbar->setCloseFormTag(false);
1567  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1568  $ilToolbar->setFormName("mep_up_form");
1569 
1570  include_once("./Modules/MediaPool/classes/class.ilUploadDirFilesTableGUI.php");
1571  $tab = new ilUploadDirFilesTableGUI($this, "selectUploadDirFiles",
1572  $_POST["file"]);
1573  $tab->setFormName("mep_up_form");
1574  $tpl->setContent($tab->getHTML());
1575  }
1576  }
1577 
1582  {
1583  $mset = new ilSetting("mobs");
1584  $upload_dir = trim($mset->get("upload_dir"));
1585 
1586  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1587 
1588  if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission())
1589  {
1590  foreach ($_POST["file"] as $f)
1591  {
1592  $f = str_replace("..", "", $f);
1593  $fullpath = $upload_dir."/".$f;
1594  $mob = new ilObjMediaObject();
1595  $mob->setTitle(basename($fullpath));
1596  $mob->setDescription("");
1597  $mob->create();
1598 
1599  // determine and create mob directory, move uploaded file to directory
1600  //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
1601  $mob->createDirectory();
1602  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1603 
1604  $media_item = new ilMediaItem();
1605  $mob->addMediaItem($media_item);
1606  $media_item->setPurpose("Standard");
1607 
1608  $file = $mob_dir."/".basename($fullpath);
1609  ilUtil::moveUploadedFile($fullpath,
1610  basename($fullpath), $file, false, $_POST["action"]);
1611 
1612  // get mime type
1614  $location = basename($fullpath);
1615 
1616  // set real meta and object data
1617  $media_item->setFormat($format);
1618  $media_item->setLocation($location);
1619  $media_item->setLocationType("LocalFile");
1620 
1621  $mob->setDescription($format);
1622 
1623  // determine width and height of known image types
1624  $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format,
1625  "File", $mob_dir."/".$location, $media_item->getLocation(),
1626  true, true, "", "");
1627  $media_item->setWidth($wh["width"]);
1628  $media_item->setHeight($wh["height"]);
1629  if ($wh["info"] != "")
1630  {
1631  // ilUtil::sendInfo($wh["info"], true);
1632  }
1633 
1634  $media_item->setHAlign("Left");
1635  ilUtil::renameExecutables($mob_dir);
1636  $mob->update();
1637 
1638 
1639  // put it into current folder
1640  $mep_item = new ilMediaPoolItem();
1641  $mep_item->setTitle($mob->getTitle());
1642  $mep_item->setType("mob");
1643  $mep_item->setForeignId($mob->getId());
1644  $mep_item->create();
1645 
1646  $tree = $this->object->getTree();
1647  $parent = ($_GET["mepitem_id"] == "")
1648  ? $tree->getRootId()
1649  : $_GET["mepitem_id"];
1650  $tree->insertNode($mep_item->getId(), $parent);
1651  }
1652  }
1653  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=".
1654  $_GET["ref_id"]."&mepitem_id=".$_GET["mepitem_id"]);
1655 
1656  }
1657 }
1658 ?>