ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilObjMediaObject Class Reference
+ Inheritance diagram for ilObjMediaObject:
+ Collaboration diagram for ilObjMediaObject:

Public Member Functions

 __construct (int $a_id=0)
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 addMediaItem (ilMediaItem $a_item)
 
getMediaItems ()
 
 getMediaItem (string $a_purpose)
 get item for media purpose More...
 
 removeMediaItem (string $a_purpose)
 
 removeAllMediaItems ()
 
 hasFullscreenItem ()
 
 hasPurposeItem (string $purpose)
 returns whether object has media item with specific purpose More...
 
 read ()
 
 setAlias (bool $a_is_alias)
 
 isAlias ()
 
 setOriginID (string $a_id)
 
 getOriginID ()
 
 create (bool $a_create_meta_data=false, bool $a_save_media_items=true, int $from_mob_id=0)
 
 update (bool $a_upload=false)
 
 createDirectory ()
 Create file directory of media object. More...
 
 getFilesOfDirectory (string $dir_path="")
 
 getXML (int $a_mode=IL_MODE_FULL, int $a_inst=0, bool $a_sign_locals=false, bool $offline=false)
 get MediaObject XLM Tag More...
 
 handleAmps (string $a_str)
 Replace "&" (if not an "&") with "&". More...
 
 exportXML (ilXmlWriter $a_xml_writer, int $a_inst=0)
 
 exportFiles (string $a_target_dir)
 export all media files of object to target directory note: target directory must be the export target directory, "/objects/il_<inst>_mob_<mob_id>/..." will be appended to this directory More...
 
 modifyExportIdentifier (string $a_tag, string $a_param, string $a_value)
 
 setContainsIntLink (bool $a_contains_link)
 content parser set this flag to true, if the media object contains internal links (this method should only be called by the import parser) More...
 
 containsIntLink ()
 returns true, if mob was marked as containing an intern link (via setContainsIntLink) (this method should only be called by the import parser) More...
 
 getUsages (bool $a_include_history=true)
 get all usages of current media object More...
 
 getDataDirectory ()
 
 addMediaItemFromLegacyUpload (string $purpose, string $tmp_name, string $name, int $resize_width=0, int $resize_height=0, bool $constrain_proportions=true, bool $deduce_size=false)
 
 addMediaItemFromUpload (string $purpose, UploadResult $result, string $upload_hash="",)
 
 addMediaItemFromLocalFile (string $purpose, string $tmp_name, string $name)
 
 replaceMediaItemFromUpload (string $purpose, UploadResult $result, string $upload_hash="",)
 
 uploadAdditionalFile (string $a_name, string $tmp_name, string $a_subdir="", string $a_mode="move_uploaded")
 Create new media object and update page in db and return new media object. More...
 
 addAdditionalFileFromUpload (UploadResult $result, string $subdir)
 
 uploadSrtFile (string $a_tmp_name, string $a_language, string $a_mode="move_uploaded")
 
 getSrtFiles (bool $vtt_only=false)
 
 makeThumbnail (string $source, string $thumbname,)
 Make thumbnail. More...
 
 removeAdditionalFile (string $a_file)
 
 getLinkedMediaObjects (array $a_ignore=[])
 Get all media objects linked in map areas of this media object. More...
 
 duplicate ()
 Duplicate media object, return new media object. More...
 
 uploadVideoPreviewPic (array $a_prevpic)
 
 getVideoPreviewPic (bool $a_filename_only=false)
 
 getMultiSrtUploadDir ()
 Get directory for multi srt upload. More...
 
 uploadMultipleSubtitleFile (array $a_file)
 Upload multi srt file. More...
 
 clearMultiSrtDirectory ()
 Clear multi srt directory. More...
 
 getMultiSrtFiles ()
 Get all srt files of srt multi upload. More...
 
 getExternalMetadata ()
 
 getStandardSrc ()
 
 getFullscreenSrc ()
 
- Public Member Functions inherited from ilObject
 getObjectProperties ()
 
 flushObjectProperties ()
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $description)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id, int $new_obj_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getDirectory (int $a_mob_id)
 Get absolute directory. More...
 
static _getRelativeDirectory (int $a_mob_id)
 Get relative (to webspace dir) directory. More...
 
static _getURL (int $a_mob_id)
 get directory for files of media object More...
 
static _lookupItemPath (int $a_mob_id, bool $a_url_encode=false, bool $a_web=true, string $a_purpose="")
 Get path for item with specific purpose. More...
 
static _deleteAllUsages (string $a_type, int $a_id, ?int $a_usage_hist_nr=0, string $a_lang="-")
 
static _getMobsOfObject (string $a_type, int $a_id, int|false $a_usage_hist_nr=0, string $a_lang="-")
 
