ILIAS  Release_5_0_x_branch Revision 61816
 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  $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 =& $ilObjMediaObjectGUI->executeCommand();
163  $ret = $this->ctrl->forwardCommand($ilObjMediaObjectGUI);
164 
165  if ($cmd == "save" && $ret != false)
166  {
167  $mep_item = new ilMediaPoolItem();
168  $mep_item->setTitle($ret->getTitle());
169  $mep_item->setType("mob");
170  $mep_item->setForeignId($ret->getId());
171  $mep_item->create();
172 
173  $parent = ($_GET["mepitem_id"] == "")
174  ? $tree->getRootId()
175  : $_GET["mepitem_id"];
176  $tree->insertNode($mep_item->getId(), $parent);
177  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=".
178  $_GET["ref_id"]."&mepitem_id=".$_GET["mepitem_id"]);
179  }
180  else
181  {
182  $this->tpl->show();
183  }
184  break;
185 
186  case "ilobjfoldergui":
187  $this->checkPermission("write");
188  $this->addHeaderAction();
189  $folder_gui = new ilObjFolderGUI("", 0, false, false);
190  $this->ctrl->setReturn($this, "listMedia");
191  $cmd.="Object";
192  switch($cmd)
193  {
194  case "createObject":
195  $this->prepareOutput();
196  $folder_gui =& new ilObjFolderGUI("", 0, false, false);
197  $folder_gui->setFormAction("save",
198  $this->ctrl->getFormActionByClass("ilobjfoldergui"));
199  $folder_gui->createObject();
200  $this->tpl->show();
201  break;
202 
203  case "saveObject":
204  //$folder_gui->setReturnLocation("save", $this->ctrl->getLinkTarget($this, "listMedia"));
205  $parent = ($_GET["mepitem_id"] == "")
206  ? $tree->getRootId()
207  : $_GET["mepitem_id"];
208  $folder_gui->setFolderTree($tree);
209  $folder_gui->saveObject($parent);
210  //$this->ctrl->redirect($this, "listMedia");
211  break;
212 
213  case "editObject":
214  $this->prepareOutput();
215  $folder_gui =& new ilObjFolderGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
216  $this->ctrl->setParameter($this, "foldereditmode", "1");
217  $folder_gui->setFormAction("update", $this->ctrl->getFormActionByClass("ilobjfoldergui"));
218  $folder_gui->editObject();
219  $this->tpl->show();
220  break;
221 
222  case "updateObject":
223  $folder_gui =& new ilObjFolderGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
224  $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
225  $this->ctrl->setReturn($this, "listMedia");
226  $folder_gui->updateObject(true); // this returns to parent
227  break;
228 
229  case "cancelObject":
230  if ($_GET["foldereditmode"])
231  {
232  $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
233  }
234  $this->ctrl->redirect($this, "listMedia");
235  break;
236  }
237  break;
238 
239  case "ileditclipboardgui":
240  $this->prepareOutput();
241  $this->addHeaderAction();
242  $this->ctrl->setReturn($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
243  $clip_gui = new ilEditClipboardGUI();
244  $clip_gui->setMultipleSelections(true);
245  $clip_gui->setInsertButtonTitle($lng->txt("mep_copy_to_mep"));
246  $ilTabs->setTabActive("clipboard");
247  //$ret =& $clip_gui->executeCommand();
248  $ret =& $this->ctrl->forwardCommand($clip_gui);
249  $this->tpl->show();
250  break;
251 
252  case 'ilinfoscreengui':
253  $this->prepareOutput();
254  $this->addHeaderAction();
255  $this->infoScreen();
256  $this->tpl->show();
257  break;
258 
259  case 'ilpermissiongui':
260  $this->checkPermission("edit_permission");
261  $this->prepareOutput();
262  $this->addHeaderAction();
263  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
264  $perm_gui =& new ilPermissionGUI($this);
265  $ret =& $this->ctrl->forwardCommand($perm_gui);
266  $this->tpl->show();
267  break;
268 
269  case "ilexportgui":
270  $this->checkPermission("write");
271  $this->prepareOutput();
272  $this->addHeaderAction();
273  include_once("./Services/Export/classes/class.ilExportGUI.php");
274  $exp_gui = new ilExportGUI($this);
275  $exp_gui->addFormat("xml");
276  $ret = $this->ctrl->forwardCommand($exp_gui);
277  $this->tpl->show();
278  break;
279 
280  case "ilfilesystemgui":
281  $this->checkPermission("write");
282  $this->prepareOutput();
283  $this->addHeaderAction();
284  $ilTabs->clearTargets();
285  $ilTabs->setBackTarget($lng->txt("back"),
286  $ilCtrl->getLinkTarget($this, "listMedia"));
287  $mset = new ilSetting("mobs");
288  if (trim($mset->get("upload_dir")) != "")
289  {
290  include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
291  $fs_gui = new ilFileSystemGUI($mset->get("upload_dir"));
292  $fs_gui->setPostDirPath(true);
293  $fs_gui->setTableId("mepud".$this->object->getId());
294  $fs_gui->setAllowFileCreation(false);
295  $fs_gui->setAllowDirectoryCreation(false);
296  $fs_gui->clearCommands();
297  $fs_gui->addCommand($this, "selectUploadDirFiles", $this->lng->txt("mep_sel_upload_dir_files"),
298  false, true);
299  //$fs_gui->addCommand($this, "assignFullscreenObject", $this->lng->txt("cont_assign_full"));
300  $ret =& $this->ctrl->forwardCommand($fs_gui);
301  }
302  $this->tpl->show();
303  break;
304 
305  case "ilcommonactiondispatchergui":
306  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
308  $this->ctrl->forwardCommand($gui);
309  break;
310 
311  default:
312  $this->prepareOutput();
313  $this->addHeaderAction();
314  $cmd = $this->ctrl->getCmd("listMedia");
315  $this->$cmd();
316  if (!$this->getCreationMode())
317  {
318  $this->tpl->show();
319  }
320  break;
321  }
322  }
323 
327  function createMediaObject()
328  {
329  $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
330  }
331 
332  protected function initCreationForms($a_new_type)
333  {
334  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
335  self::CFORM_IMPORT => $this->initImportForm($a_new_type));
336 
337  return $forms;
338  }
339 
343  function afterSave($newObj)
344  {
345  // always send a message
346  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
347 
348  //ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
349  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&ref_id=".$newObj->getRefId()."&cmd=listMedia");
350  }
351 
352  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
353  {
354  // default width
355  $ni = new ilNumberInputGUI($this->lng->txt("mep_default_width"), "default_width");
356  $ni->setMinValue(0);
357  $ni->setSuffix("px");
358  $ni->setMaxLength(5);
359  $ni->setSize(5);
360  $a_form->addItem($ni);
361 
362  // default height
363  $ni = new ilNumberInputGUI($this->lng->txt("mep_default_height"), "default_height");
364  $ni->setSuffix("px");
365  $ni->setMinValue(0);
366  $ni->setMaxLength(5);
367  $ni->setSize(5);
368  $ni->setInfo($this->lng->txt("mep_default_width_height_info"));
369  $a_form->addItem($ni);
370  }
371 
372  protected function getEditFormCustomValues(array &$a_values)
373  {
374  if ($this->object->getDefaultWidth() > 0)
375  {
376  $a_values["default_width"] = $this->object->getDefaultWidth();
377  }
378  if ($this->object->getDefaultHeight() > 0)
379  {
380  $a_values["default_height"] = $this->object->getDefaultHeight();
381  }
382  }
383 
384  protected function updateCustom(ilPropertyFormGUI $a_form)
385  {
386  $this->object->setDefaultWidth($a_form->getInput("default_width"));
387  $this->object->setDefaultHeight($a_form->getInput("default_height"));
388  }
389 
393  function listMedia()
394  {
395  global $tree, $ilAccess, $tpl, $ilTabs, $ilCtrl, $ilToolbar, $lng, $ilErr;
396 
397  $ilCtrl->setParameter($this, "mep_mode", "listMedia");
398 
399  $this->checkPermission("read");
400 
401  $ilTabs->setTabActive("objs_fold");
402 
403  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
404  {
405  $ilToolbar->addButton($lng->txt("mep_create_mob"),
406  $ilCtrl->getLinkTarget($this, "createMediaObject"));
407 
408  $mset = new ilSetting("mobs");
409  if ($mset->get("mep_activate_pages"))
410  {
411  $ilToolbar->addButton($lng->txt("mep_create_content_snippet"),
412  $ilCtrl->getLinkTarget($this, "createMediaPoolPage"));
413  }
414 
415  $ilToolbar->addButton($lng->txt("mep_create_folder"),
416  $ilCtrl->getLinkTarget($this, "createFolderForm"));
417 
418  if (trim($mset->get("upload_dir")) != "" && ilMainMenuGUI::_checkAdministrationPermission())
419  {
420  $ilToolbar->addButton($lng->txt("mep_create_from_upload_dir"),
421  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
422  }
423  }
424 
425  // tree
426  include_once("./Modules/MediaPool/classes/class.ilMediaPoolExplorerGUI.php");
427  $exp = new ilMediaPoolExplorerGUI($this, "listMedia", $this->object);
428  if (!$exp->handleCommand())
429  {
430  $this->tpl->setLeftNavContent($exp->getHTML());
431  }
432  else
433  {
434  return;
435  }
436 
437  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
438  $mep_table_gui = new ilMediaPoolTableGUI($this, "listMedia", $this->object, "mepitem_id");
439  $tpl->setContent($mep_table_gui->getHTML());
440 // $this->tpl->show();
441  }
442 
446  function allMedia()
447  {
448  global $tree, $ilAccess, $tpl, $ilTabs, $ilCtrl,$ilUser;
449 
450  $ilCtrl->setParameter($this, "mep_mode", "allMedia");
451 
452  $this->checkPermission("read");
453  $ilTabs->setTabActive("mep_all_mobs");
454 
455 
456  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
457  $mep_table_gui = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
458  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
459 
460 
461  if(isset($_GET['force_filter']) and $_GET['force_filter'])
462  {
463  $_POST['title'] = ilMediaPoolItem::lookupTitle((int) $_GET['force_filter']);
464 
465  include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
466  $tprop = new ilTablePropertiesStorage();
467  $tprop->storeProperty(
468  $mep_table_gui->getId(),
469  $ilUser->getId(),
470  'filter',
471  1
472  );
473  $mep_table_gui->resetFilter();
474  $mep_table_gui->resetOffset();
475  $mep_table_gui->writeFilterToSession();
476 
477  // Read again
478  $mep_table_gui = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
479  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
480  }
481 
482  $tpl->setContent($mep_table_gui->getHTML());
483 // $this->tpl->show();
484  }
485 
489  function applyFilter()
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->writeFilterToSession();
495  $mtab->resetOffset();
496  $this->allMedia();
497  }
498 
502  function resetFilter()
503  {
504  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
505  $mtab = new ilMediaPoolTableGUI($this, "allMedia", $this->object,
506  "mepitem_id", ilMediaPoolTableGUI::IL_MEP_EDIT, true);
507  $mtab->resetFilter();
508  $mtab->resetOffset();
509  $this->allMedia();
510  }
511 
515  function getTemplate()
516  {
517  $this->tpl->getStandardTemplate();
518  }
519 
520 
524  function getParentFolderId()
525  {
526  if ($_GET["mepitem_id"] == "")
527  {
528  return "";
529  }
530  $par_id = $this->object->tree->getParentId($_GET["mepitem_id"]);
531  if ($par_id != $this->object->tree->getRootId())
532  {
533  return $par_id;
534  }
535  else
536  {
537  return "";
538  }
539  }
540 
544  protected function showMedia()
545  {
546  global $ilAccess;
547 
548  $this->checkPermission("read");
549 
550  $item = new ilMediaPoolItem((int) $_GET["mepitem_id"]);
551  $mob_id = $item->getForeignId();
552 
553  $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
554  include_once("Services/Style/classes/class.ilObjStyleSheet.php");
555  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
556  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
558 
559 
560  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
561  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
563  $media_obj = new ilObjMediaObject((int) $mob_id);
564 
565 
566  $this->tpl->setVariable("TITLE", " - ".$media_obj->getTitle());
567 
568  $xml = "<dummy>";
569  // todo: we get always the first alias now (problem if mob is used multiple
570  // times in page)
571  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
572  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
573  $xml.= $link_xml;
574  $xml.="</dummy>";
575 
576  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
577  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
578  $xh = xslt_create();
579 
580  $wb_path = ilUtil::getWebspaceDir("output")."/";
581 
582  $mode = ($_GET["cmd"] != "showPreview")
583  ? "fullscreen"
584  : "media";
585  $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output");
586  $fullscreen_link =
587  $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
588  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
589  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
590  'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
591  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
592  echo xslt_error($xh);
593  xslt_free($xh);
594  // unmask user html
595  $this->tpl->setVariable("MEDIA_CONTENT", $output);
596  }
597 
604  function showPage()
605  {
606  global $tpl;
607 
608  $tpl = new ilTemplate("tpl.main.html", true, true);
609 
610  include_once("./Services/Container/classes/class.ilContainerPage.php");
611  include_once("./Services/Container/classes/class.ilContainerPageGUI.php");
612 
613  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
614  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
615  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
617  $tpl->setCurrentBlock("SyntaxStyle");
618  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
620  $tpl->parseCurrentBlock();
621 
622  // get page object
623  //include_once("./Services/Object/classes/class.ilObjectTranslation.php");
624  //$ot = ilObjectTranslation::getInstance($this->object->getId());
625  //$lang = $ot->getEffectiveContentLang($ilUser->getCurrentLanguage(), "cont");
626  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
627  $page_gui = new ilMediaPoolPageGUI((int) $_GET["mepitem_id"]);
628  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
629  //$page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
630  // $this->object->getStyleSheetId(), $this->object->getType()));
631 
632  $page_gui->setTemplateOutput(false);
633  $page_gui->setHeader("");
634  $ret = $page_gui->showPage(true);
635 
636  $tpl->setBodyClass("ilMediaPoolPagePreviewBody");
637  $tpl->setVariable("CONTENT", $ret);
638  //$ret = "<div style='background-color: white; padding:5px; margin-bottom: 30px;'>".$ret."</div>";
639 
640  //$ret =& $page_gui->executeCommand();
641  $tpl->show();
642  exit;
643  }
644 
645 
649  function showPreview()
650  {
651  $this->checkPermission("read");
652 
653  $item = new ilMediaPoolItem((int) $_GET["mepitem_id"]);
654 
655  switch ($item->getType())
656  {
657  case "mob":
658  $this->showMedia();
659  break;
660 
661  case "pg":
662  $this->showPage();
663  break;
664  }
665  }
666 
667 
671  function showFullscreen()
672  {
673  $this->showMedia();
674  }
675 
679  function confirmRemove()
680  {
681  global $ilAccess, $ilCtrl, $lng;
682 
683  $this->checkPermission("write");
684 
685  if(!isset($_POST["id"]))
686  {
687  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
688  }
689 
690  // display confirmation message
691  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
692  $cgui = new ilConfirmationGUI();
693  $cgui->setFormAction($this->ctrl->getFormAction($this));
694  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
695  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemove");
696  $cgui->setConfirm($this->lng->txt("confirm"), "remove");
697 
698  foreach($_POST["id"] as $obj_id)
699  {
700  $type = ilMediaPoolItem::lookupType($obj_id);
701  $title = ilMediaPoolItem::lookupTitle($obj_id);
702 
703  // check whether page can be removed
704  $add = "";
705  if ($type == "pg")
706  {
707  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
708  $usages = ilPageContentUsage::getUsages("incl", $obj_id, false);
709  if (count($usages) > 0)
710  {
711  ilUtil::sendFailure(sprintf($lng->txt("mep_content_snippet_in_use"), $title), true);
712  $ilCtrl->redirect($this, "listMedia");
713  }
714  else
715  {
716  // check whether the snippet is used in older versions of pages
717  $usages = ilPageContentUsage::getUsages("incl", $obj_id, true);
718  if (count($usages) > 0)
719  {
720  $add = "<div class='small'>".$lng->txt("mep_content_snippet_used_in_older_versions")."</div>";
721  }
722  }
723  }
724 
725  $caption = ilUtil::getImageTagByType($type, $this->tpl->tplPath).
726  " ".$title.$add;
727 
728  $cgui->addItem("id[]", $obj_id, $caption);
729  }
730 
731  $this->tpl->setContent($cgui->getHTML());
732  }
733 
737  function openClipboard()
738  {
739  global $ilCtrl, $ilAccess;
740 
741  $this->checkPermission("write");
742 
743  $ilCtrl->setParameterByClass("ileditclipboardgui", "returnCommand",
744  rawurlencode($ilCtrl->getLinkTarget($this,
745  "insertFromClipboard", "", false, false)));
746  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
747  }
748 
749 
754  {
755  global $ilAccess;
756 
757  $this->checkPermission("write");
758 
759  include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
761  $not_inserted = array();
762  if (is_array($ids))
763  {
764  foreach ($ids as $id2)
765  {
766  $id = explode(":", $id2);
767  $type = $id[0];
768  $id = $id[1];
769 
770  if ($type == "mob") // media object
771  {
772  if (ilObjMEdiaPool::isForeignIdInTree($this->object->getId(), $id))
773  {
774  $not_inserted[] = ilObject::_lookupTitle($id)." [".
775  $id."]";
776  }
777  else
778  {
779  $item = new ilMediaPoolItem();
780  $item->setType("mob");
781  $item->setForeignId($id);
782  $item->setTitle(ilObject::_lookupTitle($id));
783  $item->create();
784  if ($item->getId() > 0)
785  {
786  $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
787  }
788  }
789  }
790  if ($type == "incl") // content snippet
791  {
792  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
793  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
794  if (ilObjMEdiaPool::isItemIdInTree($this->object->getId(), $id))
795  {
796  $not_inserted[] = ilMediaPoolPage::lookupTitle($id)." [".
797  $id."]";
798  }
799  else
800  {
801  $original = new ilMediaPoolPage($id);
802 
803  // copy the page into the pool
804  $item = new ilMediaPoolItem();
805  $item->setType("pg");
806  $item->setTitle(ilMediaPoolItem::lookupTitle($id));
807  $item->create();
808  if ($item->getId() > 0)
809  {
810  $this->object->insertInTree($item->getId(), $_GET["mepitem_id"]);
811 
812  // create page
813  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
814  $page = new ilMediaPoolPage();
815  $page->setId($item->getId());
816  $page->create();
817 
818  // copy content
819  $original->copy($page->getId(), $page->getParentType(), $page->getParentId(), true);
820 
821  //$page->setXMLContent($original->copyXMLContent());
822  //$page->buildDom();
823  //$page->update();
824  }
825  }
826  }
827  }
828  }
829  if (count($not_inserted) > 0)
830  {
831  ilUtil::sendInfo($this->lng->txt("mep_not_insert_already_exist")."<br>".
832  implode($not_inserted,"<br>"), true);
833  }
834  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
835  }
836 
837 
841  function cancelRemove()
842  {
843  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
844  }
845 
849  function remove()
850  {
851  global $ilAccess;
852 
853  $this->checkPermission("write");
854 
855  foreach($_POST["id"] as $obj_id)
856  {
857  $this->object->deleteChild($obj_id);
858  }
859 
860  ilUtil::sendSuccess($this->lng->txt("cont_obj_removed"),true);
861  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
862  }
863 
864 
868  function copyToClipboard()
869  {
870  global $ilUser, $ilAccess;
871 
872  $this->checkPermission("write");
873 
874  if(!isset($_POST["id"]))
875  {
876  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
877  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
878  }
879 
880  foreach ($_POST["id"] as $obj_id)
881  {
882  $type = ilMediaPoolItem::lookupType($obj_id);
883  if ($type == "fold")
884  {
885  ilUtil::sendFailure($this->lng->txt("cont_cant_copy_folders"), true);
886  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
887  }
888  }
889  foreach ($_POST["id"] as $obj_id)
890  {
891  $fid = ilMediaPoolItem::lookupForeignId($obj_id);
892  $type = ilMediaPoolItem::lookupType($obj_id);
893  if ($type == "mob")
894  {
895  $ilUser->addObjectToClipboard($fid, "mob", "");
896  }
897  if ($type == "pg")
898  {
899  $ilUser->addObjectToClipboard($obj_id, "incl", "");
900  }
901  }
902  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"),true);
903  $this->ctrl->redirect($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
904  }
905 
909  function addLocatorItems()
910  {
911  global $ilLocator, $ilAccess;
912 
913  if (!$this->getCreationMode() && $this->ctrl->getCmd() != "explorer")
914  {
915  $tree =& $this->object->getTree();
916  $obj_id = ($_GET["mepitem_id"] == "")
917  ? $tree->getRootId()
918  : $_GET["mepitem_id"];
919  $path = $tree->getPathFull($obj_id);
920  foreach($path as $node)
921  {
922  if ($node["child"] == $tree->getRootId())
923  {
924  $this->ctrl->setParameter($this, "mepitem_id", "");
925  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
926  {
927  $link = $this->ctrl->getLinkTarget($this, "listMedia");
928  }
929  else if ($ilAccess->checkAccess("visible", "", $this->object->getRefId()))
930  {
931  $link = $this->ctrl->getLinkTarget($this, "infoScreen");
932  }
933  $title = $this->object->getTitle();
934  $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
935  $ilLocator->addItem($title, $link, "", $_GET["ref_id"]);
936  }
937  }
938  }
939  }
940 
944 
948  function createFolderForm()
949  {
950  global $ilAccess, $tpl;
951 
952  $this->checkPermission("write");
953 
954  $this->initFolderForm("create");
955  $tpl->setContent($this->form->getHTML());
956 
957 /* $folder_gui =& new ilObjFolderGUI("", 0, false, false);
958  $this->ctrl->setParameterByClass("ilobjfoldergui", "obj_id", $_GET["obj_id"]);
959  $folder_gui->setFormAction("save",
960  $this->ctrl->getFormActionByClass("ilobjfoldergui"));
961  $folder_gui->createObject();*/
962 // $this->tpl->show();
963  }
964 
971  function editFolder()
972  {
973  global $tpl;
974 
975  $this->checkPermission("write");
976 
977  $this->initFolderForm();
978  $this->getFolderValues();
979  $tpl->setContent($this->form->getHTML());
980  }
981 
985  public function getFolderValues()
986  {
987  $values = array();
988 
989  $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
990 
991  $this->form->setValuesByArray($values);
992  }
993 
997  public function saveFolder()
998  {
999  global $tpl, $lng, $ilCtrl;
1000 
1001  $this->checkPermission("write");
1002 
1003  $this->initFolderForm("create");
1004  if ($this->form->checkInput())
1005  {
1006  if ($this->object->createFolder($_POST["title"], (int) $_GET["mepitem_id"]))
1007  {
1008  ilUtil::sendSuccess($lng->txt("mep_folder_created"), true);
1009  }
1010  $ilCtrl->redirect($this, "listMedia");
1011  }
1012 
1013  $this->form->setValuesByPost();
1014  $tpl->setContent($this->form->getHtml());
1015  }
1016 
1020  function updateFolder()
1021  {
1022  global $lng, $ilCtrl, $tpl;
1023 
1024  $this->checkPermission("write");
1025 
1026  $this->initFolderForm("edit");
1027  if ($this->form->checkInput())
1028  {
1029  $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1030  $item->setTitle($_POST["title"]);
1031  $item->update();
1032  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1033  $ilCtrl->setParameter($this, "mepitem_id",
1034  $this->object->getTree()->getParentId($_GET["mepitem_id"]));
1035  $ilCtrl->redirect($this, "listMedia");
1036  }
1037 
1038  $this->form->setValuesByPost();
1039  $tpl->setContent($this->form->getHtml());
1040  }
1041 
1047  public function initFolderForm($a_mode = "edit")
1048  {
1049  global $lng, $ilCtrl;
1050 
1051  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1052  $this->form = new ilPropertyFormGUI();
1053 
1054  // desc
1055  $ti = new ilTextInputGUI($lng->txt("title"), "title");
1056  $ti->setMaxLength(128);
1057  $ti->setRequired(true);
1058  $this->form->addItem($ti);
1059 
1060  // save and cancel commands
1061  if ($a_mode == "create")
1062  {
1063  $this->form->addCommandButton("saveFolder", $lng->txt("save"));
1064  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1065  $this->form->setTitle($lng->txt("mep_new_folder"));
1066  }
1067  else
1068  {
1069  $this->form->addCommandButton("updateFolder", $lng->txt("save"));
1070  $this->form->addCommandButton("cancelFolderUpdate", $lng->txt("cancel"));
1071  $this->form->setTitle($lng->txt("mep_edit_folder"));
1072  }
1073 
1074  $this->form->setFormAction($ilCtrl->getFormAction($this));
1075  }
1076 
1081  {
1082  global $ilCtrl;
1083  $ilCtrl->setParameter($this, "mepitem_id",
1084  $this->object->getTree()->getParentId($_GET["mepitem_id"]));
1085  $ilCtrl->redirect($this, "listMedia");
1086  }
1087 
1091  function cancelSave()
1092  {
1093  global $ilCtrl;
1094  $ilCtrl->redirect($this, "listMedia");
1095  }
1096 
1100 
1105  {
1106  global $tpl;
1107 
1108  $this->checkPermission("write");
1109 
1110  $this->initMediaPoolPageForm("create");
1111  $tpl->setContent($this->form->getHTML());
1112  }
1113 
1121  {
1122  global $tpl;
1123 
1124  $this->checkPermission("write");
1125 
1126  $this->setMediaPoolPageTabs();
1127 
1128  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1129  $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1130  $mep_page_gui->getTabs();
1131 
1132  $this->initMediaPoolPageForm("edit");
1133  $this->getMediaPoolPageValues();
1134  $tpl->setContent($this->form->getHTML());
1135  }
1136 
1140  public function saveMediaPoolPage()
1141  {
1142  global $tpl, $lng, $ilCtrl;
1143 
1144  $this->checkPermission("write");
1145 
1146  $this->initMediaPoolPageForm("create");
1147  if ($this->form->checkInput())
1148  {
1149  // create media pool item
1150  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1151  $item = new ilMediaPoolItem();
1152  $item->setTitle($_POST["title"]);
1153  $item->setType("pg");
1154  $item->create();
1155 
1156  if ($item->getId() > 0)
1157  {
1158  // put in tree
1159  $tree = $this->object->getTree();
1160  $parent = $_GET["mepitem_id"] > 0
1161  ? $_GET["mepitem_id"]
1162  : $tree->getRootId();
1163  $this->object->insertInTree($item->getId(), $parent);
1164 
1165  // create page
1166  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1167  $page = new ilMediaPoolPage();
1168  $page->setId($item->getId());
1169  $page->create();
1170 
1171  $ilCtrl->setParameterByClass("ilmediapoolpagegui", "mepitem_id", $item->getId());
1172  $ilCtrl->redirectByClass("ilmediapoolpagegui", "edit");
1173 
1174  }
1175  $ilCtrl->redirect($this, "listMedia");
1176  }
1177 
1178  $this->form->setValuesByPost();
1179  $tpl->setContent($this->form->getHtml());
1180  }
1181 
1186  {
1187  global $lng, $ilCtrl, $tpl;
1188 
1189  $this->checkPermission("write");
1190 
1191  $this->initMediaPoolPageForm("edit");
1192  if ($this->form->checkInput())
1193  {
1194  $item = new ilMediaPoolItem($_GET["mepitem_id"]);
1195  $item->setTitle($_POST["title"]);
1196  $item->update();
1197  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1198  $ilCtrl->redirect($this, "editMediaPoolPage");
1199  }
1200 
1201  $this->form->setValuesByPost();
1202  $tpl->setContent($this->form->getHtml());
1203  }
1209  public function initMediaPoolPageForm($a_mode = "edit")
1210  {
1211  global $lng, $ilCtrl;
1212 
1213  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1214  $this->form = new ilPropertyFormGUI();
1215 
1216  // title
1217  $ti = new ilTextInputGUI($lng->txt("title"), "title");
1218  $ti->setMaxLength(128);
1219  $ti->setRequired(true);
1220  $this->form->addItem($ti);
1221 
1222  // save and cancel commands
1223  if ($a_mode == "create")
1224  {
1225  $this->form->addCommandButton("saveMediaPoolPage", $lng->txt("save"));
1226  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
1227  $this->form->setTitle($lng->txt("mep_new_content_snippet"));
1228  }
1229  else
1230  {
1231  $this->form->addCommandButton("updateMediaPoolPage", $lng->txt("save"));
1232  $this->form->setTitle($lng->txt("mep_edit_content_snippet"));
1233  }
1234 
1235  $this->form->setFormAction($ilCtrl->getFormAction($this));
1236  }
1237 
1241  public function getMediaPoolPageValues()
1242  {
1243  $values = array();
1244 
1245  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1246  $values["title"] = ilMediaPoolItem::lookupTitle($_GET["mepitem_id"]);
1247 
1248  $this->form->setValuesByArray($values);
1249  }
1250 
1258  {
1259  global $ilTabs, $ilCtrl, $lng;
1260 
1261  $ilTabs->clearTargets();
1262  //$ilTabs->addTab("mep_pg_prop", $lng->txt("mep_page_properties"),
1263  // $ilCtrl->getLinkTarget($this, "editMediaPoolPage"));
1264  $ilTabs->addTarget("mep_page_properties", $ilCtrl->getLinkTarget($this, "editMediaPoolPage"),
1265  "editMediaPoolPage", get_class($this));
1266  $ilTabs->addTarget("cont_usage", $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages"),
1267  array("showMediaPoolPageUsages", "showAllMediaPoolPageUsages"), get_class($this));
1268  $ilCtrl->setParameter($this, "mepitem_id", $this->object->tree->getParentId($_GET["mepitem_id"]));
1269  $ilTabs->setBackTarget($lng->txt("mep_folder"), $ilCtrl->getLinkTarget($this, "listMedia"));
1270  $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1271  }
1272 
1277  {
1278  $this->showMediaPoolPageUsages(true);
1279  }
1280 
1281 
1285  function showMediaPoolPageUsages($a_all = false)
1286  {
1287  global $ilTabs, $ilCtrl, $lng, $tpl;
1288 
1289  $this->checkPermission("write");
1290 
1291  $this->setMediaPoolPageTabs();
1292 
1293  $ilTabs->addSubTab("current_usages", $lng->txt("cont_current_usages"),
1294  $ilCtrl->getLinkTarget($this, "showMediaPoolPageUsages"));
1295 
1296  $ilTabs->addSubTab("all_usages", $lng->txt("cont_all_usages"),
1297  $ilCtrl->getLinkTarget($this, "showAllMediaPoolPageUsages"));
1298 
1299  if ($a_all)
1300  {
1301  $ilTabs->activateSubTab("all_usages");
1302  $cmd = "showAllMediaPoolPageUsages";
1303  }
1304  else
1305  {
1306  $ilTabs->activateSubTab("current_usages");
1307  $cmd = "showMediaPoolPageUsages";
1308  }
1309 
1310 
1311  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1312  $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
1313  $mep_page_gui->getTabs();
1314 
1315  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1316  $page = new ilMediaPoolPage((int) $_GET["mepitem_id"]);
1317 
1318  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageUsagesTableGUI.php");
1319  $table = new ilMediaPoolPageUsagesTableGUI($this, $cmd, $page, $a_all);
1320 
1321  $tpl->setContent($table->getHTML());
1322 
1323  }
1324 
1325 
1329 
1333  function setTabs()
1334  {
1335  global $ilAccess, $ilTabs, $ilCtrl, $ilHelp;
1336 
1337  $ilHelp->setScreenIdComponent("mep");
1338 
1339  if ($ilAccess->checkAccess('read', '', $this->ref_id) ||
1340  $ilAccess->checkAccess('write', '', $this->ref_id))
1341  {
1342  $ilTabs->addTarget("objs_fold", $this->ctrl->getLinkTarget($this, ""),
1343  "listMedia", "", "_top");
1344 
1345  $ilCtrl->setParameter($this, "mepitem_id", "");
1346  $ilTabs->addTarget("mep_all_mobs", $this->ctrl->getLinkTarget($this, "allMedia"),
1347  "allMedia", "", "_top");
1348  $ilCtrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
1349  }
1350 
1351  // info tab
1352  if ($ilAccess->checkAccess('visible', '', $this->ref_id) ||
1353  $ilAccess->checkAccess('read', '', $this->ref_id) ||
1354  $ilAccess->checkAccess('write', '', $this->ref_id))
1355  {
1356  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
1357  || strtolower($_GET["cmdClass"]) == "ilnotegui")
1358  ? true
1359  : false;
1360  //echo "-$force_active-";
1361  $ilTabs->addTarget("info_short",
1362  $this->ctrl->getLinkTargetByClass(
1363  array("ilobjmediapoolgui", "ilinfoscreengui"), "showSummary"),
1364  array("showSummary", "infoScreen"),
1365  "", "", $force_active);
1366  }
1367 
1368  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1369  {
1370  $ilTabs->addTarget("settings", $this->ctrl->getLinkTarget($this, "edit"),
1371  "edit", array("", "ilobjmediapoolgui"));
1372  }
1373 
1374  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1375  {
1376  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTarget($this, "openClipboard"),
1377  "view", "ileditclipboardgui");
1378  }
1379 
1380  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1381  {
1382  $ilTabs->addTarget("export", $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1383  "", "ilexportgui");
1384  }
1385 
1386  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
1387  {
1388  $ilTabs->addTarget("perm_settings",
1389  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1390  }
1391 
1392  }
1393 
1394 
1398  public static function _goto($a_target)
1399  {
1400  global $ilAccess, $ilErr, $lng;
1401 
1402  $targets = explode('_',$a_target);
1403  if(count((array) $targets) > 1)
1404  {
1405  $ref_id = $targets[0];
1406  $subitem_id = $targets[1];
1407  }
1408  else
1409  {
1410  $ref_id = $targets[0];
1411  }
1412 
1413  if ($ilAccess->checkAccess("read", "", $ref_id))
1414  {
1415  $_GET["baseClass"] = "ilMediaPoolPresentationGUI";
1416  $_GET["ref_id"] = $ref_id;
1417  $_GET['mepitem_id'] = $subitem_id;
1418  include("ilias.php");
1419  exit;
1420  } else if ($ilAccess->checkAccess("visible", "", $ref_id))
1421  {
1422  $_GET["baseClass"] = "ilMediaPoolPresentationGUI";
1423  $_GET["ref_id"] = $ref_id;
1424  $_GET["cmd"] = "infoScreen";
1425  include("ilias.php");
1426  exit;
1427  }
1428  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1429  {
1430  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1431  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1433  }
1434 
1435  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1436  }
1437 
1443  function infoScreenObject()
1444  {
1445  $this->ctrl->setCmd("showSummary");
1446  $this->ctrl->setCmdClass("ilinfoscreengui");
1447  $this->infoScreen();
1448  }
1449 
1453  function infoScreen()
1454  {
1455  global $ilAccess;
1456 
1457  if (!$ilAccess->checkAccess("visible", "", $this->ref_id) &&
1458  !$ilAccess->checkAccess("read", "", $this->ref_id) &&
1459  !$ilAccess->checkAccess("write", "", $this->ref_id))
1460  {
1461  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1462  }
1463 
1464  if ($this->ctrl->getCmd() == "infoScreen")
1465  {
1466  $this->ctrl->setCmd("showSummary");
1467  $this->ctrl->setCmdClass("ilinfoscreengui");
1468  }
1469 
1470  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1471  $info = new ilInfoScreenGUI($this);
1472 
1473  $info->enablePrivateNotes();
1474 
1475  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1476  {
1477  //$info->enableNews();
1478  }
1479 
1480  // no news editing for files, just notifications
1481 // $info->enableNewsEditing(false);
1482  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1483  {
1484 // $news_set = new ilSetting("news");
1485 // $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1486 
1487 // if ($enable_internal_rss)
1488 // {
1489 // $info->setBlockProperty("news", "settings", true);
1490 // $info->setBlockProperty("news", "public_notifications_option", true);
1491 // }
1492  }
1493 
1494 
1495  // standard meta data
1496  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1497 
1498  // forward the command
1499  $this->ctrl->forwardCommand($info);
1500 
1501 // $this->tpl->show();
1502  }
1503 
1504 
1508 
1513  {
1514  global $tpl, $ilTabs, $lng, $ilCtrl, $ilToolbar;
1515 
1516  $ilTabs->clearTargets();
1517  $ilTabs->setBackTarget($lng->txt("back"),
1518  $ilCtrl->getLinkTarget($this, "listMedia"));
1519 
1520  $this->checkPermission("write");
1521 
1523  {
1524 
1525  // action type
1526  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1527  $options = array(
1528  "rename" => $lng->txt("mep_up_dir_move"),
1529  "copy" => $lng->txt("mep_up_dir_copy"),
1530  );
1531  $si = new ilSelectInputGUI("", "action");
1532  $si->setOptions($options);
1533  $ilToolbar->addInputItem($si);
1534  $ilToolbar->setCloseFormTag(false);
1535  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1536  $ilToolbar->setFormName("mep_up_form");
1537 
1538  include_once("./Modules/MediaPool/classes/class.ilUploadDirFilesTableGUI.php");
1539  $tab = new ilUploadDirFilesTableGUI($this, "selectUploadDirFiles",
1540  $_POST["file"]);
1541  $tab->setFormName("mep_up_form");
1542  $tpl->setContent($tab->getHTML());
1543  }
1544  }
1545 
1550  {
1551  $this->checkPermission("write");
1552 
1553  $mset = new ilSetting("mobs");
1554  $upload_dir = trim($mset->get("upload_dir"));
1555 
1556  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1557 
1558  if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission())
1559  {
1560  foreach ($_POST["file"] as $f)
1561  {
1562  $f = str_replace("..", "", $f);
1563  $fullpath = $upload_dir."/".$f;
1564  $mob = new ilObjMediaObject();
1565  $mob->setTitle(basename($fullpath));
1566  $mob->setDescription("");
1567  $mob->create();
1568 
1569  // determine and create mob directory, move uploaded file to directory
1570  //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
1571  $mob->createDirectory();
1572  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1573 
1574  $media_item = new ilMediaItem();
1575  $mob->addMediaItem($media_item);
1576  $media_item->setPurpose("Standard");
1577 
1578  $file = $mob_dir."/".basename($fullpath);
1579  ilUtil::moveUploadedFile($fullpath,
1580  basename($fullpath), $file, false, $_POST["action"]);
1581 
1582  // get mime type
1584  $location = basename($fullpath);
1585 
1586  // set real meta and object data
1587  $media_item->setFormat($format);
1588  $media_item->setLocation($location);
1589  $media_item->setLocationType("LocalFile");
1590 
1591  $mob->setDescription($format);
1592 
1593  // determine width and height of known image types
1594  $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format,
1595  "File", $mob_dir."/".$location, $media_item->getLocation(),
1596  true, true, "", "");
1597  $media_item->setWidth($wh["width"]);
1598  $media_item->setHeight($wh["height"]);
1599  if ($wh["info"] != "")
1600  {
1601  // ilUtil::sendInfo($wh["info"], true);
1602  }
1603 
1604  $media_item->setHAlign("Left");
1605  ilUtil::renameExecutables($mob_dir);
1606  $mob->update();
1607 
1608 
1609  // put it into current folder
1610  $mep_item = new ilMediaPoolItem();
1611  $mep_item->setTitle($mob->getTitle());
1612  $mep_item->setType("mob");
1613  $mep_item->setForeignId($mob->getId());
1614  $mep_item->create();
1615 
1616  $tree = $this->object->getTree();
1617  $parent = ($_GET["mepitem_id"] == "")
1618  ? $tree->getRootId()
1619  : $_GET["mepitem_id"];
1620  $tree->insertNode($mep_item->getId(), $parent);
1621  }
1622  }
1623  ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=".
1624  $_GET["ref_id"]."&mepitem_id=".$_GET["mepitem_id"]);
1625 
1626  }
1627 
1631  static function getPreviewModalHTML($a_mpool_ref_id, $a_tpl)
1632  {
1633  global $tpl, $ilCtrl, $lng;
1634 
1635  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1637 
1638  $tpl->addJavaScript("./Modules/MediaPool/js/ilMediaPool.js");
1639 
1640  $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", "");
1641  $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $a_mpool_ref_id);
1642  $tpl->addOnloadCode("il.MediaPool.setPreviewUrl('".$ilCtrl->getLinkTargetByClass(array("ilmediapoolpresentationgui", "ilobjmediapoolgui"), "showPreview", "", false, false)."');");
1643  $ilCtrl->setParameterByClass("ilobjmediapoolgui", "mepitem_id", $_GET["mepitem_id"]);
1644  $ilCtrl->setParameterByClass("ilobjmediapoolgui", "ref_id", $_GET["red_id"]);
1645 
1646  include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1647  $modal = ilModalGUI::getInstance();
1648  $modal->setHeading($lng->txt("preview"));
1649  $modal->setId("ilMepPreview");
1650  $modal->setType(ilModalGUI::TYPE_LARGE);
1651  $modal->setBody("<iframe id='ilMepPreviewContent'></iframe>");
1652 
1653  return $modal->getHTML();
1654  }
1655 
1656 }
1657 ?>