4 define (
"IL_MODE_ALIAS", 1);
5 define (
"IL_MODE_OUTPUT", 2);
6 define (
"IL_MODE_FULL", 3);
8 require_once(
"./Services/MediaObjects/classes/class.ilMediaItem.php");
9 include_once
"./Services/Object/classes/class.ilObject.php";
40 $this->is_alias =
false;
41 $this->media_items = array();
42 $this->contains_int_link =
false;
49 $this->ilias->raiseError(
"Operation ilObjMedia::setRefId() not allowed.",$this->ilias->error_obj->FATAL);
59 $this->ilias->raiseError(
"Operation ilObjMedia::putInTree() not allowed.",$this->ilias->error_obj->FATAL);
64 $this->ilias->raiseError(
"Operation ilObjMedia::createReference() not allowed.",$this->ilias->error_obj->FATAL);
88 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
89 if (is_int(strpos($a_id,
"_")))
102 if (!($this->
getId() > 0))
109 if (count($usages) == 0)
159 include_once
'Services/MetaData/classes/class.ilMD.php';
167 $md_gen = $md->getGeneral();
169 if (is_object($md_gen))
172 $this->
setTitle($md_gen->getTitle());
174 foreach($md_gen->getDescriptionIds() as
$id)
176 $md_des = $md_gen->getDescription(
$id);
195 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
200 $md_creator->setTitle($this->
getTitle());
201 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
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();
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");
221 $md_gen =& $md->getGeneral();
222 $md_gen->setTitle($this->
getTitle());
225 $md_des_ids =& $md_gen->getDescriptionIds();
226 if (count($md_des_ids) > 0)
228 $md_des =& $md_gen->getDescription($md_des_ids[0]);
242 include_once(
'Services/MetaData/classes/class.ilMD.php');
255 $this->media_items[] = $a_item;
277 foreach ($this->media_items as $media_item)
279 if($media_item->getPurpose() == $a_purpose)
293 foreach ($this->media_items as $key => $media_item)
295 if($media_item->getPurpose() == $a_purpose)
297 unset($this->media_items[$key]);
303 foreach ($this->media_items as $media_item)
306 $media_item->setMobId($this->
getId());
307 $media_item->setNr($i);
318 $this->media_items = array();
324 for($i=0; $i<count($this->media_items); $i++)
326 if($this->media_items[$i]->getPurpose() == $a_purpose)
390 $this->is_alias = $a_is_alias;
400 return $this->origin_id = $a_id;
425 $this->import_id = $a_id;
431 function create($a_create_meta_data =
false, $a_save_media_items =
true)
435 if (!$a_create_meta_data)
440 if ($a_save_media_items)
446 $item->setMobId($this->
getId());
473 if (is_object($item))
475 $item->setMobId($this->
getId());
477 if ($item->getLocationType() ==
"Reference")
479 $item->extractUrlParameters();
534 $a_web =
true, $a_purpose =
"")
536 if ($a_purpose ==
"")
538 $a_purpose =
"Standard";
551 return $path.
"/data/".CLIENT_ID.
"/mobs/mm_".$a_mob_id.
"/".
$location;
579 $a_subdir = str_replace(
"..",
"", $a_subdir);
583 $dir.=
"/".$a_subdir;
590 foreach ($entries as $e)
592 if (is_file($dir.
"/".$e[
"entry"]) && $e[
"entry"] !=
"." && $e[
"entry"] !=
"..")
594 $files[] = $e[
"entry"];
614 $xml =
"<MediaObject>";
615 $xml .=
"<MediaAlias OriginId=\"il__mob_".$this->getId().
"\"/>";
620 $xml .=
"<MediaAliasItem Purpose=\"".$item->getPurpose().
"\">";
623 $width = ($item->getWidth() !=
"")
624 ?
"Width=\"".$item->getWidth().
"\""
626 $height = ($item->getHeight() !=
"")
627 ?
"Height=\"".$item->getHeight().
"\""
629 $halign = ($item->getHAlign() !=
"")
630 ?
"HorizontalAlign=\"".$item->getHAlign().
"\""
632 $xml .=
"<Layout $width $height $halign />";
635 if ($item->getCaption() !=
"")
637 $xml .=
"<Caption Align=\"bottom\">".
638 str_replace(
"&",
"&", $item->getCaption()).
"</Caption>";
642 if ($item->getTextRepresentation() !=
"")
644 $xml .=
"<TextRepresentation>".
645 str_replace(
"&",
"&", $item->getTextRepresentation()).
"</TextRepresentation>";
649 $parameters = $item->getParameters();
650 foreach ($parameters as $name => $value)
652 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
654 $xml .= $item->getMapAreasXML();
655 $xml .=
"</MediaAliasItem>";
664 $xml =
"<MediaObject Id=\"il__mob_".$this->getId().
"\">";
671 $xml .=
"<MediaItem Purpose=\"".$item->getPurpose().
"\">";
674 $xml.=
"<Location Type=\"".$item->getLocationType().
"\">".
675 $this->
handleAmps($item->getLocation()).
"</Location>";
678 $xml.=
"<Format>".$item->getFormat().
"</Format>";
681 $width = ($item->getWidth() !=
"")
682 ?
"Width=\"".$item->getWidth().
"\""
684 $height = ($item->getHeight() !=
"")
685 ?
"Height=\"".$item->getHeight().
"\""
687 $halign = ($item->getHAlign() !=
"")
688 ?
"HorizontalAlign=\"".$item->getHAlign().
"\""
690 $xml .=
"<Layout $width $height $halign />";
693 if ($item->getCaption() !=
"")
695 $xml .=
"<Caption Align=\"bottom\">".
696 str_replace(
"&",
"&", $item->getCaption()).
"</Caption>";
700 if ($item->getTextRepresentation() !=
"")
702 $xml .=
"<TextRepresentation>".
703 str_replace(
"&",
"&", $item->getTextRepresentation()).
"</TextRepresentation>";
707 $parameters = $item->getParameters();
708 foreach ($parameters as $name => $value)
710 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
712 $xml .= $item->getMapAreasXML();
713 $xml .=
"</MediaItem>";
721 $xml =
"<MediaObject>";
724 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
726 $md2xml->setExportMode(
true);
727 $md2xml->startExport();
728 $xml.= $md2xml->getXML();
736 $xml .=
"<MediaItem Purpose=\"".$item->getPurpose().
"\">";
739 $xml.=
"<Location Type=\"".$item->getLocationType().
"\">".
740 $this->
handleAmps($item->getLocation()).
"</Location>";
743 $xml.=
"<Format>".$item->getFormat().
"</Format>";
746 $width = ($item->getWidth() !=
"")
747 ?
"Width=\"".$item->getWidth().
"\""
749 $height = ($item->getHeight() !=
"")
750 ?
"Height=\"".$item->getHeight().
"\""
752 $halign = ($item->getHAlign() !=
"")
753 ?
"HorizontalAlign=\"".$item->getHAlign().
"\""
755 $xml .=
"<Layout $width $height $halign />";
758 if ($item->getCaption() !=
"")
760 $xml .=
"<Caption Align=\"bottom\">".
761 str_replace(
"&",
"&", $item->getCaption()).
"</Caption>";
765 if ($item->getTextRepresentation() !=
"")
767 $xml .=
"<TextRepresentation>".
768 str_replace(
"&",
"&", $item->getTextRepresentation()).
"</TextRepresentation>";
772 $parameters = $item->getParameters();
773 foreach ($parameters as $name => $value)
775 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
777 $xml .= $item->getMapAreasXML(
true, $a_inst);
778 $xml .=
"</MediaItem>";
782 $xml .=
"</MediaObject>";
791 $a_str = str_replace(
"&",
"&", $a_str);
792 $a_str = str_replace(
"&",
"&", $a_str);
814 $subdir =
"il_".IL_INST_ID.
"_mob_".$this->
getId();
824 $subdir =
"il_".IL_INST_ID.
"_mob_".$this->
getId();
825 $a_target_dir = $a_target_dir.
"/objects/".$subdir;
827 $tpl =
new ilTemplate(
"tpl.fullscreen.html",
true,
true,
"Modules/LearningModule");
828 $tpl->setCurrentBlock(
"ilMedia");
836 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
838 require_once(
"./Services/COPage/classes/class.ilPageObject.php");
843 $xml.= $pg_obj->getMediaAliasElement($this->
getId());
850 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
851 $args = array(
'/_xml' => $xml,
'/_xsl' => $xsl );
858 $params = array (
'mode' =>
"fullscreen",
'enlarge_path' => $enlarge_path,
859 'link_params' =>
"ref_id=".
$_GET[
"ref_id"],
'fullscreen_link' =>
"",
860 'ref_id' =>
$_GET[
"ref_id"],
'webspace_path' => $wb_path);
861 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args, $params);
866 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
867 $tpl->setVariable(
"LOCATION_CONTENT_STYLESHEET",
"../../css/style.css");
868 $tpl->setVariable(
"LOCATION_STYLESHEET",
"../../css/system.css");
869 $tpl->setVariable(
"MEDIA_CONTENT", $output);
870 $output =
$tpl->get();
872 $output = preg_replace(
"/mobs\/mm_(\d+)\/([^\"]+)/i",
"$2",$output);
873 $output = preg_replace(
"/\.\/Services\/MediaObjects\/flash_mp3_player/i",
"../../players",$output);
875 $output = preg_replace(
"/file=..\/..\/..\//i",
"file=../objects/".$subdir.
"/",$output);
877 fwrite(fopen($a_target_dir.
'/fullscreen.html',
'w'), $output );
882 if ($a_tag ==
"Identifier" && $a_param ==
"Entry")
903 $this->contains_int_link = $a_contains_link;
922 $q =
"DELETE FROM mob_usage WHERE usage_type = ".
923 $ilDB->quote($a_type,
"text").
924 " AND usage_id= ".$ilDB->quote($a_id,
"integer").
925 " AND usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr,
"integer");
926 $ilDB->manipulate($q);
936 $q =
"SELECT * FROM mob_usage WHERE ".
937 "usage_type = ".$ilDB->quote($a_type,
"text").
" AND ".
938 "usage_id = ".$ilDB->quote($a_id,
"integer").
" AND ".
939 "usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr,
"integer");
941 $mob_set = $ilDB->query($q);
942 while($mob_rec = $ilDB->fetchAssoc($mob_set))
946 $mobs[$mob_rec[
"id"]] = $mob_rec[
"id"];
956 function _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr = 0)
960 $q =
"DELETE FROM mob_usage WHERE ".
961 " id = ".$ilDB->quote((
int) $a_mob_id,
"integer").
" AND ".
962 " usage_type = ".$ilDB->quote($a_type,
"text").
" AND ".
963 " usage_id = ".$ilDB->quote((
int) $a_id,
"integer").
" AND ".
964 " usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr,
"integer");
965 $ilDB->manipulate($q);
966 $q =
"INSERT INTO mob_usage (id, usage_type, usage_id, usage_hist_nr) VALUES".
967 " (".$ilDB->quote((
int) $a_mob_id,
"integer").
",".
968 $ilDB->quote($a_type,
"text").
",".
969 $ilDB->quote((
int) $a_id,
"integer").
",".
970 $ilDB->quote((
int) $a_usage_hist_nr,
"integer").
")";
971 $ilDB->manipulate($q);
981 $q =
"DELETE FROM mob_usage WHERE ".
982 " id = ".$ilDB->quote((
int) $a_mob_id,
"integer").
" AND ".
983 " usage_type = ".$ilDB->quote($a_type,
"text").
" AND ".
984 " usage_id = ".$ilDB->quote((
int) $a_id,
"integer").
" AND ".
985 " usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr,
"integer");
986 $ilDB->manipulate($q);
1007 if ($a_include_history)
1009 $hist_str =
", usage_hist_nr";
1013 $q =
"SELECT DISTINCT usage_type, usage_id".$hist_str.
" FROM mob_usage WHERE id = ".
1014 $ilDB->quote($a_id,
"integer");
1016 if (!$a_include_history)
1018 $q.=
" AND usage_hist_nr = ".$ilDB->quote(0,
"integer");
1021 $us_set = $ilDB->query($q);
1023 while($us_rec = $ilDB->fetchAssoc($us_set))
1026 if(is_int(strpos($us_rec[
"usage_type"],
":")))
1028 $us_arr = explode(
":", $us_rec[
"usage_type"]);
1037 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
1046 $ret[] = array(
"type" => $us_rec[
"usage_type"],
1047 "id" => $us_rec[
"usage_id"],
1048 "hist_nr" => $us_rec[
"usage_hist_nr"]);
1053 $q =
"SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = ".
1054 $ilDB->quote($a_id,
"integer").
" AND mep_item.type = ".$ilDB->quote(
"mob",
"text");
1055 $us_set = $ilDB->query($q);
1056 while($us_rec = $ilDB->fetchAssoc($us_set))
1058 $ret[] = array(
"type" =>
"mep",
1059 "id" => $us_rec[
"mep_id"]);
1063 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1065 foreach($news_usages as $nu)
1072 $q =
"SELECT DISTINCT mob_id FROM media_item it, map_area area ".
1073 " WHERE area.item_id = it.id ".
1074 " AND area.link_type = ".$ilDB->quote(
"int",
"text").
" ".
1075 " AND area.target = ".$ilDB->quote(
"il__mob_".$a_id,
"text");
1076 $us_set = $ilDB->query($q);
1077 while($us_rec = $ilDB->fetchAssoc($us_set))
1079 $ret[] = array(
"type" =>
"map",
1080 "id" => $us_rec[
"mob_id"]);
1085 foreach ($users as $user)
1087 $ret[] = array(
"type" =>
"clip",
1099 if(is_int(strpos($a_usage[
"type"],
":")))
1101 $us_arr = explode(
":", $a_usage[
"type"]);
1103 $cont_type = $us_arr[0];
1107 $type = $a_usage[
"type"];
1110 $id = $a_usage[
"id"];
1116 if ($cont_type ==
"cat")
1121 if ($cont_type ==
"tst" || $cont_type ==
"svy")
1127 if ($cont_type ==
"qpl")
1129 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
1131 if ($qinfo[
"original_id"] > 0)
1133 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
1138 $obj_id = $qinfo[
"obj_fi"];
1143 if ($cont_type ==
"spl")
1145 include_once(
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php");
1149 if ($quest->getOriginalId() > 0)
1151 $obj_id = $quest->getSurveyId();
1155 $obj_id = $quest->getObjId();
1162 if ($cont_type ==
"frm")
1164 $post_pk = $a_usage[
'id'];
1165 include_once
'Modules/Forum/classes/class.ilForumPost.php';
1166 include_once
'Modules/Forum/classes/class.ilForum.php';
1168 $frm_pk = $oPost->getForumId();
1173 if ($cont_type ==
'frm~')
1175 $obj_id = $a_usage[
'id'];
1178 if ($cont_type ==
"dcl")
1188 if ($cont_type ==
"qpl")
1190 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
1192 if ($qinfo[
"original_id"] > 0)
1194 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
1199 $obj_id = $qinfo[
"obj_fi"];
1204 if ($cont_type ==
"lm" || $cont_type ==
"dbk")
1206 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1211 if ($cont_type ==
"gdf")
1213 include_once(
"./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
1214 include_once(
"./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1220 if ($cont_type ==
'wpg')
1222 include_once
'Modules/Wiki/classes/class.ilWikiPage.php';
1227 if ($cont_type ==
'sahs')
1230 include_once(
'./Services/COPage/classes/class.ilPageObject.php');
1235 if (in_array($cont_type, array(
"crs",
"grp",
"cat",
"fold",
"root")))
1240 if($cont_type ==
'prtf')
1242 include_once
"Services/Portfolio/classes/class.ilPortfolioPage.php";
1246 if($cont_type ==
'blp')
1248 include_once(
'./Services/COPage/classes/class.ilPageObject.php');
1252 if($cont_type ==
'impr')
1266 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1281 function _resizeImage($a_file, $a_width, $a_height, $a_constrain_prop =
false)
1283 $file_path = pathinfo($a_file);
1284 $location = substr($file_path[
"basename"],0,strlen($file_path[
"basename"]) -
1285 strlen($file_path[
"extension"]) - 1).
"_".
1287 $a_height.
".".$file_path[
"extension"];
1288 $target_file = $file_path[
"dirname"].
"/".
1291 (
int) $a_width, (
int) $a_height, $a_constrain_prop);
1305 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
1314 $a_file, $a_reference, $a_constrain_proportions, $a_use_original,
1315 $a_user_width, $a_user_height)
1320 $width = $a_def_width;
1321 $height = $a_def_height;
1324 if ($a_format ==
"audio/mpeg")
1332 if ($a_type ==
"File")
1334 $size = @getimagesize($a_file);
1338 $size = @getimagesize($a_reference);
1342 if ($a_use_original)
1351 $info = $lng->txt(
"cont_could_not_determine_resource_size");
1356 $w = (int) $a_user_width;
1357 $h = (int) $a_user_height;
1367 $wr =
$size[0] / $w;
1371 $hr =
$size[1] / $h;
1378 $width = (int) (
$size[0]/$r);
1379 $height = (int) (
$size[1]/$r);
1386 return array(
"width" => $width,
"height" => $height,
"info" => $info);
1395 return array(
"image/x-ms-bmp",
"image/gif",
"image/jpeg",
"image/x-portable-bitmap",
1396 "image/png",
"image/psd",
"image/tiff",
"application/pdf");
1412 $lpath = pathinfo($a_loc);
1413 if ($lpath[
"extension"] ==
"mp3" && $a_format ==
"audio/mpeg")
1417 if ($lpath[
"extension"] ==
"flv")
1431 $media_object->setTitle($name);
1432 $media_object->setDescription(
"");
1433 $media_object->create();
1436 $media_object->createDirectory();
1440 $media_object->addMediaItem($media_item);
1441 $media_item->setPurpose(
"Standard");
1443 $file = $mob_dir.
"/".$name;
1450 copy($tmp_name,
$file);
1456 $media_item->setFormat($format);
1458 $media_item->setLocationType(
"LocalFile");
1459 $media_object->setTitle($name);
1460 $media_object->setDescription($format);
1465 $media_item->setWidth(
$size[0]);
1466 $media_item->setHeight(
$size[1]);
1468 $media_item->setHAlign(
"Left");
1471 $media_object->update();
1473 return $media_object;
1481 $a_subdir = str_replace(
"..",
"", $a_subdir);
1483 if ($a_subdir !=
"")
1485 $dir.=
"/".$a_subdir;
1502 $t_dir.
"/".$a_thumbname, $a_format, $a_size);
1514 return $t_dir.
"/".$a_thumbname;
1523 $file = str_replace(
"..",
"", $a_file);
1539 if (!is_array($a_ignore))
1541 $a_ignore = array();
1547 foreach($med_items as $med_item)
1550 foreach ($int_links as $k => $int_link)
1552 if ($int_link[
"Type"] ==
"MediaObject")
1554 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
1558 if (!in_array($l_id, $linked) &&
1559 !in_array($l_id, $a_ignore))
1577 $str = $mset->get(
"restricted_file_types");
1578 $types = explode(
",", $str);
1579 $suffixes = array();
1580 if (count($types) > 0)
1582 foreach ($types as $k =>
$t)
1584 if (($s = strtolower(trim(
$t))) !=
"")
1599 $new_obj->setTitle($this->
getTitle());
1605 $new_obj->addMediaItem($val);
1608 $new_obj->create(
false,
true);
1611 $new_obj->createDirectory();
1619 include_once(
"Services/MetaData/classes/class.ilMD.php");
1620 $md =
new ilMD(0, $this->
getId(),
"mob");
1621 $new_md = $md->cloneMD(0, $new_obj->getId(),
"mob");
1634 $pi = pathinfo($a_prevpic[
"name"]);
1635 $ext = $pi[
"extension"];
1636 if (in_array($ext, array(
"jpg",
"jpeg",
"png")))
1652 if ($item->getLocationType() ==
"LocalFile" &&
1653 is_int(strpos($item->getFormat(),
"image/")))
1657 $item->getLocation();
1681 $ppics = array(
"mob_vpreview.jpg",
1682 "mob_vpreview.jpeg",
1683 "mob_vpreview.png");
1684 foreach ($ppics as $p)
1686 if (is_file($dir.
"/".$p))
1688 if ($a_filename_only)