static _saveUsage (int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
 Save usage of mob within another container (e.g. More...
 
static _removeUsage (int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
 Remove usage of mob in another container. More...
 
static lookupUsages (int $a_id, bool $a_include_history=true)
 Lookup usages of media object. More...
 
static getParentObjectIdForUsage (array $a_usage, bool $a_include_all_access_obj_ids=false)
 Get's the repository object ID of a parent object, if possible see ilWebAccessChecker. More...
 
static getMimeType (string $a_file, bool $a_external=false)
 get mime type for file More...
 
static _determineWidthHeight (string $a_format, string $a_type, string $a_file, string $a_reference, bool $a_constrain_proportions, bool $a_use_original, ?int $a_user_width=null, ?int $a_user_height=null)
 
static _saveTempFileAsMediaObject (string $name, string $tmp_name, bool $upload=true)
 
static isTypeAllowed (string $a_type)
 
static fixFilename (string $a_name)
 Fix filename of uploaded file. More...
 
static renameExecutables (string $a_dir)
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", ?int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static getIconForType (string $type)
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, ?\ilDBInterface $ilDB=null)
 

Data Fields

const DEFAULT_THUMB_SIZE = 80
 
const DEFAULT_PREVIEW_SIZE = 400
 
bool $is_alias
 
string $origin_id
 
array $media_items
 
bool $contains_int_link
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Protected Member Functions

 beforeMDUpdateListener (string $a_element)
 
 beforeCreateMetaData ()
 
 beforeUpdateMetaData ()
 
 beforeDeleteMetaData ()
 
 escapeProperty (string $a_value)
 Escape property (e.g. More...
 
 getLocationSrc (string $purpose)
 
- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Static Protected Member Functions

static handleQuotaUpdate (ilObjMediaObject $a_mob)
 

Protected Attributes

ThumbsManager $thumbs
 
MediaObjectManager $manager
 
InternalDomainService $domain
 
ilObjUser $user
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
LOMServices $lom_services
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Private Attributes

LegacyImages $image_converter
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 36 of file class.ilObjMediaObject.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjMediaObject::__construct ( int  $a_id = 0)

Definition at line 50 of file class.ilObjMediaObject.php.

52 {
53 global $DIC;
54
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;
61 $this->type = "mob";
62 parent::__construct($a_id, 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();
67 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAllUsages()

static ilObjMediaObject::_deleteAllUsages ( string  $a_type,
int  $a_id,
?int  $a_usage_hist_nr = 0,
string  $a_lang = "-" 
)
static

Definition at line 776 of file class.ilObjMediaObject.php.

781 : void {
782 global $DIC;
783
784 $ilDB = $DIC->database();
785
786 $and_hist = "";
787 if (!is_null($a_usage_hist_nr)) {
788 $and_hist = " AND usage_hist_nr = " . $ilDB->quote($a_usage_hist_nr, "integer");
789 }
790
791 $mob_ids = array();
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") .
796 $and_hist);
797 while ($row = $ilDB->fetchAssoc($set)) {
798 $mob_ids[] = $row["id"];
799 }
800
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") .
805 $and_hist;
806 $ilDB->manipulate($q);
807
808 foreach ($mob_ids as $mob_id) {
809 self::handleQuotaUpdate(new self($mob_id));
810 }
811 }
static handleQuotaUpdate(ilObjMediaObject $a_mob)
$q
Definition: shib_logout.php:25

References $ilDB.

Referenced by ilPageObject\delete().

+ Here is the caller graph for this function:

◆ _determineWidthHeight()

static ilObjMediaObject::_determineWidthHeight ( string  $a_format,
string  $a_type,
string  $a_file,
string  $a_reference,
bool  $a_constrain_proportions,
bool  $a_use_original,
?int  $a_user_width = null,
?int  $a_user_height = null 
)
static

Definition at line 1211 of file class.ilObjMediaObject.php.

1220 : array {
1221 global $DIC;
1222
1223 $lng = $DIC->language();
1224 $size = [];
1225 $wr = 0;
1226 $hr = 0;
1227 $width = 0;
1228 $height = 0;
1229
1230 // determine width and height of known image types
1231 //$width = 640;
1232 //$height = 360;
1233 $info = "";
1234
1235 /*
1236 if ($a_format == "audio/mpeg") {
1237 $width = 300;
1238 $height = 20;
1239 }*/
1240
1241 if (ilUtil::deducibleSize($a_format)) {
1242 if ($a_type == "File") {
1243 $size = ilMediaImageUtil::getImageSize($a_file);
1244 } else {
1245 $size = ilMediaImageUtil::getImageSize($a_reference);
1246 }
1247 }
1248
1249 if (!isset($size[0])) {
1250 $size[0] = 0;
1251 }
1252 if (!isset($size[1])) {
1253 $size[1] = 0;
1254 }
1255
1256 if ($a_use_original) {
1257 if ($size[0] > 0 && $size[1] > 0) {
1258 //$width = $size[0];
1259 //$height = $size[1];
1260 $width = "";
1261 $height = "";
1262 } else {
1263 $info = $lng->txt("cont_could_not_determine_resource_size");
1264 }
1265 } else {
1266 $w = $a_user_width;
1267 $h = $a_user_height;
1268 $width = $w;
1269 $height = $h;
1270 //echo "<br>C-$width-$height-";
1271 if (ilUtil::deducibleSize($a_format) && $a_constrain_proportions) {
1272 if ($size[0] > 0 && $size[1] > 0) {
1273 if ($w > 0) {
1274 $wr = $size[0] / $w;
1275 }
1276 if ($h > 0) {
1277 $hr = $size[1] / $h;
1278 }
1279 //echo "<br>+".$wr."+".$size[0]."+".$w."+";
1280 //echo "<br>+".$hr."+".$size[1]."+".$h."+";
1281 $r = max($wr, $hr);
1282 if ($r > 0) {
1283 $width = (int) round($size[0] / $r);
1284 $height = (int) round($size[1] / $r);
1285 }
1286 }
1287 }
1288 //echo "<br>D-$width-$height-";
1289 }
1290 //echo "<br>E-$width-$height-";
1291
1292 if ($width == 0 && is_null($a_user_width)) {
1293 $width = "";
1294 }
1295 if ($height == 0 && is_null($a_user_height)) {
1296 $height = "";
1297 }
1298 return array("width" => $width, "height" => $height, "info" => $info);
1299 }
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 getImageSize(string $a_location)
Get image size from location.
ilLanguage $lng
static deducibleSize(string $a_mime)
checks if mime type is provided by getimagesize()
$info
Definition: entry_point.php:21

References ilMediaImageUtil\getImageSize().

Referenced by ilObjMediaObjectGUI\savePropertiesObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _exists()

static ilObjMediaObject::_exists ( int  $id,
bool  $reference = false,
?string  $type = null 
)
static

checks if an object exists in object_data

Parameters
integer$idobject id or reference id
bool$referencetrue if id is a reference, else false (default)
string | null$typestring restrict on a certain type.
Returns
bool true if object exists

Reimplemented from ilObject.

Definition at line 69 of file class.ilObjMediaObject.php.

73 : bool {
74 if (is_int(strpos($id, "_"))) {
76 }
77
78 if (parent::_exists($id) && ilObject::_lookupType($id) === "mob") {
79 return true;
80 }
81 return false;
82 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookupType(int $id, bool $reference=false)

References $id, and ilInternalLink\_extractObjIdOfTarget().

Referenced by ilRTE\_cleanupMediaObjectUsage(), ilInternalLink\_exists(), ilRTE\_getMediaObjects(), assQuestionExport\addQTIMaterial(), ilObjTest\addQTIMaterial(), ilDclMobRecordFieldModel\afterClone(), ilObjForumGUI\createThread(), assQuestion\delete(), ilForumDraftsHistory\deleteMobs(), ilForumPostDraft\deleteMobsOfDraft(), ilObjForumGUI\deleteMobsOfDraft(), ilForum\deletePost(), ilObjTest\deleteTest(), ILIAS\Test\ExportImport\Export\exportXHTMLMediaObjects(), ilQuestionpoolExport\exportXHTMLMediaObjects(), ilObjQuestionPool\exportXMLMediaObjects(), ILIAS\MediaObjects\OverviewGUI\Table\Retrieval\getInternalData(), ilDclMobRecordFieldModel\removeData(), ilObjForumGUI\savePostObject(), ilForumXMLWriter\start(), and ilObjForumGUI\viewThreadObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getDirectory()

static ilObjMediaObject::_getDirectory ( int  $a_mob_id)
static

◆ _getMobsOfObject()

static ilObjMediaObject::_getMobsOfObject ( string  $a_type,
int  $a_id,
int|false  $a_usage_hist_nr = 0,
string  $a_lang = "-" 
)
static
Returns
int[]

Definition at line 816 of file class.ilObjMediaObject.php.

821 : array {
822 global $DIC;
823
824 $ilDB = $DIC->database();
825
826 $lstr = "";
827 if ($a_lang != "") {
828 $lstr = " AND usage_lang = " . $ilDB->quote($a_lang, "text");
829 }
830 $hist_str = "";
831 if ($a_usage_hist_nr !== false) { // see #45933, restore ILIAS 7 behaviour
832 $hist_str = " AND usage_hist_nr = " . $ilDB->quote($a_usage_hist_nr, "integer");
833 }
834
835 $q = "SELECT * FROM mob_usage WHERE " .
836 "usage_type = " . $ilDB->quote($a_type, "text") . " AND " .
837 "usage_id = " . $ilDB->quote($a_id, "integer") .
838 $lstr . $hist_str;
839 $mobs = array();
840 $mob_set = $ilDB->query($q);
841 while ($mob_rec = $ilDB->fetchAssoc($mob_set)) {
842 $mob_id = (int) $mob_rec['id'];
843 if (ilObject::_lookupType($mob_id) === "mob") {
844 $mobs[$mob_id] = $mob_id;
845 }
846 }
847
848 return $mobs;
849 }

References $ilDB.

Referenced by ilRTE\_cleanupMediaObjectUsage(), assQuestionExport\addQTIMaterial(), ilObjTest\addQTIMaterial(), ilPCMediaObject\afterPageUpdate(), assQuestion\cloneXHTMLMediaObjectsOfQuestion(), ilObjForumGUI\createThread(), ilPageObject\delete(), SurveyQuestion\delete(), assQuestion\delete(), ilForumDraftsHistory\deleteMobs(), ilForumPostDraft\deleteMobsOfDraft(), ilObjForumGUI\deleteMobsOfDraft(), ilForum\deletePost(), ilObjSurvey\deleteSurveyRecord(), ilObjTest\deleteTest(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), ILIAS\Test\ExportImport\Export\exportXHTMLMediaObjects(), ilQuestionpoolExport\exportXHTMLMediaObjects(), ILIAS\MediaObjects\OverviewGUI\Table\Retrieval\getInternalData(), ilPageObject\getLastUpdateOfIncludedElements(), ilLMMultiSrt\getMobIds(), ilMepMultiSrt\getMobIds(), ilSoapUtils\getMobsOfObject(), ilCOPageExporter\getXmlExportHeadDependencies(), ilTestExporter\getXmlExportHeadDependencies(), ilPCMediaObject\modifyPageContentPostXsl(), ilObjForumGUI\publishDraftObject(), ILIAS\COPage\PC\MediaObject\MediaObjectManager\resolveMediaAliases(), ilObjForumGUI\savePostObject(), ilForumXMLWriter\start(), assClozeTest\toJSON(), assErrorText\toJSON(), assKprimChoice\toJSON(), assLongMenu\toJSON(), assMatchingQuestion\toJSON(), assMultipleChoice\toJSON(), assOrderingHorizontal\toJSON(), assOrderingQuestion\toJSON(), assSingleChoice\toJSON(), assTextSubset\toJSON(), ilObjForumGUI\updateDraftObject(), and ilObjForumGUI\viewThreadObject().

+ Here is the caller graph for this function:

◆ _getRelativeDirectory()

static ilObjMediaObject::_getRelativeDirectory ( int  $a_mob_id)
static

Get relative (to webspace dir) directory.

Definition at line 387 of file class.ilObjMediaObject.php.

387 : string
388 {
389 return "mobs/mm_" . $a_mob_id;
390 }

◆ _getURL()

static ilObjMediaObject::_getURL ( int  $a_mob_id)
static

get directory for files of media object

Definition at line 395 of file class.ilObjMediaObject.php.

397 : string {
398 return ilUtil::getHtmlPath(ilFileUtils::getWebspaceDir() . "/mobs/mm_" . $a_mob_id);
399 }
static getHtmlPath(string $relative_path)
get url of path

Referenced by ILIAS\MediaObjects\MediaObjectManager\getLocalSrc().

+ Here is the caller graph for this function:

◆ _lookupItemPath()

static ilObjMediaObject::_lookupItemPath ( int  $a_mob_id,
bool  $a_url_encode = false,
bool  $a_web = true,
string  $a_purpose = "" 
)
static

Get path for item with specific purpose.

Definition at line 404 of file class.ilObjMediaObject.php.

409 : string {
410 if ($a_purpose == "") {
411 $a_purpose = "Standard";
412 }
413 $location = ilMediaItem::_lookupLocationForMobId($a_mob_id, $a_purpose);
414 if (preg_match("/https?\:/i", $location)) {
415 return $location;
416 }
417
418 if ($a_url_encode) {
419 $location = rawurlencode($location);
420 }
421
422 $path = ($a_web)
423 ? ILIAS_HTTP_PATH
424 : ".";
425
426 return $path . "/public/data/" . CLIENT_ID . "/mobs/mm_" . $a_mob_id . "/" . $location;
427 }
$location
Definition: buildRTE.php:22
static _lookupLocationForMobId(int $a_mob_id, string $a_purpose)
const CLIENT_ID
Definition: constants.php:41
$path
Definition: ltiservices.php:30

Referenced by ilObjectFeedWriter\__construct(), ilMediaCastManageTableGUI\fillRow(), ilMediaCastTableGUI\fillRow(), and ilMediaCastManageTableGUI\getRows().

+ Here is the caller graph for this function:

◆ _removeUsage()

static ilObjMediaObject::_removeUsage ( int  $a_mob_id,
string  $a_type,
int  $a_id,
int  $a_usage_hist_nr = 0,
string  $a_lang = "-" 
)
static

Remove usage of mob in another container.

Definition at line 883 of file class.ilObjMediaObject.php.

889 : void {
890 global $DIC;
891
892 $ilDB = $DIC->database();
893
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");
900 $ilDB->manipulate($q);
901
902 self::handleQuotaUpdate(new self($a_mob_id));
903 }

Referenced by ilRTE\_cleanupMediaObjectUsage(), ilObjForumGUI\createThread(), SurveyQuestion\delete(), assQuestion\delete(), ilForumDraftsHistory\deleteMobs(), ilForumPostDraft\deleteMobsOfDraft(), ilObjForumGUI\deleteMobsOfDraft(), ilForum\deletePost(), ilObjSurvey\deleteSurveyRecord(), ilObjTest\deleteTest(), ilForumAutoSaveAsyncDraftAction\handleMedia(), ilObjForumGUI\publishDraftObject(), ilObjForumGUI\savePostObject(), ilObjForumGUI\updateDraftObject(), and ilObjForumGUI\viewThreadObject().

+ Here is the caller graph for this function:

◆ _saveTempFileAsMediaObject()

static ilObjMediaObject::_saveTempFileAsMediaObject ( string  $name,
string  $tmp_name,
bool  $upload = true 
)
static
Deprecated:
  • for upload cases use $media_object->addMediaItemFrom(Legacy)Upload
  • imports must use the dependency mechanism

Definition at line 1311 of file class.ilObjMediaObject.php.

1316 // create dummy object in db (we need an id)
1317 $media_object = new ilObjMediaObject();
1318 $media_object->setTitle($name);
1319 $media_object->setDescription("");
1320 $media_object->create();
1321
1322 // determine and create mob directory, move uploaded file to directory
1323 $media_object->createDirectory();
1324 $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId());
1325
1326 $file = $mob_dir . "/" . $name;
1327 if ($upload) {
1328 $media_item = $media_object->addMediaItemFromLegacyUpload(
1329 "Standard",
1330 $tmp_name,
1331 $name,
1332 0,
1333 0,
1334 true,
1335 true
1336 );
1337 } else {
1338 $media_item = $media_object->addMediaItemFromLocalFile(
1339 "Standard",
1340 $tmp_name,
1341 $name
1342 );
1343 /*
1344 $media_item = new ilMediaItem();
1345 $media_object->addMediaItem($media_item);
1346 $media_item->setPurpose("Standard");
1347
1348 copy($tmp_name, $file);
1349 // get mime type
1350 $format = ilObjMediaObject::getMimeType($file);
1351 $media_item->setFormat($format);
1352 $location = $name;
1353 $media_item->setLocation($location);
1354 $media_item->setLocationType("LocalFile");*/
1355 }
1356
1357 // set real meta and object data
1358 $media_object->setTitle($name);
1359 $media_object->setDescription($media_item->getFormat());
1360 $media_item->setHAlign("Left");
1361
1362 /*
1363 self::renameExecutables($mob_dir);
1364 ilMediaSvgSanitizer::sanitizeDir($mob_dir); // see #20339
1365 */
1366
1367 $media_object->update();
1368
1369 return $media_object;
1370 }
static _getDirectory(int $a_mob_id)
Get absolute directory.

Referenced by ilForumXMLParser\handlerEndTag(), ilNewsTimelineGUI\save(), ilNewsItemGUI\saveNewsItem(), ilSoapUtils\saveTempFileAsMediaObject(), ilNewsTimelineGUI\update(), and ilNewsItemGUI\updateNewsItem().

+ Here is the caller graph for this function:

◆ _saveUsage()

static ilObjMediaObject::_saveUsage ( int  $a_mob_id,
string  $a_type,
int  $a_id,
int  $a_usage_hist_nr = 0,
string  $a_lang = "-" 
)
static

Save usage of mob within another container (e.g.

page)

Definition at line 854 of file class.ilObjMediaObject.php.

860 : void {
861 global $DIC;
862
863 $ilDB = $DIC->database();
864
865 $ilDB->replace(
866 "mob_usage",
867 array(
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)
873 ),
874 array()
875 );
876
877 self::handleQuotaUpdate(new self($a_mob_id));
878 }

Referenced by ilRTE\_cleanupMediaObjectUsage(), assQuestion\cloneXHTMLMediaObjectsOfQuestion(), SurveyQuestion\copyXHTMLMediaObjectsOfQuestion(), ilObjForumGUI\createThread(), ilDclMobRecordFieldModel\handleFileUpload(), ilForumAutoSaveAsyncDraftAction\handleMedia(), ilForumXMLParser\handlerEndTag(), ilObjForumGUI\publishDraftObject(), ilObjTest\replaceMobsInPageImports(), ilForumUtil\saveMediaObjects(), and ilObjForumGUI\updateDraftObject().

+ Here is the caller graph for this function:

◆ addAdditionalFileFromUpload()

ilObjMediaObject::addAdditionalFileFromUpload ( UploadResult  $result,
string  $subdir 
)

Definition at line 1521 of file class.ilObjMediaObject.php.

1524 : void {
1525 $this->manager->addFileFromUpload(
1526 $this->getId(),
1527 $result,
1528 $subdir
1529 );
1530 }

◆ addMediaItem()

ilObjMediaObject::addMediaItem ( ilMediaItem  $a_item)

Definition at line 186 of file class.ilObjMediaObject.php.

188 : void {
189 $this->media_items[] = $a_item;
190 }

Referenced by ilMediaItem\_getMediaItemsOfMOb().

+ Here is the caller graph for this function:

◆ addMediaItemFromLegacyUpload()

ilObjMediaObject::addMediaItemFromLegacyUpload ( string  $purpose,
string  $tmp_name,
string  $name,
int  $resize_width = 0,
int  $resize_height = 0,
bool  $constrain_proportions = true,
bool  $deduce_size = false 
)

Definition at line 1372 of file class.ilObjMediaObject.php.

1380 : \ilMediaItem {
1381 $media_item = new ilMediaItem();
1382 $this->addMediaItem($media_item);
1383 $media_item->setPurpose($purpose);
1384 //$location = self::fixFilename($_FILES[$upload_name]['name']);
1385 $location = $name;
1386 $this->manager->addFileFromLegacyUpload($this->getId(), $tmp_name);
1387
1388 // get mime type
1389 $format = self::getMimeType($location, true);
1390
1391 // resize standard images
1392 if ($resize_width > 0 && $resize_height > 0 && is_int(strpos($format, "image"))) {
1393 /*
1394 $location = ilObjMediaObject::_resizeImage(
1395 $file,
1396 $resize_width,
1397 $resize_height,
1398 $constrain_proportions
1399 );*/
1400 }
1401
1402 if ($deduce_size) {
1403 /*
1404 if (ilUtil::deducibleSize($format)) {
1405 $size = ilMediaImageUtil::getImageSize($file);
1406 $media_item->setWidth($size[0]);
1407 $media_item->setHeight($size[1]);
1408 }*/
1409 }
1410
1411 // set real meta and object data
1412 $media_item->setFormat($format);
1413 $media_item->setLocation($location);
1414 $media_item->setLocationType("LocalFile");
1415 if ($purpose === "Standard") {
1416 $this->generatePreviewPic(320, 240);
1417 }
1418 return $media_item;
1419 }
Class ilMediaItem Media Item, component of a media object (file or reference)
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
addMediaItem(ilMediaItem $a_item)

◆ addMediaItemFromLocalFile()

ilObjMediaObject::addMediaItemFromLocalFile ( string  $purpose,
string  $tmp_name,
string  $name 
)

Definition at line 1447 of file class.ilObjMediaObject.php.

1451 : \ilMediaItem {
1452 $media_item = new ilMediaItem();
1453 $this->addMediaItem($media_item);
1454 $media_item->setPurpose($purpose);
1455 $location = $name;
1456 $this->manager->addFileFromLocal($this->getId(), $tmp_name, $name);
1457
1458 // get mime type
1459 $format = self::getMimeType($location, true);
1460
1461 // set real meta and object data
1462 $media_item->setFormat($format);
1463 $media_item->setLocation($location);
1464 $media_item->setLocationType("LocalFile");
1465 if ($purpose === "Standard") {
1466 $this->generatePreviewPic(320, 240);
1467 }
1468 return $media_item;
1469 }

◆ addMediaItemFromUpload()

ilObjMediaObject::addMediaItemFromUpload ( string  $purpose,
UploadResult  $result,
string  $upload_hash = "" 
)

Definition at line 1421 of file class.ilObjMediaObject.php.

1425 : \ilMediaItem {
1426 $media_item = new ilMediaItem();
1427 $this->addMediaItem($media_item);
1428 $media_item->setPurpose($purpose);
1429 $this->manager->addFileFromUpload($this->getId(), $result);
1430
1431 // get mime type
1432 $format = self::getMimeType($result->getName(), true);
1433
1434 // set real meta and object data
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);
1440 }
1441 if ($purpose === "Standard") {
1442 $this->generatePreviewPic(320, 240);
1443 }
1444 return $media_item;
1445 }

