ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 $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 _resizeImage (string $a_file, int $a_width, int $a_height, bool $a_constrain_prop=false)
 Resize image and return new image file ("_width_height" string appended) 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_PREVIEW_SIZE = 80
 
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 49 of file class.ilObjMediaObject.php.

51 {
52 global $DIC;
53
54 $this->user = $DIC->user();
55 $this->app_event_handler = $DIC["ilAppEventHandler"];
56 $this->lng = $DIC->language();
57 $this->is_alias = false;
58 $this->media_items = array();
59 $this->contains_int_link = false;
60 $this->type = "mob";
61 parent::__construct($a_id, false);
62 $this->image_converter = $DIC->fileConverters()->legacyImages();
63 $this->domain = $DIC->mediaObjects()->internal()->domain();
64 $this->manager = $this->domain->mediaObject();
65 $this->thumbs = $this->domain->thumbs();
66 }
__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 770 of file class.ilObjMediaObject.php.

775 : void {
776 global $DIC;
777
778 $ilDB = $DIC->database();
779
780 $and_hist = "";
781 if (!is_null($a_usage_hist_nr)) {
782 $and_hist = " AND usage_hist_nr = " . $ilDB->quote($a_usage_hist_nr, "integer");
783 }
784
785 $mob_ids = array();
786 $set = $ilDB->query("SELECT id FROM mob_usage" .
787 " WHERE usage_type = " . $ilDB->quote($a_type, "text") .
788 " AND usage_id = " . $ilDB->quote($a_id, "integer") .
789 " AND usage_lang = " . $ilDB->quote($a_lang, "text") .
790 $and_hist);
791 while ($row = $ilDB->fetchAssoc($set)) {
792 $mob_ids[] = $row["id"];
793 }
794
795 $q = "DELETE FROM mob_usage WHERE usage_type = " .
796 $ilDB->quote($a_type, "text") .
797 " AND usage_id= " . $ilDB->quote($a_id, "integer") .
798 " AND usage_lang = " . $ilDB->quote($a_lang, "text") .
799 $and_hist;
800 $ilDB->manipulate($q);
801
802 foreach ($mob_ids as $mob_id) {
803 self::handleQuotaUpdate(new self($mob_id));
804 }
805 }
static handleQuotaUpdate(ilObjMediaObject $a_mob)
$q
Definition: shib_logout.php:23

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 1240 of file class.ilObjMediaObject.php.

1249 : array {
1250 global $DIC;
1251
1252 $lng = $DIC->language();
1253 $size = [];
1254 $wr = 0;
1255 $hr = 0;
1256 $width = 0;
1257 $height = 0;
1258
1259 // determine width and height of known image types
1260 //$width = 640;
1261 //$height = 360;
1262 $info = "";
1263
1264 /*
1265 if ($a_format == "audio/mpeg") {
1266 $width = 300;
1267 $height = 20;
1268 }*/
1269
1270 if (ilUtil::deducibleSize($a_format)) {
1271 if ($a_type == "File") {
1272 $size = ilMediaImageUtil::getImageSize($a_file);
1273 } else {
1274 $size = ilMediaImageUtil::getImageSize($a_reference);
1275 }
1276 }
1277
1278 if (!isset($size[0])) {
1279 $size[0] = 0;
1280 }
1281 if (!isset($size[1])) {
1282 $size[1] = 0;
1283 }
1284
1285 if ($a_use_original) {
1286 if ($size[0] > 0 && $size[1] > 0) {
1287 //$width = $size[0];
1288 //$height = $size[1];
1289 $width = "";
1290 $height = "";
1291 } else {
1292 $info = $lng->txt("cont_could_not_determine_resource_size");
1293 }
1294 } else {
1295 $w = $a_user_width;
1296 $h = $a_user_height;
1297 $width = $w;
1298 $height = $h;
1299 //echo "<br>C-$width-$height-";
1300 if (ilUtil::deducibleSize($a_format) && $a_constrain_proportions) {
1301 if ($size[0] > 0 && $size[1] > 0) {
1302 if ($w > 0) {
1303 $wr = $size[0] / $w;
1304 }
1305 if ($h > 0) {
1306 $hr = $size[1] / $h;
1307 }
1308 //echo "<br>+".$wr."+".$size[0]."+".$w."+";
1309 //echo "<br>+".$hr."+".$size[1]."+".$h."+";
1310 $r = max($wr, $hr);
1311 if ($r > 0) {
1312 $width = (int) round($size[0] / $r);
1313 $height = (int) round($size[1] / $r);
1314 }
1315 }
1316 }
1317 //echo "<br>D-$width-$height-";
1318 }
1319 //echo "<br>E-$width-$height-";
1320
1321 if ($width == 0 && is_null($a_user_width)) {
1322 $width = "";
1323 }
1324 if ($height == 0 && is_null($a_user_height)) {
1325 $height = "";
1326 }
1327 return array("width" => $width, "height" => $height, "info" => $info);
1328 }
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 68 of file class.ilObjMediaObject.php.

