21 define(
"IL_MODE_ALIAS", 1);
22 define(
"IL_MODE_OUTPUT", 2);
23 define(
"IL_MODE_FULL", 3);
41 $this->
user = $DIC->user();
42 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
43 $this->
lng = $DIC->language();
44 $this->is_alias =
false;
45 $this->media_items = array();
46 $this->contains_int_link =
false;
53 bool $reference =
false,
56 if (is_int(strpos($id,
"_"))) {
66 public function delete():
bool 69 $mob_logger->debug(
"ilObjMediaObject: Delete called for media object ID '" . $this->
getId() .
"'.");
71 if (!($this->
getId() > 0)) {
77 $mob_logger->debug(
"ilObjMediaObject: ... Found " . count($usages) .
" usages.");
79 if (count($usages) == 0) {
94 self::handleQuotaUpdate($this);
99 $mob_logger->debug(
"ilObjMediaObject: ... deleted.");
101 foreach ($usages as $u) {
102 $mob_logger->debug(
"ilObjMediaObject: ... usage type:" . $u[
"type"] .
104 ", lang:" . ($u[
"lang"] ??
"") .
105 ", hist_nr:" . ($u[
"hist_nr"] ??
"") .
".");
107 $mob_logger->debug(
"ilObjMediaObject: ... not deleted.");
114 switch ($a_element) {
119 $md_gen = $md->getGeneral();
121 if (is_object($md_gen)) {
123 $this->
setTitle($md_gen->getTitle());
125 foreach ($md_gen->getDescriptionIds() as
$id) {
126 $md_des = $md_gen->getDescription(
$id);
143 $md_creator->setTitle($this->
getTitle());
144 $md_creator->setTitleLanguage(
$ilUser->getPref(
'language'));
146 $md_creator->setDescriptionLanguage(
$ilUser->getPref(
'language'));
147 $md_creator->setKeywordLanguage(
$ilUser->getPref(
'language'));
148 $md_creator->setLanguage(
$ilUser->getPref(
'language'));
149 $md_creator->create();
157 $md_gen = $md->getGeneral();
158 $md_gen->setTitle($this->
getTitle());
161 $md_des_ids = $md_gen->getDescriptionIds();
162 if (count($md_des_ids) > 0) {
163 $md_des = $md_gen->getDescription($md_des_ids[0]);
184 $this->media_items[] = $a_item;
198 foreach ($this->media_items as $media_item) {
199 if ($media_item->getPurpose() == $a_purpose) {
209 foreach ($this->media_items as
$key => $media_item) {
210 if ($media_item->getPurpose() == $a_purpose) {
211 unset($this->media_items[
$key]);
216 $media_items = array();
217 foreach ($this->media_items as $media_item) {
218 $media_items [
$i] = $media_item;
219 $media_item->setMobId($this->
getId());
220 $media_item->setNr(
$i);
228 $this->media_items = array();
260 $this->is_alias = $a_is_alias;
273 $this->origin_id = $a_id;
281 public function create(
bool $a_create_meta_data =
false,
bool $a_save_media_items =
true):
int 283 $id = parent::create();
285 if (!$a_create_meta_data) {
289 if ($a_save_media_items) {
291 for (
$i = 0;
$i < count($media_items);
$i++) {
292 $item = $media_items[
$i];
293 $item->setMobId($this->
getId());
294 $item->setNr(
$i + 1);
299 self::handleQuotaUpdate($this);
302 $ilAppEventHandler->
raise(
303 'Services/MediaObjects',
305 array(
'object' => $this,
307 'obj_id' => $this->
getId())
313 public function update(
bool $a_upload =
false): bool
326 foreach ($media_items as
$key => $val) {
328 if (is_object($item)) {
329 $item->setMobId($this->
getId());
331 if ($item->getLocationType() ==
"Reference") {
332 $item->extractUrlParameters();
339 self::handleQuotaUpdate($this);
341 $ilAppEventHandler->
raise(
342 'Services/MediaObjects',
344 array(
'object' => $this,
346 'obj_id' => $this->
getId())
374 return "mobs/mm_" . $a_mob_id;
391 string $a_mode =
"filesystem" 401 bool $a_url_encode =
false,
412 bool $a_url_encode =
false,
414 string $a_purpose =
"" 416 if ($a_purpose ==
"") {
417 $a_purpose =
"Standard";
420 if (preg_match(
"/https?\:/i",
$location)) {
443 if (!is_dir(
$path)) {
462 string $a_subdir =
"" 464 $a_subdir = str_replace(
"..",
"", $a_subdir);
466 if ($a_subdir !=
"") {
467 $dir .=
"/" . $a_subdir;
473 foreach ($entries as
$e) {
474 if (is_file($dir .
"/" . $e[
"entry"]) && $e[
"entry"] !=
"." && $e[
"entry"] !=
"..") {
475 $files[] = $e[
"entry"];
494 bool $a_sign_locals =
false 502 $xml =
"<MediaObject>";
503 $xml .=
"<MediaAlias OriginId=\"il__mob_" . $this->
getId() .
"\"/>";
505 for (
$i = 0;
$i < count($media_items);
$i++) {
506 $item = $media_items[
$i];
507 $xml .=
"<MediaAliasItem Purpose=\"" . $item->getPurpose() .
"\">";
510 $width = ($item->getWidth() !=
"")
511 ?
"Width=\"" . $item->getWidth() .
"\"" 513 $height = ($item->getHeight() !=
"")
514 ?
"Height=\"" . $item->getHeight() .
"\"" 516 $halign = ($item->getHAlign() !=
"")
517 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 519 $xml .=
"<Layout $width $height $halign />";
522 if ($item->getCaption() !=
"") {
523 $xml .=
"<Caption Align=\"bottom\">" .
528 if ($item->getTextRepresentation() !=
"") {
529 $xml .=
"<TextRepresentation>" .
530 $this->
escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
534 $parameters = $item->getParameters();
535 foreach ($parameters as
$name => $value) {
536 $xml .=
"<Parameter Name=\"$name\" Value=\"" . $this->
escapeProperty($value) .
"\"/>";
538 $xml .= $item->getMapAreasXML();
539 $xml .=
"</MediaAliasItem>";
548 $xml =
"<MediaObject Id=\"il__mob_" . $this->
getId() .
"\">";
551 for (
$i = 0;
$i < count($media_items);
$i++) {
552 $item = $media_items[
$i];
554 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
556 if ($a_sign_locals && $item->getLocationType() ==
"LocalFile") {
558 $location = substr($location, strrpos($location,
"/") + 1);
561 if ($item->getLocationType() !=
"LocalFile") {
566 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
570 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
573 $width = ($item->getWidth() !=
"")
574 ?
"Width=\"" . $item->getWidth() .
"\"" 576 $height = ($item->getHeight() !=
"")
577 ?
"Height=\"" . $item->getHeight() .
"\"" 579 $halign = ($item->getHAlign() !=
"")
580 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 582 $xml .=
"<Layout $width $height $halign />";
585 if ($item->getCaption() !=
"") {
586 $xml .=
"<Caption Align=\"bottom\">" .
591 if ($item->getTextRepresentation() !=
"") {
592 $xml .=
"<TextRepresentation>" .
593 $this->
escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
603 $parameters = $item->getParameters();
604 foreach ($parameters as
$name => $value) {
605 $xml .=
"<Parameter Name=\"$name\" Value=\"" . $this->
escapeProperty($value) .
"\"/>";
607 $xml .= $item->getMapAreasXML();
610 if ($item->getPurpose() ==
"Standard") {
612 foreach ($srts as $srt) {
615 if (
$ilUser->getLanguage() != $meta_lang &&
616 $ilUser->getLanguage() == $srt[
"language"]) {
617 $def =
' Default="true" ';
619 $xml .=
"<Subtitle File=\"" . $srt[
"full_path"] .
620 "\" Language=\"" . $srt[
"language"] .
"\" " . $def .
"/>";
623 $xml .=
"</MediaItem>";
631 $xml =
"<MediaObject>";
635 $md2xml->setExportMode(
true);
636 $md2xml->startExport();
637 $xml .= $md2xml->getXML();
640 for (
$i = 0;
$i < count($media_items);
$i++) {
641 $item = $media_items[
$i];
644 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
647 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
648 $this->
handleAmps($item->getLocation()) .
"</Location>";
651 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
654 $width = ($item->getWidth() !=
"")
655 ?
"Width=\"" . $item->getWidth() .
"\"" 657 $height = ($item->getHeight() !=
"")
658 ?
"Height=\"" . $item->getHeight() .
"\"" 660 $halign = ($item->getHAlign() !=
"")
661 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\"" 663 $xml .=
"<Layout $width $height $halign />";
666 if ($item->getCaption() !=
"") {
667 $xml .=
"<Caption Align=\"bottom\">" .
668 str_replace(
"&",
"&", $item->getCaption()) .
"</Caption>";
672 if ($item->getTextRepresentation() !=
"") {
673 $xml .=
"<TextRepresentation>" .
674 str_replace(
"&",
"&", $item->getTextRepresentation()) .
"</TextRepresentation>";
678 $parameters = $item->getParameters();
679 foreach ($parameters as
$name => $value) {
680 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
682 $xml .= $item->getMapAreasXML(
true, $a_inst);
683 $xml .=
"</MediaItem>";
687 $xml .=
"</MediaObject>";
697 return htmlspecialchars($a_value);
707 $a_str = str_replace(
"&",
"&", $a_str);
708 $a_str = str_replace(
"&",
"&", $a_str);
743 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
760 bool $a_contains_link
762 $this->contains_int_link = $a_contains_link;
777 ?
int $a_usage_hist_nr = 0,
782 $ilDB = $DIC->database();
785 if (!is_null($a_usage_hist_nr)) {
786 $and_hist =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
790 $set =
$ilDB->query(
"SELECT id FROM mob_usage" .
791 " WHERE usage_type = " .
$ilDB->quote($a_type,
"text") .
792 " AND usage_id = " .
$ilDB->quote($a_id,
"integer") .
793 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
795 while ($row =
$ilDB->fetchAssoc($set)) {
796 $mob_ids[] = $row[
"id"];
799 $q =
"DELETE FROM mob_usage WHERE usage_type = " .
800 $ilDB->quote($a_type,
"text") .
801 " AND usage_id= " .
$ilDB->quote($a_id,
"integer") .
802 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
804 $ilDB->manipulate($q);
806 foreach ($mob_ids as $mob_id) {
807 self::handleQuotaUpdate(
new self($mob_id));
817 int $a_usage_hist_nr = 0,
822 $ilDB = $DIC->database();
826 $lstr =
" AND usage_lang = " .
$ilDB->quote($a_lang,
"text");
829 if ($a_usage_hist_nr > 0) {
830 $hist_str =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
833 $q =
"SELECT * FROM mob_usage WHERE " .
834 "usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " .
835 "usage_id = " .
$ilDB->quote($a_id,
"integer") .
838 $mob_set =
$ilDB->query($q);
839 while ($mob_rec =
$ilDB->fetchAssoc($mob_set)) {
840 $mob_id = (
int) $mob_rec[
'id'];
842 $mobs[$mob_id] = $mob_id;
856 int $a_usage_hist_nr = 0,
861 $ilDB = $DIC->database();
863 $log->
debug(
"save usage mob: " . $a_mob_id .
", type " . $a_type .
" id: " . $a_id .
", hist: " . $a_usage_hist_nr .
", lang: " . $a_lang);
867 "id" => array(
"integer", $a_mob_id),
868 "usage_type" => array(
"text", $a_type),
869 "usage_id" => array(
"integer", $a_id),
870 "usage_lang" => array(
"text", $a_lang),
871 "usage_hist_nr" => array(
"integer", $a_usage_hist_nr)
876 self::handleQuotaUpdate(
new self($a_mob_id));
886 int $a_usage_hist_nr = 0,
891 $ilDB = $DIC->database();
893 $q =
"DELETE FROM mob_usage WHERE " .
894 " id = " .
$ilDB->quote($a_mob_id,
"integer") .
" AND " .
895 " usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " .
896 " usage_id = " .
$ilDB->quote($a_id,
"integer") .
" AND " .
897 " usage_lang = " .
$ilDB->quote($a_lang,
"text") .
" AND " .
898 " usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
899 $ilDB->manipulate($q);
901 self::handleQuotaUpdate(
new self($a_mob_id));
908 bool $a_include_history =
true 910 return self::lookupUsages($this->
getId(), $a_include_history);
920 bool $a_include_history =
true 924 $ilDB = $DIC->database();
927 if ($a_include_history) {
928 $hist_str =
", usage_hist_nr";
931 $q =
"SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str .
" FROM mob_usage WHERE id = " .
932 $ilDB->quote($a_id,
"integer");
934 if (!$a_include_history) {
935 $q .=
" AND usage_hist_nr = " .
$ilDB->quote(0,
"integer");
938 $us_set =
$ilDB->query($q);
940 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
943 if (is_int(strpos($us_rec[
"usage_type"],
":"))) {
944 $us_arr = explode(
":", $us_rec[
"usage_type"]);
959 "type" => $us_rec[
"usage_type"],
960 "id" => $us_rec[
"usage_id"],
961 "lang" => $us_rec[
"usage_lang"],
962 "hist_nr" => ($us_rec[
"usage_hist_nr"] ?? 0)
968 $q =
"SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = " .
969 $ilDB->quote($a_id,
"integer") .
" AND mep_item.type = " .
$ilDB->quote(
"mob",
"text");
970 $us_set =
$ilDB->query($q);
971 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
972 $ret[] = array(
"type" =>
"mep",
973 "id" => $us_rec[
"mep_id"]);
978 foreach ($news_usages as $nu) {
984 $q =
"SELECT DISTINCT mob_id FROM media_item it, map_area area " .
985 " WHERE area.item_id = it.id " .
986 " AND area.link_type = " .
$ilDB->quote(
"int",
"text") .
" " .
987 " AND area.target = " .
$ilDB->quote(
"il__mob_" . $a_id,
"text");
988 $us_set =
$ilDB->query($q);
989 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
990 $ret[] = array(
"type" =>
"map",
991 "id" => $us_rec[
"mob_id"]);
996 foreach ($users as $user) {
997 $ret[] = array(
"type" =>
"clip",
1010 bool $a_include_all_access_obj_ids =
false 1013 if (is_int(strpos($a_usage[
"type"],
":"))) {
1014 $us_arr = explode(
":", $a_usage[
"type"]);
1016 $cont_type = $us_arr[0];
1018 $type = $a_usage[
"type"];
1021 $id = $a_usage[
"id"];
1028 switch ($cont_type) {
1032 if (isset($qinfo[
"original_id"]) && $qinfo[
"original_id"] > 0) {
1035 $obj_id = (
int) ($qinfo[
"obj_fi"] ?? 0);
1043 $parent_id = $quest->getObjId();
1046 if ($quest->getOriginalId() &&
1052 $obj_id = (
int) $parent_id;
1061 $returned_pk = $a_usage[
'id'];
1068 $post_pk = $a_usage[
'id'];
1070 $frm_pk = $oPost->getForumId();
1076 $draft_id = $a_usage[
'id'];
1079 $frm_pk = $oDraft->getForumId();
1083 $history_id = $a_usage[
'id'];
1087 $frm_pk = $oDraft->getForumId();
1093 $obj_id = (
int) $a_usage[
'id'];
1111 switch ($cont_type) {
1116 if ($cont_type ==
"qfbg") {
1122 if ($qinfo[
"original_id"] > 0) {
1125 $obj_id = $qinfo[
"obj_fi"];
1129 if ($pinfo && $pinfo[
"parent_type"] ==
"lm") {
1133 if ($pinfo && $pinfo[
"parent_type"] ==
"sahs") {
1134 $obj_id = (
int) ilSCORM2004Node::_lookupSLMID($pinfo[
"page_id"]);
1215 bool $a_constrain_prop =
false 1217 $file_path = pathinfo($a_file);
1218 $location = substr($file_path[
"basename"], 0, strlen($file_path[
"basename"]) -
1219 strlen($file_path[
"extension"]) - 1) .
"_" .
1221 $a_height .
"." . $file_path[
"extension"];
1222 $target_file = $file_path[
"dirname"] .
"/" .
1240 bool $a_external =
false 1242 $mime = MimeType::lookupMimeType($a_file, MimeType::APPLICATION__OCTET_STREAM, $a_external);
1250 string $a_reference,
1251 bool $a_constrain_proportions,
1252 bool $a_use_original,
1253 ?
int $a_user_width = null,
1254 ?
int $a_user_height = null
1258 $lng = $DIC->language();
1277 if ($a_type ==
"File") {
1284 if (!isset($size[0])) {
1287 if (!isset($size[1])) {
1291 if ($a_use_original) {
1292 if ($size[0] > 0 && $size[1] > 0) {
1298 $info =
$lng->
txt(
"cont_could_not_determine_resource_size");
1302 $h = $a_user_height;
1307 if ($size[0] > 0 && $size[1] > 0) {
1309 $wr = $size[0] / $w;
1312 $hr = $size[1] / $h;
1318 $width = (
int) round($size[0] / $r);
1319 $height = (
int) round($size[1] / $r);
1327 if ($width == 0 && is_null($a_user_width)) {
1330 if ($height == 0 && is_null($a_user_height)) {
1333 return array(
"width" => $width,
"height" => $height,
"info" => $info);
1351 $media_object->setTitle($name);
1352 $media_object->setDescription(
"");
1353 $media_object->create();
1356 $media_object->createDirectory();
1360 $media_object->addMediaItem($media_item);
1361 $media_item->setPurpose(
"Standard");
1363 $file = $mob_dir .
"/" .
$name;
1367 copy($tmp_name, $file);
1373 $media_item->setFormat(
$format);
1375 $media_item->setLocationType(
"LocalFile");
1376 $media_object->setTitle($name);
1377 $media_object->setDescription(
$format);
1381 $media_item->setWidth($size[0]);
1382 $media_item->setHeight($size[1]);
1384 $media_item->setHAlign(
"Left");
1386 self::renameExecutables($mob_dir);
1389 $media_object->update();
1391 return $media_object;
1400 string $a_subdir =
"",
1401 string $a_mode =
"move_uploaded" 1403 $a_subdir = str_replace(
"..",
"", $a_subdir);
1405 if ($a_subdir !=
"") {
1406 $dir .=
"/" . $a_subdir;
1409 if ($a_mode ==
"rename") {
1414 self::renameExecutables($mob_dir);
1421 string $a_mode =
"move_uploaded" 1423 if (is_file($a_tmp_name) && $a_language !=
"") {
1434 if (!is_dir($srt_dir)) {
1440 $srt_files = array();
1441 foreach ($items as
$i) {
1442 if (!in_array($i[
"entry"], array(
".",
"..")) && $i[
"type"] ==
"file") {
1443 $name = explode(
".", $i[
"entry"]);
1444 if (
$name[1] ==
"srt" && substr(
$name[0], 0, 9) ==
"subtitle_") {
1445 $srt_files[] = array(
"file" => $i[
"entry"],
1446 "full_path" =>
"srt/" . $i[
"entry"],
"language" => substr(
$name[0], 9, 2));
1459 string $a_thumbname,
1460 string $a_format =
"png",
1463 $size = (
int) $a_size;
1466 $file = $m_dir .
"/" . $a_file;
1472 if ($size > (
int) $wh[0] && $size > $wh[1]) {
1478 self::_createThumbnailDirectory($this->
getId());
1480 $m_dir .
"/" . $a_file,
1481 $t_dir .
"/" . $a_thumbname,
1492 return $t_dir .
"/" . $a_thumbname;
1498 $file = str_replace(
"..",
"", $a_file);
1500 if (is_file($file)) {
1511 array $a_ignore = []
1518 foreach ($med_items as $med_item) {
1520 foreach ($int_links as $k => $int_link) {
1521 if ($int_link[
"Type"] ==
"MediaObject") {
1524 if (!in_array($l_id, $linked) &&
1525 !in_array($l_id, $a_ignore)) {
1542 return array_filter(self::getAllowedFileTypes(),
function ($v) {
1543 return !in_array($v, self::getForbiddenFileTypes());
1553 if (trim((
string) $mset->get(
"black_list_file_types")) ===
"") {
1558 return strtolower(trim($v));
1560 explode(
",", $mset->get(
"black_list_file_types"))
1570 if (trim((
string) $mset->get(
"restricted_file_types")) ===
"") {
1575 return strtolower(trim($v));
1577 explode(
",", $mset->get(
"restricted_file_types"))
1584 if (in_array($a_type, self::getForbiddenFileTypes())) {
1587 if (count(self::getAllowedFileTypes()) == 0 || in_array($a_type, self::getAllowedFileTypes())) {
1599 $new_obj->setTitle($this->
getTitle());
1604 $new_obj->addMediaItem($val);
1607 $new_obj->create(
false,
true);
1610 $new_obj->createDirectory();
1611 self::_createThumbnailDirectory($new_obj->getId());
1622 $md =
new ilMD(0, $this->
getId(),
"mob");
1623 $new_md = $md->cloneMD(0, $new_obj->getId(),
"mob");
1636 $pi = pathinfo($a_prevpic[
"name"]);
1637 $ext = $pi[
"extension"];
1638 if (in_array($ext, array(
"jpg",
"jpeg",
"png"))) {
1643 public function generatePreviewPic(
1649 $logger =
$GLOBALS[
'DIC']->logger()->mob();
1652 if ($item->getFormat() ===
"image/svg+xml") {
1656 if ($item->getLocationType() ==
"LocalFile") {
1657 if (is_int(strpos($item->getFormat(),
"image/"))) {
1658 $a_width = $a_height = 400;
1662 $file = $dir .
"/" .
1663 $item->getLocation();
1664 if (is_file($file)) {
1669 ) .
"[0] -geometry " . $a_width .
"x" . $a_height .
"^ -gravity center -extent " . $a_width .
"x" . $a_height .
" PNG:" . $dir .
"/mob_vpreview.png" 1678 $logger->debug(
"Generate preview pic...");
1679 $logger->debug(
"..." . $item->getFormat());
1680 if (is_int(strpos($item->getFormat(),
"video/mp4"))) {
1689 if ($med->getLocationType() ==
"LocalFile") {
1692 $mob_file = $med->getLocation();
1695 "...extract " . $mob_file .
" in " .
1708 if (is_array($ret) && count($ret) > 0) {
1709 $message =
"\n" . implode(
"\n", $ret);
1712 $logger->warning($e->getMessage() .
$message);
1719 bool $a_filename_only =
false 1722 $ppics = array(
"mob_vpreview.jpg",
1723 "mob_vpreview.jpeg",
1724 "mob_vpreview.png");
1725 foreach ($ppics as $p) {
1726 if (is_file($dir .
"/" . $p)) {
1727 if ($a_filename_only) {
1730 return $dir .
"/" . $p;
1745 $rchars = array(
"`",
"=",
"$",
"{",
"}",
"'",
";",
" ",
"(",
")");
1746 $a_name = str_replace($rchars,
"_", $a_name);
1747 $a_name = str_replace(
"__",
"_", $a_name);
1769 if (!is_file($a_file[
"tmp_name"])) {
1799 foreach ($files as $k =>
$i) {
1801 if (
$i[
"type"] ==
"file" && !in_array($k, array(
".",
".."))) {
1802 if (pathinfo($k, PATHINFO_EXTENSION) ==
"srt") {
1804 if (substr($k, strlen($k) - 7, 1) ==
"_") {
1805 $lang = substr($k, strlen($k) - 6, 2);
1806 if (!in_array(
$lang, $lang_codes)) {
1810 $items[] = array(
"filename" => $k,
"lang" =>
$lang);
1821 if (!self::isTypeAllowed(
"html")) {
1830 if ($st_item->getLocationType() ==
"Reference") {
1832 $st_item->setFormat(
"video/vimeo");
1835 $this->
setTitle($meta[
"title"] ??
"");
1836 $description = str_replace(
"\n",
"", $meta[
"description"] ??
"");
1837 $description = str_replace([
"<br>",
"<br />"], [
"\n",
"\n"], $description);
1838 $description = strip_tags($description);
1840 $st_item->setDuration((
int) ($meta[
"duration"] ?? 0));
1841 $url = parse_url($meta[
"thumbnail_url"] ??
"");
1842 $file = basename(
$url[
"path"]);
1843 $ext = pathinfo($file, PATHINFO_EXTENSION);
1848 $meta[
"thumbnail_url"],
1853 if (ilExternalMediaAnalyzer::isYoutube($st_item->getLocation())) {
1854 $st_item->setFormat(
"video/youtube");
1855 $par = ilExternalMediaAnalyzer::extractYoutubeParameters($st_item->getLocation());
1858 $this->
setTitle($meta[
"title"] ??
"");
1859 $description = str_replace(
"\n",
"", $meta[
"description"] ??
"");
1861 $this->
setTitle($st_item->getLocation());
1864 $description = str_replace([
"<br>",
"<br />"], [
"\n",
"\n"], $description);
1865 $description = strip_tags($description);
1867 $st_item->setDuration((
int) ($meta[
"duration"] ?? 0));
1868 $thumbnail_url = $meta[
"thumbnail_url"] ??
"";
1869 $url = parse_url($thumbnail_url);
1870 if ($thumbnail_url !==
"") {
1871 $file = basename(
$url[
"path"]);
1873 $meta[
"thumbnail_url"],
1875 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.
static _lookupTestObjIdForQuestionId($a_q_id)
Get test Object ID for question ID.
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 isConvertVersionAtLeast(string $a_version)
Compare convert version numbers.
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
debug(string $a_message, array $a_context=array())
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 escapeShellArg(string $a_arg)
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 unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
Class ilForumDraftHistory.
static getASCIIFilename(string $a_filename)
static renameExecutables(string $a_dir)
setDescription(string $desc)
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
static createDirectory(string $a_dir, int $a_mod=0755)
create directory
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
static _getQuestionInfo(int $question_id)
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 convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image
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 _lookupTermId(int $a_def_id)
Looks up term id for a definition id.
__construct(Container $dic, ilPlugin $plugin)
static lookupObjIdByPage(int $a_page_id)
returns the wiki/object id to a given page id
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.
static execConvert(string $args)
execute convert command
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.
static resizeImage(string $a_from, string $a_to, int $a_width, int $a_height, bool $a_constrain_prop=false)
resize image
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