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" ';
610 ?
"mobs/mm_" . $this->
getId() . $srt[
"full_path"]
612 $xml .=
"<Subtitle File=\"" . $src .
613 "\" Language=\"" . $srt[
"language"] .
"\" " . $def .
"/>";
616 if ($this->getVideoPreviewPic(
false)) {
617 $xml .=
"<PreviewPic File=\"" . $this->handleAmps($this->getVideoPreviewPic(
false)) .
620 if ($item->getLocationType() ==
"LocalFile") {
623 $xml .=
"<Url Base=\"" . $base_url .
626 $xml .=
"</MediaItem>";
632 $xml =
"<MediaObject>";
635 $xml .=
"<Identifier Entry=\"il_" .
IL_INST_ID .
"_mob_" . $this->
getId() .
"\"/>";
638 $this->escapeProperty($this->
getTitle()) .
"</Title>";
641 $media_items = $this->getMediaItems();
642 for ($i = 0; $i < count($media_items); $i++) {
643 $item = $media_items[$i];
646 $xml .=
"<MediaItem Purpose=\"" . $item->getPurpose() .
"\">";
649 $xml .=
"<Location Type=\"" . $item->getLocationType() .
"\">" .
650 $this->handleAmps($item->getLocation()) .
"</Location>";
653 $xml .=
"<Format>" . $item->getFormat() .
"</Format>";
656 $width = ($item->getWidth() !=
"")
657 ?
"Width=\"" . $item->getWidth() .
"\""
659 $height = ($item->getHeight() !=
"")
660 ?
"Height=\"" . $item->getHeight() .
"\""
662 $halign = ($item->getHAlign() !=
"")
663 ?
"HorizontalAlign=\"" . $item->getHAlign() .
"\""
665 $xml .=
"<Layout $width $height $halign />";
668 if ($item->getCaption() !=
"") {
669 $xml .=
"<Caption Align=\"bottom\">" .
670 str_replace(
"&",
"&", $item->getCaption()) .
"</Caption>";
674 if ($item->getTextRepresentation() !=
"") {
675 $xml .=
"<TextRepresentation>" .
676 str_replace(
"&",
"&", $item->getTextRepresentation()) .
"</TextRepresentation>";
680 $parameters = $item->getParameters();
681 foreach ($parameters as $name => $value) {
682 $xml .=
"<Parameter Name=\"$name\" Value=\"$value\"/>";
684 $xml .= $item->getMapAreasXML(
true, $a_inst);
685 $xml .=
"</MediaItem>";
689 $xml .=
"</MediaObject>";
699 return htmlspecialchars($a_value);
709 $a_str = str_replace(
"&",
"&", $a_str);
710 $a_str = str_replace(
"&",
"&", $a_str);
718 $a_xml_writer->appendXML($this->getXML(
IL_MODE_FULL, $a_inst));
745 if ($a_tag ==
"Identifier" && $a_param ==
"Entry") {
762 bool $a_contains_link
764 $this->contains_int_link = $a_contains_link;
773 return $this->contains_int_link;
779 ?
int $a_usage_hist_nr = 0,
787 if (!is_null($a_usage_hist_nr)) {
788 $and_hist =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
792 $set =
$ilDB->query(
"SELECT id FROM mob_usage" .
793 " WHERE usage_type = " .
$ilDB->quote($a_type,
"text") .
794 " AND usage_id = " .
$ilDB->quote($a_id,
"integer") .
795 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
797 while ($row =
$ilDB->fetchAssoc($set)) {
798 $mob_ids[] = $row[
"id"];
801 $q =
"DELETE FROM mob_usage WHERE usage_type = " .
802 $ilDB->quote($a_type,
"text") .
803 " AND usage_id= " .
$ilDB->quote($a_id,
"integer") .
804 " AND usage_lang = " .
$ilDB->quote($a_lang,
"text") .
808 foreach ($mob_ids as $mob_id) {
809 self::handleQuotaUpdate(
new self($mob_id));
819 int|
false $a_usage_hist_nr = 0,
828 $lstr =
" AND usage_lang = " .
$ilDB->quote($a_lang,
"text");
831 if ($a_usage_hist_nr !==
false) {
832 $hist_str =
" AND usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
835 $q =
"SELECT * FROM mob_usage WHERE " .
836 "usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " .
837 "usage_id = " .
$ilDB->quote($a_id,
"integer") .
841 while ($mob_rec =
$ilDB->fetchAssoc($mob_set)) {
842 $mob_id = (
int) $mob_rec[
'id'];
844 $mobs[$mob_id] = $mob_id;
858 int $a_usage_hist_nr = 0,
868 "id" => array(
"integer", $a_mob_id),
869 "usage_type" => array(
"text", $a_type),
870 "usage_id" => array(
"integer", $a_id),
871 "usage_lang" => array(
"text", $a_lang),
872 "usage_hist_nr" => array(
"integer", $a_usage_hist_nr)
877 self::handleQuotaUpdate(
new self($a_mob_id));
887 int $a_usage_hist_nr = 0,
894 $q =
"DELETE FROM mob_usage WHERE " .
895 " id = " .
$ilDB->quote($a_mob_id,
"integer") .
" AND " .
896 " usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " .
897 " usage_id = " .
$ilDB->quote($a_id,
"integer") .
" AND " .
898 " usage_lang = " .
$ilDB->quote($a_lang,
"text") .
" AND " .
899 " usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
902 self::handleQuotaUpdate(
new self($a_mob_id));
909 bool $a_include_history =
true
911 return self::lookupUsages($this->
getId(), $a_include_history);
921 bool $a_include_history =
true
928 if ($a_include_history) {
929 $hist_str =
", usage_hist_nr";
933 $q =
"SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str .
" FROM mob_usage WHERE id = " .
934 $ilDB->quote($a_id,
"integer");
936 if (!$a_include_history) {
937 $q .=
" AND usage_hist_nr = " .
$ilDB->quote(0,
"integer");
942 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
945 if (is_int(strpos($us_rec[
"usage_type"],
":"))) {
946 $us_arr = explode(
":", $us_rec[
"usage_type"]);
961 "type" => $us_rec[
"usage_type"],
962 "id" => $us_rec[
"usage_id"],
963 "lang" => $us_rec[
"usage_lang"],
964 "hist_nr" => ($us_rec[
"usage_hist_nr"] ?? 0)
970 $q =
"SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = " .
971 $ilDB->quote($a_id,
"integer") .
" AND mep_item.type = " .
$ilDB->quote(
"mob",
"text");
973 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
974 $ret[] = array(
"type" =>
"mep",
975 "id" => $us_rec[
"mep_id"]);
980 foreach ($news_usages as $nu) {
986 $q =
"SELECT DISTINCT mob_id FROM media_item it, map_area area " .
987 " WHERE area.item_id = it.id " .
988 " AND area.link_type = " .
$ilDB->quote(
"int",
"text") .
" " .
989 " AND area.target = " .
$ilDB->quote(
"il__mob_" . $a_id,
"text");
991 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
992 $ret[] = array(
"type" =>
"map",
993 "id" => $us_rec[
"mob_id"]);
998 foreach ($users as $user) {
999 $ret[] = array(
"type" =>
"clip",
1012 bool $a_include_all_access_obj_ids =
false
1015 if (is_int(strpos($a_usage[
"type"],
":"))) {
1016 $us_arr = explode(
":", $a_usage[
"type"]);
1018 $cont_type = $us_arr[0];
1020 $type = $a_usage[
"type"];
1023 $id = $a_usage[
"id"];
1030 switch ($cont_type) {
1034 $qinfo =
$DIC->testQuestion()->getGeneralQuestionProperties(
$id);
1035 if ($qinfo->getOriginalId() > 0) {
1038 $obj_id = (
int) ($qinfo[
"obj_fi"] ?? 0);
1046 $parent_id = $quest->getObjId();
1049 if ($quest->getOriginalId() &&
1055 $obj_id = (
int) $parent_id;
1064 $returned_pk = $a_usage[
'id'];
1071 $post_pk = $a_usage[
'id'];
1073 $frm_pk = $oPost->getForumId();
1079 $draft_id = $a_usage[
'id'];
1082 $frm_pk = $oDraft->getForumId();
1086 $history_id = $a_usage[
'id'];
1090 $frm_pk = $oDraft->getForumId();
1096 $obj_id = (
int) $a_usage[
'id'];
1114 switch ($cont_type) {
1119 if ($cont_type ==
"qfbg") {
1125 $qinfo =
$DIC->testQuestion()->getGeneralQuestionProperties(
$id);
1126 if ($qinfo->getOriginalId() > 0) {
1129 $obj_id = $qinfo[
"obj_fi"];
1133 if ($pinfo && $pinfo[
"parent_type"] ==
"lm") {
1205 bool $a_external =
false
1207 $mime =
MimeType::lookupMimeType($a_file,
MimeType::APPLICATION__OCTET_STREAM, $a_external);
1215 string $a_reference,
1216 bool $a_constrain_proportions,
1217 bool $a_use_original,
1218 ?
int $a_user_width =
null,
1219 ?
int $a_user_height =
null
1242 if ($a_type ==
"File") {
1249 if (!isset($size[0])) {
1252 if (!isset($size[1])) {
1256 if ($a_use_original) {
1257 if ($size[0] > 0 && $size[1] > 0) {
1263 $info =
$lng->txt(
"cont_could_not_determine_resource_size");
1267 $h = $a_user_height;
1272 if ($size[0] > 0 && $size[1] > 0) {
1274 $wr = $size[0] / $w;
1277 $hr = $size[1] / $h;
1283 $width = (
int) round($size[0] / $r);
1284 $height = (
int) round($size[1] / $r);
1292 if ($width == 0 && is_null($a_user_width)) {
1295 if ($height == 0 && is_null($a_user_height)) {
1298 return array(
"width" => $width,
"height" => $height,
"info" =>
$info);
1319 $media_object->setDescription(
"");
1320 $media_object->create();
1323 $media_object->createDirectory();
1326 $file = $mob_dir .
"/" . $name;
1328 $media_item = $media_object->addMediaItemFromLegacyUpload(
1338 $media_item = $media_object->addMediaItemFromLocalFile(
1358 $media_object->setTitle($name);
1359 $media_object->setDescription($media_item->getFormat());
1360 $media_item->setHAlign(
"Left");
1367 $media_object->update();
1369 return $media_object;
1376 int $resize_width = 0,
1377 int $resize_height = 0,
1378 bool $constrain_proportions =
true,
1379 bool $deduce_size =
false
1382 $this->addMediaItem($media_item);
1383 $media_item->setPurpose($purpose);
1386 $this->manager->addFileFromLegacyUpload($this->
getId(), $tmp_name);
1389 $format = self::getMimeType(
$location,
true);
1392 if ($resize_width > 0 && $resize_height > 0 && is_int(strpos($format,
"image"))) {
1412 $media_item->setFormat($format);
1414 $media_item->setLocationType(
"LocalFile");
1415 if ($purpose ===
"Standard") {
1416 $this->generatePreviewPic(320, 240);
1424 string $upload_hash =
"",
1427 $this->addMediaItem($media_item);
1428 $media_item->setPurpose($purpose);
1429 $this->manager->addFileFromUpload($this->
getId(), $result);
1432 $format = self::getMimeType($result->
getName(),
true);
1435 $media_item->setFormat($format);
1436 $media_item->setLocation($result->
getName());
1437 $media_item->setLocationType(
"LocalFile");
1438 if ($upload_hash !==
"") {
1439 $media_item->setUploadHash($upload_hash);
1441 if ($purpose ===
"Standard") {
1442 $this->generatePreviewPic(320, 240);
1453 $this->addMediaItem($media_item);
1454 $media_item->setPurpose($purpose);
1456 $this->manager->addFileFromLocal($this->
getId(), $tmp_name, $name);
1459 $format = self::getMimeType(
$location,
true);
1462 $media_item->setFormat($format);
1464 $media_item->setLocationType(
"LocalFile");
1465 if ($purpose ===
"Standard") {
1466 $this->generatePreviewPic(320, 240);
1474 string $upload_hash =
"",
1476 $media_item = $this->getMediaItem($purpose);
1477 $this->manager->removeLocation($this->
getId(), $media_item->getLocation());
1478 $this->manager->addFileFromUpload($this->
getId(), $result);
1481 $format = self::getMimeType($result->
getName(),
true);
1484 $media_item->setFormat($format);
1485 $media_item->setLocation($result->
getName());
1486 $media_item->setLocationType(
"LocalFile");
1487 if ($upload_hash !==
"") {
1488 $media_item->setUploadHash($upload_hash);
1490 if ($purpose ===
"Standard") {
1491 $this->generatePreviewPic(320, 240);
1502 string $a_subdir =
"",
1503 string $a_mode =
"move_uploaded"
1505 $a_subdir = str_replace(
"..",
"", $a_subdir);
1506 if ($a_mode ==
"rename") {
1507 $this->manager->addFileFromLocal(
1510 $a_subdir .
"/" . $a_name
1513 $this->manager->addFileFromLegacyUpload(
1516 $a_subdir .
"/" . $a_name
1525 $this->manager->addFileFromUpload(
1535 string $a_mode =
"move_uploaded"
1537 if (is_file($a_tmp_name) && $a_language !=
"") {
1538 $this->uploadAdditionalFile(
"subtitle_" . $a_language .
".vtt", $a_tmp_name,
"srt", $a_mode);
1546 return $this->manager->getSrtFiles($this->
getId(), $vtt_only);
1556 $format = self::getMimeType($source,
true);
1557 $this->thumbs->createPreview(
1570 $this->manager->removeLocation(
1582 array $a_ignore = []
1587 $med_items = $this->getMediaItems();
1589 foreach ($med_items as $med_item) {
1591 foreach ($int_links as $k => $int_link) {
1592 if ($int_link[
"Type"] ==
"MediaObject") {
1595 if (!in_array($l_id, $linked) &&
1596 !in_array($l_id, $a_ignore)) {
1611 return in_array($a_type, iterator_to_array(
1612 $DIC->mediaObjects()->internal()->domain()->mediaType()->getAllowedSuffixes()
1622 $new_obj->setTitle($this->
getTitle());
1623 $new_obj->setDescription($this->getDescription());
1626 foreach ($this->getMediaItems() as $key => $val) {
1627 $new_obj->addMediaItem($val);
1637 $this->domain->metadata()->learningObjectMetadata()
1639 ->fromObject(0, $this->
getId(),
"mob")
1640 ->forObject(0, $new_obj->getId(),
"mob");
1649 if ($this->getVideoPreviewPic(
true) !=
"") {
1650 $this->removeAdditionalFile($this->getVideoPreviewPic(
true));
1653 $pi = pathinfo($a_prevpic[
"name"]);
1654 $ext = $pi[
"extension"];
1655 if (in_array($ext, array(
"jpg",
"jpeg",
"png"))) {
1656 $this->uploadAdditionalFile(
"mob_vpreview." . $ext, $a_prevpic[
"tmp_name"]);
1660 public function generatePreviewPic(
1668 $item = $this->getMediaItem(
"Standard");
1669 if ($item->getFormat() ===
"image/svg+xml") {
1673 $logger->debug(
"Generate preview pic...");
1674 $logger->debug(
"..." . $item->getFormat());
1675 $this->thumbs->createPreview(
1677 $item->getLocation(),
1678 $item->getLocationType() ===
"LocalFile",
1685 bool $a_filename_only =
false
1688 if (!$a_filename_only) {
1689 $src = $this->thumbs->getPreviewSrc($this->
getId());
1696 $ppics = array(
"mob_vpreview.jpg",
1697 "mob_vpreview.jpeg",
1698 "mob_vpreview.png");
1699 $med = $this->getMediaItem(
"Standard");
1700 if ($med && $med->getFormat() ===
"image/svg+xml" && $med->getLocationType() ===
"LocalFile") {
1701 $ppics[] = $med->getLocation();
1703 foreach ($ppics as $p) {
1704 if (is_file($dir .
"/" . $p)) {
1705 if ($a_filename_only) {
1708 return $dir .
"/" . $p;
1723 $rchars = array(
"`",
"=",
"$",
"{",
"}",
"'",
";",
" ",
"(",
")");
1724 $a_name = str_replace($rchars,
"_", $a_name);
1725 $a_name = str_replace(
"__",
"_", $a_name);
1747 if (!is_file($a_file[
"tmp_name"])) {
1751 $dir = $this->getMultiSrtUploadDir();
1755 $this->domain->resources()->zip()->unzipFile($dir .
"/multi_vtt.zip");
1773 $lang_codes = $this->domain->metadata()->getLOMLanguageCodes();
1775 $dir = $this->getMultiSrtUploadDir();
1777 foreach ($files as $k => $i) {
1779 if ($i[
"type"] ==
"file" && !in_array($k, array(
".",
".."))) {
1780 if (pathinfo($k, PATHINFO_EXTENSION) ==
"vtt") {
1782 if (substr($k, strlen($k) - 7, 1) ==
"_") {
1783 $lang = substr($k, strlen($k) - 6, 2);
1784 if (!in_array($lang, $lang_codes)) {
1788 $items[] = array(
"filename" => $k,
"lang" => $lang);
1799 if (!self::isTypeAllowed(
"html")) {
1807 $st_item = $this->getMediaItem(
"Standard");
1808 if ($st_item->getLocationType() ==
"Reference") {
1810 $st_item->setFormat(
"video/vimeo");
1813 $this->setTitle($meta[
"title"] ??
"");
1814 $description = str_replace(
"\n",
"", $meta[
"description"] ??
"");
1815 $description = str_replace([
"<br>",
"<br />"], [
"\n",
"\n"], $description);
1816 $description = strip_tags($description);
1817 $this->setDescription($description);
1818 $st_item->setDuration((
int) ($meta[
"duration"] ?? 0));
1819 $url = parse_url($meta[
"thumbnail_url"] ??
"");
1820 $file = basename(
$url[
"path"]);
1821 $ext = pathinfo($file, PATHINFO_EXTENSION);
1825 $this->manager->addPreviewFromUrl(
1827 $meta[
"thumbnail_url"],
1828 "/mob_vpreview." . $ext
1831 if (ilExternalMediaAnalyzer::isYoutube($st_item->getLocation())) {
1832 $st_item->setFormat(
"video/youtube");
1833 $par = ilExternalMediaAnalyzer::extractYoutubeParameters($st_item->getLocation());
1836 $this->setTitle($meta[
"title"] ??
"");
1837 $description = str_replace(
"\n",
"", $meta[
"description"] ??
"");
1838 }
catch (Exception
$e) {
1839 $this->setTitle($st_item->getLocation());
1842 $description = str_replace([
"<br>",
"<br />"], [
"\n",
"\n"], $description);
1843 $description = strip_tags($description);
1844 $this->setDescription($description);
1845 $st_item->setDuration((
int) ($meta[
"duration"] ?? 0));
1846 $thumbnail_url = $meta[
"thumbnail_url"] ??
"";
1847 $url = parse_url($thumbnail_url);
1848 if ($thumbnail_url !==
"") {
1850 $file = basename(
$url[
"path"]);
1851 $this->manager->addPreviewFromUrl(
1853 $meta[
"thumbnail_url"],
1855 pathinfo($file, PATHINFO_EXTENSION)
1864 return $this->getLocationSrc(
"Standard");
1869 return $this->getLocationSrc(
"Fullscreen");
1874 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'))