72 : bool {
73 if (is_int(strpos($id, "_"))) {
75 }
76
77 if (parent::_exists($id) && ilObject::_lookupType($id) === "mob") {
78 return true;
79 }
80 return false;
81 }
$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(), ilObjForumGUI\createThread(), assQuestion\delete(), ilForumDraftsHistory\deleteMobs(), ilForumPostDraft\deleteMobsOfDraft(), ilObjForumGUI\deleteMobsOfDraft(), ilForum\deletePost(), ilObjTest\deleteTest(), ILIAS\Test\ExportImport\Export\exportXHTMLMediaObjects(), ilQuestionpoolExport\exportXHTMLMediaObjects(), ilObjTest\exportXMLMediaObjects(), ilObjQuestionPool\exportXMLMediaObjects(), ilObjForumGUI\savePostObject(), ilForumXMLWriter\start(), and ilObjForumGUI\viewThreadObject().

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

◆ _getDirectory()

◆ _getMobsOfObject()

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

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

815 : array {
816 global $DIC;
817
818 $ilDB = $DIC->database();
819
820 $lstr = "";
821 if ($a_lang != "") {
822 $lstr = " AND usage_lang = " . $ilDB->quote($a_lang, "text");
823 }
824 $hist_str = "";
825 if ($a_usage_hist_nr > 0) {
826 $hist_str = " AND usage_hist_nr = " . $ilDB->quote($a_usage_hist_nr, "integer");
827 }
828
829 $q = "SELECT * FROM mob_usage WHERE " .
830 "usage_type = " . $ilDB->quote($a_type, "text") . " AND " .
831 "usage_id = " . $ilDB->quote($a_id, "integer") .
832 $lstr . $hist_str;
833 $mobs = array();
834 $mob_set = $ilDB->query($q);
835 while ($mob_rec = $ilDB->fetchAssoc($mob_set)) {
836 $mob_id = (int) $mob_rec['id'];
837 if (ilObject::_lookupType($mob_id) === "mob") {
838 $mobs[$mob_id] = $mob_id;
839 }
840 }
841
842 return $mobs;
843 }

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(), 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 384 of file class.ilObjMediaObject.php.

384 : string
385 {
386 return "mobs/mm_" . $a_mob_id;
387 }

◆ _getURL()

static ilObjMediaObject::_getURL ( int  $a_mob_id)
static

get directory for files of media object

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

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

Referenced by ilDclMobRecordRepresentation\getHTML(), and 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 401 of file class.ilObjMediaObject.php.

406 : string {
407 if ($a_purpose == "") {
408 $a_purpose = "Standard";
409 }
410 $location = ilMediaItem::_lookupLocationForMobId($a_mob_id, $a_purpose);
411 if (preg_match("/https?\:/i", $location)) {
412 return $location;
413 }
414
415 if ($a_url_encode) {
416 $location = rawurlencode($location);
417 }
418
419 $path = ($a_web)
420 ? ILIAS_HTTP_PATH
421 : ".";
422
423 return $path . "/public/data/" . CLIENT_ID . "/mobs/mm_" . $a_mob_id . "/" . $location;
424 }
$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 877 of file class.ilObjMediaObject.php.

883 : void {
884 global $DIC;
885
886 $ilDB = $DIC->database();
887
888 $q = "DELETE FROM mob_usage WHERE " .
889 " id = " . $ilDB->quote($a_mob_id, "integer") . " AND " .
890 " usage_type = " . $ilDB->quote($a_type, "text") . " AND " .
891 " usage_id = " . $ilDB->quote($a_id, "integer") . " AND " .
892 " usage_lang = " . $ilDB->quote($a_lang, "text") . " AND " .
893 " usage_hist_nr = " . $ilDB->quote($a_usage_hist_nr, "integer");
894 $ilDB->manipulate($q);
895
896 self::handleQuotaUpdate(new self($a_mob_id));
897 }

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(), ilDclMobRecordFieldModel\removeData(), ilObjForumGUI\savePostObject(), ilObjForumGUI\updateDraftObject(), and ilObjForumGUI\viewThreadObject().

+ Here is the caller graph for this function:

◆ _resizeImage()

static ilObjMediaObject::_resizeImage ( string  $a_file,
int  $a_width,
int  $a_height,
bool  $a_constrain_prop = false 
)
static

Resize image and return new image file ("_width_height" string appended)

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

1202 : string {
1203 global $DIC;
1204 $file_path = pathinfo($a_file);
1205 $location = substr($file_path["basename"], 0, strlen($file_path["basename"]) -
1206 strlen($file_path["extension"]) - 1) . "_" .
1207 $a_width . "_" .
1208 $a_height . "." . $file_path["extension"];
1209 $target_file = $file_path["dirname"] . "/" .
1210 $location;
1211
1212 $returned_target_file = $DIC->fileConverters()
1213 ->legacyImages()
1214 ->resizeToFixedSize(
1215 $a_file,
1216 $target_file,
1217 $a_width,
1218 $a_height,
1219 $a_constrain_prop
1220 );
1221
1222 if ($returned_target_file !== $target_file) {
1223 throw new RuntimeException('Could not resize image');
1224 }
1225
1226 return $location;
1227 }

