27 define(
"IL_MODE_ALIAS", 1);
28 define(
"IL_MODE_OUTPUT", 2);
29 define(
"IL_MODE_FULL", 3);
50 $this->
user = $DIC->user();
51 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
52 $this->
lng = $DIC->language();
53 $this->is_alias =
false;
54 $this->media_items = array();
55 $this->contains_int_link =
false;
58 $this->image_converter = $DIC->fileConverters()->legacyImages();
59 $this->domain = $DIC->mediaObjects()->internal()->domain();
64 bool $reference =
false,
67 if (is_int(strpos($id,
"_"))) {
77 public function delete():
bool 80 $mob_logger->debug(
"ilObjMediaObject: Delete called for media object ID '" . $this->
getId() .
"'.");
82 if (!($this->
getId() > 0)) {
88 $mob_logger->debug(
"ilObjMediaObject: ... Found " . count($usages) .
" usages.");
90 if (count($usages) == 0) {
105 self::handleQuotaUpdate($this);
110 $mob_logger->debug(
"ilObjMediaObject: ... deleted.");
112 foreach ($usages as $u) {
113 $mob_logger->debug(
"ilObjMediaObject: ... usage type:" . $u[
"type"] .
115 ", lang:" . ($u[
"lang"] ??
"") .
116 ", hist_nr:" . ($u[
"hist_nr"] ??
"") .
".");
118 $mob_logger->debug(
"ilObjMediaObject: ... not deleted.");
125 switch ($a_element) {
130 $md_gen = $md->getGeneral();
132 if (is_object($md_gen)) {
134 $this->
setTitle($md_gen->getTitle());
136 foreach ($md_gen->getDescriptionIds() as
$id) {
137 $md_des = $md_gen->getDescription(
$id);
154 $md_creator->setTitle($this->
getTitle());
155 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
157 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
158 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
159 $md_creator->setLanguage($ilUser->getPref(
'language'));
160 $md_creator->create();
168 $md_gen = $md->getGeneral();
169 $md_gen->setTitle($this->
getTitle());
172 $md_des_ids = $md_gen->getDescriptionIds();
173 if (count($md_des_ids) > 0) {
174 $md_des = $md_gen->getDescription($md_des_ids[0]);
195 $this->media_items[] = $a_item;
209 foreach ($this->media_items as $media_item) {
210 if ($media_item->getPurpose() == $a_purpose) {
220 foreach ($this->media_items as
$key => $media_item) {
221 if ($media_item->getPurpose() == $a_purpose) {
222 unset($this->media_items[
$key]);
227 $media_items = array();
228 foreach ($this->media_items as $media_item) {
229 $media_items [$i] = $media_item;
230 $media_item->setMobId($this->
getId());
231 $media_item->setNr($i);
239 $this->media_items = array();
271 $this->is_alias = $a_is_alias;
284 $this->origin_id = $a_id;
292 public function create(
bool $a_create_meta_data =
false,
bool $a_save_media_items =
true):
int 294 $id = parent::create();
296 if (!$a_create_meta_data) {
300 if ($a_save_media_items) {
302 for ($i = 0; $i < count($media_items); $i++) {
303 $item = $media_items[$i];
304 $item->setMobId($this->
getId());
305 $item->setNr($i + 1);
310 self::handleQuotaUpdate($this);
313 $ilAppEventHandler->
raise(
314 'Services/MediaObjects',
316 array(
'object' => $this,
318 'obj_id' => $this->
getId())
324 public function update(
bool $a_upload =
false): bool
337 foreach ($media_items as
$key => $val) {
339 if (is_object($item)) {
340 $item->setMobId($this->
getId());
342 if ($item->getLocationType() ==
"Reference") {
343 $item->extractUrlParameters();
350 self::handleQuotaUpdate($this);
352 $ilAppEventHandler->
raise(
353 'Services/MediaObjects',
355 array(
'object' => $this,
357 'obj_id' => $this->
getId())
385 return "mobs/mm_" . $a_mob_id;
402 string $a_mode =
"filesystem" 412 bool $a_url_encode =
false,
423 bool $a_url_encode =
false,
425 string $a_purpose =
"" 427 if ($a_purpose ==
"") {
428 $a_purpose =
"Standard";
431 if (preg_match(
"/https?\:/i",
$location)) {
454 if (!is_dir(
$path)) {
473 string $a_subdir =
"" 475 $a_subdir = str_replace(
"..",
"", $a_subdir);
477 if ($a_subdir !=
"") {
478 $dir .=
"/" . $a_subdir;
484 foreach ($entries as
$e) {
485 if (is_file($dir .
"/" . $e[
"entry"]) && $e[
"entry"] !=
"." && $e[
"entry"] !=
"..") {
486 $files[] = $e[
"entry"];
505 bool $a_sign_locals =
false 513 $xml =
"<MediaObject>";
514 $xml .=
"<MediaAlias OriginId=\"il__mob_" . $this->
getId() .
"\"/>";
516 for ($i = 0; $i < count($media_items); $i++) {
517 $item = $media_items[$i];
518 $xml .=
"<MediaAliasItem Purpose=\"" . $item->getPurpose() .
"\">";
521 $width = ($item->getWidth() !=
"")
522 ?
"Width=\"" . $item->getWidth() .
"\"" 524 $height = ($item->getHeight() !=
"")
525 ?
"Height=\"" . $item->getHeight() .
"\"" 527 $halign = ($item->getHAlign() !=
"")
528 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 530 $xml .=
"<Layout $width $height $halign />";
533 if ($item->getCaption() !=
"") {
534 $xml .=
"<Caption Align=\"bottom\">" .
539 if ($item->getTextRepresentation() !=
"") {
540 $xml .=
"<TextRepresentation>" .
541 $this->
escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
545 $parameters = $item->getParameters();
546 foreach ($parameters as $name => $value) {
547 $xml .=
"<Parameter Name=\"$name\" Value=\"" . $this->
escapeProperty($value) .
"\"/>";
549 $xml .= $item->getMapAreasXML();
550 $xml .=
"</MediaAliasItem>";
559 $xml =
"<MediaObject Id=\"il__mob_" . $this->
getId() .
"\">";
562 for ($i = 0; $i < count($media_items); $i++) {
563 $item = $media_items[$i];
565 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
567 if ($a_sign_locals && $item->getLocationType() ==
"LocalFile") {
569 $location = substr($location, strrpos($location,
"/") + 1);
572 if ($item->getLocationType() !=
"LocalFile") {
577 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
581 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
584 $width = ($item->getWidth() !=
"")
585 ?
"Width=\"" . $item->getWidth() .
"\"" 587 $height = ($item->getHeight() !=
"")
588 ?
"Height=\"" . $item->getHeight() .
"\"" 590 $halign = ($item->getHAlign() !=
"")
591 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 593 $xml .=
"<Layout $width $height $halign />";
596 if ($item->getCaption() !=
"") {
597 $xml .=
"<Caption Align=\"bottom\">" .
602 if ($item->getTextRepresentation() !=
"") {
603 $xml .=
"<TextRepresentation>" .
604 $this->
escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
614 $parameters = $item->getParameters();
615 foreach ($parameters as $name => $value) {
616 $xml .=
"<Parameter Name=\"$name\" Value=\"" . $this->
escapeProperty($value) .
"\"/>";
618 $xml .= $item->getMapAreasXML();
621 if ($item->getPurpose() ==
"Standard") {
623 foreach ($srts as $srt) {
626 if ($ilUser->getLanguage() != $meta_lang &&
627 $ilUser->getLanguage() == $srt[
"language"]) {
628 $def =
' Default="true" ';
630 $xml .=
"<Subtitle File=\"" . $srt[
"full_path"] .
631 "\" Language=\"" . $srt[
"language"] .
"\" " . $def .
"/>";
638 $xml .=
"</MediaItem>";
646 $xml =
"<MediaObject>";
650 $md2xml->setExportMode(
true);
651 $md2xml->startExport();
652 $xml .= $md2xml->getXML();
655 for ($i = 0; $i < count($media_items); $i++) {
656 $item = $media_items[$i];
659 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
662 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
663 $this->
handleAmps($item->getLocation()) .
"</Location>";
666 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
669 $width = ($item->getWidth() !=
"")
670 ?
"Width=\"" . $item->getWidth() .
"\"" 672 $height = ($item->getHeight() !=
"")
673 ?
"Height=\"" . $item->getHeight() .
"\"" 675 $halign = ($item->getHAlign() !=
"")
676 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 678 $xml .=
"<Layout $width $height $halign />";
681 if ($item->getCaption() !=
"") {
682 $xml .=
"<Caption Align=\"bottom\">" .
683 str_replace(
"&",
"&", $item->getCaption()) .
"</Caption>";
687 if ($item->getTextRepresentation() !=
"") {
688 $xml .=
"<TextRepresentation>" .
689 str_replace(
"&",
"&", $item->getTextRepresentation()) .
"</TextRepresentation>";
693 $parameters = $item->getParameters();
694 foreach ($parameters as $name => $value) {
695 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
697 $xml .= $item->getMapAreasXML(
true, $a_inst);
698 $xml .=
"</MediaItem>";
702 $xml .=
"</MediaObject>";
712 return htmlspecialchars($a_value);
722 $a_str = str_replace(
"&",
"&", $a_str);
723 $a_str = str_replace(
"&",
"&", $a_str);
758 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
775 bool $a_contains_link
777 $this->contains_int_link = $a_contains_link;
792 ?
int $a_usage_hist_nr = 0,
797 $ilDB = $DIC->database();
800 if (!is_null($a_usage_hist_nr)) {
801 $and_hist =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
805 $set =
$ilDB->query(
"SELECT id FROM mob_usage" .
806 " WHERE usage_type = " .
$ilDB->quote($a_type,
"text") .
807 " AND usage_id = " .
$ilDB->quote($a_id,
"integer") .
808 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
810 while ($row =
$ilDB->fetchAssoc($set)) {
811 $mob_ids[] = $row[
"id"];
814 $q =
"DELETE FROM mob_usage WHERE usage_type = " .
815 $ilDB->quote($a_type,
"text") .
816 " AND usage_id= " .
$ilDB->quote($a_id,
"integer") .
817 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
821 foreach ($mob_ids as $mob_id) {
822 self::handleQuotaUpdate(
new self($mob_id));
832 int $a_usage_hist_nr = 0,
837 $ilDB = $DIC->database();
841 $lstr =
" AND usage_lang = " .
$ilDB->quote($a_lang,
"text");
844 if ($a_usage_hist_nr > 0) {
845 $hist_str =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
848 $q =
"SELECT * FROM mob_usage WHERE " .
849 "usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " .
850 "usage_id = " .
$ilDB->quote($a_id,
"integer") .
854 while ($mob_rec =
$ilDB->fetchAssoc($mob_set)) {
855 $mob_id = (
int) $mob_rec[
'id'];
857 $mobs[$mob_id] = $mob_id;
871 int $a_usage_hist_nr = 0,
876 $ilDB = $DIC->database();
881 "id" => array(
"integer", $a_mob_id),
882 "usage_type" => array(
"text", $a_type),
883 "usage_id" => array(
"integer", $a_id),
884 "usage_lang" => array(
"text", $a_lang),
885 "usage_hist_nr" => array(
"integer", $a_usage_hist_nr)
890 self::handleQuotaUpdate(
new self($a_mob_id));
900 int $a_usage_hist_nr = 0,
905 $ilDB = $DIC->database();
907 $q =
"DELETE FROM mob_usage WHERE " .
908 " id = " .
$ilDB->quote($a_mob_id,
"integer") .
" AND " .
909 " usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " .
910 " usage_id = " .
$ilDB->quote($a_id,
"integer") .
" AND " .
911 " usage_lang = " .
$ilDB->quote($a_lang,
"text") .
" AND " .
912 " usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
915 self::handleQuotaUpdate(
new self($a_mob_id));
922 bool $a_include_history =
true 924 return self::lookupUsages($this->
getId(), $a_include_history);
934 bool $a_include_history =
true 938 $ilDB = $DIC->database();
941 if ($a_include_history) {
942 $hist_str =
", usage_hist_nr";
946 $q =
"SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str .
" FROM mob_usage WHERE id = " .
947 $ilDB->quote($a_id,
"integer");
949 if (!$a_include_history) {
950 $q .=
" AND usage_hist_nr = " .
$ilDB->quote(0,
"integer");
955 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
958 if (is_int(strpos($us_rec[
"usage_type"],
":"))) {
959 $us_arr = explode(
":", $us_rec[
"usage_type"]);
974 "type" => $us_rec[
"usage_type"],
975 "id" => $us_rec[
"usage_id"],
976 "lang" => $us_rec[
"usage_lang"],
977 "hist_nr" => ($us_rec[
"usage_hist_nr"] ?? 0)
983 $q =
"SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = " .
984 $ilDB->quote($a_id,
"integer") .
" AND mep_item.type = " .
$ilDB->quote(
"mob",
"text");
986 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
987 $ret[] = array(
"type" =>
"mep",
988 "id" => $us_rec[
"mep_id"]);
993 foreach ($news_usages as $nu) {
999 $q =
"SELECT DISTINCT mob_id FROM media_item it, map_area area " .
1000 " WHERE area.item_id = it.id " .
1001 " AND area.link_type = " .
$ilDB->quote(
"int",
"text") .
" " .
1002 " AND area.target = " .
$ilDB->quote(
"il__mob_" . $a_id,
"text");
1004 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
1005 $ret[] = array(
"type" =>
"map",
1006 "id" => $us_rec[
"mob_id"]);
1011 foreach ($users as $user) {
1012 $ret[] = array(
"type" =>
"clip",
1025 bool $a_include_all_access_obj_ids =
false 1028 if (is_int(strpos($a_usage[
"type"],
":"))) {
1029 $us_arr = explode(
":", $a_usage[
"type"]);
1031 $cont_type = $us_arr[0];
1033 $type = $a_usage[
"type"];
1036 $id = $a_usage[
"id"];
1043 switch ($cont_type) {
1047 $qinfo = $DIC->testQuestionPool()->questionInfo()->getQuestionInfo(
$id);
1048 if (isset($qinfo[
"original_id"]) && $qinfo[
"original_id"] > 0) {
1051 $obj_id = (
int) ($qinfo[
"obj_fi"] ?? 0);
1059 $parent_id = $quest->getObjId();
1062 if ($quest->getOriginalId() &&
1068 $obj_id = (
int) $parent_id;
1077 $returned_pk = $a_usage[
'id'];
1084 $post_pk = $a_usage[
'id'];
1086 $frm_pk = $oPost->getForumId();
1092 $draft_id = $a_usage[
'id'];
1095 $frm_pk = $oDraft->getForumId();
1099 $history_id = $a_usage[
'id'];
1103 $frm_pk = $oDraft->getForumId();
1109 $obj_id = (
int) $a_usage[
'id'];
1127 switch ($cont_type) {
1132 if ($cont_type ==
"qfbg") {
1138 $qinfo = $DIC->testQuestionPool()->questionInfo()->getQuestionInfo(
$id);
1139 if ($qinfo[
"original_id"] > 0) {
1142 $obj_id = $qinfo[
"obj_fi"];
1146 if ($pinfo && $pinfo[
"parent_type"] ==
"lm") {
1220 bool $a_constrain_prop =
false 1223 $file_path = pathinfo($a_file);
1224 $location = substr($file_path[
"basename"], 0, strlen($file_path[
"basename"]) -
1225 strlen($file_path[
"extension"]) - 1) .
"_" .
1227 $a_height .
"." . $file_path[
"extension"];
1228 $target_file = $file_path[
"dirname"] .
"/" .
1231 $returned_target_file = $DIC->fileConverters()
1233 ->resizeToFixedSize(
1241 if ($returned_target_file !== $target_file) {
1253 bool $a_external =
false 1255 $mime = MimeType::lookupMimeType($a_file, MimeType::APPLICATION__OCTET_STREAM, $a_external);
1263 string $a_reference,
1264 bool $a_constrain_proportions,
1265 bool $a_use_original,
1266 ?
int $a_user_width = null,
1267 ?
int $a_user_height = null
1271 $lng = $DIC->language();
1290 if ($a_type ==
"File") {
1297 if (!isset($size[0])) {
1300 if (!isset($size[1])) {
1304 if ($a_use_original) {
1305 if ($size[0] > 0 && $size[1] > 0) {
1311 $info =
$lng->
txt(
"cont_could_not_determine_resource_size");
1315 $h = $a_user_height;
1320 if ($size[0] > 0 && $size[1] > 0) {
1322 $wr = $size[0] / $w;
1325 $hr = $size[1] / $h;
1331 $width = (
int) round($size[0] /
$r);
1332 $height = (
int) round($size[1] /
$r);
1340 if ($width == 0 && is_null($a_user_width)) {
1343 if ($height == 0 && is_null($a_user_height)) {
1346 return array(
"width" => $width,
"height" => $height,
"info" => $info);
1364 $media_object->setTitle($name);
1365 $media_object->setDescription(
"");
1366 $media_object->create();
1369 $media_object->createDirectory();
1373 $media_object->addMediaItem($media_item);
1374 $media_item->setPurpose(
"Standard");
1376 $file = $mob_dir .
"/" . $name;
1380 copy($tmp_name, $file);
1386 $media_item->setFormat($format);
1388 $media_item->setLocationType(
"LocalFile");
1389 $media_object->setTitle($name);
1390 $media_object->setDescription($format);
1394 $media_item->setWidth($size[0]);
1395 $media_item->setHeight($size[1]);
1397 $media_item->setHAlign(
"Left");
1399 self::renameExecutables($mob_dir);
1402 $media_object->update();
1404 return $media_object;
1413 string $a_subdir =
"",
1414 string $a_mode =
"move_uploaded" 1416 $a_subdir = str_replace(
"..",
"", $a_subdir);
1418 if ($a_subdir !=
"") {
1419 $dir .=
"/" . $a_subdir;
1422 if ($a_mode ==
"rename") {
1427 self::renameExecutables($mob_dir);
1436 $mob_dir = self::_getRelativeDirectory($this->
getId());
1437 $mob_dir .=
"/" . $subdir;
1450 string $a_mode =
"move_uploaded" 1452 if (is_file($a_tmp_name) && $a_language !=
"") {
1463 if (!is_dir($srt_dir)) {
1469 $srt_files = array();
1470 foreach ($items as $i) {
1471 if (!in_array($i[
"entry"], array(
".",
"..")) && $i[
"type"] ==
"file") {
1472 $name = explode(
".", $i[
"entry"]);
1473 if ($name[1] ==
"srt" && substr($name[0], 0, 9) ==
"subtitle_") {
1474 $srt_files[] = array(
"file" => $i[
"entry"],
1475 "full_path" =>
"srt/" . $i[
"entry"],
"language" => substr($name[0], 9, 2));
1488 string $a_thumbname,
1490 $size = self::DEFAULT_PREVIEW_SIZE;
1493 $file = $m_dir .
"/" . $a_file;
1499 if ($size > (
int) $wh[0] && $size > $wh[1]) {
1500 $size = min($wh[0], $wh[1]);
1505 self::_createThumbnailDirectory($this->
getId());
1506 $this->image_converter->croppedSquare(
1507 $m_dir .
"/" . $a_file,
1508 $t_dir .
"/" . $a_thumbname,
1518 return $t_dir .
"/" . $a_thumbname;
1524 $file = str_replace(
"..",
"", $a_file);
1526 if (is_file($file)) {
1537 array $a_ignore = []
1544 foreach ($med_items as $med_item) {
1546 foreach ($int_links as $k => $int_link) {
1547 if ($int_link[
"Type"] ==
"MediaObject") {
1550 if (!in_array($l_id, $linked) &&
1551 !in_array($l_id, $a_ignore)) {
1566 return in_array($a_type, iterator_to_array(
1567 $DIC->mediaObjects()->internal()->domain()->mediaType()->getAllowedSuffixes()
1577 $new_obj->setTitle($this->
getTitle());
1582 $new_obj->addMediaItem($val);
1585 $new_obj->create(
false,
true);
1588 $new_obj->createDirectory();
1589 self::_createThumbnailDirectory($new_obj->getId());
1600 $md =
new ilMD(0, $this->
getId(),
"mob");
1601 $new_md = $md->cloneMD(0, $new_obj->getId(),
"mob");
1614 $pi = pathinfo($a_prevpic[
"name"]);
1615 $ext = $pi[
"extension"];
1616 if (in_array($ext, array(
"jpg",
"jpeg",
"png"))) {
1621 public function generatePreviewPic(
1627 $logger =
$GLOBALS[
'DIC']->logger()->mob();
1630 if ($item->getFormat() ===
"image/svg+xml") {
1634 $logger->debug(
"Generate preview pic...");
1635 $logger->debug(
"..." . $item->getFormat());
1637 if ($item->getLocationType() ==
"LocalFile") {
1638 if (is_int(strpos($item->getFormat(),
"image/"))) {
1639 $a_width = $a_height = self::DEFAULT_PREVIEW_SIZE;
1642 $file = $dir .
"/" .
1643 $item->getLocation();
1644 if (is_file($file)) {
1645 $logger->debug(
"Calling image converter.");
1646 $this->image_converter->resizeToFixedSize(
1648 $dir .
"/mob_vpreview.png",
1652 ImageOutputOptions::FORMAT_PNG
1658 if (in_array($item->getFormat(), [
"video/mp4",
"video/webm"])) {
1667 if ($med->getLocationType() ==
"LocalFile") {
1670 $mob_file = $med->getLocation();
1673 "...extract " . $mob_file .
" in " .
1676 $logger->debug(
"Call ffmpeg.");
1687 if (is_array($ret) && count($ret) > 0) {
1688 $message =
"\n" . implode(
"\n", $ret);
1691 $logger->warning($e->getMessage() .
$message);
1698 bool $a_filename_only =
false 1701 $ppics = array(
"mob_vpreview.jpg",
1702 "mob_vpreview.jpeg",
1703 "mob_vpreview.png");
1705 if ($med && $med->getFormat() ===
"image/svg+xml" && $med->getLocationType() ===
"LocalFile") {
1706 $ppics[] = $med->getLocation();
1708 foreach ($ppics as $p) {
1709 if (is_file($dir .
"/" . $p)) {
1710 if ($a_filename_only) {
1713 return $dir .
"/" . $p;
1728 $rchars = array(
"`",
"=",
"$",
"{",
"}",
"'",
";",
" ",
"(",
")");
1729 $a_name = str_replace($rchars,
"_", $a_name);
1730 $a_name = str_replace(
"__",
"_", $a_name);
1752 if (!is_file($a_file[
"tmp_name"])) {
1760 $this->domain->resources()->zip()->unzipFile($dir .
"/multi_srt.zip");
1782 foreach ($files as $k => $i) {
1784 if ($i[
"type"] ==
"file" && !in_array($k, array(
".",
".."))) {
1785 if (pathinfo($k, PATHINFO_EXTENSION) ==
"srt") {
1787 if (substr($k, strlen($k) - 7, 1) ==
"_") {
1788 $lang = substr($k, strlen($k) - 6, 2);
1789 if (!in_array(
$lang, $lang_codes)) {
1793 $items[] = array(
"filename" => $k,
"lang" =>
$lang);
1804 if (!self::isTypeAllowed(
"html")) {
1813 if ($st_item->getLocationType() ==
"Reference") {
1815 $st_item->setFormat(
"video/vimeo");
1818 $this->
setTitle($meta[
"title"] ??
"");
1819 $description = str_replace(
"\n",
"", $meta[
"description"] ??
"");
1820 $description = str_replace([
"<br>",
"<br />"], [
"\n",
"\n"], $description);
1821 $description = strip_tags($description);
1823 $st_item->setDuration((
int) ($meta[
"duration"] ?? 0));
1824 $url = parse_url($meta[
"thumbnail_url"] ??
"");
1825 $file = basename(
$url[
"path"]);
1826 $ext = pathinfo($file, PATHINFO_EXTENSION);
1831 $meta[
"thumbnail_url"],
1836 if (ilExternalMediaAnalyzer::isYoutube($st_item->getLocation())) {
1837 $st_item->setFormat(
"video/youtube");
1838 $par = ilExternalMediaAnalyzer::extractYoutubeParameters($st_item->getLocation());
1841 $this->
setTitle($meta[
"title"] ??
"");
1842 $description = str_replace(
"\n",
"", $meta[
"description"] ??
"");
1844 $this->
setTitle($st_item->getLocation());
1847 $description = str_replace([
"<br>",
"<br />"], [
"\n",
"\n"], $description);
1848 $description = strip_tags($description);
1850 $st_item->setDuration((
int) ($meta[
"duration"] ?? 0));
1851 $thumbnail_url = $meta[
"thumbnail_url"] ??
"";
1852 $url = parse_url($thumbnail_url);
1853 if ($thumbnail_url !==
"") {
1854 $file = basename(
$url[
"path"]);
1856 $meta[
"thumbnail_url"],
1858 pathinfo($file, PATHINFO_EXTENSION)
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static getLastReturnValues()
Get last return values.
static _writeTitle(int $obj_id, string $title)
write title to db (static)
static getLogger(string $a_component_id)
Get component logger.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _extractObjIdOfTarget(string $a_target)
Extract object id out of target.
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getIntLinks(int $a_item_id)
get all internal links of a media items map areas
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getPageForQuestionId(int $a_q_id, string $a_parent_type="")
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static rRenameSuffix(string $a_dir, string $a_old_suffix, string $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.
appendXML(string $a_str)
append xml string to document
static extractImage(string $a_file, string $a_target_filename, string $a_target_dir="", int $a_sec=1)
Extract image from video file.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static secureUrl(string $url)
static _lookupTestObjIdForQuestionId(int $q_id)
Get test Object ID for question ID.
Class ilForumDraftHistory.
static getASCIIFilename(string $a_filename)
static renameExecutables(string $a_dir)
ilAppEventHandler $app_event_handler
static _getPossibleLanguageCodes()
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static _lookupObjIdForForumId(int $a_for_id)
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
moveOneFileTo(UploadResult $uploadResult, string $destination, int $location=Location::STORAGE, string $file_name='', bool $override_existing=false)
Moves a single File (the attributes, metadata and upload-status of which are contained in UploadResul...
static createDirectory(string $a_dir, int $a_mod=0755)
create directory
static lookupExerciseIdForReturnedId(int $a_returned_id)
Get exercise from submission id (used in ilObjMediaObject)
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
static getHtmlPath(string $relative_path)
get url of path
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static lookupParentId(int $a_id, string $a_type)
static _lookupSurveyObjId(int $a_question_id)
static deducibleSize(string $a_mime)
checks if mime type is provided by getimagesize()
static _getUsersForClipboadObject(string $a_type, int $a_id)
get all users, that have a certain object within their clipboard
static lookupObjIdByPage(int $a_page_id)
returns the wiki/object id to a given page id
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static findPortfolioForPage(int $a_page_id)
Get portfolio id of page id.
static _lookupContObjID(int $a_id)
get learning module id for lm object
static signFile(string $path_to_file)
static rename(string $a_source, string $a_target)
static _lookupMediaObjectUsages(int $a_mob_id)
Lookup media object usage(s)
static newInstanceByDraftId(int $draft_id)
static _lookupType(int $id, bool $reference=false)
static insertInstIntoID(string $a_value)
inserts installation id into ILIAS id
static _instanciateQuestion(int $question_id)
Get question object.
static _lookupContextObjId(int $a_news_id)
Context Object ID.
setDescription(string $description)
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static _writeDescription(int $obj_id, string $desc)
write description to db (static)
static _lookGlossaryID(int $term_id)
get glossary id form term id