◆ beforeCreateMetaData()

ilObjMediaObject::beforeCreateMetaData ( )
protected

Reimplemented from ilObject.

Definition at line 144 of file class.ilObjMediaObject.php.

144 : bool
145 {
146 $ilUser = $this->user;
147
148 $this->domain->metadata()->learningObjectMetadata()->derive()->fromBasicProperties(
149 $this->getTitle(),
150 $this->getLongDescription(),
151 $ilUser->getPref('language')
152 )->forObject(0, $this->getId(), $this->getType());
153
154 return false; // avoid parent to create md
155 }
getLongDescription()
get object long description (stored in object_description)

References ILIAS\Survey\Mode\getId(), and ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle().

+ Here is the call graph for this function:

◆ beforeDeleteMetaData()

ilObjMediaObject::beforeDeleteMetaData ( )
protected

Reimplemented from ilObject.

Definition at line 176 of file class.ilObjMediaObject.php.

176 : bool
177 {
178 // Delete meta data
179 $this->domain->metadata()->learningObjectMetadata()
180 ->deleteAll(0, $this->getId(), $this->getType());
181
182 return false;
183 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ beforeMDUpdateListener()

ilObjMediaObject::beforeMDUpdateListener ( string  $a_element)
protected

Reimplemented from ilObject.

Definition at line 124 of file class.ilObjMediaObject.php.

124 : bool
125 {
126 switch ($a_element) {
127 case 'General':
128 // Update Title and description
129 $paths = $this->domain->metadata()->learningObjectMetadata()->paths();
130 $reader = $this->domain->metadata()->learningObjectMetadata()->read(
131 0,
132 $this->getId(),
133 $this->getType(),
134 $paths->custom()->withNextStep('general')->get()
135 );
136
137 ilObject::_writeTitle($this->getId(), $reader->firstData($paths->title())->value());
138 ilObject::_writeDescription($this->getId(), $reader->firstData($paths->descriptions())->value());
139 break;
140 }
141 return false; // prevent parent from creating ilMD
142 }
static _writeDescription(int $obj_id, string $desc)
write description to db (static)
static _writeTitle(int $obj_id, string $title)
write title to db (static)

References ilObject\_writeDescription(), ilObject\_writeTitle(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ beforeUpdateMetaData()

ilObjMediaObject::beforeUpdateMetaData ( )
protected

Reimplemented from ilObject.

Definition at line 157 of file class.ilObjMediaObject.php.

157 : bool
158 {
159 $paths = $this->domain->metadata()->learningObjectMetadata()->paths();
160
161 $manipulator = $this->domain->metadata()->learningObjectMetadata()
162 ->manipulate(0, $this->getId(), $this->getType())
163 ->prepareCreateOrUpdate($paths->title(), $this->getTitle());
164
165 if ($this->getDescription() !== '') {
166 $manipulator = $manipulator->prepareCreateOrUpdate($paths->firstDescription(), $this->getDescription());
167 } else {
168 $manipulator = $manipulator->prepareDelete($paths->firstDescription());
169 }
170
171 $manipulator->execute();
172
173 return false;
174 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ clearMultiSrtDirectory()

ilObjMediaObject::clearMultiSrtDirectory ( )

Clear multi srt directory.

Definition at line 1761 of file class.ilObjMediaObject.php.

1761 : void
1762 {
1764 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getMultiSrtUploadDir()
Get directory for multi srt upload.

References ilFileUtils\delDir().

+ Here is the call graph for this function:

◆ containsIntLink()

ilObjMediaObject::containsIntLink ( )

returns true, if mob was marked as containing an intern link (via setContainsIntLink) (this method should only be called by the import parser)

Definition at line 771 of file class.ilObjMediaObject.php.

771 : bool
772 {
774 }

◆ create()

ilObjMediaObject::create ( bool  $a_create_meta_data = false,
bool  $a_save_media_items = true,
int  $from_mob_id = 0 
)

Definition at line 286 of file class.ilObjMediaObject.php.

290 : int {
291 $id = parent::create();
292
293 if (!$a_create_meta_data) {
294 $this->createMetaData();
295 }
296 $this->manager->create(
297 $id,
298 $this->getTitle(),
299 $from_mob_id
300 );
301
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);
308 $item->create();
309 }
310 }
311
313
314 $ilAppEventHandler = $this->app_event_handler;
315 $ilAppEventHandler->raise(
316 'components/ILIAS/MediaObjects',
317 'create',
318 array('object' => $this,
319 'obj_type' => 'mob',
320 'obj_id' => $this->getId())
321 );
322
323 return $id;
324 }
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.
ilAppEventHandler $app_event_handler

◆ createDirectory()

ilObjMediaObject::createDirectory ( )

Create file directory of media object.

Exceptions
ilMediaObjectsException

Definition at line 433 of file class.ilObjMediaObject.php.

433 : void
434 {
437 if (!is_dir($path)) {
438 throw new ilMediaObjectsException("Failed to create directory $path.");
439 }
440 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $path, _getDirectory(), ILIAS\Survey\Mode\getId(), and ilFileUtils\makeDirParents().

+ Here is the call graph for this function:

◆ delete()

ilObjMediaObject::delete ( )

delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!!

Returns
bool true if object was removed completely; false if only a references was removed

Reimplemented from ilObject.

Definition at line 84 of file class.ilObjMediaObject.php.

84 : bool
85 {
86 $mob_logger = ilLoggerFactory::getLogger('mob');
87 $mob_logger->debug("ilObjMediaObject: Delete called for media object ID '" . $this->getId() . "'.");
88
89 if (!($this->getId() > 0)) {
90 return false;
91 }
92
93 $usages = $this->getUsages();
94
95 $mob_logger->debug("ilObjMediaObject: ... Found " . count($usages) . " usages.");
96
97 if (count($usages) == 0) {
98 // delete meta data of mob
99 $this->deleteMetaData();
100
101 // delete media items
103
104 // this is just to make sure, there should be no entries left at
105 // this point as they depend on the usage
107
108 // delete object
109 parent::delete();
110
111 $mob_logger->debug("ilObjMediaObject: ... deleted.");
112 } else {
113 foreach ($usages as $u) {
114 $mob_logger->debug("ilObjMediaObject: ... usage type:" . $u["type"] .
115 ", id:" . $u["id"] .
116 ", lang:" . ($u["lang"] ?? "") .
117 ", hist_nr:" . ($u["hist_nr"] ?? "") . ".");
118 }
119 $mob_logger->debug("ilObjMediaObject: ... not deleted.");
120 }
121 return true;
122 }
static getLogger(string $a_component_id)
Get component logger.
static deleteAllItemsOfMob(int $a_mob_id)
getUsages(bool $a_include_history=true)
get all usages of current media object

References ilMediaItem\deleteAllItemsOfMob(), ILIAS\Survey\Mode\getId(), and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

◆ duplicate()

ilObjMediaObject::duplicate ( )

Duplicate media object, return new media object.

Definition at line 1619 of file class.ilObjMediaObject.php.

1620 {
1621 $new_obj = new ilObjMediaObject();
1622 $new_obj->setTitle($this->getTitle());
1623 $new_obj->setDescription($this->getDescription());
1624
1625 // media items
1626 foreach ($this->getMediaItems() as $key => $val) {
1627 $new_obj->addMediaItem($val);
1628 }
1629
1630 $new_obj->create(
1631 false,
1632 true,
1633 $this->getId() // "from" id
1634 );
1635
1636 // meta data
1637 $this->domain->metadata()->learningObjectMetadata()
1638 ->derive()
1639 ->fromObject(0, $this->getId(), "mob")
1640 ->forObject(0, $new_obj->getId(), "mob");
1641
1642 return $new_obj;
1643 }

References ILIAS\Survey\Mode\getId(), and ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle().

+ Here is the call graph for this function:

◆ escapeProperty()

ilObjMediaObject::escapeProperty ( string  $a_value)
protected

Escape property (e.g.

title, caption) to XSLT -> HTML output

Definition at line 696 of file class.ilObjMediaObject.php.

698 : string {
699 return htmlspecialchars($a_value);
700 }

◆ exportFiles()

ilObjMediaObject::exportFiles ( string  $a_target_dir)

export all media files of object to target directory note: target directory must be the export target directory, "/objects/il_<inst>_mob_<mob_id>/..." will be appended to this directory

Exceptions

ILIAS\Filesystem\Exception\DirectoryNotFoundException

Exceptions

ILIAS\Filesystem\Exception\FileNotFoundException

Exceptions

ILIAS\Filesystem\Exception\IOException

Definition at line 730 of file class.ilObjMediaObject.php.

732 : void {
733 $subdir = "il_" . IL_INST_ID . "_mob_" . $this->getId();
734 ilFileUtils::makeDir($a_target_dir . "/objects/" . $subdir);
735
736 $mobdir = ilFileUtils::getWebspaceDir() . "/mobs/mm_" . $this->getId();
737 ilFileUtils::rCopy($mobdir, $a_target_dir . "/objects/" . $subdir);
738 }
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
const IL_INST_ID
Definition: constants.php:40

◆ exportXML()

ilObjMediaObject::exportXML ( ilXmlWriter  $a_xml_writer,
int  $a_inst = 0 
)

Definition at line 714 of file class.ilObjMediaObject.php.

717 : void {
718 $a_xml_writer->appendXML($this->getXML(IL_MODE_FULL, $a_inst));
719 }
const IL_MODE_FULL
getXML(int $a_mode=IL_MODE_FULL, int $a_inst=0, bool $a_sign_locals=false, bool $offline=false)
get MediaObject XLM Tag
appendXML(string $a_str)
append xml string to document

◆ fixFilename()

static ilObjMediaObject::fixFilename ( string  $a_name)
static

Fix filename of uploaded file.

Definition at line 1718 of file class.ilObjMediaObject.php.

1720 : string {
1721 $a_name = ilFileUtils::getASCIIFilename($a_name);
1722
1723 $rchars = array("`", "=", "$", "{", "}", "'", ";", " ", "(", ")");
1724 $a_name = str_replace($rchars, "_", $a_name);
1725 $a_name = str_replace("__", "_", $a_name);
1726 return $a_name;
1727 }
static getASCIIFilename(string $a_filename)

◆ getDataDirectory()

ilObjMediaObject::getDataDirectory ( )

Definition at line 1301 of file class.ilObjMediaObject.php.

1301 : string
1302 {
1303 return ilFileUtils::getWebspaceDir() . "/mobs/mm_" . $this->getId();
1304 }

References ILIAS\Survey\Mode\getId(), and ilFileUtils\getWebspaceDir().

+ Here is the call graph for this function:

◆ getExternalMetadata()

ilObjMediaObject::getExternalMetadata ( )

Definition at line 1804 of file class.ilObjMediaObject.php.

1804 : void
1805 {
1806 // see https://oembed.com/
1807 $st_item = $this->getMediaItem("Standard");
1808 if ($st_item->getLocationType() == "Reference") {
1809 if (ilExternalMediaAnalyzer::isVimeo($st_item->getLocation())) {
1810 $st_item->setFormat("video/vimeo");
1811 $par = ilExternalMediaAnalyzer::extractVimeoParameters($st_item->getLocation());
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);
1822 if ($ext == "") {
1823 $ext = "jpg";
1824 }
1825 $this->manager->addPreviewFromUrl(
1826 $this->getId(),
1827 $meta["thumbnail_url"],
1828 "/mob_vpreview." . $ext
1829 );
1830 }
1831 if (ilExternalMediaAnalyzer::isYoutube($st_item->getLocation())) {
1832 $st_item->setFormat("video/youtube");
1833 $par = ilExternalMediaAnalyzer::extractYoutubeParameters($st_item->getLocation());
1834 try {
1836 $this->setTitle($meta["title"] ?? "");
1837 $description = str_replace("\n", "", $meta["description"] ?? "");
1838 } catch (Exception $e) {
1839 $this->setTitle($st_item->getLocation());
1840 $description = "";
1841 }
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 !== "") {
1849 $mob_logger = ilLoggerFactory::getLogger('mob');
1850 $file = basename($url["path"]);
1851 $this->manager->addPreviewFromUrl(
1852 $this->getId(),
1853 $meta["thumbnail_url"],
1854 "/mob_vpreview." .
1855 pathinfo($file, PATHINFO_EXTENSION)
1856 );
1857 }
1858 }
1859 }
1860 }
static isVimeo(string $a_location)
Identify Vimeo links.
static extractVimeoParameters(string $a_location)
Extract Vimeo Parameter.
getMediaItem(string $a_purpose)
get item for media purpose
setTitle(string $title)
setDescription(string $description)
$url
Definition: shib_logout.php:70