Referenced by ilObjMediaObjectGUI\resizeImagesObject(), and ilObjMediaObjectGUI\savePropertiesObject().

+ 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 1340 of file class.ilObjMediaObject.php.

1345 // create dummy object in db (we need an id)
1346 $media_object = new ilObjMediaObject();
1347 $media_object->setTitle($name);
1348 $media_object->setDescription("");
1349 $media_object->create();
1350
1351 // determine and create mob directory, move uploaded file to directory
1352 $media_object->createDirectory();
1353 $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId());
1354
1355 $file = $mob_dir . "/" . $name;
1356 if ($upload) {
1357 $media_item = $media_object->addMediaItemFromLegacyUpload(
1358 "Standard",
1359 $tmp_name,
1360 $name,
1361 0,
1362 0,
1363 true,
1364 true
1365 );
1366 } else {
1367 $media_item = $media_object->addMediaItemFromLocalFile(
1368 "Standard",
1369 $tmp_name,
1370 $name
1371 );
1372 /*
1373 $media_item = new ilMediaItem();
1374 $media_object->addMediaItem($media_item);
1375 $media_item->setPurpose("Standard");
1376
1377 copy($tmp_name, $file);
1378 // get mime type
1379 $format = ilObjMediaObject::getMimeType($file);
1380 $media_item->setFormat($format);
1381 $location = $name;
1382 $media_item->setLocation($location);
1383 $media_item->setLocationType("LocalFile");*/
1384 }
1385
1386 // set real meta and object data
1387 $media_object->setTitle($name);
1388 $media_object->setDescription($media_item->getFormat());
1389 $media_item->setHAlign("Left");
1390
1391 /*
1392 self::renameExecutables($mob_dir);
1393 ilMediaSvgSanitizer::sanitizeDir($mob_dir); // see #20339
1394 */
1395
1396 $media_object->update();
1397
1398 return $media_object;
1399 }
static _getDirectory(int $a_mob_id)
Get absolute directory.

Referenced by ilForumXMLParser\handlerEndTag(), ilObjTest\retrieveMobsFromLegacyImports(), 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 848 of file class.ilObjMediaObject.php.

854 : void {
855 global $DIC;
856
857 $ilDB = $DIC->database();
858
859 $ilDB->replace(
860 "mob_usage",
861 array(
862 "id" => array("integer", $a_mob_id),
863 "usage_type" => array("text", $a_type),
864 "usage_id" => array("integer", $a_id),
865 "usage_lang" => array("text", $a_lang),
866 "usage_hist_nr" => array("integer", $a_usage_hist_nr)
867 ),
868 array()
869 );
870
871 self::handleQuotaUpdate(new self($a_mob_id));
872 }

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

+ Here is the caller graph for this function:

◆ addAdditionalFileFromUpload()

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

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

1553 : void {
1554 $this->manager->addFileFromUpload(
1555 $this->getId(),
1556 $result,
1557 $subdir
1558 );
1559 }

◆ addMediaItem()

ilObjMediaObject::addMediaItem ( ilMediaItem  $a_item)

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

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

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 1401 of file class.ilObjMediaObject.php.

1409 : \ilMediaItem {
1410 $media_item = new ilMediaItem();
1411 $this->addMediaItem($media_item);
1412 $media_item->setPurpose($purpose);
1413 //$location = self::fixFilename($_FILES[$upload_name]['name']);
1414 $location = $name;
1415 $this->manager->addFileFromLegacyUpload($this->getId(), $tmp_name);
1416
1417 // get mime type
1418 $format = self::getMimeType($location, true);
1419
1420 // resize standard images
1421 if ($resize_width > 0 && $resize_height > 0 && is_int(strpos($format, "image"))) {
1422 /*
1423 $location = ilObjMediaObject::_resizeImage(
1424 $file,
1425 $resize_width,
1426 $resize_height,
1427 $constrain_proportions
1428 );*/
1429 }
1430
1431 if ($deduce_size) {
1432 /*
1433 if (ilUtil::deducibleSize($format)) {
1434 $size = ilMediaImageUtil::getImageSize($file);
1435 $media_item->setWidth($size[0]);
1436 $media_item->setHeight($size[1]);
1437 }*/
1438 }
1439
1440 // set real meta and object data
1441 $media_item->setFormat($format);
1442 $media_item->setLocation($location);
1443 $media_item->setLocationType("LocalFile");
1444 if ($purpose === "Standard") {
1445 $this->generatePreviewPic(320, 240);
1446 }
1447 return $media_item;
1448 }
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 1476 of file class.ilObjMediaObject.php.

1480 : \ilMediaItem {
1481 $media_item = new ilMediaItem();
1482 $this->addMediaItem($media_item);
1483 $media_item->setPurpose($purpose);
1484 $location = $name;
1485 $this->manager->addFileFromLocal($this->getId(), $tmp_name, $name);
1486
1487 // get mime type
1488 $format = self::getMimeType($location, true);
1489
1490 // set real meta and object data
1491 $media_item->setFormat($format);
1492 $media_item->setLocation($location);
1493 $media_item->setLocationType("LocalFile");
1494 if ($purpose === "Standard") {
1495 $this->generatePreviewPic(320, 240);
1496 }
1497 return $media_item;
1498 }

