ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjMediaObject.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 define ("IL_MODE_ALIAS", 1);
5 define ("IL_MODE_OUTPUT", 2);
6 define ("IL_MODE_FULL", 3);
7 
8 require_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
9 include_once "classes/class.ilObject.php";
10 
27 {
28  var $is_alias;
30  var $id;
33 
38  function ilObjMediaObject($a_id = 0)
39  {
40  $this->is_alias = false;
41  $this->media_items = array();
42  $this->contains_int_link = false;
43  $this->type = "mob";
44  parent::ilObject($a_id, false);
45  }
46 
47  function setRefId()
48  {
49  $this->ilias->raiseError("Operation ilObjMedia::setRefId() not allowed.",$this->ilias->error_obj->FATAL);
50  }
51 
52  function getRefId()
53  {
54  return false;
55  }
56 
57  function putInTree()
58  {
59  $this->ilias->raiseError("Operation ilObjMedia::putInTree() not allowed.",$this->ilias->error_obj->FATAL);
60  }
61 
62  function createReference()
63  {
64  $this->ilias->raiseError("Operation ilObjMedia::createReference() not allowed.",$this->ilias->error_obj->FATAL);
65  }
66 
67  function setTitle($a_title)
68  {
69  parent::setTitle($a_title);
70  }
71 
72  function getTitle()
73  {
74  return parent::getTitle();
75  }
76 
84  function _exists($a_id)
85  {
86  global $ilDB;
87 
88  include_once("./Services/COPage/classes/class.ilInternalLink.php");
89  if (is_int(strpos($a_id, "_")))
90  {
92  }
93 
94  return parent::_exists($a_id, false);
95  }
96 
100  function delete()
101  {
102  if (!($this->getId() > 0))
103  {
104  return;
105  }
106 
107  $usages = $this->getUsages();
108 
109  if (count($usages) == 0)
110  {
111  // remove directory
113 
114  // remove thumbnail directory
116 
117  // delete meta data of mob
118  $this->deleteMetaData();
119 
120  // delete media items
122 
123  // delete object
124  parent::delete();
125  }
126  }
127 
133  function getDescription()
134  {
135  return parent::getDescription();
136  }
137 
141  function setDescription($a_description)
142  {
143  parent::setDescription($a_description);
144  }
145 
157  function MDUpdateListener($a_element)
158  {
159  include_once 'Services/MetaData/classes/class.ilMD.php';
160 
161  switch($a_element)
162  {
163  case 'General':
164 
165  // Update Title and description
166  $md = new ilMD(0, $this->getId(), $this->getType());
167  $md_gen = $md->getGeneral();
168 
169  if (is_object($md_gen))
170  {
171  ilObject::_writeTitle($this->getId(),$md_gen->getTitle());
172  $this->setTitle($md_gen->getTitle());
173 
174  foreach($md_gen->getDescriptionIds() as $id)
175  {
176  $md_des = $md_gen->getDescription($id);
177  ilObject::_writeDescription($this->getId(),$md_des->getDescription());
178  $this->setDescription($md_des->getDescription());
179  break;
180  }
181  }
182 
183  break;
184 
185  default:
186  }
187  return true;
188  }
189 
193  function createMetaData()
194  {
195  include_once 'Services/MetaData/classes/class.ilMDCreator.php';
196 
197  global $ilUser;
198 
199  $md_creator = new ilMDCreator(0, $this->getId(), $this->getType());
200  $md_creator->setTitle($this->getTitle());
201  $md_creator->setTitleLanguage($ilUser->getPref('language'));
202  $md_creator->setDescription($this->getDescription());
203  $md_creator->setDescriptionLanguage($ilUser->getPref('language'));
204  $md_creator->setKeywordLanguage($ilUser->getPref('language'));
205  $md_creator->setLanguage($ilUser->getPref('language'));
206  $md_creator->create();
207 
208  return true;
209  }
210 
214  function updateMetaData()
215  {
216  include_once("Services/MetaData/classes/class.ilMD.php");
217  include_once("Services/MetaData/classes/class.ilMDGeneral.php");
218  include_once("Services/MetaData/classes/class.ilMDDescription.php");
219 
220  $md =& new ilMD(0, $this->getId(), $this->getType());
221  $md_gen =& $md->getGeneral();
222  $md_gen->setTitle($this->getTitle());
223 
224  // sets first description (maybe not appropriate)
225  $md_des_ids =& $md_gen->getDescriptionIds();
226  if (count($md_des_ids) > 0)
227  {
228  $md_des =& $md_gen->getDescription($md_des_ids[0]);
229  $md_des->setDescription($this->getDescription());
230  $md_des->update();
231  }
232  $md_gen->update();
233 
234  }
235 
239  function deleteMetaData()
240  {
241  // Delete meta data
242  include_once('Services/MetaData/classes/class.ilMD.php');
243  $md = new ilMD(0, $this->getId(), $this->getType());
244  $md->deleteAll();
245  }
246 
247 
253  function addMediaItem(&$a_item)
254  {
255  $this->media_items[] =& $a_item;
256  }
257 
258 
264  function &getMediaItems()
265  {
266  return $this->media_items;
267  }
268 
275  function &getMediaItem($a_purpose)
276  {
277  foreach ($this->media_items as $media_item)
278  {
279  if($media_item->getPurpose() == $a_purpose)
280  {
281  return $media_item;
282  }
283  }
284  return false;
285  }
286 
287 
291  function removeMediaItem($a_purpose)
292  {
293  foreach ($this->media_items as $key => $media_item)
294  {
295  if($media_item->getPurpose() == $a_purpose)
296  {
297  unset($this->media_items[$key]);
298  }
299  }
300  // update numbers and keys
301  $i = 1;
302  $media_items = array();
303  foreach ($this->media_items as $media_item)
304  {
305  $media_items [$i] = $media_item;
306  $media_item->setMobId($this->getId());
307  $media_item->setNr($i);
308  $i++;
309  }
310  $this->media_items = $media_items;
311  }
312 
317  {
318  $this->media_items = array();
319  }
320 
321 
322  function getMediaItemNr($a_purpose)
323  {
324  for($i=0; $i<count($this->media_items); $i++)
325  {
326  if($this->media_items[$i]->getPurpose() == $a_purpose)
327  {
328  return $i + 1;
329  }
330  }
331  return false;
332  }
333 
334 
335  function hasFullscreenItem()
336  {
337  return $this->hasPurposeItem("Fullscreen");
338  }
339 
346  function hasPurposeItem($purpose)
347  {
348  if(is_object($this->getMediaItem($purpose)))
349  {
350  return true;
351  }
352  else
353  {
354  return false;
355  }
356  }
357 
358 
359 
363  function read()
364  {
365 //echo "<br>ilObjMediaObject:read";
366  parent::read();
367 
368  // get media items
370  }
371 
375  function setId($a_id)
376  {
377  $this->id = $a_id;
378  }
379 
380  function getId()
381  {
382  return $this->id;
383  }
384 
388  function setAlias($a_is_alias)
389  {
390  $this->is_alias = $a_is_alias;
391  }
392 
393  function isAlias()
394  {
395  return $this->is_alias;
396  }
397 
398  function setOriginID($a_id)
399  {
400  return $this->origin_id = $a_id;
401  }
402 
403  function getOriginID()
404  {
405  return $this->origin_id;
406  }
407 
408  /*
409  function getimportId()
410  {
411  return $this->meta_data->getImportIdentifierEntryID();
412  }*/
413 
414 
418  function getImportId()
419  {
420  return $this->import_id;
421  }
422 
423  function setImportId($a_id)
424  {
425  $this->import_id = $a_id;
426  }
427 
431  function create($a_create_meta_data = false, $a_save_media_items = true)
432  {
433  parent::create();
434 
435  if (!$a_create_meta_data)
436  {
437  $this->createMetaData();
438  }
439 
440  if ($a_save_media_items)
441  {
442  $media_items =& $this->getMediaItems();
443  for($i=0; $i<count($media_items); $i++)
444  {
445  $item =& $media_items[$i];
446  $item->setMobId($this->getId());
447  $item->setNr($i+1);
448  $item->create();
449  }
450  }
451 
452  }
453 
454 
458  function update($a_upload=false)
459  {
460  parent::update();
461  if(!$a_upload)
462  {
463  $this->updateMetaData();
464  }
466 
467  // iterate all items
468  $media_items =& $this->getMediaItems();
469  $j = 1;
470  foreach($media_items as $key => $val)
471  {
472  $item =& $media_items[$key];
473  if (is_object($item))
474  {
475  $item->setMobId($this->getId());
476  $item->setNr($j);
477  if ($item->getLocationType() == "Reference")
478  {
479  $item->extractUrlParameters();
480  }
481  $item->create();
482  $j++;
483  }
484  }
485  }
486 
492  function _getDirectory($a_mob_id)
493  {
494  return ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
495  }
496 
502  function _getURL($a_mob_id)
503  {
504  return ilUtil::getHtmlPath(ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id);
505  }
506 
512  function _getThumbnailDirectory($a_mob_id, $a_mode = "filesystem")
513  {
514  return ilUtil::getWebspaceDir($a_mode)."/thumbs/mm_".$a_mob_id;
515  }
516 
522  static function _lookupStandardItemPath($a_mob_id, $a_url_encode = false,
523  $a_web = true)
524  {
525  return ilObjMediaObject::_lookupItemPath($a_mob_id, $a_url_encode, $a_web, "Standard");
526  }
527 
533  static function _lookupItemPath($a_mob_id, $a_url_encode = false,
534  $a_web = true, $a_purpose = "")
535  {
536  if ($a_purpose == "")
537  {
538  $a_purpose = "Standard";
539  }
540  $location = ilMediaItem::_lookupLocationForMobId($a_mob_id, $a_purpose);
541  if (preg_match("/https?\:/i",$location))
542  return $location;
543 
544  if ($a_url_encode)
545  $location = rawurlencode($location);
546 
547  $path = ($a_web)
548  ? ILIAS_HTTP_PATH
549  : ".";
550 
551  return $path."/data/".CLIENT_ID."/mobs/mm_".$a_mob_id."/".$location;
552  }
553 
557  function createDirectory()
558  {
560  }
561 
565  function _createThumbnailDirectory($a_obj_id)
566  {
568  ilUtil::createDirectory(ilUtil::getWebspaceDir()."/thumbs/mm_".$a_obj_id);
569  }
570 
577  function getFilesOfDirectory($a_subdir = "")
578  {
579  $a_subdir = str_replace("..", "", $a_subdir);
581  if ($a_subdir != "")
582  {
583  $dir.= "/".$a_subdir;
584  }
585 
586  $files = array();
587  if (is_dir($dir))
588  {
589  $entries = ilUtil::getDir($dir);
590  foreach ($entries as $e)
591  {
592  if (is_file($dir."/".$e["entry"]) && $e["entry"] != "." && $e["entry"] != "..")
593  {
594  $files[] = $e["entry"];
595  }
596  }
597  }
598 
599  return $files;
600  }
601 
602 
607  function getXML($a_mode = IL_MODE_FULL, $a_inst = 0)
608  {
609  // TODO: full implementation of all parameters
610 //echo "-".$a_mode."-";
611  switch ($a_mode)
612  {
613  case IL_MODE_ALIAS:
614  $xml = "<MediaObject>";
615  $xml .= "<MediaAlias OriginId=\"il__mob_".$this->getId()."\"/>";
616  $media_items =& $this->getMediaItems();
617  for($i=0; $i<count($media_items); $i++)
618  {
619  $item =& $media_items[$i];
620  $xml .= "<MediaAliasItem Purpose=\"".$item->getPurpose()."\">";
621 
622  // Layout
623  $width = ($item->getWidth() != "")
624  ? "Width=\"".$item->getWidth()."\""
625  : "";
626  $height = ($item->getHeight() != "")
627  ? "Height=\"".$item->getHeight()."\""
628  : "";
629  $halign = ($item->getHAlign() != "")
630  ? "HorizontalAlign=\"".$item->getHAlign()."\""
631  : "";
632  $xml .= "<Layout $width $height $halign />";
633 
634  // Caption
635  if ($item->getCaption() != "")
636  {
637  $xml .= "<Caption Align=\"bottom\">".
638  str_replace("&", "&amp;", $item->getCaption())."</Caption>";
639  }
640 
641  // Text Representation
642  if ($item->getTextRepresentation() != "")
643  {
644  $xml .= "<TextRepresentation>".
645  str_replace("&", "&amp;", $item->getTextRepresentation())."</TextRepresentation>";
646  }
647 
648  // Parameter
649  $parameters = $item->getParameters();
650  foreach ($parameters as $name => $value)
651  {
652  $xml .= "<Parameter Name=\"$name\" Value=\"$value\"/>";
653  }
654  $xml .= "</MediaAliasItem>";
655  }
656  break;
657 
658  // for output we need technical sections of meta data
659  case IL_MODE_OUTPUT:
660 
661  // get first technical section
662 // $meta =& $this->getMetaData();
663  $xml = "<MediaObject Id=\"il__mob_".$this->getId()."\">";
664 
665  $media_items =& $this->getMediaItems();
666  for($i=0; $i<count($media_items); $i++)
667  {
668  $item =& $media_items[$i];
669  $xml .= "<MediaItem Purpose=\"".$item->getPurpose()."\">";
670 
671  // Location
672  $xml.= "<Location Type=\"".$item->getLocationType()."\">".
673  $this->handleAmps($item->getLocation())."</Location>";
674 
675  // Format
676  $xml.= "<Format>".$item->getFormat()."</Format>";
677 
678  // Layout
679  $width = ($item->getWidth() != "")
680  ? "Width=\"".$item->getWidth()."\""
681  : "";
682  $height = ($item->getHeight() != "")
683  ? "Height=\"".$item->getHeight()."\""
684  : "";
685  $halign = ($item->getHAlign() != "")
686  ? "HorizontalAlign=\"".$item->getHAlign()."\""
687  : "";
688  $xml .= "<Layout $width $height $halign />";
689 
690  // Caption
691  if ($item->getCaption() != "")
692  {
693  $xml .= "<Caption Align=\"bottom\">".
694  str_replace("&", "&amp;", $item->getCaption())."</Caption>";
695  }
696 
697  // Text Representation
698  if ($item->getTextRepresentation() != "")
699  {
700  $xml .= "<TextRepresentation>".
701  str_replace("&", "&amp;", $item->getTextRepresentation())."</TextRepresentation>";
702  }
703 
704  // Parameter
705  $parameters = $item->getParameters();
706  foreach ($parameters as $name => $value)
707  {
708  $xml .= "<Parameter Name=\"$name\" Value=\"$value\"/>";
709  }
710  $xml .= $item->getMapAreasXML();
711  $xml .= "</MediaItem>";
712  }
713  break;
714 
715  // full xml for export
716  case IL_MODE_FULL:
717 
718 // $meta =& $this->getMetaData();
719  $xml = "<MediaObject>";
720 
721  // meta data
722  include_once("Services/MetaData/classes/class.ilMD2XML.php");
723  $md2xml = new ilMD2XML(0, $this->getId(), $this->getType());
724  $md2xml->setExportMode(true);
725  $md2xml->startExport();
726  $xml.= $md2xml->getXML();
727 
728  $media_items =& $this->getMediaItems();
729  for($i=0; $i<count($media_items); $i++)
730  {
731  $item =& $media_items[$i];
732  $xml .= "<MediaItem Purpose=\"".$item->getPurpose()."\">";
733 
734  // Location
735  $xml.= "<Location Type=\"".$item->getLocationType()."\">".
736  $this->handleAmps($item->getLocation())."</Location>";
737 
738  // Format
739  $xml.= "<Format>".$item->getFormat()."</Format>";
740 
741  // Layout
742  $width = ($item->getWidth() != "")
743  ? "Width=\"".$item->getWidth()."\""
744  : "";
745  $height = ($item->getHeight() != "")
746  ? "Height=\"".$item->getHeight()."\""
747  : "";
748  $halign = ($item->getHAlign() != "")
749  ? "HorizontalAlign=\"".$item->getHAlign()."\""
750  : "";
751  $xml .= "<Layout $width $height $halign />";
752 
753  // Caption
754  if ($item->getCaption() != "")
755  {
756  $xml .= "<Caption Align=\"bottom\">".
757  str_replace("&", "&amp;", $item->getCaption())."</Caption>";
758  }
759 
760  // Text Representation
761  if ($item->getTextRepresentation() != "")
762  {
763  $xml .= "<TextRepresentation>".
764  str_replace("&", "&amp;", $item->getTextRepresentation())."</TextRepresentation>";
765  }
766 
767  // Parameter
768  $parameters = $item->getParameters();
769  foreach ($parameters as $name => $value)
770  {
771  $xml .= "<Parameter Name=\"$name\" Value=\"$value\"/>";
772  }
773  $xml .= $item->getMapAreasXML(true, $a_inst);
774  $xml .= "</MediaItem>";
775  }
776  break;
777  }
778  $xml .= "</MediaObject>";
779  return $xml;
780  }
781 
785  function handleAmps($a_str)
786  {
787  $a_str = str_replace("&amp;", "&", $a_str);
788  $a_str = str_replace("&", "&amp;", $a_str);
789  return $a_str;
790  }
791 
795  function exportXML(&$a_xml_writer, $a_inst = 0)
796  {
797  $a_xml_writer->appendXML($this->getXML(IL_MODE_FULL, $a_inst));
798  }
799 
800 
808  function exportFiles($a_target_dir)
809  {
810  $subdir = "il_".IL_INST_ID."_mob_".$this->getId();
811  ilUtil::makeDir($a_target_dir."/objects/".$subdir);
812 
813  $mobdir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->getId();
814  ilUtil::rCopy($mobdir, $a_target_dir."/objects/".$subdir);
815 //echo "from:$mobdir:to:".$a_target_dir."/objects/".$subdir.":<br>";
816  }
817 
818  function exportMediaFullscreen($a_target_dir, $pg_obj)
819  {
820  $subdir = "il_".IL_INST_ID."_mob_".$this->getId();
821  $a_target_dir = $a_target_dir."/objects/".$subdir;
822  ilUtil::makeDir($a_target_dir);
823  $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule");
824  $tpl->setCurrentBlock("ilMedia");
825 
826  //$int_links = $page_object->getInternalLinks();
827  $med_links = ilMediaItem::_getMapAreasIntLinks($this->getId());
828 
829  // @todo
830  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
831 
832  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
833  //$media_obj = new ilObjMediaObject($_GET["mob_id"]);
834  require_once("./Services/COPage/classes/class.ilPageObject.php");
835 
836  $xml = "<dummy>";
837  // todo: we get always the first alias now (problem if mob is used multiple
838  // times in page)
839  $xml.= $pg_obj->getMediaAliasElement($this->getId());
840  $xml.= $this->getXML(IL_MODE_OUTPUT);
841  //$xml.= $link_xml;
842  $xml.="</dummy>";
843 
844  //die(htmlspecialchars($xml));
845 
846  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
847  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
848  $xh = xslt_create();
849 
850  //echo "<b>XML:</b>".htmlentities($xml);
851  // determine target frames for internal links
852  $wb_path = "";
853  $enlarge_path = "";
854  $params = array ('mode' => "fullscreen", 'enlarge_path' => $enlarge_path,
855  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => "",
856  'ref_id' => $_GET["ref_id"], 'webspace_path' => $wb_path);
857  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
858  //echo xslt_error($xh);
859  xslt_free($xh);
860 
861  // unmask user html
862  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "../../css/style.css");
863  $tpl->setVariable("LOCATION_STYLESHEET", "../../css/system.css");
864  $tpl->setVariable("MEDIA_CONTENT", $output);
865  $output = $tpl->get();
866  //$output = preg_replace("/\/mobs\/mm_(\d+)\/([^\"]+)/i","$2",$output);
867  $output = preg_replace("/mobs\/mm_(\d+)\/([^\"]+)/i","$2",$output);
868  $output = preg_replace("/\.\/Services\/MediaObjects\/flash_mp3_player/i","../../players",$output);
869  $output = preg_replace("/\.\/Services\/MediaObjects\/flash_flv_player/i","../../players",$output);
870  $output = preg_replace("/file=..\/..\/..\//i","file=../objects/".$subdir."/",$output);
871  //die(htmlspecialchars($output));
872  fwrite(fopen($a_target_dir.'/fullscreen.html','w'), $output );
873  }
874 
875  function modifyExportIdentifier($a_tag, $a_param, $a_value)
876  {
877  if ($a_tag == "Identifier" && $a_param == "Entry")
878  {
879  $a_value = ilUtil::insertInstIntoID($a_value);
880  }
881 
882  return $a_value;
883  }
884 
885 
887  // EDIT METHODS: these methods act on the media alias in the dom
889 
896  function setContainsIntLink($a_contains_link)
897  {
898  $this->contains_int_link = $a_contains_link;
899  }
900 
905  function containsIntLink()
906  {
908  }
909 
913  function _deleteAllUsages($a_type, $a_id, $a_usage_hist_nr = 0)
914  {
915  global $ilDB;
916 
917  $q = "DELETE FROM mob_usage WHERE usage_type = ".
918  $ilDB->quote($a_type, "text").
919  " AND usage_id= ".$ilDB->quote($a_id, "integer").
920  " AND usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr, "integer");
921  $ilDB->manipulate($q);
922  }
923 
927  function _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr = 0)
928  {
929  global $ilDB;
930 
931  $q = "SELECT * FROM mob_usage WHERE ".
932  "usage_type = ".$ilDB->quote($a_type, "text")." AND ".
933  "usage_id = ".$ilDB->quote($a_id, "integer")." AND ".
934  "usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr, "integer");
935  $mobs = array();
936  $mob_set = $ilDB->query($q);
937  while($mob_rec = $ilDB->fetchAssoc($mob_set))
938  {
939  if (ilObject::_lookupType($mob_rec["id"]) == "mob")
940  {
941  $mobs[$mob_rec["id"]] = $mob_rec["id"];
942  }
943  }
944 
945  return $mobs;
946  }
947 
951  function _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr = 0)
952  {
953  global $ilDB;
954 
955  $q = "DELETE FROM mob_usage WHERE ".
956  " id = ".$ilDB->quote((int) $a_mob_id, "integer")." AND ".
957  " usage_type = ".$ilDB->quote($a_type, "text")." AND ".
958  " usage_id = ".$ilDB->quote((int) $a_id, "integer")." AND ".
959  " usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer");
960  $ilDB->manipulate($q);
961  $q = "INSERT INTO mob_usage (id, usage_type, usage_id, usage_hist_nr) VALUES".
962  " (".$ilDB->quote((int) $a_mob_id, "integer").",".
963  $ilDB->quote($a_type, "text").",".
964  $ilDB->quote((int) $a_id, "integer").",".
965  $ilDB->quote((int) $a_usage_hist_nr, "integer").")";
966  $ilDB->manipulate($q);
967  }
968 
972  function _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr = 0)
973  {
974  global $ilDB;
975 
976  $q = "DELETE FROM mob_usage WHERE ".
977  " id = ".$ilDB->quote((int) $a_mob_id, "integer")." AND ".
978  " usage_type = ".$ilDB->quote($a_type, "text")." AND ".
979  " usage_id = ".$ilDB->quote((int) $a_id, "integer")." AND ".
980  " usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer");
981  $ilDB->manipulate($q);
982  }
983 
987  function getUsages($a_include_history = true)
988  {
989  return $this->lookupUsages($this->getId(), $a_include_history);
990  }
991 
997  function lookupUsages($a_id, $a_include_history = true)
998  {
999  global $ilDB;
1000 
1001  $hist_str = "";
1002  if ($a_include_history)
1003  {
1004  $hist_str = ", usage_hist_nr";
1005  }
1006 
1007  // get usages in pages
1008  $q = "SELECT DISTINCT usage_type, usage_id".$hist_str." FROM mob_usage WHERE id = ".
1009  $ilDB->quote($a_id, "integer");
1010 
1011  if (!$a_include_history)
1012  {
1013  $q.= " AND usage_hist_nr = ".$ilDB->quote(0, "integer");
1014  }
1015 
1016  $us_set = $ilDB->query($q);
1017  $ret = array();
1018  while($us_rec = $ilDB->fetchAssoc($us_set))
1019  {
1020  $ut = "";
1021  if(is_int(strpos($us_rec["usage_type"], ":")))
1022  {
1023  $us_arr = explode(":", $us_rec["usage_type"]);
1024  $ut = $us_arr[1];
1025  $ct = $us_arr[0];
1026  }
1027 
1028  // check whether page exists
1029  $skip = false;
1030  if ($ut == "pg")
1031  {
1032  include_once("./Services/COPage/classes/class.ilPageObject.php");
1033  if (!ilPageObject::_exists($ct, $us_rec["usage_id"]))
1034  {
1035  $skip = true;
1036  }
1037  }
1038 
1039  if (!$skip)
1040  {
1041  $ret[] = array("type" => $us_rec["usage_type"],
1042  "id" => $us_rec["usage_id"],
1043  "hist_nr" => $us_rec["usage_hist_nr"]);
1044  }
1045  }
1046 
1047  // get usages in media pools
1048  $q = "SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = ".
1049  $ilDB->quote($a_id, "integer")." AND mep_item.type = ".$ilDB->quote("mob", "text");
1050  $us_set = $ilDB->query($q);
1051  while($us_rec = $ilDB->fetchAssoc($us_set))
1052  {
1053  $ret[] = array("type" => "mep",
1054  "id" => $us_rec["mep_id"]);
1055  }
1056 
1057  // get usages in news items (media casts)
1058  include_once("./Services/News/classes/class.ilNewsItem.php");
1059  $news_usages = ilNewsItem::_lookupMediaObjectUsages($a_id);
1060  foreach($news_usages as $nu)
1061  {
1062  $ret[] = $nu;
1063  }
1064 
1065 
1066  // get usages in map areas
1067  $q = "SELECT DISTINCT mob_id FROM media_item it, map_area area ".
1068  " WHERE area.item_id = it.id ".
1069  " AND area.link_type = ".$ilDB->quote("int", "text")." ".
1070  " AND area.target = ".$ilDB->quote("il__mob_".$a_id, "text");
1071  $us_set = $ilDB->query($q);
1072  while($us_rec = $ilDB->fetchAssoc($us_set))
1073  {
1074  $ret[] = array("type" => "map",
1075  "id" => $us_rec["mob_id"]);
1076  }
1077 
1078  // get usages in personal clipboards
1079  $users = ilObjUser::_getUsersForClipboadObject("mob", $a_id);
1080  foreach ($users as $user)
1081  {
1082  $ret[] = array("type" => "clip",
1083  "id" => $user);
1084  }
1085 
1086  return $ret;
1087  }
1088 
1092  function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false)
1093  {
1094  if(is_int(strpos($a_usage["type"], ":")))
1095  {
1096  $us_arr = explode(":", $a_usage["type"]);
1097  $type = $us_arr[1];
1098  $cont_type = $us_arr[0];
1099  }
1100  else
1101  {
1102  $type = $a_usage["type"];
1103  }
1104 
1105  $id = $a_usage["id"];
1106  $obj_id = false;
1107 
1108  switch($type)
1109  {
1110  case "html": // "old" category pages
1111  if ($cont_type == "cat")
1112  {
1113  $obj_id = $id;
1114  }
1115  // Test InfoScreen Text
1116  if ($cont_type == "tst")
1117  {
1118  $obj_id = $id;
1119  //var_dump($qinfo);
1120  }
1121  // Question Pool *Question* Text
1122  if ($cont_type == "qpl")
1123  {
1124  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
1126  if ($qinfo["original_id"] > 0)
1127  {
1128  include_once("./Modules/Test/classes/class.ilObjTest.php");
1129  $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test
1130  }
1131  else
1132  {
1133  $obj_id = $qinfo["obj_fi"]; // usage in pool
1134  }
1135  }
1136 
1137  // Forum
1138  if ($cont_type == "frm")
1139  {
1140  $post_pk = $a_usage['id'];
1141  include_once 'Modules/Forum/classes/class.ilForumPost.php';
1142  include_once 'Modules/Forum/classes/class.ilForum.php';
1143  $oPost = new ilForumPost($post_pk);
1144  $frm_pk = $oPost->getForumId();
1145 
1146  $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
1147  }
1148 
1149  if ($cont_type == 'frm~')
1150  {
1151  $obj_id = $a_usage['id'];
1152  }
1153 
1154  break;
1155 
1156  case "pg":
1157 
1158  // Question Pool Question Pages
1159  if ($cont_type == "qpl")
1160  {
1161  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
1163  if ($qinfo["original_id"] > 0)
1164  {
1165  include_once("./Modules/Test/classes/class.ilObjTest.php");
1166  $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test
1167  }
1168  else
1169  {
1170  $obj_id = $qinfo["obj_fi"]; // usage in pool
1171  }
1172  }
1173 
1174  // learning modules
1175  if ($cont_type == "lm" || $cont_type == "dbk")
1176  {
1177  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1178  $obj_id = ilLMObject::_lookupContObjID($id);
1179  }
1180 
1181  // glossary definition
1182  if ($cont_type == "gdf")
1183  {
1184  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
1185  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1187  $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id);
1188  }
1189 
1190  // wiki page
1191  if ($cont_type == 'wpg')
1192  {
1193  include_once 'Modules/Wiki/classes/class.ilWikiPage.php';
1195  }
1196 
1197  // sahs page
1198  if ($cont_type == 'sahs')
1199  {
1200  // can this implementation be used for other content types, too?
1201  include_once('./Services/COPage/classes/class.ilPageObject.php');
1202  $obj_id = ilPageObject::lookupParentId($id, 'sahs');
1203  }
1204 
1205  // repository pages
1206  if (in_array($cont_type, array("crs", "grp", "cat", "fold", "root")))
1207  {
1208  $obj_id = $id;
1209  }
1210 
1211  if($cont_type == 'prtf')
1212  {
1213  include_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
1215  }
1216 
1217  if($cont_type == 'blp')
1218  {
1219  include_once('./Services/COPage/classes/class.ilPageObject.php');
1220  $obj_id = ilPageObject::lookupParentId($id, 'blp');
1221  }
1222  break;
1223 
1224  // Media Pool
1225  case "mep":
1226  $obj_id = $id;
1227  break;
1228 
1229  // News Context Object (e.g. MediaCast)
1230  case "news":
1231  include_once("./Services/News/classes/class.ilNewsItem.php");
1233  break;
1234  }
1235 
1236  return $obj_id;
1237  }
1238 
1246  function _resizeImage($a_file, $a_width, $a_height, $a_constrain_prop = false)
1247  {
1248  $file_path = pathinfo($a_file);
1249  $location = substr($file_path["basename"],0,strlen($file_path["basename"]) -
1250  strlen($file_path["extension"]) - 1)."_".
1251  $a_width."_".
1252  $a_height.".".$file_path["extension"];
1253  $target_file = $file_path["dirname"]."/".
1254  $location;
1255  ilUtil::resizeImage($a_file, $target_file,
1256  (int) $a_width, (int) $a_height, $a_constrain_prop);
1257 
1258  return $location;
1259  }
1260 
1268  static function getMimeType ($a_file)
1269  {
1270  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
1271  $mime = ilMimeTypeUtil::getMimeType($a_file);
1272  return $mime;
1273 /*
1274  // check if mimetype detection enabled in php.ini
1275  $set = ini_get("mime_magic.magicfile");
1276  // get mimetype
1277  if ($set <> "")
1278  {
1279  $mime = @mime_content_type($a_file);
1280  }
1281 
1282  // some php installations return always
1283  // text/plain, so we make our own detection in this case, too
1284  if (empty($mime) || $mime == "text/plain")
1285  {
1286  $path = pathinfo($a_file);
1287  $ext = ".".strtolower($path["extension"]);
1288 
1289  $types_map = ilObjMediaObject::getExt2MimeMap();
1290  $mime = $types_map[$ext];
1291  }
1292 
1293  // set default if mimetype detection failed or not possible (e.g. remote file)
1294  if (empty($mime))
1295  {
1296  $mime = "application/octet-stream";
1297  }
1298 
1299  return $mime;
1300 */
1301  }
1302 
1306  static function _determineWidthHeight($a_def_width, $a_def_height, $a_format, $a_type,
1307  $a_file, $a_reference, $a_constrain_proportions, $a_use_original,
1308  $a_user_width, $a_user_height)
1309  {
1310  global $lng;
1311 
1312  // determine width and height of known image types
1313  $width = $a_def_width;
1314  $height = $a_def_height;
1315  $info = "";
1316 
1317  if ($a_format == "audio/mpeg")
1318  {
1319  $width = 300;
1320  $height = 20;
1321  }
1322 
1323  if (ilUtil::deducibleSize($a_format))
1324  {
1325  if ($a_type == "File")
1326  {
1327  $size = @getimagesize($a_file);
1328  }
1329  else
1330  {
1331  $size = @getimagesize($a_reference);
1332  }
1333  }
1334 
1335  if ($a_use_original)
1336  {
1337  if ($size[0] > 0 && $size[1] > 0)
1338  {
1339  $width = $size[0];
1340  $height = $size[1];
1341  }
1342  else
1343  {
1344  $info = $lng->txt("cont_could_not_determine_resource_size");
1345  }
1346  }
1347  else
1348  {
1349  $w = (int) $a_user_width;
1350  $h = (int) $a_user_height;
1351  $width = $w;
1352  $height = $h;
1353 //echo "<br>C-$width-$height-";
1354  if (ilUtil::deducibleSize($a_format) && $a_constrain_proportions)
1355  {
1356  if ($size[0] > 0 && $size[1] > 0)
1357  {
1358  if ($w > 0)
1359  {
1360  $wr = $size[0] / $w;
1361  }
1362  if ($h > 0)
1363  {
1364  $hr = $size[1] / $h;
1365  }
1366 //echo "<br>+".$wr."+".$size[0]."+".$w."+";
1367 //echo "<br>+".$hr."+".$size[1]."+".$h."+";
1368  $r = max($wr, $hr);
1369  if ($r > 0)
1370  {
1371  $width = (int) ($size[0]/$r);
1372  $height = (int) ($size[1]/$r);
1373  }
1374  }
1375  }
1376 //echo "<br>D-$width-$height-";
1377  }
1378 //echo "<br>E-$width-$height-";
1379  return array("width" => $width, "height" => $height, "info" => $info);
1380  }
1381 
1385  function getExt2MimeMap()
1386  {
1387  $types_map = array (
1388  '.a' => 'application/octet-stream',
1389  '.ai' => 'application/postscript',
1390  '.aif' => 'audio/x-aiff',
1391  '.aifc' => 'audio/x-aiff',
1392  '.aiff' => 'audio/x-aiff',
1393  '.asd' => 'application/astound',
1394  '.asf' => 'video/x-ms-asf',
1395  '.asn' => 'application/astound',
1396  '.asx' => 'video/x-ms-asf',
1397  '.au' => 'audio/basic',
1398  '.avi' => 'video/x-msvideo',
1399  '.bat' => 'text/plain',
1400  '.bcpio' => 'application/x-bcpio',
1401  '.bin' => 'application/octet-stream',
1402  '.bmp' => 'image/x-ms-bmp',
1403  '.c' => 'text/plain',
1404  '.cdf' => 'application/x-cdf',
1405  '.class' => 'application/x-java-applet',
1406  '.com' => 'application/octet-stream',
1407  '.cpio' => 'application/x-cpio',
1408  '.csh' => 'application/x-csh',
1409  '.css' => 'text/css',
1410  '.csv' => 'text/comma-separated-values',
1411  '.dcr' => 'application/x-director',
1412  '.dir' => 'application/x-director',
1413  '.dll' => 'application/octet-stream',
1414  '.doc' => 'application/msword',
1415  '.dot' => 'application/msword',
1416  '.dvi' => 'application/x-dvi',
1417  '.dwg' => 'application/acad',
1418  '.dxf' => 'application/dxf',
1419  '.dxr' => 'application/x-director',
1420  '.eml' => 'message/rfc822',
1421  '.eps' => 'application/postscript',
1422  '.etx' => 'text/x-setext',
1423  '.exe' => 'application/octet-stream',
1424  '.flv' => 'video/x-flv',
1425  '.gif' => 'image/gif',
1426  '.gtar' => 'application/x-gtar',
1427  '.gz' => 'application/gzip',
1428  '.h' => 'text/plain',
1429  '.hdf' => 'application/x-hdf',
1430  '.htm' => 'text/html',
1431  '.html' => 'text/html',
1432  '.ief' => 'image/ief',
1433  '.iff' => 'image/iff',
1434  '.jar' => 'application/x-java-applet',
1435  '.jpe' => 'image/jpeg',
1436  '.jpeg' => 'image/jpeg',
1437  '.jpg' => 'image/jpeg',
1438  '.js' => 'application/x-javascript',
1439  '.ksh' => 'text/plain',
1440  '.latex' => 'application/x-latex',
1441  '.m1v' => 'video/mpeg',
1442  '.man' => 'application/x-troff-man',
1443  '.me' => 'application/x-troff-me',
1444  '.mht' => 'message/rfc822',
1445  '.mhtml' => 'message/rfc822',
1446  '.mid' => 'audio/x-midi',
1447  '.midi' => 'audio/x-midi',
1448  '.mif' => 'application/x-mif',
1449  '.mov' => 'video/quicktime',
1450  '.movie' => 'video/x-sgi-movie',
1451  '.mp2' => 'audio/mpeg',
1452  '.mp3' => 'audio/mpeg',
1453  '.mpa' => 'video/mpeg',
1454  '.mpe' => 'video/mpeg',
1455  '.mpeg' => 'video/mpeg',
1456  '.mpg' => 'video/mpeg',
1457  '.mp4' => 'video/mp4',
1458  '.mv4' => 'video/mp4',
1459  '.ms' => 'application/x-troff-ms',
1460  '.nc' => 'application/x-netcdf',
1461  '.nws' => 'message/rfc822',
1462  '.o' => 'application/octet-stream',
1463  '.ogg' => 'application/ogg',
1464  '.obj' => 'application/octet-stream',
1465  '.oda' => 'application/oda',
1466  '.p12' => 'application/x-pkcs12',
1467  '.p7c' => 'application/pkcs7-mime',
1468  '.pbm' => 'image/x-portable-bitmap',
1469  '.pdf' => 'application/pdf',
1470  '.pfx' => 'application/x-pkcs12',
1471  '.pgm' => 'image/x-portable-graymap',
1472  '.php' => 'application/x-httpd-php',
1473  '.phtml' => 'application/x-httpd-php',
1474  '.pl' => 'text/plain',
1475  '.png' => 'image/png',
1476  '.pnm' => 'image/x-portable-anymap',
1477  '.pot' => 'application/vnd.ms-powerpoint',
1478  '.ppa' => 'application/vnd.ms-powerpoint',
1479  '.ppm' => 'image/x-portable-pixmap',
1480  '.pps' => 'application/vnd.ms-powerpoint',
1481  '.ppt' => 'application/vnd.ms-powerpoint',
1482  '.ps' => 'application/postscript',
1483  '.psd' => 'image/psd',
1484  '.pwz' => 'application/vnd.ms-powerpoint',
1485  '.py' => 'text/x-python',
1486  '.pyc' => 'application/x-python-code',
1487  '.pyo' => 'application/x-python-code',
1488  '.qt' => 'video/quicktime',
1489  '.ra' => 'audio/x-pn-realaudio',
1490  '.ram' => 'application/x-pn-realaudio',
1491  '.ras' => 'image/x-cmu-raster',
1492  '.rdf' => 'application/xml',
1493  '.rgb' => 'image/x-rgb',
1494  '.roff' => 'application/x-troff',
1495  '.rpm' => 'audio/x-pn-realaudio-plugin',
1496  '.rtf' => 'application/rtf',
1497  '.rtx' => 'text/richtext',
1498  '.sgm' => 'text/x-sgml',
1499  '.sgml' => 'text/x-sgml',
1500  '.sh' => 'application/x-sh',
1501  '.shar' => 'application/x-shar',
1502  '.sit' => 'application/x-stuffit',
1503  '.snd' => 'audio/basic',
1504  '.so' => 'application/octet-stream',
1505  '.spc' => 'text/x-speech',
1506  '.src' => 'application/x-wais-source',
1507  '.sv4cpio'=> 'application/x-sv4cpio',
1508  '.sv4crc' => 'application/x-sv4crc',
1509  '.svg' => 'image/svg+xml',
1510  '.swf' => 'application/x-shockwave-flash',
1511  '.t' => 'application/x-troff',
1512  '.tar' => 'application/x-tar',
1513  '.talk' => 'text/x-speech',
1514  '.tbk' => 'application/toolbook',
1515  '.tcl' => 'application/x-tcl',
1516  '.tex' => 'application/x-tex',
1517  '.texi' => 'application/x-texinfo',
1518  '.texinfo'=> 'application/x-texinfo',
1519  '.tif' => 'image/tiff',
1520  '.tiff' => 'image/tiff',
1521  '.tr' => 'application/x-troff',
1522  '.tsv' => 'text/tab-separated-values',
1523  '.tsp' => 'application/dsptype',
1524  '.txt' => 'text/plain',
1525  '.ustar' => 'application',
1526  '.vcf' => 'text/x-vcard',
1527  '.vox' => 'audio/voxware',
1528  '.wav' => 'audio/x-wav',
1529  '.wax' => 'audio/x-ms-wax',
1530  '.wiz' => 'application/msword',
1531  '.wm' => 'video/x-ms-wm',
1532  '.wma' => 'audio/x-ms-wma',
1533  '.wmd' => 'video/x-ms-wmd',
1534  '.wml' => 'text/vnd.wap.wml',
1535  '.wmlc' => 'application/vnd.wap.wmlc',
1536  '.wmls' => 'text/vnd.wap.wmlscript',
1537  '.wmlsc' => 'application/vnd.wap.wmlscriptc',
1538  '.wmv' => 'video/x-ms-wmv',
1539  '.wmx' => 'video/x-ms-wmx',
1540  '.wmz' => 'video/x-ms-wmz',
1541  '.wvx' => 'video/x-ms-wvx',
1542  '.wrl' => 'x-world/x-vrml',
1543  '.xbm' => 'image/x-xbitmap',
1544  '.xla' => 'application/msexcel',
1545  '.xlb' => 'application/vnd.ms-excel',
1546  '.xls' => 'application/msexcel',
1547  '.xml' => 'text/xml',
1548  '.xpm' => 'image/x-xpixmap',
1549  '.xsl' => 'application/xml',
1550  '.xwd' => 'image/x-xwindowdump',
1551  '.zip' => 'application/zip');
1552 
1553  return $types_map;
1554  }
1555 
1560  static function _getSimpleMimeTypes()
1561  {
1562  return array("image/x-ms-bmp", "image/gif", "image/jpeg", "image/x-portable-bitmap",
1563  "image/png", "image/psd", "image/tiff", "application/pdf");
1564  }
1565 
1566  function getDataDirectory()
1567  {
1568  return ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1569  }
1570 
1577  static function _useAutoStartParameterOnly($a_loc, $a_format)
1578  {
1579  $lpath = pathinfo($a_loc);
1580  if ($lpath["extension"] == "mp3" && $a_format == "audio/mpeg")
1581  {
1582  return true;
1583  }
1584  if ($lpath["extension"] == "flv")
1585  {
1586  return true;
1587  }
1588  return false;
1589  }
1590 
1594  function &_saveTempFileAsMediaObject($name, $tmp_name, $upload = TRUE)
1595  {
1596  // create dummy object in db (we need an id)
1597  $media_object = new ilObjMediaObject();
1598  $media_object->setTitle($name);
1599  $media_object->setDescription("");
1600  $media_object->create();
1601 
1602  // determine and create mob directory, move uploaded file to directory
1603  $media_object->createDirectory();
1604  $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId());
1605 
1606  $media_item =& new ilMediaItem();
1607  $media_object->addMediaItem($media_item);
1608  $media_item->setPurpose("Standard");
1609 
1610  $file = $mob_dir."/".$name;
1611  if ($upload)
1612  {
1613  ilUtil::moveUploadedFile($tmp_name,$name, $file);
1614  }
1615  else
1616  {
1617  copy($tmp_name, $file);
1618  }
1619  // get mime type
1621  $location = $name;
1622  // set real meta and object data
1623  $media_item->setFormat($format);
1624  $media_item->setLocation($location);
1625  $media_item->setLocationType("LocalFile");
1626  $media_object->setTitle($name);
1627  $media_object->setDescription($format);
1628 
1629  if (ilUtil::deducibleSize($format))
1630  {
1631  $size = getimagesize($file);
1632  $media_item->setWidth($size[0]);
1633  $media_item->setHeight($size[1]);
1634  }
1635  $media_item->setHAlign("Left");
1636 
1637  ilUtil::renameExecutables($mob_dir);
1638  $media_object->update();
1639 
1640  return $media_object;
1641  }
1642 
1646  function uploadAdditionalFile($a_name, $tmp_name, $a_subdir = "")
1647  {
1648  $a_subdir = str_replace("..", "", $a_subdir);
1649  $dir = $mob_dir = ilObjMediaObject::_getDirectory($this->getId());
1650  if ($a_subdir != "")
1651  {
1652  $dir.= "/".$a_subdir;
1653  }
1655  ilUtil::moveUploadedFile($tmp_name, $a_name, $dir."/".$a_name);
1656  ilUtil::renameExecutables($mob_dir);
1657  }
1658 
1662  function makeThumbnail($a_file, $a_thumbname, $a_format = "png",
1663  $a_size = "80")
1664  {
1665  $m_dir = ilObjMediaObject::_getDirectory($this->getId());
1668  ilUtil::convertImage($m_dir."/".$a_file,
1669  $t_dir."/".$a_thumbname, $a_format, $a_size);
1670  }
1671 
1678  static function getThumbnailPath($a_mob_id, $a_thumbname)
1679  {
1680  $t_dir = ilObjMediaObject::_getThumbnailDirectory($a_mob_id);
1681  return $t_dir."/".$a_thumbname;
1682  }
1683 
1684 
1688  function removeAdditionalFile($a_file)
1689  {
1690  $file = str_replace("..", "", $a_file);
1692  if (is_file($file))
1693  {
1694  unlink($file);
1695  }
1696  }
1697 
1698 
1702  function getLinkedMediaObjects($a_ignore = "")
1703  {
1704  $linked = array();
1705 
1706  if (!is_array($a_ignore))
1707  {
1708  $a_ignore = array();
1709  }
1710 
1711  // get linked media objects (map areas)
1712  $med_items = $this->getMediaItems();
1713 
1714  foreach($med_items as $med_item)
1715  {
1716  $int_links = ilMapArea::_getIntLinks($med_item->getId());
1717  foreach ($int_links as $k => $int_link)
1718  {
1719  if ($int_link["Type"] == "MediaObject")
1720  {
1721  include_once("./Services/COPage/classes/class.ilInternalLink.php");
1722  $l_id = ilInternalLink::_extractObjIdOfTarget($int_link["Target"]);
1723  if (ilObject::_exists($l_id))
1724  {
1725  if (!in_array($l_id, $linked) &&
1726  !in_array($l_id, $a_ignore))
1727  {
1728  $linked[] = $l_id;
1729  }
1730  }
1731  }
1732  }
1733  }
1734 //var_dump($linked);
1735  return $linked;
1736  }
1737 
1741  static function getRestrictedFileTypes()
1742  {
1743  $mset = new ilSetting("mobs");
1744  $str = $mset->get("restricted_file_types");
1745  $types = explode(",", $str);
1746  $suffixes = array();
1747  if (count($types) > 0)
1748  {
1749  foreach ($types as $k => $t)
1750  {
1751  if (($s = strtolower(trim($t))) != "")
1752  {
1753  $suffixes[] = $s;
1754  }
1755  }
1756  }
1757  return $suffixes;
1758  }
1759 
1763  function duplicate()
1764  {
1765  $new_obj = new ilObjMediaObject();
1766  $new_obj->setTitle($this->getTitle());
1767  $new_obj->setDescription($this->getDescription());
1768 
1769  // media items
1770  foreach($this->getMediaItems() as $key => $val)
1771  {
1772  $new_obj->addMediaItem($val);
1773  }
1774 
1775  $new_obj->create(false, true);
1776 
1777  // files
1778  $new_obj->createDirectory();
1779  self::_createThumbnailDirectory($new_obj->getId());
1781  ilObjMediaObject::_getDirectory($new_obj->getId()));
1782  ilUtil::rCopy(ilObjMediaObject::_getThumbnailDirectory($this->getId()),
1783  ilObjMediaObject::_getThumbnailDirectory($new_obj->getId()));
1784 
1785  // meta data
1786  include_once("Services/MetaData/classes/class.ilMD.php");
1787  $md = new ilMD(0, $this->getId(), "mob");
1788  $new_md = $md->cloneMD(0, $new_obj->getId(), "mob");
1789 
1790  return $new_obj;
1791  }
1792 
1793 
1794 }
1795 ?>