References Vendor\Package\$e, $url, ilExternalMediaAnalyzer\extractVimeoParameters(), ILIAS\Survey\Mode\getId(), ilLoggerFactory\getLogger(), ilExternalMediaAnalyzer\getVimeoMetadata(), ilExternalMediaAnalyzer\getYoutubeMetadata(), and ilExternalMediaAnalyzer\isVimeo().

Referenced by ilObjMediaCast\addMobToCast().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilesOfDirectory()

ilObjMediaObject::getFilesOfDirectory ( string  $dir_path = "")

Definition at line 442 of file class.ilObjMediaObject.php.

444 : array {
445 return $this->manager->getFilesOfPath(
446 $this->getId(),
447 $dir_path
448 );
449 }

Referenced by ILIAS\COPage\PC\InteractiveImage\IIMManager\getOverlays().

+ Here is the caller graph for this function:

◆ getFullscreenSrc()

ilObjMediaObject::getFullscreenSrc ( )

Definition at line 1867 of file class.ilObjMediaObject.php.

1867 : string
1868 {
1869 return $this->getLocationSrc("Fullscreen");
1870 }
getLocationSrc(string $purpose)

◆ getLinkedMediaObjects()

ilObjMediaObject::getLinkedMediaObjects ( array  $a_ignore = [])