◆ addMediaItemFromUpload()

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

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

1454 : \ilMediaItem {
1455 $media_item = new ilMediaItem();
1456 $this->addMediaItem($media_item);
1457 $media_item->setPurpose($purpose);
1458 $this->manager->addFileFromUpload($this->getId(), $result);
1459
1460 // get mime type
1461 $format = self::getMimeType($result->getName(), true);
1462
1463 // set real meta and object data
1464 $media_item->setFormat($format);
1465 $media_item->setLocation($result->getName());
1466 $media_item->setLocationType("LocalFile");
1467 if ($upload_hash !== "") {
1468 $media_item->setUploadHash($upload_hash);
1469 }
1470 if ($purpose === "Standard") {
1471 $this->generatePreviewPic(320, 240);
1472 }
1473 return $media_item;
1474 }

◆ beforeCreateMetaData()

ilObjMediaObject::beforeCreateMetaData ( )
protected

Reimplemented from ilObject.

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

143 : bool
144 {
145 $ilUser = $this->user;
146
147 $this->domain->metadata()->learningObjectMetadata()->derive()->fromBasicProperties(
148 $this->getTitle(),
149 $this->getLongDescription(),
150 $ilUser->getPref('language')
151 )->forObject(0, $this->getId(), $this->getType());
152
153 return false; // avoid parent to create md
154 }
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 175 of file class.ilObjMediaObject.php.

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

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 123 of file class.ilObjMediaObject.php.

123 : bool
124 {
125 switch ($a_element) {
126 case 'General':
127 // Update Title and description
128 $paths = $this->domain->metadata()->learningObjectMetadata()->paths();
129 $reader = $this->domain->metadata()->learningObjectMetadata()->read(
130 0,
131 $this->getId(),
132 $this->getType(),
133 $paths->custom()->withNextStep('general')->get()
134 );
135
136 ilObject::_writeTitle($this->getId(), $reader->firstData($paths->title())->value());
137 ilObject::_writeDescription($this->getId(), $reader->firstData($paths->descriptions())->value());
138 break;
139 }
140 return false; // prevent parent from creating ilMD
141 }
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 156 of file class.ilObjMediaObject.php.

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

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ clearMultiSrtDirectory()

ilObjMediaObject::clearMultiSrtDirectory ( )

Clear multi srt directory.

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

1791 : void
1792 {
1794 }
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 765 of file class.ilObjMediaObject.php.

765 : bool
766 {
768 }

◆ create()

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

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

289 : int {
290 $id = parent::create();
291
292 if (!$a_create_meta_data) {
293 $this->createMetaData();
294 }
295 $this->manager->create(
296 $id,
297 $this->getTitle(),
298 $from_mob_id
299 );
300
301 if ($a_save_media_items) {
302 $media_items = $this->getMediaItems();
303 for ($i = 0; $i < count($media_items); $i++) {
304 $item = $media_items[$i];
305 $item->setMobId($this->getId());
306 $item->setNr($i + 1);
307 $item->create();
308 }
309 }
310
312
313 $ilAppEventHandler = $this->app_event_handler;
314 $ilAppEventHandler->raise(
315 'components/ILIAS/MediaObjects',
316 'create',
317 array('object' => $this,
318 'obj_type' => 'mob',
319 'obj_id' => $this->getId())
320 );
321
322 return $id;
323 }
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 430 of file class.ilObjMediaObject.php.

430 : void
431 {
434 if (!is_dir($path)) {
435 throw new ilMediaObjectsException("Failed to create directory $path.");
436 }
437 }
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 83 of file class.ilObjMediaObject.php.

83 : bool
84 {
85 $mob_logger = ilLoggerFactory::getLogger('mob');
86 $mob_logger->debug("ilObjMediaObject: Delete called for media object ID '" . $this->getId() . "'.");
87
88 if (!($this->getId() > 0)) {
89 return false;
90 }
91
92 $usages = $this->getUsages();
93
94 $mob_logger->debug("ilObjMediaObject: ... Found " . count($usages) . " usages.");
95
96 if (count($usages) == 0) {
97 // delete meta data of mob
98 $this->deleteMetaData();
99
100 // delete media items
102
103 // this is just to make sure, there should be no entries left at
104 // this point as they depend on the usage
106
107 // delete object
108 parent::delete();
109
110 $mob_logger->debug("ilObjMediaObject: ... deleted.");
111 } else {
112 foreach ($usages as $u) {
113 $mob_logger->debug("ilObjMediaObject: ... usage type:" . $u["type"] .
114 ", id:" . $u["id"] .
115 ", lang:" . ($u["lang"] ?? "") .
116 ", hist_nr:" . ($u["hist_nr"] ?? "") . ".");
117 }
118 $mob_logger->debug("ilObjMediaObject: ... not deleted.");
119 }
120 return true;
121 }
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 1648 of file class.ilObjMediaObject.php.

