29define(
"IL_MODE_ALIAS", 1);
30define(
"IL_MODE_OUTPUT", 2);
31define(
"IL_MODE_FULL", 3);
55 $this->
user = $DIC->user();
56 $this->app_event_handler =
$DIC[
"ilAppEventHandler"];
57 $this->
lng = $DIC->language();
58 $this->is_alias =
false;
59 $this->media_items = array();
60 $this->contains_int_link =
false;
63 $this->image_converter =
$DIC->fileConverters()->legacyImages();
64 $this->domain =
$DIC->mediaObjects()->internal()->domain();
65 $this->manager = $this->domain->mediaObject();
66 $this->thumbs = $this->domain->thumbs();
71 bool $reference =
false,
74 if (is_int(strpos(
$id,
"_"))) {
84 public function delete():
bool
87 $mob_logger->debug(
"ilObjMediaObject: Delete called for media object ID '" . $this->
getId() .
"'.");
89 if (!($this->
getId() > 0)) {
93 $usages = $this->getUsages();
95 $mob_logger->debug(
"ilObjMediaObject: ... Found " . count($usages) .
" usages.");
97 if (count($usages) == 0) {
99 $this->deleteMetaData();
106 self::handleQuotaUpdate($this);
111 $mob_logger->debug(
"ilObjMediaObject: ... deleted.");
113 foreach ($usages as $u) {
114 $mob_logger->debug(
"ilObjMediaObject: ... usage type:" . $u[
"type"] .
116 ", lang:" . ($u[
"lang"] ??
"") .
117 ", hist_nr:" . ($u[
"hist_nr"] ??
"") .
".");
119 $mob_logger->debug(
"ilObjMediaObject: ... not deleted.");
126 switch ($a_element) {
129 $paths = $this->domain->metadata()->learningObjectMetadata()->paths();
130 $reader = $this->domain->metadata()->learningObjectMetadata()->read(
134 $paths->custom()->withNextStep(
'general')->get()
146 $ilUser = $this->user;
148 $this->domain->metadata()->learningObjectMetadata()->derive()->fromBasicProperties(
150 $this->getLongDescription(),
151 $ilUser->getPref(
'language')
152 )->forObject(0, $this->
getId(), $this->getType());
159 $paths = $this->domain->metadata()->learningObjectMetadata()->paths();
161 $manipulator = $this->domain->metadata()->learningObjectMetadata()
162 ->manipulate(0, $this->
getId(), $this->getType())
163 ->prepareCreateOrUpdate($paths->title(), $this->getTitle());
165 if ($this->getDescription() !==
'') {
166 $manipulator = $manipulator->prepareCreateOrUpdate($paths->firstDescription(), $this->getDescription());
168 $manipulator = $manipulator->prepareDelete($paths->firstDescription());
171 $manipulator->execute();
179 $this->domain->metadata()->learningObjectMetadata()
180 ->deleteAll(0, $this->
getId(), $this->getType());
189 $this->media_items[] = $a_item;
194 return $this->media_items;
203 foreach ($this->media_items as $media_item) {
204 if ($media_item->getPurpose() == $a_purpose) {
214 foreach ($this->media_items as $key => $media_item) {
215 if ($media_item->getPurpose() == $a_purpose) {
216 unset($this->media_items[$key]);
221 $media_items = array();
222 foreach ($this->media_items as $media_item) {
223 $media_items [$i] = $media_item;
224 $media_item->setMobId($this->
getId());
225 $media_item->setNr($i);
228 $this->media_items = $media_items;
233 $this->media_items = array();
238 return $this->hasPurposeItem(
"Fullscreen");
246 if (is_object($this->getMediaItem($purpose))) {
265 $this->is_alias = $a_is_alias;
270 return $this->is_alias;
278 $this->origin_id = $a_id;
283 return $this->origin_id;
287 bool $a_create_meta_data =
false,
288 bool $a_save_media_items =
true,
291 $id = parent::create();
293 if (!$a_create_meta_data) {
294 $this->createMetaData();
296 $this->manager->create(
302 if ($a_save_media_items) {
303 $media_items = $this->getMediaItems();
304 for ($i = 0; $i < count($media_items); $i++) {
305 $item = $media_items[$i];
306 $item->setMobId($this->
getId());
307 $item->setNr($i + 1);
312 self::handleQuotaUpdate($this);
314 $ilAppEventHandler = $this->app_event_handler;
315 $ilAppEventHandler->raise(
316 'components/ILIAS/MediaObjects',
318 array(
'object' => $this,
320 'obj_id' => $this->
getId())
326 public function update(
bool $a_upload =
false): bool
331 $this->updateMetaData();
335 $media_items = $this->getMediaItems();
339 foreach ($media_items as $key => $val) {
341 if (is_object($item)) {
342 $item->setMobId($this->
getId());
344 if ($item->getLocationType() ==
"Reference") {
345 $item->extractUrlParameters();
352 $this->manager->updateLastChange($this->
getId());
354 self::handleQuotaUpdate($this);
355 $ilAppEventHandler = $this->app_event_handler;
356 $ilAppEventHandler->raise(
357 'components/ILIAS/MediaObjects',
359 array(
'object' => $this,
361 'obj_id' => $this->
getId())
378 public static function _getDirectory(
381 return ilFileUtils::getWebspaceDir() .
"/" . self::_getRelativeDirectory($a_mob_id);
389 return "mobs/mm_" . $a_mob_id;
406 bool $a_url_encode =
false,
408 string $a_purpose =
""
410 if ($a_purpose ==
"") {
411 $a_purpose =
"Standard";
414 if (preg_match(
"/https?\:/i",
$location)) {
437 if (!is_dir(
$path)) {
443 string $dir_path =
""
445 return $this->manager->getFilesOfPath(
462 bool $a_sign_locals =
false,
463 bool $offline =
false
465 $ilUser = $this->
user;
469 $xml =
"<MediaObject>";
470 $xml .=
"<MediaAlias OriginId=\"il__mob_" . $this->
getId() .
"\"/>";
471 $media_items = $this->getMediaItems();
472 for ($i = 0; $i < count($media_items); $i++) {
473 $item = $media_items[$i];
474 $xml .=
"<MediaAliasItem Purpose=\"" . $item->getPurpose() .
"\">";
477 $width = ($item->getWidth() !=
"")
478 ?
"Width=\"" . $item->getWidth() .
"\""
480 $height = ($item->getHeight() !=
"")
481 ?
"Height=\"" . $item->getHeight() .
"\""
483 $halign = ($item->getHAlign() !=
"")
484 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\""
486 $xml .=
"<Layout $width $height $halign />";
489 if ($item->getCaption() !=
"") {
490 $xml .=
"<Caption Align=\"bottom\">" .
491 $this->escapeProperty($item->getCaption()) .
"</Caption>";
495 if ($item->getTextRepresentation() !=
"") {
496 $xml .=
"<TextRepresentation>" .
497 $this->escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
501 $parameters = $item->getParameters();
502 foreach ($parameters as $name => $value) {
503 $xml .=
"<Parameter Name=\"$name\" Value=\"" . $this->escapeProperty($value) .
"\"/>";
505 $xml .= $item->getMapAreasXML();
506 $xml .=
"</MediaAliasItem>";
515 $xml =
"<MediaObject Id=\"il__mob_" . $this->
getId() .
"\">";
517 $media_items = $this->getMediaItems();
518 for ($i = 0; $i < count($media_items); $i++) {
519 $item = $media_items[$i];
521 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
522 if ($a_sign_locals && $item->getLocationType() ==
"LocalFile") {
524 if (is_file($this->getDataDirectory() .
"/" . $item->getLocation())) {
540 if ($item->getLocationType() ===
"LocalFile" &&
541 !is_file($this->getDataDirectory() .
"/" . $item->getLocation())) {
547 if ($item->getLocationType() !=
"LocalFile") {
552 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
553 $this->handleAmps(
$location) .
"</Location>";
556 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
559 $width = ($item->getWidth() !=
"")
560 ?
"Width=\"" . $item->getWidth() .
"\""
562 $height = ($item->getHeight() !=
"")
563 ?
"Height=\"" . $item->getHeight() .
"\""
565 $halign = ($item->getHAlign() !=
"")
566 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\""
568 $xml .=
"<Layout $width $height $halign />";
571 if ($item->getCaption() !=
"") {
572 $xml .=
"<Caption Align=\"bottom\">" .
573 $this->escapeProperty($item->getCaption()) .
"</Caption>";
577 if ($item->getTextRepresentation() !=
"") {
578 $xml .=
"<TextRepresentation>" .
579 $this->escapeProperty($item->getTextRepresentation()) .
"</TextRepresentation>";
585 $this->escapeProperty($this->
getTitle()) .
"</Title>";
589 $parameters = $item->getParameters();
590 if ($item->getFormat() ===
"video/vimeo") {
593 foreach ($parameters as $name => $value) {
594 $xml .=
"<Parameter Name=\"$name\" Value=\"" . $this->escapeProperty($value) .
"\"/>";
596 $xml .= $item->getMapAreasXML();
599 if ($item->getPurpose() ==
"Standard") {
600 $this->manager->generateMissingVTT($this->
getId());
601 $srts = $this->getSrtFiles(
true);
602 foreach ($srts as $srt) {
605 if ($ilUser->getLanguage() != $meta_lang &&
606 $ilUser->getLanguage() == $srt[
"language"]) {
607 $def =
' Default="true" ';
609 $xml .=
"<Subtitle File=\"" . $srt[
"src"] .
610 "\" Language=\"" . $srt[
"language"] .
"\" " . $def .
"/>";
613 if ($this->getVideoPreviewPic(
true)) {
614 $xml .=
"<PreviewPic File=\"" . $this->getVideoPreviewPic(
true) .
617 if ($item->getLocationType() ==
"LocalFile") {
620 $xml .=
"<Url Base=\"" . $base_url .
623 $xml .=
"</MediaItem>";
629 $xml =
"<MediaObject>";
632 $xml .=
"<Identifier Entry=\"il_" .
IL_INST_ID .
"_mob_" . $this->
getId() .
"\"/>";
635 $this->escapeProperty($this->
getTitle()) .
"</Title>";
638 $media_items = $this->getMediaItems();
639 for ($i = 0; $i < count($media_items); $i++) {
640 $item = $media_items[$i];
643 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
646 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
647 $this->handleAmps($item->getLocation()) .
"</Location>";
650 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
653 $width = ($item->getWidth() !=
"")
654 ?
"Width=\"" . $item->getWidth() .
"\""
656 $height = ($item->getHeight() !=
"")
657 ?
"Height=\"" . $item->getHeight() .
"\""
659 $halign = ($item->getHAlign() !=
"")
660 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\""
662 $xml .=
"<Layout $width $height $halign />";
665 if ($item->getCaption() !=
"") {
666 $xml .=
"<Caption Align=\"bottom\">" .
667 str_replace(
"&",
"&", $item->getCaption()) .
"</Caption>";
671 if ($item->getTextRepresentation() !=
"") {
672 $xml .=
"<TextRepresentation>" .
673 str_replace(
"&",
"&", $item->getTextRepresentation()) .
"</TextRepresentation>";
677 $parameters = $item->getParameters();
678 foreach ($parameters as $name => $value) {
679 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
681 $xml .= $item->getMapAreasXML(
true, $a_inst);
682 $xml .=
"</MediaItem>";
686 $xml .=
"</MediaObject>";
696 return htmlspecialchars($a_value);
706 $a_str = str_replace(
"&",
"&", $a_str);
707 $a_str = str_replace(
"&",
"&", $a_str);
715 $a_xml_writer->appendXML($this->getXML(
IL_MODE_FULL, $a_inst));
742 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
759 bool $a_contains_link
761 $this->contains_int_link = $a_contains_link;
770 return $this->contains_int_link;
776 ?
int $a_usage_hist_nr = 0,
784 if (!is_null($a_usage_hist_nr)) {
785 $and_hist =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
789 $set =
$ilDB->query(
"SELECT id FROM mob_usage" .
790 " WHERE usage_type = " .
$ilDB->quote($a_type,
"text") .
791 " AND usage_id = " .
$ilDB->quote($a_id,
"integer") .
792 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
794 while ($row =
$ilDB->fetchAssoc($set)) {
795 $mob_ids[] = $row[
"id"];
798 $q =
"DELETE FROM mob_usage WHERE usage_type = " .
799 $ilDB->quote($a_type,
"text") .
800 " AND usage_id= " .
$ilDB->quote($a_id,
"integer") .
801 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
805 foreach ($mob_ids as $mob_id) {
806 self::handleQuotaUpdate(
new self($mob_id));
816 int|
false $a_usage_hist_nr = 0,
825 $lstr =
" AND usage_lang = " .
$ilDB->quote($a_lang,
"text");
828 if ($a_usage_hist_nr !==
false) {
829 $hist_str =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
832 $q =
"SELECT * FROM mob_usage WHERE " .
833 "usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " .
834 "usage_id = " .
$ilDB->quote($a_id,
"integer") .
838 while ($mob_rec =
$ilDB->fetchAssoc($mob_set)) {
839 $mob_id = (
int) $mob_rec[
'id'];
841 $mobs[$mob_id] = $mob_id;
855 int $a_usage_hist_nr = 0,
865 "id" => array(
"integer", $a_mob_id),
866 "usage_type" => array(
"text", $a_type),
867 "usage_id" => array(
"integer", $a_id),
868 "usage_lang" => array(
"text", $a_lang),
869 "usage_hist_nr" => array(
"integer", $a_usage_hist_nr)
874 self::handleQuotaUpdate(
new self($a_mob_id));
884 int $a_usage_hist_nr = 0,
891 $q =
"DELETE FROM mob_usage WHERE " .
892 " id = " .
$ilDB->quote($a_mob_id,
"integer") .
" AND " .
893 " usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " .
894 " usage_id = " .
$ilDB->quote($a_id,
"integer") .
" AND " .
895 " usage_lang = " .
$ilDB->quote($a_lang,
"text") .
" AND " .
896 " usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
899 self::handleQuotaUpdate(
new self($a_mob_id));
906 bool $a_include_history =
true
908 return self::lookupUsages($this->
getId(), $a_include_history);
918 bool $a_include_history =
true
925 if ($a_include_history) {
926 $hist_str =
", usage_hist_nr";
930 $q =
"SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str .
" FROM mob_usage WHERE id = " .
931 $ilDB->quote($a_id,
"integer");
933 if (!$a_include_history) {
934 $q .=
" AND usage_hist_nr = " .
$ilDB->quote(0,
"integer");
939 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
942 if (is_int(strpos($us_rec[
"usage_type"],
":"))) {
943 $us_arr = explode(
":", $us_rec[
"usage_type"]);
958 "type" => $us_rec[
"usage_type"],
959 "id" => $us_rec[
"usage_id"],
960 "lang" => $us_rec[
"usage_lang"],
961 "hist_nr" => ($us_rec[
"usage_hist_nr"] ?? 0)
967 $q =
"SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = " .
968 $ilDB->quote($a_id,
"integer") .
" AND mep_item.type = " .
$ilDB->quote(
"mob",
"text");
970 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
971 $ret[] = array(
"type" =>
"mep",
972 "id" => $us_rec[
"mep_id"]);
977 foreach ($news_usages as $nu) {
983 $q =
"SELECT DISTINCT mob_id FROM media_item it, map_area area " .
984 " WHERE area.item_id = it.id " .
985 " AND area.link_type = " .
$ilDB->quote(
"int",
"text") .
" " .
986 " AND area.target = " .
$ilDB->quote(
"il__mob_" . $a_id,
"text");
988 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
989 $ret[] = array(
"type" =>
"map",
990 "id" => $us_rec[
"mob_id"]);
995 foreach ($users as $user) {
996 $ret[] = array(
"type" =>
"clip",
1009 bool $a_include_all_access_obj_ids =
false
1012 if (is_int(strpos($a_usage[
"type"],
":"))) {
1013 $us_arr = explode(
":", $a_usage[
"type"]);
1015 $cont_type = $us_arr[0];
1017 $type = $a_usage[
"type"];
1020 $id = $a_usage[
"id"];
1027 switch ($cont_type) {
1031 $qinfo =
$DIC->testQuestion()->getGeneralQuestionProperties(
$id);
1032 if ($qinfo->getOriginalId() > 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 $qinfo =
$DIC->testQuestion()->getGeneralQuestionProperties(
$id);
1123 if ($qinfo->getOriginalId() > 0) {
1126 $obj_id = $qinfo[
"obj_fi"];
1130 if ($pinfo && $pinfo[
"parent_type"] ==
"lm") {
1204 bool $a_constrain_prop =
false
1207 $file_path = pathinfo($a_file);
1208 $location = substr($file_path[
"basename"], 0, strlen($file_path[
"basename"]) -
1209 strlen($file_path[
"extension"]) - 1) .
"_" .
1211 $a_height .
"." . $file_path[
"extension"];
1212 $target_file = $file_path[
"dirname"] .
"/" .
1215 $returned_target_file =
$DIC->fileConverters()
1217 ->resizeToFixedSize(
1225 if ($returned_target_file !== $target_file) {
1226 throw new RuntimeException(
'Could not resize image');
1237 bool $a_external =
false
1239 $mime =
MimeType::lookupMimeType($a_file,
MimeType::APPLICATION__OCTET_STREAM, $a_external);
1247 string $a_reference,
1248 bool $a_constrain_proportions,
1249 bool $a_use_original,
1250 ?
int $a_user_width =
null,
1251 ?
int $a_user_height =
null
1274 if ($a_type ==
"File") {
1281 if (!isset($size[0])) {
1284 if (!isset($size[1])) {
1288 if ($a_use_original) {
1289 if ($size[0] > 0 && $size[1] > 0) {
1295 $info =
$lng->txt(
"cont_could_not_determine_resource_size");
1299 $h = $a_user_height;
1304 if ($size[0] > 0 && $size[1] > 0) {
1306 $wr = $size[0] / $w;
1309 $hr = $size[1] / $h;
1315 $width = (
int) round($size[0] / $r);
1316 $height = (
int) round($size[1] / $r);
1324 if ($width == 0 && is_null($a_user_width)) {
1327 if ($height == 0 && is_null($a_user_height)) {
1330 return array(
"width" => $width,
"height" => $height,
"info" =>
$info);
1351 $media_object->setDescription(
"");
1352 $media_object->create();
1355 $media_object->createDirectory();
1358 $file = $mob_dir .
"/" . $name;
1360 $media_item = $media_object->addMediaItemFromLegacyUpload(
1370 $media_item = $media_object->addMediaItemFromLocalFile(
1390 $media_object->setTitle($name);
1391 $media_object->setDescription($media_item->getFormat());
1392 $media_item->setHAlign(
"Left");
1399 $media_object->update();
1401 return $media_object;
1408 int $resize_width = 0,
1409 int $resize_height = 0,
1410 bool $constrain_proportions =
true,
1411 bool $deduce_size =
false
1414 $this->addMediaItem($media_item);
1415 $media_item->setPurpose($purpose);
1418 $this->manager->addFileFromLegacyUpload($this->
getId(), $tmp_name);
1421 $format = self::getMimeType(
$location,
true);
1424 if ($resize_width > 0 && $resize_height > 0 && is_int(strpos($format,
"image"))) {
1444 $media_item->setFormat($format);
1446 $media_item->setLocationType(
"LocalFile");
1447 if ($purpose ===
"Standard") {
1448 $this->generatePreviewPic(320, 240);
1456 string $upload_hash =
"",
1459 $this->addMediaItem($media_item);
1460 $media_item->setPurpose($purpose);
1461 $this->manager->addFileFromUpload($this->
getId(), $result);
1464 $format = self::getMimeType($result->
getName(),
true);
1467 $media_item->setFormat($format);
1468 $media_item->setLocation($result->
getName());
1469 $media_item->setLocationType(
"LocalFile");
1470 if ($upload_hash !==
"") {
1471 $media_item->setUploadHash($upload_hash);
1473 if ($purpose ===
"Standard") {
1474 $this->generatePreviewPic(320, 240);
1485 $this->addMediaItem($media_item);
1486 $media_item->setPurpose($purpose);
1488 $this->manager->addFileFromLocal($this->
getId(), $tmp_name, $name);
1491 $format = self::getMimeType(
$location,
true);
1494 $media_item->setFormat($format);
1496 $media_item->setLocationType(
"LocalFile");
1497 if ($purpose ===
"Standard") {
1498 $this->generatePreviewPic(320, 240);
1506 string $upload_hash =
"",
1508 $media_item = $this->getMediaItem($purpose);
1509 $this->manager->removeLocation($this->
getId(), $media_item->getLocation());
1510 $this->manager->addFileFromUpload($this->
getId(), $result);
1513 $format = self::getMimeType($result->
getName(),
true);
1516 $media_item->setFormat($format);
1517 $media_item->setLocation($result->
getName());
1518 $media_item->setLocationType(
"LocalFile");
1519 if ($upload_hash !==
"") {
1520 $media_item->setUploadHash($upload_hash);
1522 if ($purpose ===
"Standard") {
1523 $this->generatePreviewPic(320, 240);
1534 string $a_subdir =
"",
1535 string $a_mode =
"move_uploaded"
1537 $a_subdir = str_replace(
"..",
"", $a_subdir);
1538 if ($a_mode ==
"rename") {
1539 $this->manager->addFileFromLocal(
1542 $a_subdir .
"/" . $a_name
1545 $this->manager->addFileFromLegacyUpload(
1548 $a_subdir .
"/" . $a_name
1557 $this->manager->addFileFromUpload(
1567 string $a_mode =
"move_uploaded"
1569 if (is_file($a_tmp_name) && $a_language !=
"") {
1570 $this->uploadAdditionalFile(
"subtitle_" . $a_language .
".vtt", $a_tmp_name,
"srt", $a_mode);
1578 return $this->manager->getSrtFiles($this->
getId(), $vtt_only);
1588 $format = self::getMimeType($source,
true);
1589 $this->thumbs->createPreview(
1602 $this->manager->removeLocation(
1614 array $a_ignore = []
1619 $med_items = $this->getMediaItems();
1621 foreach ($med_items as $med_item) {
1623 foreach ($int_links as $k => $int_link) {
1624 if ($int_link[
"Type"] ==
"MediaObject") {
1627 if (!in_array($l_id, $linked) &&
1628 !in_array($l_id, $a_ignore)) {
1643 return in_array($a_type, iterator_to_array(
1644 $DIC->mediaObjects()->internal()->domain()->mediaType()->getAllowedSuffixes()
1654 $new_obj->setTitle($this->
getTitle());
1655 $new_obj->setDescription($this->getDescription());
1658 foreach ($this->getMediaItems() as $key => $val) {
1659 $new_obj->addMediaItem($val);
1669 $this->domain->metadata()->learningObjectMetadata()
1671 ->fromObject(0, $this->
getId(),
"mob")
1672 ->forObject(0, $new_obj->getId(),
"mob");
1681 if ($this->getVideoPreviewPic(
true) !=
"") {
1682 $this->removeAdditionalFile($this->getVideoPreviewPic(
true));
1685 $pi = pathinfo($a_prevpic[
"name"]);
1686 $ext = $pi[
"extension"];
1687 if (in_array($ext, array(
"jpg",
"jpeg",
"png"))) {
1688 $this->uploadAdditionalFile(
"mob_vpreview." . $ext, $a_prevpic[
"tmp_name"]);
1692 public function generatePreviewPic(
1700 $item = $this->getMediaItem(
"Standard");
1701 if ($item->getFormat() ===
"image/svg+xml") {
1705 $logger->debug(
"Generate preview pic...");
1706 $logger->debug(
"..." . $item->getFormat());
1708 $this->thumbs->createPreview(
1710 $item->getLocation(),
1711 $item->getLocationType() ===
"LocalFile",
1718 bool $a_filename_only =
false
1721 if (!$a_filename_only) {
1722 $src = $this->thumbs->getPreviewSrc($this->
getId());
1729 $ppics = array(
"mob_vpreview.jpg",
1730 "mob_vpreview.jpeg",
1731 "mob_vpreview.png");
1732 $med = $this->getMediaItem(
"Standard");
1733 if ($med && $med->getFormat() ===
"image/svg+xml" && $med->getLocationType() ===
"LocalFile") {
1734 $ppics[] = $med->getLocation();
1736 foreach ($ppics as $p) {
1737 if (is_file($dir .
"/" . $p)) {
1738 if ($a_filename_only) {
1741 return $dir .
"/" . $p;
1756 $rchars = array(
"`",
"=",
"$",
"{",
"}",
"'",
";",
" ",
"(",
")");
1757 $a_name = str_replace($rchars,
"_", $a_name);
1758 $a_name = str_replace(
"__",
"_", $a_name);
1780 if (!is_file($a_file[
"tmp_name"])) {
1784 $dir = $this->getMultiSrtUploadDir();
1788 $this->domain->resources()->zip()->unzipFile($dir .
"/multi_vtt.zip");
1806 $lang_codes = $this->domain->metadata()->getLOMLanguageCodes();
1808 $dir = $this->getMultiSrtUploadDir();
1810 foreach ($files as $k => $i) {
1812 if ($i[
"type"] ==
"file" && !in_array($k, array(
".",
".."))) {
1813 if (pathinfo($k, PATHINFO_EXTENSION) ==
"vtt") {
1815 if (substr($k, strlen($k) - 7, 1) ==
"_") {
1816 $lang = substr($k, strlen($k) - 6, 2);
1817 if (!in_array($lang, $lang_codes)) {
1821 $items[] = array(
"filename" => $k,
"lang" => $lang);
1832 if (!self::isTypeAllowed(
"html")) {
1840 $st_item = $this->getMediaItem(
"Standard");
1841 if ($st_item->getLocationType() ==
"Reference") {
1843 $st_item->setFormat(
"video/vimeo");
1846 $this->setTitle($meta[
"title"] ??
"");
1847 $description = str_replace(
"\n",
"", $meta[
"description"] ??
"");
1848 $description = str_replace([
"<br>",
"<br />"], [
"\n",
"\n"], $description);
1849 $description = strip_tags($description);
1850 $this->setDescription($description);
1851 $st_item->setDuration((
int) ($meta[
"duration"] ?? 0));
1852 $url = parse_url($meta[
"thumbnail_url"] ??
"");
1853 $file = basename(
$url[
"path"]);
1854 $ext = pathinfo($file, PATHINFO_EXTENSION);
1858 $this->manager->addPreviewFromUrl(
1860 $meta[
"thumbnail_url"],
1861 "/mob_vpreview." . $ext
1864 if (ilExternalMediaAnalyzer::isYoutube($st_item->getLocation())) {
1865 $st_item->setFormat(
"video/youtube");
1866 $par = ilExternalMediaAnalyzer::extractYoutubeParameters($st_item->getLocation());
1869 $this->setTitle($meta[
"title"] ??
"");
1870 $description = str_replace(
"\n",
"", $meta[
"description"] ??
"");
1871 }
catch (Exception
$e) {
1872 $this->setTitle($st_item->getLocation());
1875 $description = str_replace([
"<br>",
"<br />"], [
"\n",
"\n"], $description);
1876 $description = strip_tags($description);
1877 $this->setDescription($description);
1878 $st_item->setDuration((
int) ($meta[
"duration"] ?? 0));
1879 $thumbnail_url = $meta[
"thumbnail_url"] ??
"";
1880 $url = parse_url($thumbnail_url);
1881 if ($thumbnail_url !==
"") {
1883 $file = basename(
$url[
"path"]);
1884 $this->manager->addPreviewFromUrl(
1886 $meta[
"thumbnail_url"],
1888 pathinfo($file, PATHINFO_EXTENSION)
1897 return $this->getLocationSrc(
"Standard");
1902 return $this->getLocationSrc(
"Fullscreen");
1907 return (
string) $this->getMediaItem($purpose)?->getLocationSrc();
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static _lookupSurveyObjId(int $a_question_id)
static _instanciateQuestion(int $question_id)
Get question object.
static lookupExerciseIdForReturnedId(int $a_returned_id)
Get exercise from submission id (used in ilObjMediaObject)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
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.
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 rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
Class ilForumDraftHistory.
static newInstanceByDraftId(int $draft_id)
static _lookupObjIdForForumId(int $a_for_id)
static _lookGlossaryID(int $term_id)
get glossary id form term id
static _extractObjIdOfTarget(string $a_target)
Extract object id out of target.
static _lookupContObjID(int $a_id)
get learning module id for lm object
static getLogger(string $a_component_id)
Get component logger.
static _getIntLinks(int $a_item_id)
get all internal links of a media items map areas
static _lookupMediaObjectUsages(int $a_mob_id)
Lookup media object usage(s)
static _lookupContextObjId(int $a_news_id)
Context Object ID.
static _lookupTestObjIdForQuestionId(int $q_id)
Get test Object ID for question ID.
static _getUsersForClipboadObject(string $a_type, int $a_id)
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
static _writeDescription(int $obj_id, string $desc)
write description to db (static)
static _writeTitle(int $obj_id, string $title)
write title to db (static)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getPageForQuestionId(int $a_q_id, string $a_parent_type="")
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static lookupParentId(int $a_id, string $a_type)
static findPortfolioForPage(int $a_page_id)
Get portfolio id of page id.
Util class various functions, usage as namespace.
static deducibleSize(string $a_mime)
checks if mime type is provided by getimagesize()
static secureUrl(string $url)
static insertInstIntoID(string $a_value)
inserts installation id into ILIAS id
static signFile(string $path_to_file)
static lookupObjIdByPage(int $a_page_id)
returns the wiki/object id to a given page id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))