Get all media objects linked in map areas of this media object.

Parameters
int[]$a_ignorearray of IDs that should be ignored

Definition at line 1581 of file class.ilObjMediaObject.php.

1583 : array {
1584 $linked = array();
1585
1586 // get linked media objects (map areas)
1587 $med_items = $this->getMediaItems();
1588
1589 foreach ($med_items as $med_item) {
1590 $int_links = ilMapArea::_getIntLinks($med_item->getId());
1591 foreach ($int_links as $k => $int_link) {
1592 if ($int_link["Type"] == "MediaObject") {
1593 $l_id = ilInternalLink::_extractObjIdOfTarget($int_link["Target"]);
1594 if (ilObject::_exists($l_id)) {
1595 if (!in_array($l_id, $linked) &&
1596 !in_array($l_id, $a_ignore)) {
1597 $linked[] = $l_id;
1598 }
1599 }
1600 }
1601 }
1602 }
1603 //var_dump($linked);
1604 return $linked;
1605 }
static _getIntLinks(int $a_item_id)
get all internal links of a media items map areas
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data

◆ getLocationSrc()

ilObjMediaObject::getLocationSrc ( string  $purpose)
protected

Definition at line 1872 of file class.ilObjMediaObject.php.

1872 : string
1873 {
1874 return (string) $this->getMediaItem($purpose)?->getLocationSrc();
1875 }

◆ getMediaItem()

ilObjMediaObject::getMediaItem ( string  $a_purpose)

get item for media purpose

Definition at line 200 of file class.ilObjMediaObject.php.

202 : ?ilMediaItem {
203 foreach ($this->media_items as $media_item) {
204 if ($media_item->getPurpose() == $a_purpose) {
205 return $media_item;
206 }
207 }
208 return null;
209 }

Referenced by ilObjMediaCastGUI\determinePlaytimeObject(), ilMediaObjectsPlayerWrapperGUI\getComponent(), ilObjMediaCastGUI\getMediaItem(), ilObjMediaCastGUI\showCastItemObject(), and ilObjMediaCastGUI\updateCastItemObject().

+ Here is the caller graph for this function:

◆ getMediaItems()

& ilObjMediaObject::getMediaItems ( )

Definition at line 192 of file class.ilObjMediaObject.php.

192 : array
193 {
194 return $this->media_items;
195 }

Referenced by ilObjMediaCastGUI\getMediaItems().

+ Here is the caller graph for this function:

◆ getMimeType()

static ilObjMediaObject::getMimeType ( string  $a_file,
bool  $a_external = false 
)
static

get mime type for file

Definition at line 1203 of file class.ilObjMediaObject.php.

1206 : string {
1207 $mime = MimeType::lookupMimeType($a_file, MimeType::APPLICATION__OCTET_STREAM, $a_external);
1208 return $mime;
1209 }

Referenced by ilKprimChoiceWizardInputGUI\checkUploads(), ilNewsTimelineItemGUI\renderMedia(), ilNewsTimelineItemGUI\renderMediaModal(), ilObjMediaObjectGUI\savePropertiesObject(), ilMediaCreationGUI\saveUrl(), assMultipleChoice\setImageFile(), ilPCInteractiveImageGUI\update(), and ilObjMediaCastGUI\updateMediaItem().

+ Here is the caller graph for this function:

◆ getMultiSrtFiles()

ilObjMediaObject::getMultiSrtFiles ( )

Get all srt files of srt multi upload.

Definition at line 1769 of file class.ilObjMediaObject.php.

1769 : array
1770 {
1771 $items = array();
1772
1773 $lang_codes = $this->domain->metadata()->getLOMLanguageCodes();
1774
1775 $dir = $this->getMultiSrtUploadDir();
1776 $files = ilFileUtils::getDir($dir);
1777 foreach ($files as $k => $i) {
1778 // check directory
1779 if ($i["type"] == "file" && !in_array($k, array(".", ".."))) {
1780 if (pathinfo($k, PATHINFO_EXTENSION) == "vtt") {
1781 $lang = "";
1782 if (substr($k, strlen($k) - 7, 1) == "_") {
1783 $lang = substr($k, strlen($k) - 6, 2);
1784 if (!in_array($lang, $lang_codes)) {
1785 $lang = "";
1786 }
1787 }
1788 $items[] = array("filename" => $k, "lang" => $lang);
1789 }
1790 }
1791 }
1792 return $items;
1793 }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory

References ilFileUtils\getDir().

+ Here is the call graph for this function:

◆ getMultiSrtUploadDir()

ilObjMediaObject::getMultiSrtUploadDir ( )

Get directory for multi srt upload.

Definition at line 1733 of file class.ilObjMediaObject.php.

1733 : string
1734 {
1735 return ilObjMediaObject::_getDirectory($this->getId()) . "/srt/tmp";
1736 }

References _getDirectory(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getOriginID()

ilObjMediaObject::getOriginID ( )

Definition at line 281 of file class.ilObjMediaObject.php.

281 : string
282 {
283 return $this->origin_id;
284 }

◆ getParentObjectIdForUsage()

static ilObjMediaObject::getParentObjectIdForUsage ( array  $a_usage,
bool  $a_include_all_access_obj_ids = false 
)
static

Get's the repository object ID of a parent object, if possible see ilWebAccessChecker.

Definition at line 1010 of file class.ilObjMediaObject.php.

1013 : ?int {
1014 $cont_type = "";
1015 if (is_int(strpos($a_usage["type"], ":"))) {
1016 $us_arr = explode(":", $a_usage["type"]);
1017 $type = $us_arr[1];
1018 $cont_type = $us_arr[0];
1019 } else {
1020 $type = $a_usage["type"];
1021 }
1022
1023 $id = $a_usage["id"];
1024 $obj_id = null;
1025
1026 switch ($type) {
1027 // RTE / tiny mce
1028 case "html":
1029
1030 switch ($cont_type) {
1031 case "qpl":
1032 // Question Pool *Question* Text (Test)
1033 global $DIC;
1034 $qinfo = $DIC->testQuestion()->getGeneralQuestionProperties($id);
1035 if ($qinfo->getOriginalId() > 0) {
1036 $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test
1037 } else {
1038 $obj_id = (int) ($qinfo["obj_fi"] ?? 0); // usage in pool
1039 }
1040 break;
1041
1042 case "spl":
1043 // Question Pool *Question* Text (Survey)
1045 if ($quest) {
1046 $parent_id = $quest->getObjId();
1047
1048 // pool question copy - find survey, do not use pool itself
1049 if ($quest->getOriginalId() &&
1050 ilObject::_lookupType($parent_id) == "spl") {
1052 }
1053 // original question (in pool or survey)
1054 else {
1055 $obj_id = (int) $parent_id;
1056 }
1057
1058 unset($quest);
1059 }
1060 break;
1061
1062 case "exca":
1063 // Exercise assignment
1064 $returned_pk = $a_usage['id'];
1065 // #15995 - we are just checking against exercise object
1066 $obj_id = ilExSubmission::lookupExerciseIdForReturnedId($returned_pk);
1067 break;
1068
1069 case "frm":
1070 // Forum
1071 $post_pk = $a_usage['id'];
1072 $oPost = new ilForumPost($post_pk);
1073 $frm_pk = $oPost->getForumId();
1074 $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
1075 break;
1076
1077
1078 case "frm~d":
1079 $draft_id = $a_usage['id'];
1080 $oDraft = ilForumPostDraft::newInstanceByDraftId($draft_id);
1081
1082 $frm_pk = $oDraft->getForumId();
1083 $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
1084 break;
1085 case "frm~h":
1086 $history_id = $a_usage['id'];
1087 $oHistoryDraft = new ilForumDraftsHistory($history_id);
1088 $oDraft = ilForumPostDraft::newInstanceByDraftId($oHistoryDraft->getDraftId());
1089
1090 $frm_pk = $oDraft->getForumId();
1091 $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
1092 break;
1093 // temporary items (per user)
1094 case "frm~":
1095 case "exca~":
1096 $obj_id = (int) $a_usage['id'];
1097 break;
1098
1099 // "old" category pages
1100 case "cat":
1101 // InfoScreen Text
1102 case "tst":
1103 case "svy":
1104 // data collection
1105 case "dcl":
1106 $obj_id = (int) $id;
1107 break;
1108 }
1109 break;
1110
1111 // page editor
1112 case "pg":
1113
1114 switch ($cont_type) {
1115 // question feedback // parent obj id is q id
1116 case "qfbg":
1117 case "qpl":
1118
1119 if ($cont_type == "qfbg") {
1121 }
1122
1123 // Question Pool Question Pages
1124 global $DIC;
1125 $qinfo = $DIC->testQuestion()->getGeneralQuestionProperties($id);
1126 if ($qinfo->getOriginalId() > 0) {
1127 $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test
1128 } else {
1129 $obj_id = $qinfo["obj_fi"]; // usage in pool
1130 }
1131 if ($obj_id == 0) { // this is the case, if question is in learning module -> get lm id
1133 if ($pinfo && $pinfo["parent_type"] == "lm") {
1134 $obj_id = ilLMObject::_lookupContObjID($pinfo["page_id"]);
1135 }
1136 }
1137 break;
1138
1139 case "lm":
1140 // learning modules
1142 break;
1143
1144 case "term":
1145 $term_id = $id;
1146 $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id);
1147 break;
1148
1149 case "wpg":
1150 // wiki page
1152 break;
1153
1154 case "sahs":
1155 // sahs page
1156 // can this implementation be used for other content types, too?
1157 $obj_id = ilPageObject::lookupParentId($id, 'sahs');
1158 break;
1159
1160 case "prtf":
1161 // portfolio
1163 break;
1164
1165 case "prtt":
1166 // portfolio template
1168 break;
1169
1170
1171 case "impr":
1172 // imprint page - always id 1
1173 // fallthrough
1174
1175 case "copa":
1176 case "cstr":
1177 $obj_id = $id;
1178 break;
1179
1180 default:
1181 $obj_id = ilPageObject::lookupParentId($id, $cont_type);
1182 break;
1183 }
1184 break;
1185
1186 // Media Pool
1187 case "mep":
1188 $obj_id = $id;
1189 break;
1190
1191 // News Context Object (e.g. MediaCast)
1192 case "news":
1194 break;
1195 }
1196
1197 return $obj_id;
1198 }
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)
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 _lookupContObjID(int $a_id)
get learning module id for lm object
static _lookupContextObjId(int $a_news_id)
Context Object ID.
static _lookupTestObjIdForQuestionId(int $q_id)
Get test Object ID for question ID.
string $type
static _getPageForQuestionId(int $a_q_id, string $a_parent_type="")
static lookupParentId(int $a_id, string $a_type)
static findPortfolioForPage(int $a_page_id)
Get portfolio id of page id.
static lookupObjIdByPage(int $a_page_id)
returns the wiki/object id to a given page id

