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";
51 $this->
user = $DIC->user();
52 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
53 $this->lng = $DIC->language();
54 $this->is_alias =
false;
55 $this->media_items = array();
56 $this->contains_int_link =
false;
63 $this->
ilias->raiseError(
"Operation ilObjMedia::setRefId() not allowed.", $this->
ilias->error_obj->FATAL);
73 $this->
ilias->raiseError(
"Operation ilObjMedia::putInTree() not allowed.", $this->
ilias->error_obj->FATAL);
78 $this->
ilias->raiseError(
"Operation ilObjMedia::createReference() not allowed.", $this->
ilias->error_obj->FATAL);
83 parent::setTitle($a_title);
88 return parent::getTitle();
102 $ilDB = $DIC->database();
104 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
105 if (is_int(strpos($a_id,
"_"))) {
118 public function delete()
121 $mob_logger->debug(
"ilObjMediaObject: Delete called for media object ID '" . $this->
getId() .
"'.");
123 if (!($this->
getId() > 0)) {
129 $mob_logger->debug(
"ilObjMediaObject: ... Found " . count($usages) .
" usages.");
131 if (count($usages) == 0) {
146 self::handleQuotaUpdate($this);
151 $mob_logger->debug(
"ilObjMediaObject: ... deleted.");
153 foreach ($usages as $u) {
154 $mob_logger->debug(
"ilObjMediaObject: ... usage type:" . $u[
"type"] .
156 ", lang:" . $u[
"lang"] .
157 ", hist_nr:" . $u[
"hist_nr"] .
".");
159 $mob_logger->debug(
"ilObjMediaObject: ... not deleted.");
170 return parent::getDescription();
178 parent::setDescription($a_description);
194 include_once
'Services/MetaData/classes/class.ilMD.php';
196 switch ($a_element) {
201 $md_gen = $md->getGeneral();
203 if (is_object($md_gen)) {
205 $this->
setTitle($md_gen->getTitle());
207 foreach ($md_gen->getDescriptionIds() as
$id) {
208 $md_des = $md_gen->getDescription(
$id);
227 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
232 $md_creator->setTitle($this->
getTitle());
233 $md_creator->setTitleLanguage(
$ilUser->getPref(
'language'));
235 $md_creator->setDescriptionLanguage(
$ilUser->getPref(
'language'));
236 $md_creator->setKeywordLanguage(
$ilUser->getPref(
'language'));
237 $md_creator->setLanguage(
$ilUser->getPref(
'language'));
238 $md_creator->create();
248 include_once(
"Services/MetaData/classes/class.ilMD.php");
249 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
250 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
253 $md_gen = $md->getGeneral();
254 $md_gen->setTitle($this->
getTitle());
257 $md_des_ids = $md_gen->getDescriptionIds();
258 if (count($md_des_ids) > 0) {
259 $md_des = $md_gen->getDescription($md_des_ids[0]);
272 include_once(
'Services/MetaData/classes/class.ilMD.php');
285 $this->media_items[] = $a_item;
307 foreach ($this->media_items as $media_item) {
308 if ($media_item->getPurpose() == $a_purpose) {
321 foreach ($this->media_items as $key => $media_item) {
322 if ($media_item->getPurpose() == $a_purpose) {
323 unset($this->media_items[$key]);
329 foreach ($this->media_items as $media_item) {
331 $media_item->setMobId($this->
getId());
332 $media_item->setNr(
$i);
343 $this->media_items = array();
349 for (
$i = 0;
$i < count($this->media_items);
$i++) {
350 if ($this->media_items[
$i]->getPurpose() == $a_purpose) {
397 $this->is_alias = $a_is_alias;
407 return $this->origin_id = $a_id;
432 $this->import_id = $a_id;
438 public function create($a_create_meta_data =
false, $a_save_media_items =
true)
442 if (!$a_create_meta_data) {
446 if ($a_save_media_items) {
450 $item->setMobId($this->
getId());
451 $item->setNr(
$i + 1);
456 self::handleQuotaUpdate($this);
459 $ilAppEventHandler->raise(
460 'Services/MediaObjects',
462 array(
'object' => $this,
464 'obj_id' => $this->
getId())
472 public function update($a_upload =
false)
487 if (is_object($item)) {
488 $item->setMobId($this->
getId());
490 if ($item->getLocationType() ==
"Reference") {
491 $item->extractUrlParameters();
498 self::handleQuotaUpdate($this);
500 $ilAppEventHandler->raise(
501 'Services/MediaObjects',
503 array(
'object' => $this,
505 'obj_id' => $this->
getId())
524 $parent_obj_ids = array();
527 if ($parent_obj_id &&
528 !in_array($parent_obj_id, $parent_obj_ids)) {
529 $parent_obj_ids[] = $parent_obj_id;
538 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
566 return "mobs/mm_" . $a_mob_id;
597 $a_url_encode =
false,
610 $a_url_encode =
false,
614 if ($a_purpose ==
"") {
615 $a_purpose =
"Standard";
618 if (preg_match(
"/https?\:/i",
$location)) {
630 return $path .
"/data/" . CLIENT_ID .
"/mobs/mm_" . $a_mob_id .
"/" .
$location;
640 if (!is_dir($path)) {
641 $this->
ilias->raiseError(
"Failed to create directory $path.", $this->
ilias->error_obj->FATAL);
662 $a_subdir = str_replace(
"..",
"", $a_subdir);
664 if ($a_subdir !=
"") {
665 $dir .=
"/" . $a_subdir;
671 foreach ($entries as
$e) {
672 if (is_file($dir .
"/" . $e[
"entry"]) && $e[
"entry"] !=
"." && $e[
"entry"] !=
"..") {
673 $files[] = $e[
"entry"];
694 $xml =
"<MediaObject>";
695 $xml .=
"<MediaAlias OriginId=\"il__mob_" . $this->
getId() .
"\"/>";
699 $xml .=
"<MediaAliasItem Purpose=\"" . $item->getPurpose() .
"\">";
702 $width = ($item->getWidth() !=
"")
703 ?
"Width=\"" . $item->getWidth() .
"\"" 705 $height = ($item->getHeight() !=
"")
706 ?
"Height=\"" . $item->getHeight() .
"\"" 708 $halign = ($item->getHAlign() !=
"")
709 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 711 $xml .=
"<Layout $width $height $halign />";
714 if ($item->getCaption() !=
"") {
715 $xml .=
"<Caption Align=\"bottom\">" .
720 if ($item->getTextRepresentation() !=
"") {
721 $xml .=
"<TextRepresentation>" .
722 $this->
escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
726 $parameters = $item->getParameters();
727 foreach ($parameters as
$name => $value) {
728 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
730 $xml .= $item->getMapAreasXML();
731 $xml .=
"</MediaAliasItem>";
740 $xml =
"<MediaObject Id=\"il__mob_" . $this->
getId() .
"\">";
746 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
748 if ($a_sign_locals && $item->getLocationType() ==
"LocalFile") {
749 require_once
'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
751 $location = substr($location, strrpos($location,
"/") + 1);
754 if ($item->getLocationType() !=
"LocalFile") {
759 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
763 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
766 $width = ($item->getWidth() !=
"")
767 ?
"Width=\"" . $item->getWidth() .
"\"" 769 $height = ($item->getHeight() !=
"")
770 ?
"Height=\"" . $item->getHeight() .
"\"" 772 $halign = ($item->getHAlign() !=
"")
773 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 775 $xml .=
"<Layout $width $height $halign />";
778 if ($item->getCaption() !=
"") {
779 $xml .=
"<Caption Align=\"bottom\">" .
784 if ($item->getTextRepresentation() !=
"") {
785 $xml .=
"<TextRepresentation>" .
786 $this->
escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
796 $parameters = $item->getParameters();
797 foreach ($parameters as
$name => $value) {
798 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
800 $xml .= $item->getMapAreasXML();
803 if ($item->getPurpose() ==
"Standard") {
805 foreach ($srts as $srt) {
808 if (
$ilUser->getLanguage() != $meta_lang &&
809 $ilUser->getLanguage() == $srt[
"language"]) {
810 $def =
' Default="true" ';
812 $xml .=
"<Subtitle File=\"" . $srt[
"full_path"] .
813 "\" Language=\"" . $srt[
"language"] .
"\" " . $def .
"/>";
816 $xml .=
"</MediaItem>";
824 $xml =
"<MediaObject>";
827 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
829 $md2xml->setExportMode(
true);
830 $md2xml->startExport();
831 $xml .= $md2xml->getXML();
838 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
841 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
842 $this->
handleAmps($item->getLocation()) .
"</Location>";
845 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
848 $width = ($item->getWidth() !=
"")
849 ?
"Width=\"" . $item->getWidth() .
"\"" 851 $height = ($item->getHeight() !=
"")
852 ?
"Height=\"" . $item->getHeight() .
"\"" 854 $halign = ($item->getHAlign() !=
"")
855 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 857 $xml .=
"<Layout $width $height $halign />";
860 if ($item->getCaption() !=
"") {
861 $xml .=
"<Caption Align=\"bottom\">" .
862 str_replace(
"&",
"&", $item->getCaption()) .
"</Caption>";
866 if ($item->getTextRepresentation() !=
"") {
867 $xml .=
"<TextRepresentation>" .
868 str_replace(
"&",
"&", $item->getTextRepresentation()) .
"</TextRepresentation>";
872 $parameters = $item->getParameters();
873 foreach ($parameters as
$name => $value) {
874 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
876 $xml .= $item->getMapAreasXML(
true, $a_inst);
877 $xml .=
"</MediaItem>";
881 $xml .=
"</MediaObject>";
893 return htmlspecialchars($a_value);
902 $a_str = str_replace(
"&",
"&", $a_str);
903 $a_str = str_replace(
"&",
"&", $a_str);
925 $subdir =
"il_" . IL_INST_ID .
"_mob_" . $this->
getId();
929 ilUtil::rCopy($mobdir, $a_target_dir .
"/objects/" . $subdir);
935 $subdir =
"il_" . IL_INST_ID .
"_mob_" . $this->
getId();
936 $a_target_dir = $a_target_dir .
"/objects/" . $subdir;
939 $tpl->setCurrentBlock(
"ilMedia");
947 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
949 require_once(
"./Services/COPage/classes/class.ilPageObject.php");
954 $xml .= $pg_obj->getMediaAliasElement($this->
getId());
961 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
962 $args = array(
'/_xml' =>
$xml,
'/_xsl' => $xsl );
969 $params = array(
'mode' =>
"fullscreen",
'enlarge_path' => $enlarge_path,
970 'link_params' =>
"ref_id=" .
$_GET[
"ref_id"],
'fullscreen_link' =>
"",
971 'ref_id' =>
$_GET[
"ref_id"],
'webspace_path' => $wb_path);
972 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args, $params);
977 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
978 $tpl->setVariable(
"LOCATION_CONTENT_STYLESHEET",
"../../css/style.css");
979 $tpl->setVariable(
"LOCATION_STYLESHEET",
"../../css/system.css");
980 $tpl->setVariable(
"MEDIA_CONTENT", $output);
981 $output =
$tpl->get();
983 $output = preg_replace(
"/mobs\/mm_(\d+)\/([^\"]+)/i",
"$2", $output);
984 $output = preg_replace(
"/\.\/Services\/MediaObjects\/flash_mp3_player/i",
"../../players", $output);
986 $output = preg_replace(
"/file=..\/..\/..\//i",
"file=../objects/" . $subdir .
"/", $output);
988 fwrite(fopen($a_target_dir .
'/fullscreen.html',
'w'), $output);
993 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
1013 $this->contains_int_link = $a_contains_link;
1032 $ilDB = $DIC->database();
1035 if ($a_usage_hist_nr !==
false) {
1036 $and_hist =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
1040 $set =
$ilDB->query(
"SELECT id FROM mob_usage" .
1041 " WHERE usage_type = " .
$ilDB->quote(
$a_type,
"text") .
1042 " AND usage_id = " .
$ilDB->quote($a_id,
"integer") .
1043 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
1045 while ($row =
$ilDB->fetchAssoc($set)) {
1046 $mob_ids[] = $row[
"id"];
1049 $q =
"DELETE FROM mob_usage WHERE usage_type = " .
1051 " AND usage_id= " .
$ilDB->quote($a_id,
"integer") .
1052 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
1054 $ilDB->manipulate($q);
1056 foreach ($mob_ids as $mob_id) {
1057 self::handleQuotaUpdate(
new self($mob_id));
1068 $ilDB = $DIC->database();
1071 if ($a_lang !=
"") {
1072 $lstr =
" AND usage_lang = " .
$ilDB->quote($a_lang,
"text");
1075 if ($a_usage_hist_nr !==
false) {
1076 $hist_str =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
1079 $q =
"SELECT * FROM mob_usage WHERE " .
1080 "usage_type = " .
$ilDB->quote(
$a_type,
"text") .
" AND " .
1081 "usage_id = " .
$ilDB->quote($a_id,
"integer") .
1084 $mob_set =
$ilDB->query($q);
1085 while ($mob_rec =
$ilDB->fetchAssoc($mob_set)) {
1087 $mobs[$mob_rec[
"id"]] = $mob_rec[
"id"];
1101 $ilDB = $DIC->database();
1106 "id" => array(
"integer", (
int) $a_mob_id),
1107 "usage_type" => array(
"text",
$a_type),
1108 "usage_id" => array(
"integer", $a_id),
1109 "usage_lang" => array(
"text", $a_lang),
1110 "usage_hist_nr" => array(
"integer", (
int) $a_usage_hist_nr)
1115 self::handleQuotaUpdate(
new self($a_mob_id));
1125 $ilDB = $DIC->database();
1127 $q =
"DELETE FROM mob_usage WHERE " .
1128 " id = " .
$ilDB->quote((
int) $a_mob_id,
"integer") .
" AND " .
1129 " usage_type = " .
$ilDB->quote(
$a_type,
"text") .
" AND " .
1130 " usage_id = " .
$ilDB->quote((
int) $a_id,
"integer") .
" AND " .
1131 " usage_lang = " .
$ilDB->quote($a_lang,
"text") .
" AND " .
1132 " usage_hist_nr = " .
$ilDB->quote((
int) $a_usage_hist_nr,
"integer");
1133 $ilDB->manipulate($q);
1135 self::handleQuotaUpdate(
new self($a_mob_id));
1143 return self::lookupUsages($this->
getId(), $a_include_history);
1155 $ilDB = $DIC->database();
1158 if ($a_include_history) {
1159 $hist_str =
", usage_hist_nr";
1163 $q =
"SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str .
" FROM mob_usage WHERE id = " .
1164 $ilDB->quote($a_id,
"integer");
1166 if (!$a_include_history) {
1167 $q .=
" AND usage_hist_nr = " .
$ilDB->quote(0,
"integer");
1170 $us_set =
$ilDB->query($q);
1172 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
1174 if (is_int(strpos($us_rec[
"usage_type"],
":"))) {
1175 $us_arr = explode(
":", $us_rec[
"usage_type"]);
1183 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
1190 $ret[] = array(
"type" => $us_rec[
"usage_type"],
1191 "id" => $us_rec[
"usage_id"],
1192 "lang" => $us_rec[
"usage_lang"],
1193 "hist_nr" => $us_rec[
"usage_hist_nr"]);
1198 $q =
"SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = " .
1199 $ilDB->quote($a_id,
"integer") .
" AND mep_item.type = " .
$ilDB->quote(
"mob",
"text");
1200 $us_set =
$ilDB->query($q);
1201 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
1202 $ret[] = array(
"type" =>
"mep",
1203 "id" => $us_rec[
"mep_id"]);
1207 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1209 foreach ($news_usages as $nu) {
1215 $q =
"SELECT DISTINCT mob_id FROM media_item it, map_area area " .
1216 " WHERE area.item_id = it.id " .
1217 " AND area.link_type = " .
$ilDB->quote(
"int",
"text") .
" " .
1218 " AND area.target = " .
$ilDB->quote(
"il__mob_" . $a_id,
"text");
1219 $us_set =
$ilDB->query($q);
1220 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
1221 $ret[] = array(
"type" =>
"map",
1222 "id" => $us_rec[
"mob_id"]);
1227 foreach ($users as
$user) {
1228 $ret[] = array(
"type" =>
"clip",
1242 if (is_int(strpos($a_usage[
"type"],
":"))) {
1243 $us_arr = explode(
":", $a_usage[
"type"]);
1245 $cont_type = $us_arr[0];
1247 $type = $a_usage[
"type"];
1250 $id = $a_usage[
"id"];
1257 switch ($cont_type) {
1260 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
1262 if ($qinfo[
"original_id"] > 0) {
1263 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
1266 $obj_id = $qinfo[
"obj_fi"];
1274 $parent_id = $quest->getObjId();
1277 if ($quest->getOriginalId() &&
1283 $obj_id = $parent_id;
1292 $returned_pk = $a_usage[
'id'];
1294 include_once
'Modules/Exercise/classes/class.ilExSubmission.php';
1300 $post_pk = $a_usage[
'id'];
1301 include_once
'Modules/Forum/classes/class.ilForumPost.php';
1302 include_once
'Modules/Forum/classes/class.ilForum.php';
1304 $frm_pk = $oPost->getForumId();
1310 $draft_id = $a_usage[
'id'];
1311 include_once
'Modules/Forum/classes/class.ilForumPostDraft.php';
1312 include_once
'Modules/Forum/classes/class.ilForum.php';
1315 $frm_pk = $oDraft->getForumId();
1319 $history_id = $a_usage[
'id'];
1320 include_once
'Modules/Forum/classes/class.ilForumDraftsHistory.php';
1321 include_once
'Modules/Forum/classes/class.ilForumPostDraft.php';
1322 include_once
'Modules/Forum/classes/class.ilForum.php';
1326 $frm_pk = $oDraft->getForumId();
1332 $obj_id = $a_usage[
'id'];
1350 switch ($cont_type) {
1353 include_once(
'./Services/COPage/classes/class.ilPageObject.php');
1360 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
1362 if ($qinfo[
"original_id"] > 0) {
1363 include_once(
"./Modules/Test/classes/class.ilObjTest.php");
1366 $obj_id = $qinfo[
"obj_fi"];
1369 include_once(
"./Services/COPage/classes/class.ilPCQuestion.php");
1371 if ($pinfo && $pinfo[
"parent_type"] ==
"lm") {
1372 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
1376 if ($pinfo && $pinfo[
"parent_type"] ==
"sahs") {
1377 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1385 include_once(
"./Modules/LearningModule/classes/class.ilLMObject.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');
1451 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1466 public static function _resizeImage($a_file, $a_width, $a_height, $a_constrain_prop =
false)
1468 $file_path = pathinfo($a_file);
1469 $location = substr($file_path[
"basename"], 0, strlen($file_path[
"basename"]) -
1470 strlen($file_path[
"extension"]) - 1) .
"_" .
1472 $a_height .
"." . $file_path[
"extension"];
1473 $target_file = $file_path[
"dirname"] .
"/" .
1495 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
1508 $a_constrain_proportions,
1515 $lng = $DIC->language();
1522 if ($a_format ==
"audio/mpeg") {
1528 include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
1536 if ($a_use_original) {
1543 $info =
$lng->txt(
"cont_could_not_determine_resource_size");
1546 $w = (int) $a_user_width;
1547 $h = (int) $a_user_height;
1554 $wr =
$size[0] / $w;
1557 $hr =
$size[1] / $h;
1563 $width = (int) round(
$size[0] / $r);
1564 $height = (int) round(
$size[1] / $r);
1572 if ($width == 0 && $a_user_width ===
"") {
1575 if ($height == 0 && $a_user_height ===
"") {
1579 return array(
"width" => $width,
"height" => $height,
"info" => $info);
1588 return array(
"image/x-ms-bmp",
"image/gif",
"image/jpeg",
"image/x-portable-bitmap",
1589 "image/png",
"image/psd",
"image/tiff",
"application/pdf");
1605 $lpath = pathinfo($a_loc);
1606 if ($lpath[
"extension"] ==
"mp3" && $a_format ==
"audio/mpeg") {
1609 if ($lpath[
"extension"] ==
"flv") {
1612 if (in_array($a_format, array(
"video/mp4",
"video/webm"))) {
1625 $media_object->setTitle(
$name);
1626 $media_object->setDescription(
"");
1627 $media_object->create();
1630 $media_object->createDirectory();
1634 $media_object->addMediaItem($media_item);
1635 $media_item->setPurpose(
"Standard");
1637 $file = $mob_dir .
"/" .
$name;
1641 copy($tmp_name, $file);
1647 $media_item->setFormat(
$format);
1649 $media_item->setLocationType(
"LocalFile");
1650 $media_object->setTitle(
$name);
1651 $media_object->setDescription(
$format);
1654 include_once(
"./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
1656 $media_item->setWidth(
$size[0]);
1657 $media_item->setHeight(
$size[1]);
1659 $media_item->setHAlign(
"Left");
1661 self::renameExecutables($mob_dir);
1662 include_once(
"./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
1665 $media_object->update();
1667 return $media_object;
1675 $a_subdir = str_replace(
"..",
"", $a_subdir);
1677 if ($a_subdir !=
"") {
1678 $dir .=
"/" . $a_subdir;
1681 if ($a_mode ==
"rename") {
1682 rename($tmp_name, $dir .
"/" . $a_name);
1686 self::renameExecutables($mob_dir);
1687 include_once(
"./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
1697 public function uploadSrtFile($a_tmp_name, $a_language, $a_mode =
"move_uploaded")
1699 if (is_file($a_tmp_name) && $a_language !=
"") {
1713 if (!is_dir($srt_dir)) {
1719 $srt_files = array();
1720 foreach ($items as
$i) {
1721 if (!in_array($i[
"entry"], array(
".",
"..")) && $i[
"type"] ==
"file") {
1722 $name = explode(
".", $i[
"entry"]);
1723 if (
$name[1] ==
"srt" && substr(
$name[0], 0, 9) ==
"subtitle_") {
1724 $srt_files[] = array(
"file" => $i[
"entry"],
1725 "full_path" =>
"srt/" . $i[
"entry"],
"language" => substr(
$name[0], 9, 2));
1744 self::_createThumbnailDirectory($this->
getId());
1746 $m_dir .
"/" . $a_file,
1747 $t_dir .
"/" . $a_thumbname,
1762 return $t_dir .
"/" . $a_thumbname;
1771 $file = str_replace(
"..",
"", $a_file);
1773 if (is_file($file)) {
1786 if (!is_array($a_ignore)) {
1787 $a_ignore = array();
1793 foreach ($med_items as $med_item) {
1795 foreach ($int_links as $k => $int_link) {
1796 if ($int_link[
"Type"] ==
"MediaObject") {
1797 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
1800 if (!in_array($l_id, $linked) &&
1801 !in_array($l_id, $a_ignore)) {
1817 return array_filter(self::getAllowedFileTypes(),
function ($v) {
1818 return !in_array($v, self::getForbiddenFileTypes());
1830 if (trim($mset->get(
"black_list_file_types")) ==
"") {
1835 return strtolower(trim($v));
1837 explode(
",", $mset->get(
"black_list_file_types"))
1849 if (trim($mset->get(
"restricted_file_types")) ==
"") {
1854 return strtolower(trim($v));
1856 explode(
",", $mset->get(
"restricted_file_types"))
1868 if (in_array(
$a_type, self::getForbiddenFileTypes())) {
1871 if (count(self::getAllowedFileTypes()) == 0 || in_array(
$a_type, self::getAllowedFileTypes())) {
1884 $new_obj->setTitle($this->
getTitle());
1889 $new_obj->addMediaItem($val);
1892 $new_obj->create(
false,
true);
1895 $new_obj->createDirectory();
1896 self::_createThumbnailDirectory($new_obj->getId());
1907 include_once(
"Services/MetaData/classes/class.ilMD.php");
1908 $md =
new ilMD(0, $this->
getId(),
"mob");
1909 $new_md = $md->cloneMD(0, $new_obj->getId(),
"mob");
1927 $pi = pathinfo($a_prevpic[
"name"]);
1928 $ext = $pi[
"extension"];
1929 if (in_array($ext, array(
"jpg",
"jpeg",
"png"))) {
1944 if ($item->getLocationType() ==
"LocalFile" &&
1945 is_int(strpos($item->getFormat(),
"image/"))) {
1947 $file = $dir .
"/" .
1948 $item->getLocation();
1949 if (is_file($file)) {
1968 $ppics = array(
"mob_vpreview.jpg",
1969 "mob_vpreview.jpeg",
1970 "mob_vpreview.png");
1971 foreach ($ppics as $p) {
1972 if (is_file($dir .
"/" . $p)) {
1973 if ($a_filename_only) {
1976 return $dir .
"/" . $p;
1993 $rchars = array(
"`",
"=",
"$",
"{",
"}",
"'",
";",
" ",
"(",
")");
1994 $a_name = str_replace($rchars,
"_", $a_name);
1995 $a_name = str_replace(
"__",
"_", $a_name);
2023 include_once(
"./Services/MediaObjects/exceptions/class.ilMediaObjectsException.php");
2024 if (!is_file($a_file[
"tmp_name"])) {
2050 include_once(
"./Services/MetaData/classes/class.ilMDLanguageItem.php");
2055 foreach ($files as $k =>
$i) {
2057 if (
$i[
"type"] ==
"file" && !in_array($k, array(
".",
".."))) {
2058 if (pathinfo($k, PATHINFO_EXTENSION) ==
"srt") {
2060 if (substr($k, strlen($k) - 7, 1) ==
"_") {
2061 $lang = substr($k, strlen($k) - 6, 2);
2062 if (!in_array(
$lang, $lang_codes)) {
2066 $items[] = array(
"filename" => $k,
"lang" =>
$lang);
2081 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.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
static _lookupSLMID($a_id)
Lookup Scorm Learning Module ID for node id.
static _lookupTestObjIdForQuestionId($a_q_id)
Get test Object ID for question ID.
special template class to simplify handling of ITX/PEAR
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
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
getId()
get object id public
static _getPageForQuestionId($a_q_id, $a_parent_type="")
Get page for question id.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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
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)
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)
__construct(Container $dic, ilPlugin $plugin)
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.
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