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";
52 $this->
user = $DIC->user();
53 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
54 $this->lng = $DIC->language();
55 $this->is_alias =
false;
56 $this->media_items =
array();
57 $this->contains_int_link =
false;
59 parent::__construct($a_id,
false);
64 $this->
ilias->raiseError(
"Operation ilObjMedia::setRefId() not allowed.", $this->
ilias->error_obj->FATAL);
74 $this->
ilias->raiseError(
"Operation ilObjMedia::putInTree() not allowed.", $this->
ilias->error_obj->FATAL);
79 $this->
ilias->raiseError(
"Operation ilObjMedia::createReference() not allowed.", $this->
ilias->error_obj->FATAL);
84 parent::setTitle($a_title);
89 return parent::getTitle();
103 $ilDB = $DIC->database();
105 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
106 if (is_int(strpos($a_id,
"_"))) {
119 public function delete()
122 $mob_logger->debug(
"ilObjMediaObject: Delete called for media object ID '" . $this->
getId() .
"'.");
124 if (!($this->
getId() > 0)) {
130 $mob_logger->debug(
"ilObjMediaObject: ... Found " . count($usages) .
" usages.");
132 if (count($usages) == 0) {
147 self::handleQuotaUpdate($this);
152 $mob_logger->debug(
"ilObjMediaObject: ... deleted.");
154 foreach ($usages as $u) {
155 $mob_logger->debug(
"ilObjMediaObject: ... usage type:" . $u[
"type"] .
157 ", lang:" . $u[
"lang"] .
158 ", hist_nr:" . $u[
"hist_nr"] .
".");
160 $mob_logger->debug(
"ilObjMediaObject: ... not deleted.");
171 return parent::getDescription();
179 parent::setDescription($a_description);
195 include_once
'Services/MetaData/classes/class.ilMD.php';
197 switch ($a_element) {
202 $md_gen = $md->getGeneral();
204 if (is_object($md_gen)) {
206 $this->
setTitle($md_gen->getTitle());
208 foreach ($md_gen->getDescriptionIds() as
$id) {
209 $md_des = $md_gen->getDescription(
$id);
228 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
233 $md_creator->setTitle($this->
getTitle());
234 $md_creator->setTitleLanguage(
$ilUser->getPref(
'language'));
236 $md_creator->setDescriptionLanguage(
$ilUser->getPref(
'language'));
237 $md_creator->setKeywordLanguage(
$ilUser->getPref(
'language'));
238 $md_creator->setLanguage(
$ilUser->getPref(
'language'));
239 $md_creator->create();
249 include_once(
"Services/MetaData/classes/class.ilMD.php");
250 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
251 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
254 $md_gen = $md->getGeneral();
255 $md_gen->setTitle($this->
getTitle());
258 $md_des_ids = $md_gen->getDescriptionIds();
259 if (count($md_des_ids) > 0) {
260 $md_des = $md_gen->getDescription($md_des_ids[0]);
273 include_once(
'Services/MetaData/classes/class.ilMD.php');
286 $this->media_items[] = $a_item;
308 foreach ($this->media_items as $media_item) {
309 if ($media_item->getPurpose() == $a_purpose) {
322 foreach ($this->media_items as
$key => $media_item) {
323 if ($media_item->getPurpose() == $a_purpose) {
324 unset($this->media_items[
$key]);
330 foreach ($this->media_items as $media_item) {
332 $media_item->setMobId($this->
getId());
333 $media_item->setNr(
$i);
344 $this->media_items =
array();
350 for (
$i=0;
$i<count($this->media_items);
$i++) {
351 if ($this->media_items[
$i]->getPurpose() == $a_purpose) {
411 $this->is_alias = $a_is_alias;
421 return $this->origin_id = $a_id;
446 $this->import_id = $a_id;
452 public function create($a_create_meta_data =
false, $a_save_media_items =
true)
456 if (!$a_create_meta_data) {
460 if ($a_save_media_items) {
464 $item->setMobId($this->
getId());
470 self::handleQuotaUpdate($this);
473 $ilAppEventHandler->raise(
474 'Services/MediaObjects',
476 array(
'object' => $this,
478 'obj_id' => $this->
getId())
501 if (is_object($item)) {
502 $item->setMobId($this->
getId());
504 if ($item->getLocationType() ==
"Reference") {
505 $item->extractUrlParameters();
512 self::handleQuotaUpdate($this);
514 $ilAppEventHandler->raise(
515 'Services/MediaObjects',
517 array(
'object' => $this,
519 'obj_id' => $this->
getId())
538 $parent_obj_ids =
array();
541 if ($parent_obj_id &&
542 !in_array($parent_obj_id, $parent_obj_ids)) {
543 $parent_obj_ids[]= $parent_obj_id;
552 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
598 $a_url_encode =
false,
611 $a_url_encode =
false,
615 if ($a_purpose ==
"") {
616 $a_purpose =
"Standard";
619 if (preg_match(
"/https?\:/i",
$location)) {
631 return $path .
"/data/" . CLIENT_ID .
"/mobs/mm_" . $a_mob_id .
"/" .
$location;
659 $a_subdir = str_replace(
"..",
"", $a_subdir);
661 if ($a_subdir !=
"") {
662 $dir.=
"/" . $a_subdir;
668 foreach ($entries as $e) {
669 if (is_file($dir .
"/" . $e[
"entry"]) && $e[
"entry"] !=
"." && $e[
"entry"] !=
"..") {
691 $xml =
"<MediaObject>";
692 $xml .=
"<MediaAlias OriginId=\"il__mob_" . $this->
getId() .
"\"/>";
696 $xml .=
"<MediaAliasItem Purpose=\"" . $item->getPurpose() .
"\">";
699 $width = ($item->getWidth() !=
"")
700 ?
"Width=\"" . $item->getWidth() .
"\"" 702 $height = ($item->getHeight() !=
"")
703 ?
"Height=\"" . $item->getHeight() .
"\"" 705 $halign = ($item->getHAlign() !=
"")
706 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 708 $xml .=
"<Layout $width $height $halign />";
711 if ($item->getCaption() !=
"") {
712 $xml .=
"<Caption Align=\"bottom\">" .
717 if ($item->getTextRepresentation() !=
"") {
718 $xml .=
"<TextRepresentation>" .
719 $this->
escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
723 $parameters = $item->getParameters();
724 foreach ($parameters as
$name => $value) {
725 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
727 $xml .= $item->getMapAreasXML();
728 $xml .=
"</MediaAliasItem>";
737 $xml =
"<MediaObject Id=\"il__mob_" . $this->
getId() .
"\">";
743 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
745 if ($a_sign_locals && $item->getLocationType() ==
"LocalFile") {
746 require_once
'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
748 $location = substr($location, strrpos($location,
"/") + 1);
751 if ($item->getLocationType() !=
"LocalFile") {
756 $xml.=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
760 $xml.=
"<Format>" . $item->getFormat() .
"</Format>";
763 $width = ($item->getWidth() !=
"")
764 ?
"Width=\"" . $item->getWidth() .
"\"" 766 $height = ($item->getHeight() !=
"")
767 ?
"Height=\"" . $item->getHeight() .
"\"" 769 $halign = ($item->getHAlign() !=
"")
770 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 772 $xml .=
"<Layout $width $height $halign />";
775 if ($item->getCaption() !=
"") {
776 $xml .=
"<Caption Align=\"bottom\">" .
781 if ($item->getTextRepresentation() !=
"") {
782 $xml .=
"<TextRepresentation>" .
783 $this->
escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
789 str_replace(
"&",
"&", $this->
getTitle()) .
"</Title>";
793 $parameters = $item->getParameters();
794 foreach ($parameters as
$name => $value) {
795 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
797 $xml .= $item->getMapAreasXML();
800 if ($item->getPurpose() ==
"Standard") {
802 foreach ($srts as $srt) {
805 if (
$ilUser->getLanguage() != $meta_lang &&
806 $ilUser->getLanguage() == $srt[
"language"]) {
807 $def =
' Default="true" ';
809 $xml .=
"<Subtitle File=\"" . $srt[
"full_path"] .
810 "\" Language=\"" . $srt[
"language"] .
"\" " .
$def .
"/>";
813 $xml .=
"</MediaItem>";
821 $xml =
"<MediaObject>";
824 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
826 $md2xml->setExportMode(
true);
827 $md2xml->startExport();
828 $xml.= $md2xml->getXML();
835 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
838 $xml.=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
839 $this->
handleAmps($item->getLocation()) .
"</Location>";
842 $xml.=
"<Format>" . $item->getFormat() .
"</Format>";
845 $width = ($item->getWidth() !=
"")
846 ?
"Width=\"" . $item->getWidth() .
"\"" 848 $height = ($item->getHeight() !=
"")
849 ?
"Height=\"" . $item->getHeight() .
"\"" 851 $halign = ($item->getHAlign() !=
"")
852 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 854 $xml .=
"<Layout $width $height $halign />";
857 if ($item->getCaption() !=
"") {
858 $xml .=
"<Caption Align=\"bottom\">" .
859 str_replace(
"&",
"&", $item->getCaption()) .
"</Caption>";
863 if ($item->getTextRepresentation() !=
"") {
864 $xml .=
"<TextRepresentation>" .
865 str_replace(
"&",
"&", $item->getTextRepresentation()) .
"</TextRepresentation>";
869 $parameters = $item->getParameters();
870 foreach ($parameters as
$name => $value) {
871 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
873 $xml .= $item->getMapAreasXML(
true, $a_inst);
874 $xml .=
"</MediaItem>";
878 $xml .=
"</MediaObject>";
890 return htmlspecialchars($a_value);
899 $a_str = str_replace(
"&",
"&", $a_str);
900 $a_str = str_replace(
"&",
"&", $a_str);
922 $subdir =
"il_" . IL_INST_ID .
"_mob_" . $this->
getId();
926 ilUtil::rCopy($mobdir, $a_target_dir .
"/objects/" . $subdir);
932 $subdir =
"il_" . IL_INST_ID .
"_mob_" . $this->
getId();
933 $a_target_dir = $a_target_dir .
"/objects/" . $subdir;
935 $tpl =
new ilTemplate(
"tpl.fullscreen.html",
true,
true,
"Modules/LearningModule");
936 $tpl->setCurrentBlock(
"ilMedia");
944 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
946 require_once(
"./Services/COPage/classes/class.ilPageObject.php");
951 $xml.= $pg_obj->getMediaAliasElement($this->
getId());
958 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
959 $args =
array(
'/_xml' =>
$xml,
'/_xsl' => $xsl );
966 $params =
array(
'mode' =>
"fullscreen",
'enlarge_path' => $enlarge_path,
967 'link_params' =>
"ref_id=" .
$_GET[
"ref_id"],
'fullscreen_link' =>
"",
968 'ref_id' =>
$_GET[
"ref_id"],
'webspace_path' => $wb_path);
969 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args,
$params);
974 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
975 $tpl->setVariable(
"LOCATION_CONTENT_STYLESHEET",
"../../css/style.css");
976 $tpl->setVariable(
"LOCATION_STYLESHEET",
"../../css/system.css");
980 $output = preg_replace(
"/mobs\/mm_(\d+)\/([^\"]+)/i",
"$2",
$output);
981 $output = preg_replace(
"/\.\/Services\/MediaObjects\/flash_mp3_player/i",
"../../players",
$output);
983 $output = preg_replace(
"/file=..\/..\/..\//i",
"file=../objects/" . $subdir .
"/",
$output);
985 fwrite(fopen($a_target_dir .
'/fullscreen.html',
'w'),
$output);
990 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
1010 $this->contains_int_link = $a_contains_link;
1029 $ilDB = $DIC->database();
1032 if ($a_usage_hist_nr !==
false) {
1033 $and_hist =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
1037 $set =
$ilDB->query(
"SELECT id FROM mob_usage" .
1038 " WHERE usage_type = " .
$ilDB->quote(
$a_type,
"text") .
1039 " AND usage_id = " .
$ilDB->quote($a_id,
"integer") .
1040 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
1042 while (
$row =
$ilDB->fetchAssoc($set)) {
1043 $mob_ids[] =
$row[
"id"];
1046 $q =
"DELETE FROM mob_usage WHERE usage_type = " .
1048 " AND usage_id= " .
$ilDB->quote($a_id,
"integer") .
1049 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
1051 $ilDB->manipulate($q);
1053 foreach ($mob_ids as $mob_id) {
1054 self::handleQuotaUpdate(
new self($mob_id));
1065 $ilDB = $DIC->database();
1068 if ($a_lang !=
"") {
1069 $lstr =
" AND usage_lang = " .
$ilDB->quote($a_lang,
"text");
1072 if ($a_usage_hist_nr !==
false) {
1073 $hist_str =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
1076 $q =
"SELECT * FROM mob_usage WHERE " .
1077 "usage_type = " .
$ilDB->quote(
$a_type,
"text") .
" AND " .
1078 "usage_id = " .
$ilDB->quote($a_id,
"integer") .
1081 $mob_set =
$ilDB->query($q);
1082 while ($mob_rec =
$ilDB->fetchAssoc($mob_set)) {
1084 $mobs[$mob_rec[
"id"]] = $mob_rec[
"id"];
1098 $ilDB = $DIC->database();
1103 "id" =>
array(
"integer", (
int) $a_mob_id),
1105 "usage_id" =>
array(
"integer", $a_id),
1106 "usage_lang" =>
array(
"text", $a_lang),
1107 "usage_hist_nr" =>
array(
"integer", (
int) $a_usage_hist_nr)
1112 self::handleQuotaUpdate(
new self($a_mob_id));
1122 $ilDB = $DIC->database();
1124 $q =
"DELETE FROM mob_usage WHERE " .
1125 " id = " .
$ilDB->quote((
int) $a_mob_id,
"integer") .
" AND " .
1126 " usage_type = " .
$ilDB->quote(
$a_type,
"text") .
" AND " .
1127 " usage_id = " .
$ilDB->quote((
int) $a_id,
"integer") .
" AND " .
1128 " usage_lang = " .
$ilDB->quote($a_lang,
"text") .
" AND " .
1129 " usage_hist_nr = " .
$ilDB->quote((
int) $a_usage_hist_nr,
"integer");
1130 $ilDB->manipulate($q);
1132 self::handleQuotaUpdate(
new self($a_mob_id));
1140 return self::lookupUsages($this->
getId(), $a_include_history);
1152 $ilDB = $DIC->database();
1155 if ($a_include_history) {
1156 $hist_str =
", usage_hist_nr";
1160 $q =
"SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str .
" FROM mob_usage WHERE id = " .
1161 $ilDB->quote($a_id,
"integer");
1163 if (!$a_include_history) {
1164 $q.=
" AND usage_hist_nr = " .
$ilDB->quote(0,
"integer");
1167 $us_set =
$ilDB->query($q);
1169 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
1171 if (is_int(strpos($us_rec[
"usage_type"],
":"))) {
1172 $us_arr = explode(
":", $us_rec[
"usage_type"]);
1180 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
1187 $ret[] =
array(
"type" => $us_rec[
"usage_type"],
1188 "id" => $us_rec[
"usage_id"],
1189 "lang" => $us_rec[
"usage_lang"],
1190 "hist_nr" => $us_rec[
"usage_hist_nr"]);
1195 $q =
"SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = " .
1196 $ilDB->quote($a_id,
"integer") .
" AND mep_item.type = " .
$ilDB->quote(
"mob",
"text");
1197 $us_set =
$ilDB->query($q);
1198 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
1200 "id" => $us_rec[
"mep_id"]);
1204 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1206 foreach ($news_usages as $nu) {
1212 $q =
"SELECT DISTINCT mob_id FROM media_item it, map_area area " .
1213 " WHERE area.item_id = it.id " .
1214 " AND area.link_type = " .
$ilDB->quote(
"int",
"text") .
" " .
1215 " AND area.target = " .
$ilDB->quote(
"il__mob_" . $a_id,
"text");
1216 $us_set =
$ilDB->query($q);
1217 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
1219 "id" => $us_rec[
"mob_id"]);
1239 if (is_int(strpos($a_usage[
"type"],
":"))) {
1240 $us_arr = explode(
":", $a_usage[
"type"]);
1242 $cont_type = $us_arr[0];
1244 $type = $a_usage[
"type"];
1247 $id = $a_usage[
"id"];
1254 switch ($cont_type) {
1257 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
1259 if ($qinfo[
"original_id"] > 0) {
1260 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
1263 $obj_id = $qinfo[
"obj_fi"];
1269 include_once(
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php");
1272 $parent_id = $quest->getObjId();
1275 if ($quest->getOriginalId() &&
1281 $obj_id = $parent_id;
1290 $returned_pk = $a_usage[
'id'];
1292 include_once
'Modules/Exercise/classes/class.ilExSubmission.php';
1298 $post_pk = $a_usage[
'id'];
1299 include_once
'Modules/Forum/classes/class.ilForumPost.php';
1300 include_once
'Modules/Forum/classes/class.ilForum.php';
1302 $frm_pk = $oPost->getForumId();
1308 $draft_id = $a_usage[
'id'];
1309 include_once
'Modules/Forum/classes/class.ilForumPostDraft.php';
1310 include_once
'Modules/Forum/classes/class.ilForum.php';
1313 $frm_pk = $oDraft->getForumId();
1317 $history_id = $a_usage[
'id'];
1318 include_once
'Modules/Forum/classes/class.ilForumDraftsHistory.php';
1319 include_once
'Modules/Forum/classes/class.ilForumPostDraft.php';
1320 include_once
'Modules/Forum/classes/class.ilForum.php';
1324 $frm_pk = $oDraft->getForumId();
1330 $obj_id = $a_usage[
'id'];
1348 switch ($cont_type) {
1351 include_once(
'./Services/COPage/classes/class.ilPageObject.php');
1358 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
1360 if ($qinfo[
"original_id"] > 0) {
1361 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
1364 $obj_id = $qinfo[
"obj_fi"];
1367 include_once(
"./Services/COPage/classes/class.ilPCQuestion.php");
1369 if ($pinfo && $pinfo[
"parent_type"] ==
"lm") {
1370 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1374 if ($pinfo && $pinfo[
"parent_type"] ==
"sahs") {
1375 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1383 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1389 include_once(
"./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
1390 include_once(
"./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1397 include_once
'Modules/Wiki/classes/class.ilWikiPage.php';
1404 include_once(
'./Services/COPage/classes/class.ilPageObject.php');
1410 include_once
"Modules/Portfolio/classes/class.ilPortfolioPage.php";
1416 include_once
"Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
1422 include_once(
'./Services/COPage/classes/class.ilPageObject.php');
1450 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1465 public static function _resizeImage($a_file, $a_width, $a_height, $a_constrain_prop =
false)
1467 $file_path = pathinfo($a_file);
1468 $location = substr($file_path[
"basename"], 0, strlen($file_path[
"basename"]) -
1469 strlen($file_path[
"extension"]) - 1) .
"_" .
1471 $a_height .
"." . $file_path[
"extension"];
1472 $target_file = $file_path[
"dirname"] .
"/" .
1494 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
1507 $a_constrain_proportions,
1514 $lng = $DIC->language();
1521 if ($a_format ==
"audio/mpeg") {
1527 include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
1535 if ($a_use_original) {
1542 $info =
$lng->txt(
"cont_could_not_determine_resource_size");
1545 $w = (int) $a_user_width;
1546 $h = (int) $a_user_height;
1563 $height = (int) (
$size[1]/
$r);
1571 if ($width == 0 && $a_user_width ===
"") {
1574 if ($height == 0 && $a_user_height ===
"") {
1578 return array(
"width" => $width,
"height" => $height,
"info" =>
$info);
1587 return array(
"image/x-ms-bmp",
"image/gif",
"image/jpeg",
"image/x-portable-bitmap",
1588 "image/png",
"image/psd",
"image/tiff",
"application/pdf");
1604 $lpath = pathinfo($a_loc);
1605 if ($lpath[
"extension"] ==
"mp3" && $a_format ==
"audio/mpeg") {
1608 if ($lpath[
"extension"] ==
"flv") {
1611 if (in_array($a_format,
array(
"video/mp4",
"video/webm"))) {
1624 $media_object->setTitle(
$name);
1625 $media_object->setDescription(
"");
1626 $media_object->create();
1629 $media_object->createDirectory();
1633 $media_object->addMediaItem($media_item);
1634 $media_item->setPurpose(
"Standard");
1638 ilUtil::moveUploadedFile($tmp_name,
$name,
$file);
1640 copy($tmp_name,
$file);
1646 $media_item->setFormat(
$format);
1648 $media_item->setLocationType(
"LocalFile");
1649 $media_object->setTitle(
$name);
1650 $media_object->setDescription(
$format);
1653 include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
1655 $media_item->setWidth(
$size[0]);
1656 $media_item->setHeight(
$size[1]);
1658 $media_item->setHAlign(
"Left");
1660 self::renameExecutables($mob_dir);
1661 include_once(
"./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
1664 $media_object->update();
1666 return $media_object;
1674 $a_subdir = str_replace(
"..",
"", $a_subdir);
1676 if ($a_subdir !=
"") {
1677 $dir.=
"/" . $a_subdir;
1680 if ($a_mode ==
"rename") {
1681 rename($tmp_name, $dir .
"/" . $a_name);
1683 ilUtil::moveUploadedFile($tmp_name, $a_name, $dir .
"/" . $a_name,
true, $a_mode);
1685 self::renameExecutables($mob_dir);
1686 include_once(
"./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
1696 public function uploadSrtFile($a_tmp_name, $a_language, $a_mode =
"move_uploaded")
1698 if (is_file($a_tmp_name) && $a_language !=
"") {
1712 if (!is_dir($srt_dir)) {
1718 $srt_files =
array();
1719 foreach ($items as
$i) {
1720 if (!in_array($i[
"entry"],
array(
".",
"..")) && $i[
"type"] ==
"file") {
1721 $name = explode(
".", $i[
"entry"]);
1722 if (
$name[1] ==
"srt" && substr(
$name[0], 0, 9) ==
"subtitle_") {
1723 $srt_files[] =
array(
"file" => $i[
"entry"],
1724 "full_path" =>
"srt/" . $i[
"entry"],
"language" => substr(
$name[0], 9, 2));
1743 self::_createThumbnailDirectory($this->
getId());
1745 $m_dir .
"/" . $a_file,
1746 $t_dir .
"/" . $a_thumbname,
1761 return $t_dir .
"/" . $a_thumbname;
1770 $file = str_replace(
"..",
"", $a_file);
1772 if (is_file(
$file)) {
1785 if (!is_array($a_ignore)) {
1786 $a_ignore =
array();
1792 foreach ($med_items as $med_item) {
1794 foreach ($int_links as $k => $int_link) {
1795 if ($int_link[
"Type"] ==
"MediaObject") {
1796 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
1799 if (!in_array($l_id, $linked) &&
1800 !in_array($l_id, $a_ignore)) {
1816 return array_filter(self::getAllowedFileTypes(),
function ($v) {
1817 return !in_array($v, self::getForbiddenFileTypes());
1829 if (trim($mset->get(
"black_list_file_types")) ==
"") {
1834 return strtolower(trim($v));
1836 explode(
",", $mset->get(
"black_list_file_types"))
1848 if (trim($mset->get(
"restricted_file_types")) ==
"") {
1853 return strtolower(trim($v));
1855 explode(
",", $mset->get(
"restricted_file_types"))
1867 if (in_array(
$a_type, self::getForbiddenFileTypes())) {
1870 if (count(self::getAllowedFileTypes()) == 0 || in_array(
$a_type, self::getAllowedFileTypes())) {
1883 $new_obj->setTitle($this->
getTitle());
1888 $new_obj->addMediaItem($val);
1891 $new_obj->create(
false,
true);
1894 $new_obj->createDirectory();
1895 self::_createThumbnailDirectory($new_obj->getId());
1906 include_once(
"Services/MetaData/classes/class.ilMD.php");
1907 $md =
new ilMD(0, $this->
getId(),
"mob");
1908 $new_md = $md->cloneMD(0, $new_obj->getId(),
"mob");
1926 $pi = pathinfo($a_prevpic[
"name"]);
1927 $ext = $pi[
"extension"];
1928 if (in_array($ext,
array(
"jpg",
"jpeg",
"png"))) {
1943 if ($item->getLocationType() ==
"LocalFile" &&
1944 is_int(strpos($item->getFormat(),
"image/"))) {
1946 $file = $dir .
"/" .
1947 $item->getLocation();
1948 if (is_file(
$file)) {
1967 $ppics =
array(
"mob_vpreview.jpg",
1968 "mob_vpreview.jpeg",
1969 "mob_vpreview.png");
1970 foreach ($ppics as $p) {
1971 if (is_file($dir .
"/" . $p)) {
1972 if ($a_filename_only) {
1975 return $dir .
"/" . $p;
1992 $rchars =
array(
"`",
"=",
"$",
"{",
"}",
"'",
";",
" ",
"(",
")");
1993 $a_name = str_replace($rchars,
"_", $a_name);
1994 $a_name = str_replace(
"__",
"_", $a_name);
2022 include_once(
"./Services/MediaObjects/exceptions/class.ilMediaObjectsException.php");
2023 if (!is_file($a_file[
"tmp_name"])) {
2030 ilUtil::moveUploadedFile($a_file[
"tmp_name"],
"multi_srt.zip", $dir .
"/" .
"multi_srt.zip");
2049 include_once(
"./Services/MetaData/classes/class.ilMDLanguageItem.php");
2056 if (
$i[
"type"] ==
"file" && !in_array($k,
array(
".",
".."))) {
2057 if (pathinfo($k, PATHINFO_EXTENSION) ==
"srt") {
2059 if (substr($k, strlen($k) - 7, 1) ==
"_") {
2060 $lang = substr($k, strlen($k) - 6, 2);
2061 if (!in_array(
$lang, $lang_codes)) {
2065 $items[] =
array(
"filename" => $k,
"lang" =>
$lang);
2080 if (!self::isTypeAllowed(
"html")) {
static isConvertVersionAtLeast($a_version)
Compare convert version numbers.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static _lookupObjIdForForumId($a_for_id)
static rRenameSuffix($a_dir, $a_old_suffix, $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.
static _lookupSLMID($a_id)
Lookup Scorm Learning Module ID for node id.
static _lookupTestObjIdForQuestionId($a_q_id)
Get test Object ID for question ID.
static _lookupSurveyObjId($a_question_id)
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static _getUsersForClipboadObject($a_type, $a_id)
get all users, that have a certain object within their clipboard
static _extractObjIdOfTarget($a_target)
Extract object id out of target.
static findPortfolioForPage($a_page_id)
Get portfolio id of page id.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static _writeTitle($a_obj_id, $a_title)
write title to db (static)
static deducibleSize($a_mime)
checks if mime type is provided by getimagesize()
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=null)
static lookupExerciseIdForReturnedId($a_returned_id)
Get exercise from submission id (used in ilObjMediaObject)
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
Class ilForumDraftHistory.
static _lookupTermId($a_def_id)
Looks up term id for a definition id.
static _getQuestionInfo($question_id)
Returns question information from the database.
static lookupParentId($a_id, $a_type)
Lookup parent id.
static _getIntLinks($a_item_id)
get all internal links of a media items map areas
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
static _getPossibleLanguageCodes()
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image
static _lookupMediaObjectUsages($a_mob_id)
Lookup media object usage(s)
static execConvert($args)
execute convert command
static _getPageForQuestionId($a_q_id, $a_parent_type="")
Get page for question id.
special template class to simplify handling of ITX/PEAR
static getFlashVideoPlayerDirectory()
Get flash video player directory.
static newInstanceByDraftId($draft_id)
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
redirection script todo: (a better solution should control the processing via a xml file) ...
static createDirectory($a_dir, $a_mod=0755)
create directory
static signFile($path_to_file)
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
getType()
get object type public
static getHtmlPath($relative_path)
get url of path
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static _writeDescription($a_obj_id, $a_desc)
write description to db (static)
update($pash, $contents, Config $config)
const APPLICATION__OCTET_STREAM
static _lookGlossaryID($term_id)
get glossary id form term id
static secureUrl($url)
Prepare secure href attribute.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static escapeShellArg($a_arg)
static handleUpdatedSourceObject($a_src_obj_type, $a_src_obj_id, $a_src_filesize, $a_owner_obj_ids=null, $a_is_prtf=false)
Find and update/create all related entries for source object.
static _lookupContextObjId($a_news_id)
Context Object ID.
static insertInstIntoID($a_value)
inserts installation id into ILIAS id
static getLogger($a_component_id)
Get component logger.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static lookupObjIdByPage($a_page_id)
returns the wiki/object id to a given page id