Referenced by ILIAS\MediaObjects\OverviewGUI\Table\Retrieval\addExternalData(), ilMobStakeholder\canBeAccessedByCurrentUser(), ilObjMediaObjectAccess\checkAccessMob(), and ilMediaObjectUsagesTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ getSrtFiles()

ilObjMediaObject::getSrtFiles ( bool  $vtt_only = false)

Definition at line 1544 of file class.ilObjMediaObject.php.

1544 : array
1545 {
1546 return $this->manager->getSrtFiles($this->getId(), $vtt_only);
1547 }

References ILIAS\Survey\Mode\getId().

Referenced by ilMobSubtitleTableGUI\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStandardSrc()

ilObjMediaObject::getStandardSrc ( )

Definition at line 1862 of file class.ilObjMediaObject.php.

1862 : string
1863 {
1864 return $this->getLocationSrc("Standard");
1865 }

Referenced by ilObjMediaCastGUI\showCastItemObject().

+ Here is the caller graph for this function:

◆ getUsages()

ilObjMediaObject::getUsages ( bool  $a_include_history = true)

get all usages of current media object

Definition at line 908 of file class.ilObjMediaObject.php.

910 : array {
911 return self::lookupUsages($this->getId(), $a_include_history);
912 }
static lookupUsages(int $a_id, bool $a_include_history=true)
Lookup usages of media object.

◆ getVideoPreviewPic()

ilObjMediaObject::getVideoPreviewPic ( bool  $a_filename_only = false)

Definition at line 1684 of file class.ilObjMediaObject.php.