1649 {
1650 $new_obj = new ilObjMediaObject();
1651 $new_obj->setTitle($this->getTitle());
1652 $new_obj->setDescription($this->getDescription());
1653
1654 // media items
1655 foreach ($this->getMediaItems() as $key => $val) {
1656 $new_obj->addMediaItem($val);
1657 }
1658
1659 $new_obj->create(
1660 false,
1661 true,
1662 $this->getId() // "from" id
1663 );
1664
1665 // meta data
1666 $this->domain->metadata()->learningObjectMetadata()
1667 ->derive()
1668 ->fromObject(0, $this->getId(), "mob")
1669 ->forObject(0, $new_obj->getId(), "mob");
1670
1671 return $new_obj;
1672 }

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 690 of file class.ilObjMediaObject.php.

692 : string {
693 return htmlspecialchars($a_value);
694 }

◆ 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 724 of file class.ilObjMediaObject.php.

726 : void {
727 $subdir = "il_" . IL_INST_ID . "_mob_" . $this->getId();
728 ilFileUtils::makeDir($a_target_dir . "/objects/" . $subdir);
729
730 $mobdir = ilFileUtils::getWebspaceDir() . "/mobs/mm_" . $this->getId();
731 ilFileUtils::rCopy($mobdir, $a_target_dir . "/objects/" . $subdir);
732 }
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 708 of file class.ilObjMediaObject.php.

711 : void {
712 $a_xml_writer->appendXML($this->getXML(IL_MODE_FULL, $a_inst));
713 }
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 1748 of file class.ilObjMediaObject.php.

1750 : string {
1751 $a_name = ilFileUtils::getASCIIFilename($a_name);
1752
1753 $rchars = array("`", "=", "$", "{", "}", "'", ";", " ", "(", ")");
1754 $a_name = str_replace($rchars, "_", $a_name);
1755 $a_name = str_replace("__", "_", $a_name);
1756 return $a_name;
1757 }
static getASCIIFilename(string $a_filename)

◆ getDataDirectory()

ilObjMediaObject::getDataDirectory ( )

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

1330 : string
1331 {
1332 return ilFileUtils::getWebspaceDir() . "/mobs/mm_" . $this->getId();
1333 }

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

+ Here is the call graph for this function:

◆ getExternalMetadata()

ilObjMediaObject::getExternalMetadata ( )

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

1834 : void
1835 {
1836 // see https://oembed.com/
1837 $st_item = $this->getMediaItem("Standard");
1838 if ($st_item->getLocationType() == "Reference") {
1839 if (ilExternalMediaAnalyzer::isVimeo($st_item->getLocation())) {
1840 $st_item->setFormat("video/vimeo");
1841 $par = ilExternalMediaAnalyzer::extractVimeoParameters($st_item->getLocation());
1843 $this->setTitle($meta["title"] ?? "");
1844 $description = str_replace("\n", "", $meta["description"] ?? "");
1845 $description = str_replace(["<br>", "<br />"], ["\n", "\n"], $description);
1846 $description = strip_tags($description);
1847 $this->setDescription($description);
1848 $st_item->setDuration((int) ($meta["duration"] ?? 0));
1849 $url = parse_url($meta["thumbnail_url"] ?? "");
1850 $file = basename($url["path"]);
1851 $ext = pathinfo($file, PATHINFO_EXTENSION);
1852 if ($ext == "") {
1853 $ext = "jpg";
1854 }
1855 $this->manager->addPreviewFromUrl(
1856 $this->getId(),
1857 $meta["thumbnail_url"],
1858 "/mob_vpreview." . $ext
1859 );
1860 }
1861 if (ilExternalMediaAnalyzer::isYoutube($st_item->getLocation())) {
1862 $st_item->setFormat("video/youtube");
1863 $par = ilExternalMediaAnalyzer::extractYoutubeParameters($st_item->getLocation());
1864 try {
1866 $this->setTitle($meta["title"] ?? "");
1867 $description = str_replace("\n", "", $meta["description"] ?? "");
1868 } catch (Exception $e) {
1869 $this->setTitle($st_item->getLocation());
1870 $description = "";
1871 }
1872 $description = str_replace(["<br>", "<br />"], ["\n", "\n"], $description);
1873 $description = strip_tags($description);
1874 $this->setDescription($description);
1875 $st_item->setDuration((int) ($meta["duration"] ?? 0));
1876 $thumbnail_url = $meta["thumbnail_url"] ?? "";
1877 $url = parse_url($thumbnail_url);
1878 if ($thumbnail_url !== "") {
1879 $mob_logger = ilLoggerFactory::getLogger('mob');
1880 $file = basename($url["path"]);
1881 $this->manager->addPreviewFromUrl(
1882 $this->getId(),
1883 $meta["thumbnail_url"],
1884 "/mob_vpreview." .
1885 pathinfo($file, PATHINFO_EXTENSION)
1886 );
1887 }
1888 }
1889 }
1890 }
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:68

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 439 of file class.ilObjMediaObject.php.

441 : array {
442 return $this->manager->getFilesOfPath(
443 $this->getId(),
444 $dir_path
445 );
446 }

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

+ Here is the caller graph for this function:

◆ getFullscreenSrc()

ilObjMediaObject::getFullscreenSrc ( )

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

1897 : string
1898 {
1899 return $this->getLocationSrc("Fullscreen");
1900 }
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 1610 of file class.ilObjMediaObject.php.

1612 : array {
1613 $linked = array();
1614
1615 // get linked media objects (map areas)
1616 $med_items = $this->getMediaItems();
1617
1618 foreach ($med_items as $med_item) {
1619 $int_links = ilMapArea::_getIntLinks($med_item->getId());
1620 foreach ($int_links as $k => $int_link) {
1621 if ($int_link["Type"] == "MediaObject") {
1622 $l_id = ilInternalLink::_extractObjIdOfTarget($int_link["Target"]);
1623 if (ilObject::_exists($l_id)) {
1624 if (!in_array($l_id, $linked) &&
1625 !in_array($l_id, $a_ignore)) {
1626 $linked[] = $l_id;
1627 }
1628 }
1629 }
1630 }
1631 }
1632 //var_dump($linked);
1633 return $linked;
1634 }
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 1902 of file class.ilObjMediaObject.php.

1902 : string
1903 {
1904 return (string) $this->getMediaItem($purpose)?->getLocationSrc();
1905 }

◆ getMediaItem()

ilObjMediaObject::getMediaItem ( string  $a_purpose)

get item for media purpose

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

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

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 191 of file class.ilObjMediaObject.php.

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

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 1232 of file class.ilObjMediaObject.php.

1235 : string {
1236 $mime = MimeType::lookupMimeType($a_file, MimeType::APPLICATION__OCTET_STREAM, $a_external);
1237 return $mime;
1238 }

Referenced by ilKprimChoiceWizardInputGUI\checkUploads(), ilDclMobRecordFieldModel\parseValue(), ilNewsTimelineItemGUI\renderMedia(), ilNewsTimelineItemGUI\renderMediaModal(), ilObjMediaObjectGUI\savePropertiesObject(), ilMediaCreationGUI\saveUrl(), assMultipleChoice\setImageFile(), ilNewsForContextBlockGUI\showNews(), and ilPCInteractiveImageGUI\update().

+ Here is the caller graph for this function:

◆ getMultiSrtFiles()

ilObjMediaObject::getMultiSrtFiles ( )

Get all srt files of srt multi upload.

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

1799 : array
1800 {
1801 $items = array();
1802
1803 $lang_codes = $this->domain->metadata()->getLOMLanguageCodes();
1804
1805 $dir = $this->getMultiSrtUploadDir();
1806 $files = ilFileUtils::getDir($dir);
1807 foreach ($files as $k => $i) {
1808 // check directory
1809 if ($i["type"] == "file" && !in_array($k, array(".", ".."))) {
1810 if (pathinfo($k, PATHINFO_EXTENSION) == "vtt") {
1811 $lang = "";
1812 if (substr($k, strlen($k) - 7, 1) == "_") {
1813 $lang = substr($k, strlen($k) - 6, 2);
1814 if (!in_array($lang, $lang_codes)) {
1815 $lang = "";
1816 }
1817 }
1818 $items[] = array("filename" => $k, "lang" => $lang);
1819 }
1820 }
1821 }
1822 return $items;
1823 }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
$lang
Definition: xapiexit.php:25

References $lang, and ilFileUtils\getDir().

+ Here is the call graph for this function:

◆ getMultiSrtUploadDir()

ilObjMediaObject::getMultiSrtUploadDir ( )

Get directory for multi srt upload.

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

1763 : string
1764 {
1765 return ilObjMediaObject::_getDirectory($this->getId()) . "/srt/tmp";
1766 }

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

+ Here is the call graph for this function:

◆ getOriginID()

ilObjMediaObject::getOriginID ( )

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

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

◆ 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 1004 of file class.ilObjMediaObject.php.

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

1573 : array
1574 {
1575 return $this->manager->getSrtFiles($this->getId(), $vtt_only);
1576 }

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 1892 of file class.ilObjMediaObject.php.

1892 : string
1893 {
1894 return $this->getLocationSrc("Standard");
1895 }

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 902 of file class.ilObjMediaObject.php.

904 : array {
905 return self::lookupUsages($this->getId(), $a_include_history);
906 }
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 1714 of file class.ilObjMediaObject.php.

1716 : string {
1717
1718 if (!$a_filename_only) {
1719 $src = $this->thumbs->getPreviewSrc($this->getId());
1720 if ($src !== "") {
1721 return $src;
1722 }
1723 }
1724
1725 $dir = ilObjMediaObject::_getDirectory($this->getId());
1726 $ppics = array("mob_vpreview.jpg",
1727 "mob_vpreview.jpeg",
1728 "mob_vpreview.png");
1729 $med = $this->getMediaItem("Standard");
1730 if ($med && $med->getFormat() === "image/svg+xml" && $med->getLocationType() === "LocalFile") {
1731 $ppics[] = $med->getLocation();
1732 }
1733 foreach ($ppics as $p) {
1734 if (is_file($dir . "/" . $p)) {
1735 if ($a_filename_only) {
1736 return $p;
1737 } else {
1738 return $dir . "/" . $p;
1739 }
1740 }
1741 }
1742 return "";
1743 }

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 456 of file class.ilObjMediaObject.php.

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