1686 : string {
1687
1688 if (!$a_filename_only) {
1689 $src = $this->thumbs->getPreviewSrc($this->getId());
1690 if ($src !== "") {
1691 return $src;
1692 }
1693 }
1694
1695 $dir = ilObjMediaObject::_getDirectory($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();
1702 }
1703 foreach ($ppics as $p) {
1704 if (is_file($dir . "/" . $p)) {
1705 if ($a_filename_only) {
1706 return $p;
1707 } else {
1708 return $dir . "/" . $p;
1709 }
1710 }
1711 }
1712 return "";
1713 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getXML()

ilObjMediaObject::getXML ( int  $a_mode = IL_MODE_FULL,
int  $a_inst = 0,
bool  $a_sign_locals = false,
bool  $offline = false 
)

get MediaObject XLM Tag

Parameters
int$a_modeIL_MODE_ALIAS | IL_MODE_OUTPUT | IL_MODE_FULL
int$a_inst
bool$a_sign_locals
Returns
string
Exceptions
ilWACException

Definition at line 459 of file class.ilObjMediaObject.php.

464 : string {
465 $ilUser = $this->user;
466 $xml = "";
467 switch ($a_mode) {
468 case IL_MODE_ALIAS:
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() . "\">";
475
476 // Layout
477 $width = ($item->getWidth() != "")
478 ? "Width=\"" . $item->getWidth() . "\""
479 : "";
480 $height = ($item->getHeight() != "")
481 ? "Height=\"" . $item->getHeight() . "\""
482 : "";
483 $halign = ($item->getHAlign() != "")
484 ? "HorizontalAlign=\"" . $item->getHAlign() . "\""
485 : "";
486 $xml .= "<Layout $width $height $halign />";
487
488 // Caption
489 if ($item->getCaption() != "") {
490 $xml .= "<Caption Align=\"bottom\">" .
491 $this->escapeProperty($item->getCaption()) . "</Caption>";
492 }
493
494 // Text Representation
495 if ($item->getTextRepresentation() != "") {
496 $xml .= "<TextRepresentation>" .
497 $this->escapeProperty($item->getTextRepresentation()) . "</TextRepresentation>";
498 }
499
500 // Parameter
501 $parameters = $item->getParameters();
502 foreach ($parameters as $name => $value) {
503 $xml .= "<Parameter Name=\"$name\" Value=\"" . $this->escapeProperty($value) . "\"/>";
504 }
505 $xml .= $item->getMapAreasXML();
506 $xml .= "</MediaAliasItem>";
507 }
508 break;
509
510 // for output we need technical sections of meta data
511 case IL_MODE_OUTPUT:
512
513 // get first technical section
514 // $meta = $this->getMetaData();
515 $xml = "<MediaObject Id=\"il__mob_" . $this->getId() . "\">";
516
517 $media_items = $this->getMediaItems();
518 for ($i = 0; $i < count($media_items); $i++) {
519 $item = $media_items[$i];
520
521 $xml .= "<MediaItem Purpose=\"" . $item->getPurpose() . "\">";
522 if ($a_sign_locals && $item->getLocationType() == "LocalFile") {
523 // pre irss file
524 if (is_file($this->getDataDirectory() . "/" . $item->getLocation())) {
525 $location = ilWACSignedPath::signFile($this->getDataDirectory() . "/" . $item->getLocation());
526 $location = substr($location, strrpos($location, "/") + 1);
527 } else {
528 if ($offline) {
529 $location = $item->getLocation();
530 } else {
531 $location = $this->manager->getLocalSrc(
532 $this->getId(),
533 $item->getLocation()
534 );
535 }
536 }
537 } else {
538 $location = trim($item->getLocation());
539 // irss
540 if ($item->getLocationType() === "LocalFile" &&
541 !is_file($this->getDataDirectory() . "/" . $item->getLocation())) {
542 $location = $this->manager->getLocalSrc(
543 $this->getId(),
544 $item->getLocation()
545 );
546 }
547 if ($item->getLocationType() != "LocalFile") { //#25941
549 }
550 }
551
552 $xml .= "<Location Type=\"" . $item->getLocationType() . "\">" .
553 $this->handleAmps($location) . "</Location>";
554
555 // Format
556 $xml .= "<Format>" . $item->getFormat() . "</Format>";
557
558 // Layout
559 $width = ($item->getWidth() != "")
560 ? "Width=\"" . $item->getWidth() . "\""
561 : "";
562 $height = ($item->getHeight() != "")
563 ? "Height=\"" . $item->getHeight() . "\""
564 : "";
565 $halign = ($item->getHAlign() != "")
566 ? "HorizontalAlign=\"" . $item->getHAlign() . "\""
567 : "";
568 $xml .= "<Layout $width $height $halign />";
569
570 // Caption
571 if ($item->getCaption() != "") {
572 $xml .= "<Caption Align=\"bottom\">" .
573 $this->escapeProperty($item->getCaption()) . "</Caption>";
574 }
575
576 // Text Representation
577 if ($item->getTextRepresentation() != "") {
578 $xml .= "<TextRepresentation>" .
579 $this->escapeProperty($item->getTextRepresentation()) . "</TextRepresentation>";
580 }
581
582 // Title
583 if ($this->getTitle() != "") {
584 $xml .= "<Title>" .
585 $this->escapeProperty($this->getTitle()) . "</Title>";
586 }
587
588 // Parameter
589 $parameters = $item->getParameters();
590 if ($item->getFormat() === "video/vimeo") {
591 $parameters = ilExternalMediaAnalyzer::extractVimeoParameters($item->getLocation());
592 }
593 foreach ($parameters as $name => $value) {
594 $xml .= "<Parameter Name=\"$name\" Value=\"" . $this->escapeProperty($value) . "\"/>";
595 }
596 $xml .= $item->getMapAreasXML();
597
598 // Subtitles
599 if ($item->getPurpose() == "Standard") {
600 $this->manager->generateMissingVTT($this->getId());
601 $srts = $this->getSrtFiles(true);
602 foreach ($srts as $srt) {
603 $def = "";
604 $meta_lang = "";
605 if ($ilUser->getLanguage() != $meta_lang &&
606 $ilUser->getLanguage() == $srt["language"]) {
607 $def = ' Default="true" ';
608 }
609 $src = $offline
610 ? "mobs/mm_" . $this->getId() . $srt["full_path"]
611 : $srt["src"];
612 $xml .= "<Subtitle File=\"" . $src .
613 "\" Language=\"" . $srt["language"] . "\" " . $def . "/>";
614 }
615 }
616 if ($this->getVideoPreviewPic(false)) {
617 $xml .= "<PreviewPic File=\"" . $this->handleAmps($this->getVideoPreviewPic(false)) .
618 "\" />";
619 }
620 if ($item->getLocationType() == "LocalFile") {
621 $lpos = strrpos($location, "/");
622 $base_url = substr($location, 0, $lpos);
623 $xml .= "<Url Base=\"" . $base_url .
624 "\" />";
625 }
626 $xml .= "</MediaItem>";
627 }
628 break;
629
630 // full xml for export
631 case IL_MODE_FULL:
632 $xml = "<MediaObject>";
633
634 // Title and Identifier
635 $xml .= "<Identifier Entry=\"il_" . IL_INST_ID . "_mob_" . $this->getId() . "\"/>";
636 if ($this->getTitle() != "") {
637 $xml .= "<Title>" .
638 $this->escapeProperty($this->getTitle()) . "</Title>";
639 }
640
641 $media_items = $this->getMediaItems();
642 for ($i = 0; $i < count($media_items); $i++) {
643 $item = $media_items[$i];
644
645 // highlight mode
646 $xml .= "<MediaItem Purpose=\"" . $item->getPurpose() . "\">";
647
648 // Location
649 $xml .= "<Location Type=\"" . $item->getLocationType() . "\">" .
650 $this->handleAmps($item->getLocation()) . "</Location>";
651
652 // Format
653 $xml .= "<Format>" . $item->getFormat() . "</Format>";
654
655 // Layout
656 $width = ($item->getWidth() != "")
657 ? "Width=\"" . $item->getWidth() . "\""
658 : "";
659 $height = ($item->getHeight() != "")
660 ? "Height=\"" . $item->getHeight() . "\""
661 : "";
662 $halign = ($item->getHAlign() != "")
663 ? "HorizontalAlign=\"" . $item->getHAlign() . "\""
664 : "";
665 $xml .= "<Layout $width $height $halign />";
666
667 // Caption
668 if ($item->getCaption() != "") {
669 $xml .= "<Caption Align=\"bottom\">" .
670 str_replace("&", "&amp;", $item->getCaption()) . "</Caption>";
671 }
672
673 // Text Representation
674 if ($item->getTextRepresentation() != "") {
675 $xml .= "<TextRepresentation>" .
676 str_replace("&", "&amp;", $item->getTextRepresentation()) . "</TextRepresentation>";
677 }
678
679 // Parameter
680 $parameters = $item->getParameters();
681 foreach ($parameters as $name => $value) {
682 $xml .= "<Parameter Name=\"$name\" Value=\"$value\"/>";
683 }
684 $xml .= $item->getMapAreasXML(true, $a_inst);
685 $xml .= "</MediaItem>";
686 }
687 break;
688 }
689 $xml .= "</MediaObject>";
690 return $xml;
691 }
const IL_MODE_ALIAS
const IL_MODE_OUTPUT
getSrtFiles(bool $vtt_only=false)
escapeProperty(string $a_value)
Escape property (e.g.
getVideoPreviewPic(bool $a_filename_only=false)
handleAmps(string $a_str)
Replace "&" (if not an "&") with "&".
static secureUrl(string $url)
static signFile(string $path_to_file)

References $location, ilExternalMediaAnalyzer\extractVimeoParameters(), ILIAS\Survey\Mode\getId(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), IL_INST_ID, IL_MODE_ALIAS, IL_MODE_FULL, IL_MODE_OUTPUT, ilUtil\secureUrl(), and ilWACSignedPath\signFile().

+ Here is the call graph for this function:

◆ handleAmps()

ilObjMediaObject::handleAmps ( string  $a_str)

Replace "&" (if not an "&amp;") with "&amp;".

Definition at line 706 of file class.ilObjMediaObject.php.

708 : string {
709 $a_str = str_replace("&amp;", "&", $a_str);
710 $a_str = str_replace("&", "&amp;", $a_str);
711 return $a_str;
712 }

◆ handleQuotaUpdate()

static ilObjMediaObject::handleQuotaUpdate ( ilObjMediaObject  $a_mob)
staticprotected
Deprecated:

Definition at line 370 of file class.ilObjMediaObject.php.

372 : void {
373 }

◆ hasFullscreenItem()

ilObjMediaObject::hasFullscreenItem ( )

Definition at line 236 of file class.ilObjMediaObject.php.

236 : bool
237 {
238 return $this->hasPurposeItem("Fullscreen");
239 }
hasPurposeItem(string $purpose)
returns whether object has media item with specific purpose

◆ hasPurposeItem()

ilObjMediaObject::hasPurposeItem ( string  $purpose)

returns whether object has media item with specific purpose

Definition at line 244 of file class.ilObjMediaObject.php.

244 : bool
245 {
246 if (is_object($this->getMediaItem($purpose))) {
247 return true;
248 } else {
249 return false;
250 }
251 }

◆ isAlias()

ilObjMediaObject::isAlias ( )

Definition at line 268 of file class.ilObjMediaObject.php.

268 : bool
269 {
270 return $this->is_alias;
271 }

◆ isTypeAllowed()

static ilObjMediaObject::isTypeAllowed ( string  $a_type)
static

Definition at line 1607 of file class.ilObjMediaObject.php.

1609 : bool {
1610 global $DIC;
1611 return in_array($a_type, iterator_to_array(
1612 $DIC->mediaObjects()->internal()->domain()->mediaType()->getAllowedSuffixes()
1613 ), true);
1614 }

Referenced by ilPageObjectGUI\displayMedia(), ilLMPresentationGUI\ilMedia(), ilGlossaryPresentationGUI\media(), ilObjMediaPoolGUI\showMedia(), ilPageObjectGUI\showMediaFullscreen(), and ilPageObjectGUI\showPage().

+ Here is the caller graph for this function:

◆ lookupUsages()

static ilObjMediaObject::lookupUsages ( int  $a_id,
bool  $a_include_history = true 
)
static

Lookup usages of media object.

Todo:
: This should be all in one context -> mob id table

Definition at line 919 of file class.ilObjMediaObject.php.

922 : array {
923 global $DIC;
924
925 $ilDB = $DIC->database();
926
927 $hist_str = "";
928 if ($a_include_history) {
929 $hist_str = ", usage_hist_nr";
930 }
931
932 // get usages in pages
933 $q = "SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str . " FROM mob_usage WHERE id = " .
934 $ilDB->quote($a_id, "integer");
935
936 if (!$a_include_history) {
937 $q .= " AND usage_hist_nr = " . $ilDB->quote(0, "integer");
938 }
939
940 $us_set = $ilDB->query($q);
941 $ret = array();
942 while ($us_rec = $ilDB->fetchAssoc($us_set)) {
943 $ut = "";
944 $ct = 0;
945 if (is_int(strpos($us_rec["usage_type"], ":"))) {
946 $us_arr = explode(":", $us_rec["usage_type"]);
947 $ut = $us_arr[1];
948 $ct = $us_arr[0];
949 }
950
951 // check whether page exists
952 $skip = false;
953 if ($ut == "pg") {
954 if (!ilPageObject::_exists($ct, $us_rec["usage_id"])) {
955 $skip = true;
956 }
957 }
958
959 if (!$skip) {
960 $ret[] = array(
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)
965 );
966 }
967 }
968
969 // get usages in media pools
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");
972 $us_set = $ilDB->query($q);
973 while ($us_rec = $ilDB->fetchAssoc($us_set)) {
974 $ret[] = array("type" => "mep",
975 "id" => $us_rec["mep_id"]);
976 }
977
978 // get usages in news items (media casts)
979 $news_usages = ilNewsItem::_lookupMediaObjectUsages($a_id);
980 foreach ($news_usages as $nu) {
981 $ret[] = $nu;
982 }
983
984
985 // get usages in map areas
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");
990 $us_set = $ilDB->query($q);
991 while ($us_rec = $ilDB->fetchAssoc($us_set)) {
992 $ret[] = array("type" => "map",
993 "id" => $us_rec["mob_id"]);
994 }
995
996 // get usages in personal clipboards
997 $users = ilObjUser::_getUsersForClipboadObject("mob", $a_id);
998 foreach ($users as $user) {
999 $ret[] = array("type" => "clip",
1000 "id" => $user);
1001 }
1002
1003 return $ret;
1004 }
static _lookupMediaObjectUsages(int $a_mob_id)
Lookup media object usage(s)
static _getUsersForClipboadObject(string $a_type, int $a_id)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.

Referenced by ILIAS\MediaObjects\OverviewGUI\Table\Retrieval\addExternalData(), ilMobStakeholder\canBeAccessedByCurrentUser(), and ilLMObject\updateInternalLinks().

+ Here is the caller graph for this function:

◆ makeThumbnail()

ilObjMediaObject::makeThumbnail ( string  $source,
string  $thumbname 
)

Make thumbnail.

Definition at line 1552 of file class.ilObjMediaObject.php.

1555 : void {
1556 $format = self::getMimeType($source, true);
1557 $this->thumbs->createPreview(
1558 $this->getId(),
1559 $source,
1560 true,
1561 $format,
1562 1,
1563 $thumbname
1564 );
1565 }