702 : string {
703 $a_str = str_replace("&amp;", "&", $a_str);
704 $a_str = str_replace("&", "&amp;", $a_str);
705 return $a_str;
706 }

◆ handleQuotaUpdate()

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

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

369 : void {
370 }

◆ hasFullscreenItem()

ilObjMediaObject::hasFullscreenItem ( )

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

235 : bool
236 {
237 return $this->hasPurposeItem("Fullscreen");
238 }
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 243 of file class.ilObjMediaObject.php.

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

◆ isAlias()

ilObjMediaObject::isAlias ( )

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

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

◆ isTypeAllowed()

static ilObjMediaObject::isTypeAllowed ( string  $a_type)
static

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

1638 : bool {
1639 global $DIC;
1640 return in_array($a_type, iterator_to_array(
1641 $DIC->mediaObjects()->internal()->domain()->mediaType()->getAllowedSuffixes()
1642 ), true);
1643 }

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 913 of file class.ilObjMediaObject.php.

916 : array {
917 global $DIC;
918
919 $ilDB = $DIC->database();
920
921 $hist_str = "";
922 if ($a_include_history) {
923 $hist_str = ", usage_hist_nr";
924 }
925
926 // get usages in pages
927 $q = "SELECT DISTINCT usage_type, usage_id, usage_lang" . $hist_str . " FROM mob_usage WHERE id = " .
928 $ilDB->quote($a_id, "integer");
929
930 if (!$a_include_history) {
931 $q .= " AND usage_hist_nr = " . $ilDB->quote(0, "integer");
932 }
933
934 $us_set = $ilDB->query($q);
935 $ret = array();
936 while ($us_rec = $ilDB->fetchAssoc($us_set)) {
937 $ut = "";
938 $ct = 0;
939 if (is_int(strpos($us_rec["usage_type"], ":"))) {
940 $us_arr = explode(":", $us_rec["usage_type"]);
941 $ut = $us_arr[1];
942 $ct = $us_arr[0];
943 }
944
945 // check whether page exists
946 $skip = false;
947 if ($ut == "pg") {
948 if (!ilPageObject::_exists($ct, $us_rec["usage_id"])) {
949 $skip = true;
950 }
951 }
952
953 if (!$skip) {
954 $ret[] = array(
955 "type" => $us_rec["usage_type"],
956 "id" => $us_rec["usage_id"],
957 "lang" => $us_rec["usage_lang"],
958 "hist_nr" => ($us_rec["usage_hist_nr"] ?? 0)
959 );
960 }
961 }
962
963 // get usages in media pools
964 $q = "SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.foreign_id = " .
965 $ilDB->quote($a_id, "integer") . " AND mep_item.type = " . $ilDB->quote("mob", "text");
966 $us_set = $ilDB->query($q);
967 while ($us_rec = $ilDB->fetchAssoc($us_set)) {
968 $ret[] = array("type" => "mep",
969 "id" => $us_rec["mep_id"]);
970 }
971
972 // get usages in news items (media casts)
973 $news_usages = ilNewsItem::_lookupMediaObjectUsages($a_id);
974 foreach ($news_usages as $nu) {
975 $ret[] = $nu;
976 }
977
978
979 // get usages in map areas
980 $q = "SELECT DISTINCT mob_id FROM media_item it, map_area area " .
981 " WHERE area.item_id = it.id " .
982 " AND area.link_type = " . $ilDB->quote("int", "text") . " " .
983 " AND area.target = " . $ilDB->quote("il__mob_" . $a_id, "text");
984 $us_set = $ilDB->query($q);
985 while ($us_rec = $ilDB->fetchAssoc($us_set)) {
986 $ret[] = array("type" => "map",
987 "id" => $us_rec["mob_id"]);
988 }
989
990 // get usages in personal clipboards
991 $users = ilObjUser::_getUsersForClipboadObject("mob", $a_id);
992 foreach ($users as $user) {
993 $ret[] = array("type" => "clip",
994 "id" => $user);
995 }
996
997 return $ret;
998 }
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 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 1581 of file class.ilObjMediaObject.php.

1584 : void {
1585 $format = self::getMimeType($source, true);
1586 $this->manager->generatePreview(
1587 $this->getId(),
1588 $source,
1589 true,
1590 $format,
1591 1,
1592 $thumbname
1593 );
1594 }

◆ modifyExportIdentifier()

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

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

738 : string {
739 if ($a_tag == "Identifier" && $a_param == "Entry") {
740 $a_value = ilUtil::insertInstIntoID($a_value);
741 }
742
743 return $a_value;
744 }
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 256 of file class.ilObjMediaObject.php.

256 : void
257 {
258 parent::read();
260 }
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 1596 of file class.ilObjMediaObject.php.

1598 : void {
1599 $this->manager->removeLocation(
1600 $this->getId(),
1601 $a_file
1602 );
1603 }

◆ removeAllMediaItems()

ilObjMediaObject::removeAllMediaItems ( )

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

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

◆ removeMediaItem()

ilObjMediaObject::removeMediaItem ( string  $a_purpose)

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

212 : void {
213 foreach ($this->media_items as $key => $media_item) {
214 if ($media_item->getPurpose() == $a_purpose) {
215 unset($this->media_items[$key]);
216 }
217 }
218 // update numbers and keys
219 $i = 1;
220 $media_items = array();
221 foreach ($this->media_items as $media_item) {
222 $media_items [$i] = $media_item;
223 $media_item->setMobId($this->getId());
224 $media_item->setNr($i);
225 $i++;
226 }
227 $this->media_items = $media_items;
228 }

Referenced by ilObjMediaCastGUI\updateCastItemObject().

+ Here is the caller graph for this function:

◆ renameExecutables()

static ilObjMediaObject::renameExecutables ( string  $a_dir)
static

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

1827 : void {
1829 if (!self::isTypeAllowed("html")) {
1830 ilFileUtils::rRenameSuffix($a_dir, "html", "sec"); // see #20187
1831 }
1832 }
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 1500 of file class.ilObjMediaObject.php.

1504 : \ilMediaItem {
1505 $media_item = $this->getMediaItem($purpose);
1506 $this->manager->removeLocation($this->getId(), $media_item->getLocation());
1507 $this->manager->addFileFromUpload($this->getId(), $result);
1508
1509 // get mime type
1510 $format = self::getMimeType($result->getName(), true);
1511
1512 // set real meta and object data
1513 $media_item->setFormat($format);
1514 $media_item->setLocation($result->getName());
1515 $media_item->setLocationType("LocalFile");
1516 if ($upload_hash !== "") {
1517 $media_item->setUploadHash($upload_hash);
1518 }
1519 if ($purpose === "Standard") {
1520 $this->generatePreviewPic(320, 240);
1521 }
1522 return $media_item;
1523 }

◆ setAlias()

ilObjMediaObject::setAlias ( bool  $a_is_alias)

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

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

◆ 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 755 of file class.ilObjMediaObject.php.

757 : void {
758 $this->contains_int_link = $a_contains_link;
759 }

◆ setOriginID()

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

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

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

◆ update()

ilObjMediaObject::update ( bool  $a_upload = false)

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

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

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 1528 of file class.ilObjMediaObject.php.

1533 : void {
1534 $a_subdir = str_replace("..", "", $a_subdir);
1535 if ($a_mode == "rename") {
1536 $this->manager->addFileFromLocal(
1537 $this->getId(),
1538 $tmp_name,
1539 $a_subdir . "/" . $a_name
1540 );
1541 } else {
1542 $this->manager->addFileFromLegacyUpload(
1543 $this->getId(),
1544 $tmp_name,
1545 $a_subdir . "/" . $a_name
1546 );
1547 }
1548 }

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 1772 of file class.ilObjMediaObject.php.

1774 : void {
1775 $lng = $this->lng;
1776
1777 if (!is_file($a_file["tmp_name"])) {
1778 throw new ilMediaObjectsException($lng->txt("mob_file_could_not_be_uploaded"));
1779 }
1780
1781 $dir = $this->getMultiSrtUploadDir();
1782 ilFileUtils::delDir($dir, true);
1784 ilFileUtils::moveUploadedFile($a_file["tmp_name"], "multi_vtt.zip", $dir . "/" . "multi_vtt.zip");
1785 $this->domain->resources()->zip()->unzipFile($dir . "/multi_vtt.zip");
1786 }
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 1561 of file class.ilObjMediaObject.php.

1565 : bool {
1566 if (is_file($a_tmp_name) && $a_language != "") {
1567 $this->uploadAdditionalFile("subtitle_" . $a_language . ".vtt", $a_tmp_name, "srt", $a_mode);
1568 return true;
1569 }
1570 return false;
1571 }
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 1674 of file class.ilObjMediaObject.php.

1676 : void {
1677 // remove old one
1678 if ($this->getVideoPreviewPic(true) != "") {
1679 $this->removeAdditionalFile($this->getVideoPreviewPic(true));
1680 }
1681
1682 $pi = pathinfo($a_prevpic["name"]);
1683 $ext = $pi["extension"];
1684 if (in_array($ext, array("jpg", "jpeg", "png"))) {
1685 $this->uploadAdditionalFile("mob_vpreview." . $ext, $a_prevpic["tmp_name"]);
1686 }
1687 }
removeAdditionalFile(string $a_file)

Field Documentation

◆ $contains_int_link

bool ilObjMediaObject::$contains_int_link

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

◆ $domain

InternalDomainService ilObjMediaObject::$domain
protected

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

◆ $image_converter

LegacyImages ilObjMediaObject::$image_converter
private

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

◆ $is_alias

bool ilObjMediaObject::$is_alias

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

◆ $manager

MediaObjectManager ilObjMediaObject::$manager
protected

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

◆ $media_items

array ilObjMediaObject::$media_items

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

◆ $origin_id

string ilObjMediaObject::$origin_id

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

◆ $thumbs

ThumbsManager ilObjMediaObject::$thumbs
protected

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

◆ $user

ilObjUser ilObjMediaObject::$user
protected

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

◆ DEFAULT_PREVIEW_SIZE

const ilObjMediaObject::DEFAULT_PREVIEW_SIZE = 80

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