◆ modifyExportIdentifier()

ilObjMediaObject::modifyExportIdentifier ( string  $a_tag,
string  $a_param,
string  $a_value 
)

Definition at line 740 of file class.ilObjMediaObject.php.

744 : string {
745 if ($a_tag == "Identifier" && $a_param == "Entry") {
746 $a_value = ilUtil::insertInstIntoID($a_value);
747 }
748
749 return $a_value;
750 }
static insertInstIntoID(string $a_value)
inserts installation id into ILIAS id

References ilUtil\insertInstIntoID().

+ Here is the call graph for this function:

◆ read()

ilObjMediaObject::read ( )
Exceptions
ilObjectNotFoundException
ilObjectTypeMismatchException

Reimplemented from ilObject.

Definition at line 257 of file class.ilObjMediaObject.php.

257 : void
258 {
259 parent::read();
261 }
static _getMediaItemsOfMOb(ilObjMediaObject $a_mob)
Read media items into(!) media object (static)

References ilMediaItem\_getMediaItemsOfMOb().

+ Here is the call graph for this function:

◆ removeAdditionalFile()

ilObjMediaObject::removeAdditionalFile ( string  $a_file)

Definition at line 1567 of file class.ilObjMediaObject.php.

1569 : void {
1570 $this->manager->removeLocation(
1571 $this->getId(),
1572 $a_file
1573 );
1574 }

◆ removeAllMediaItems()

ilObjMediaObject::removeAllMediaItems ( )

Definition at line 231 of file class.ilObjMediaObject.php.

231 : void
232 {
233 $this->media_items = array();
234 }

◆ removeMediaItem()

ilObjMediaObject::removeMediaItem ( string  $a_purpose)

Definition at line 211 of file class.ilObjMediaObject.php.

213 : void {
214 foreach ($this->media_items as $key => $media_item) {
215 if ($media_item->getPurpose() == $a_purpose) {
216 unset($this->media_items[$key]);
217 }
218 }
219 // update numbers and keys
220 $i = 1;
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);
226 $i++;
227 }
228 $this->media_items = $media_items;
229 }

Referenced by ilObjMediaCastGUI\updateCastItemObject().

+ Here is the caller graph for this function:

◆ renameExecutables()

static ilObjMediaObject::renameExecutables ( string  $a_dir)
static

Definition at line 1795 of file class.ilObjMediaObject.php.

1797 : void {
1799 if (!self::isTypeAllowed("html")) {
1800 ilFileUtils::rRenameSuffix($a_dir, "html", "sec"); // see #20187
1801 }
1802 }
static renameExecutables(string $a_dir)
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.

References ilFileUtils\rRenameSuffix().

+ Here is the call graph for this function:

◆ replaceMediaItemFromUpload()

ilObjMediaObject::replaceMediaItemFromUpload ( string  $purpose,
UploadResult  $result,
string  $upload_hash = "" 
)

Definition at line 1471 of file class.ilObjMediaObject.php.

1475 : \ilMediaItem {
1476 $media_item = $this->getMediaItem($purpose);
1477 $this->manager->removeLocation($this->getId(), $media_item->getLocation());
1478 $this->manager->addFileFromUpload($this->getId(), $result);
1479
1480 // get mime type
1481 $format = self::getMimeType($result->getName(), true);
1482
1483 // set real meta and object data
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);
1489 }
1490 if ($purpose === "Standard") {
1491 $this->generatePreviewPic(320, 240);
1492 }
1493 return $media_item;
1494 }

◆ setAlias()

ilObjMediaObject::setAlias ( bool  $a_is_alias)

Definition at line 263 of file class.ilObjMediaObject.php.

263 : void
264 {
265 $this->is_alias = $a_is_alias;
266 }

◆ setContainsIntLink()

ilObjMediaObject::setContainsIntLink ( bool  $a_contains_link)

content parser set this flag to true, if the media object contains internal links (this method should only be called by the import parser)

Definition at line 761 of file class.ilObjMediaObject.php.

763 : void {
764 $this->contains_int_link = $a_contains_link;
765 }

◆ setOriginID()

ilObjMediaObject::setOriginID ( string  $a_id)
Deprecated:
(seems to be obsolete)

Definition at line 276 of file class.ilObjMediaObject.php.

276 : void
277 {
278 $this->origin_id = $a_id;
279 }

◆ update()

ilObjMediaObject::update ( bool  $a_upload = false)

Definition at line 326 of file class.ilObjMediaObject.php.

326 : bool
327 {
328 parent::update();
329
330 if (!$a_upload) {
331 $this->updateMetaData();
332 }
333
334 // iterate all items
335 $media_items = $this->getMediaItems();
337
338 $j = 1;
339 foreach ($media_items as $key => $val) {
340 $item = $val;
341 if (is_object($item)) {
342 $item->setMobId($this->getId());
343 $item->setNr($j);
344 if ($item->getLocationType() == "Reference") {
345 $item->extractUrlParameters();
346 }
347 $item->create();
348 $j++;
349 }
350 }
351
352 $this->manager->updateLastChange($this->getId());
353
355 $ilAppEventHandler = $this->app_event_handler;
356 $ilAppEventHandler->raise(
357 'components/ILIAS/MediaObjects',
358 'update',
359 array('object' => $this,
360 'obj_type' => 'mob',
361 'obj_id' => $this->getId())
362 );
363
364 return true;
365 }

References ilMediaItem\deleteAllItemsOfMob(), and ILIAS\Survey\Mode\getId().

Referenced by ilObjMediaCastGUI\updateCastItemObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uploadAdditionalFile()

ilObjMediaObject::uploadAdditionalFile ( string  $a_name,
string  $tmp_name,
string  $a_subdir = "",
string  $a_mode = "move_uploaded" 
)

Create new media object and update page in db and return new media object.

Definition at line 1499 of file class.ilObjMediaObject.php.

1504 : void {
1505 $a_subdir = str_replace("..", "", $a_subdir);
1506 if ($a_mode == "rename") {
1507 $this->manager->addFileFromLocal(
1508 $this->getId(),
1509 $tmp_name,
1510 $a_subdir . "/" . $a_name
1511 );
1512 } else {
1513 $this->manager->addFileFromLegacyUpload(
1514 $this->getId(),
1515 $tmp_name,
1516 $a_subdir . "/" . $a_name
1517 );
1518 }
1519 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ uploadMultipleSubtitleFile()

ilObjMediaObject::uploadMultipleSubtitleFile ( array  $a_file)

Upload multi srt file.

Definition at line 1742 of file class.ilObjMediaObject.php.

1744 : void {
1745 $lng = $this->lng;
1746
1747 if (!is_file($a_file["tmp_name"])) {
1748 throw new ilMediaObjectsException($lng->txt("mob_file_could_not_be_uploaded"));
1749 }
1750
1751 $dir = $this->getMultiSrtUploadDir();
1752 ilFileUtils::delDir($dir, true);
1754 ilFileUtils::moveUploadedFile($a_file["tmp_name"], "multi_vtt.zip", $dir . "/" . "multi_vtt.zip");
1755 $this->domain->resources()->zip()->unzipFile($dir . "/multi_vtt.zip");
1756 }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

References $lng.

◆ uploadSrtFile()

ilObjMediaObject::uploadSrtFile ( string  $a_tmp_name,
string  $a_language,
string  $a_mode = "move_uploaded" 
)

Definition at line 1532 of file class.ilObjMediaObject.php.

1536 : bool {
1537 if (is_file($a_tmp_name) && $a_language != "") {
1538 $this->uploadAdditionalFile("subtitle_" . $a_language . ".vtt", $a_tmp_name, "srt", $a_mode);
1539 return true;
1540 }
1541 return false;
1542 }
uploadAdditionalFile(string $a_name, string $tmp_name, string $a_subdir="", string $a_mode="move_uploaded")
Create new media object and update page in db and return new media object.

◆ uploadVideoPreviewPic()

ilObjMediaObject::uploadVideoPreviewPic ( array  $a_prevpic)

Definition at line 1645 of file class.ilObjMediaObject.php.

1647 : void {
1648 // remove old one
1649 if ($this->getVideoPreviewPic(true) != "") {
1650 $this->removeAdditionalFile($this->getVideoPreviewPic(true));
1651 }
1652
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"]);
1657 }
1658 }
removeAdditionalFile(string $a_file)

Field Documentation

◆ $contains_int_link

bool ilObjMediaObject::$contains_int_link

Definition at line 47 of file class.ilObjMediaObject.php.

◆ $domain

InternalDomainService ilObjMediaObject::$domain
protected

Definition at line 42 of file class.ilObjMediaObject.php.

◆ $image_converter

LegacyImages ilObjMediaObject::$image_converter
private

Definition at line 48 of file class.ilObjMediaObject.php.

◆ $is_alias

bool ilObjMediaObject::$is_alias

Definition at line 44 of file class.ilObjMediaObject.php.

◆ $manager

MediaObjectManager ilObjMediaObject::$manager
protected

Definition at line 41 of file class.ilObjMediaObject.php.

◆ $media_items

array ilObjMediaObject::$media_items

Definition at line 46 of file class.ilObjMediaObject.php.

◆ $origin_id

string ilObjMediaObject::$origin_id

Definition at line 45 of file class.ilObjMediaObject.php.

◆ $thumbs

ThumbsManager ilObjMediaObject::$thumbs
protected

Definition at line 40 of file class.ilObjMediaObject.php.

◆ $user

ilObjUser ilObjMediaObject::$user
protected

Definition at line 43 of file class.ilObjMediaObject.php.

◆ DEFAULT_PREVIEW_SIZE

const ilObjMediaObject::DEFAULT_PREVIEW_SIZE = 400

Definition at line 39 of file class.ilObjMediaObject.php.

◆ DEFAULT_THUMB_SIZE

const ilObjMediaObject::DEFAULT_THUMB_SIZE = 80

The documentation for this class was generated from the following file: