ILIAS  release_8 Revision v8.24
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)
 
 update (bool $a_upload=false)
 
 createDirectory ()
 Create file directory of media object. More...
 
 getFilesOfDirectory (string $a_subdir="")
 Get files of directory. More...
 
 getXML (int $a_mode=IL_MODE_FULL, int $a_inst=0, bool $a_sign_locals=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 ()
 
 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...
 
 uploadSrtFile (string $a_tmp_name, string $a_language, string $a_mode="move_uploaded")
 
 getSrtFiles ()
 
 makeThumbnail (string $a_file, string $a_thumbname, string $a_format="png", int $a_size=80)
 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 ()
 
- Public Member Functions inherited from ilObject
 __construct (int $id=0, bool $reference=true)
 
 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 $desc)
 
 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)
 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 _getThumbnailDirectory (int $a_mob_id, string $a_mode="filesystem")
 get directory for files of media object More...
 
static _lookupStandardItemPath (int $a_mob_id, bool $a_url_encode=false, bool $a_web=true)
 Get path for standard item. 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 _createThumbnailDirectory (int $a_obj_id)
 Create thumbnail directory. 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)
 Create new media object and update page in db and return new media object. More...
 
static getThumbnailPath (int $a_mob_id, string $a_thumbname)
 
static getRestrictedFileTypes ()
 Get restricted file types (this is for the input form, this list will be empty, if "allowed list" is empty) More...
 
static getForbiddenFileTypes ()
 Get forbidden file types. More...
 
static getAllowedFileTypes ()
 Get allowed file types. More...
 
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 _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

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...
 
- 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

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
 
int $id
 
bool $referenced
 
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 = ""
 
bool $offline = false
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ilObjMediaObject::__construct ( int  $a_id = 0)

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

38 {
39 global $DIC;
40
41 $this->user = $DIC->user();
42 $this->app_event_handler = $DIC["ilAppEventHandler"];
43 $this->lng = $DIC->language();
44 $this->is_alias = false;
45 $this->media_items = array();
46 $this->contains_int_link = false;
47 $this->type = "mob";
48 parent::__construct($a_id, false);
49 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ _createThumbnailDirectory()

static ilObjMediaObject::_createThumbnailDirectory ( int  $a_obj_id)
static

Create thumbnail directory.

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

453 : void {
455 ilFileUtils::createDirectory(ilFileUtils::getWebspaceDir() . "/thumbs/mm_" . $a_obj_id);
456 }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static createDirectory(string $a_dir, int $a_mod=0755)
create directory

Referenced by ilMediaObjectDataSet\importRecord().

+ Here is the caller graph for this function:

◆ _deleteAllUsages()

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

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

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

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

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

References ilMediaImageUtil\getImageSize().

Referenced by ilObjMediaPoolGUI\createMediaFromUploadDir(), ilDclMobRecordFieldModel\parseValue(), and 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 51 of file class.ilObjMediaObject.php.

55 : bool {
56 if (is_int(strpos($id, "_"))) {
58 }
59
60 if (parent::_exists($id) && ilObject::_lookupType($id) === "mob") {
61 return true;
62 }
63 return false;
64 }
static _lookupType(int $id, bool $reference=false)

References ilObject\$id, and ilInternalLink\_extractObjIdOfTarget().

Referenced by ilInternalLink\_exists(), ilRTE\_getMediaObjects(), ilObjTest\addQTIMaterial(), assQuestion\addQTIMaterial(), ilObjForumGUI\createThread(), assQuestion\delete(), ilForumDraftsHistory\deleteMobs(), ilForumPostDraft\deleteMobsOfDraft(), ilObjForumGUI\deleteMobsOfDraft(), ilForum\deletePost(), ilObjTest\deleteTest(), ilTestExport\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 814 of file class.ilObjMediaObject.php.

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

References $ilDB.

Referenced by ilRTE\_cleanupMediaObjectUsage(), ilObjTest\addQTIMaterial(), assQuestion\addQTIMaterial(), ilPCMediaObject\afterPageUpdate(), assQuestion\copyXHTMLMediaObjectsOfQuestion(), ilObjForumGUI\createThread(), ilPageObject\delete(), SurveyQuestion\delete(), assQuestion\delete(), ilForumDraftsHistory\deleteMobs(), ilForumPostDraft\deleteMobsOfDraft(), ilObjForumGUI\deleteMobsOfDraft(), ilForum\deletePost(), ilObjSurvey\deleteSurveyRecord(), ilObjTest\deleteTest(), ilForumAutoSaveAsyncDraftAction\executeAndGetResponseObject(), ilTestExport\exportXHTMLMediaObjects(), ilQuestionpoolExport\exportXHTMLMediaObjects(), ilPageObject\getLastUpdateOfIncludedElements(), ilLMMultiSrt\getMobIds(), ilMepMultiSrt\getMobIds(), ilSoapUtils\getMobsOfObject(), ilCOPageExporter\getXmlExportHeadDependencies(), ilPCMediaObject\modifyPageContentPostXsl(), ilObjForumGUI\publishDraftObject(), ilObjForumGUI\savePostObject(), ilForumXMLWriter\start(), assQuestion\syncXHTMLMediaObjectsOfQuestion(), assClozeTest\toJSON(), assErrorText\toJSON(), assImagemapQuestion\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 372 of file class.ilObjMediaObject.php.

372 : string
373 {
374 return "mobs/mm_" . $a_mob_id;
375 }

◆ _getThumbnailDirectory()

static ilObjMediaObject::_getThumbnailDirectory ( int  $a_mob_id,
string  $a_mode = "filesystem" 
)
static

get directory for files of media object

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

392 : string {
393 return ilFileUtils::getWebspaceDir($a_mode) . "/thumbs/mm_" . $a_mob_id;
394 }

Referenced by delete(), and duplicate().

+ Here is the caller graph for this function:

◆ _getURL()

static ilObjMediaObject::_getURL ( int  $a_mob_id)
static

get directory for files of media object

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

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

Referenced by ilMediaCastTableGUI\fillRow(), McstImageGalleryGUI\getHTML(), ilDclMobRecordRepresentation\getHTML(), ilNewsTimelineItemGUI\getMediaPath(), ilNewsForContextBlockGUI\getMediaPath(), and ILIAS\MediaCast\Video\VideoSequence\init().

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

415 : string {
416 if ($a_purpose == "") {
417 $a_purpose = "Standard";
418 }
419 $location = ilMediaItem::_lookupLocationForMobId($a_mob_id, $a_purpose);
420 if (preg_match("/https?\:/i", $location)) {
421 return $location;
422 }
423
424 if ($a_url_encode) {
425 $location = rawurlencode($location);
426 }
427
428 $path = ($a_web)
429 ? ILIAS_HTTP_PATH
430 : ".";
431
432 return $path . "/data/" . CLIENT_ID . "/mobs/mm_" . $a_mob_id . "/" . $location;
433 }
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
static _lookupLocationForMobId(int $a_mob_id, string $a_purpose)
const CLIENT_ID
Definition: constants.php:41
$path
Definition: ltiservices.php:32

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

+ Here is the caller graph for this function:

◆ _lookupStandardItemPath()

static ilObjMediaObject::_lookupStandardItemPath ( int  $a_mob_id,
bool  $a_url_encode = false,
bool  $a_web = true 
)
static

Get path for standard item.

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

403 : string {
404 return ilObjMediaObject::_lookupItemPath($a_mob_id, $a_url_encode, $a_web, "Standard");
405 }
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.

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

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

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:

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

1216 : string {
1217 $file_path = pathinfo($a_file);
1218 $location = substr($file_path["basename"], 0, strlen($file_path["basename"]) -
1219 strlen($file_path["extension"]) - 1) . "_" .
1220 $a_width . "_" .
1221 $a_height . "." . $file_path["extension"];
1222 $target_file = $file_path["dirname"] . "/" .
1223 $location;
1225 $a_file,
1226 $target_file,
1227 $a_width,
1228 $a_height,
1229 $a_constrain_prop
1230 );
1231
1232 return $location;
1233 }
static resizeImage(string $a_from, string $a_to, int $a_width, int $a_height, bool $a_constrain_prop=false)
resize image

Referenced by ilDclMobRecordFieldModel\parseValue(), 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

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

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

1349 // create dummy object in db (we need an id)
1350 $media_object = new ilObjMediaObject();
1351 $media_object->setTitle($name);
1352 $media_object->setDescription("");
1353 $media_object->create();
1354
1355 // determine and create mob directory, move uploaded file to directory
1356 $media_object->createDirectory();
1357 $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId());
1358
1359 $media_item = new ilMediaItem();
1360 $media_object->addMediaItem($media_item);
1361 $media_item->setPurpose("Standard");
1362
1363 $file = $mob_dir . "/" . $name;
1364 if ($upload) {
1365 ilFileUtils::moveUploadedFile($tmp_name, $name, $file);
1366 } else {
1367 copy($tmp_name, $file);
1368 }
1369 // get mime type
1371 $location = $name;
1372 // set real meta and object data
1373 $media_item->setFormat($format);
1374 $media_item->setLocation($location);
1375 $media_item->setLocationType("LocalFile");
1376 $media_object->setTitle($name);
1377 $media_object->setDescription($format);
1378
1380 $size = ilMediaImageUtil::getImageSize($file);
1381 $media_item->setWidth($size[0]);
1382 $media_item->setHeight($size[1]);
1383 }
1384 $media_item->setHAlign("Left");
1385
1386 self::renameExecutables($mob_dir);
1387 ilMediaSvgSanitizer::sanitizeDir($mob_dir); // see #20339
1388
1389 $media_object->update();
1390
1391 return $media_object;
1392 }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sanitizeDir(string $a_path)
Sanitize directory recursively.
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
static renameExecutables(string $a_dir)
static _getDirectory(int $a_mob_id)
Get absolute directory.
if($format !==null) $name
Definition: metadata.php:247
$format
Definition: metadata.php:235

Referenced by assClozeTestImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assFormulaQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assKprimChoiceImport\fromXML(), assLongMenuImport\fromXML(), assMatchingQuestionImport\fromXML(), assMultipleChoiceImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), assTextSubsetImport\fromXML(), ilObjTest\fromXML(), 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 852 of file class.ilObjMediaObject.php.

858 : void {
859 global $DIC;
860
861 $ilDB = $DIC->database();
863 $log->debug("save usage mob: " . $a_mob_id . ", type " . $a_type . " id: " . $a_id . ", hist: " . $a_usage_hist_nr . ", lang: " . $a_lang);
864 $ilDB->replace(
865 "mob_usage",
866 array(
867 "id" => array("integer", $a_mob_id),
868 "usage_type" => array("text", $a_type),
869 "usage_id" => array("integer", $a_id),
870 "usage_lang" => array("text", $a_lang),
871 "usage_hist_nr" => array("integer", $a_usage_hist_nr)
872 ),
873 array()
874 );
875
876 self::handleQuotaUpdate(new self($a_mob_id));
877 }
static getLogger(string $a_component_id)
Get component logger.
debug(string $a_message, array $a_context=array())
ilLogger $log

Referenced by ilRTE\_cleanupMediaObjectUsage(), SurveyQuestion\copyXHTMLMediaObjectsOfQuestion(), assQuestion\copyXHTMLMediaObjectsOfQuestion(), ilObjForumGUI\createThread(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assFormulaQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assKprimChoiceImport\fromXML(), assLongMenuImport\fromXML(), assMatchingQuestionImport\fromXML(), assMultipleChoiceImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), assTextSubsetImport\fromXML(), ilObjTest\fromXML(), ilForumAutoSaveAsyncDraftAction\handleMedia(), ilForumXMLParser\handlerEndTag(), ilDclMobRecordFieldModel\parseValue(), ilObjForumGUI\publishDraftObject(), ilForumUtil\saveMediaObjects(), assQuestion\syncXHTMLMediaObjectsOfQuestion(), and ilObjForumGUI\updateDraftObject().

+ Here is the caller graph for this function:

◆ addMediaItem()

ilObjMediaObject::addMediaItem ( ilMediaItem  $a_item)

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

183 : void {
184 $this->media_items[] = $a_item;
185 }

Referenced by ilMediaItem\_getMediaItemsOfMOb().

+ Here is the caller graph for this function:

◆ beforeCreateMetaData()

ilObjMediaObject::beforeCreateMetaData ( )
protected

Reimplemented from ilObject.

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

138 : bool
139 {
141
142 $md_creator = new ilMDCreator(0, $this->getId(), $this->getType());
143 $md_creator->setTitle($this->getTitle());
144 $md_creator->setTitleLanguage($ilUser->getPref('language'));
145 $md_creator->setDescription($this->getDescription());
146 $md_creator->setDescriptionLanguage($ilUser->getPref('language'));
147 $md_creator->setKeywordLanguage($ilUser->getPref('language'));
148 $md_creator->setLanguage($ilUser->getPref('language'));
149 $md_creator->create();
150
151 return false; // avoid parent to create md
152 }
$ilUser
Definition: imgupload.php:34

References $ilUser, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ beforeDeleteMetaData()

ilObjMediaObject::beforeDeleteMetaData ( )
protected

Reimplemented from ilObject.

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

171 : bool
172 {
173 // Delete meta data
174 $md = new ilMD(0, $this->getId(), $this->getType());
175 $md->deleteAll();
176
177 return false;
178 }

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

112 : bool
113 {
114 switch ($a_element) {
115 case 'General':
116
117 // Update Title and description
118 $md = new ilMD(0, $this->getId(), $this->getType());
119 $md_gen = $md->getGeneral();
120
121 if (is_object($md_gen)) {
122 ilObject::_writeTitle($this->getId(), $md_gen->getTitle());
123 $this->setTitle($md_gen->getTitle());
124
125 foreach ($md_gen->getDescriptionIds() as $id) {
126 $md_des = $md_gen->getDescription($id);
127 ilObject::_writeDescription($this->getId(), $md_des->getDescription());
128 $this->setDescription($md_des->getDescription());
129 break;
130 }
131 }
132
133 break;
134 }
135 return false; // prevent parent from creating ilMD
136 }
static _writeDescription(int $obj_id, string $desc)
write description to db (static)
static _writeTitle(int $obj_id, string $title)
write title to db (static)
setTitle(string $title)
setDescription(string $desc)

References $id, 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 154 of file class.ilObjMediaObject.php.

154 : bool
155 {
156 $md = new ilMD(0, $this->getId(), $this->getType());
157 $md_gen = $md->getGeneral();
158 $md_gen->setTitle($this->getTitle());
159
160 // sets first description (maybe not appropriate)
161 $md_des_ids = $md_gen->getDescriptionIds();
162 if (count($md_des_ids) > 0) {
163 $md_des = $md_gen->getDescription($md_des_ids[0]);
164 $md_des->setDescription($this->getDescription());
165 $md_des->update();
166 }
167 $md_gen->update();
168 return false;
169 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ clearMultiSrtDirectory()

ilObjMediaObject::clearMultiSrtDirectory ( )

Clear multi srt directory.

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

1783 : void
1784 {
1786 }
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 769 of file class.ilObjMediaObject.php.

769 : bool
770 {
772 }

◆ create()

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

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

281 : int
282 {
283 $id = parent::create();
284
285 if (!$a_create_meta_data) {
286 $this->createMetaData();
287 }
288
289 if ($a_save_media_items) {
290 $media_items = $this->getMediaItems();
291 for ($i = 0; $i < count($media_items); $i++) {
292 $item = $media_items[$i];
293 $item->setMobId($this->getId());
294 $item->setNr($i + 1);
295 $item->create();
296 }
297 }
298
300
301 $ilAppEventHandler = $this->app_event_handler;
302 $ilAppEventHandler->raise(
303 'Services/MediaObjects',
304 'create',
305 array('object' => $this,
306 'obj_type' => 'mob',
307 'obj_id' => $this->getId())
308 );
309
310 return $id;
311 }
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.
ilAppEventHandler $app_event_handler
$i
Definition: metadata.php:41

References $i, $id, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ createDirectory()

ilObjMediaObject::createDirectory ( )

Create file directory of media object.

Exceptions
ilMediaObjectsException

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

439 : void
440 {
443 if (!is_dir($path)) {
444 throw new ilMediaObjectsException("Failed to create directory $path.");
445 }
446 }
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 66 of file class.ilObjMediaObject.php.

66 : bool
67 {
68 $mob_logger = ilLoggerFactory::getLogger('mob');
69 $mob_logger->debug("ilObjMediaObject: Delete called for media object ID '" . $this->getId() . "'.");
70
71 if (!($this->getId() > 0)) {
72 return false;
73 }
74
75 $usages = $this->getUsages();
76
77 $mob_logger->debug("ilObjMediaObject: ... Found " . count($usages) . " usages.");
78
79 if (count($usages) == 0) {
80 // remove directory
82
83 // remove thumbnail directory
85
86 // delete meta data of mob
87 $this->deleteMetaData();
88
89 // delete media items
91
92 // this is just to make sure, there should be no entries left at
93 // this point as they depend on the usage
95
96 // delete object
97 parent::delete();
98
99 $mob_logger->debug("ilObjMediaObject: ... deleted.");
100 } else {
101 foreach ($usages as $u) {
102 $mob_logger->debug("ilObjMediaObject: ... usage type:" . $u["type"] .
103 ", id:" . $u["id"] .
104 ", lang:" . ($u["lang"] ?? "") .
105 ", hist_nr:" . ($u["hist_nr"] ?? "") . ".");
106 }
107 $mob_logger->debug("ilObjMediaObject: ... not deleted.");
108 }
109 return true;
110 }
static deleteAllItemsOfMob(int $a_mob_id)
getUsages(bool $a_include_history=true)
get all usages of current media object
static _getThumbnailDirectory(int $a_mob_id, string $a_mode="filesystem")
get directory for files of media object

References _getDirectory(), _getThumbnailDirectory(), ilFileUtils\delDir(), 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 1596 of file class.ilObjMediaObject.php.

1597 {
1598 $new_obj = new ilObjMediaObject();
1599 $new_obj->setTitle($this->getTitle());
1600 $new_obj->setDescription($this->getDescription());
1601
1602 // media items
1603 foreach ($this->getMediaItems() as $key => $val) {
1604 $new_obj->addMediaItem($val);
1605 }
1606
1607 $new_obj->create(false, true);
1608
1609 // files
1610 $new_obj->createDirectory();
1611 self::_createThumbnailDirectory($new_obj->getId());
1614 ilObjMediaObject::_getDirectory($new_obj->getId())
1615 );
1619 );
1620
1621 // meta data
1622 $md = new ilMD(0, $this->getId(), "mob");
1623 $new_md = $md->cloneMD(0, $new_obj->getId(), "mob");
1624
1625 return $new_obj;
1626 }
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static _createThumbnailDirectory(int $a_obj_id)
Create thumbnail directory.
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, _getDirectory(), _getThumbnailDirectory(), ILIAS\Survey\Mode\getId(), and ilFileUtils\rCopy().

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

696 : string {
697 return htmlspecialchars($a_value);
698 }

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

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

◆ exportXML()

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

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

715 : void {
716 $a_xml_writer->appendXML($this->getXML(IL_MODE_FULL, $a_inst));
717 }
const IL_MODE_FULL
getXML(int $a_mode=IL_MODE_FULL, int $a_inst=0, bool $a_sign_locals=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 1740 of file class.ilObjMediaObject.php.

1742 : string {
1743 $a_name = ilFileUtils::getASCIIFilename($a_name);
1744
1745 $rchars = array("`", "=", "$", "{", "}", "'", ";", " ", "(", ")");
1746 $a_name = str_replace($rchars, "_", $a_name);
1747 $a_name = str_replace("__", "_", $a_name);
1748 return $a_name;
1749 }
static getASCIIFilename(string $a_filename)

Referenced by ilObjMediaObjectGUI\savePropertiesObject().

+ Here is the caller graph for this function:

◆ getAllowedFileTypes()

static ilObjMediaObject::getAllowedFileTypes ( )
static

Get allowed file types.

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

1567 : array
1568 {
1569 $mset = new ilSetting("mobs");
1570 if (trim((string) $mset->get("restricted_file_types")) === "") {
1571 return array();
1572 }
1573 return array_map(
1574 function ($v) {
1575 return strtolower(trim($v));
1576 },
1577 explode(",", $mset->get("restricted_file_types"))
1578 );
1579 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDataDirectory()

ilObjMediaObject::getDataDirectory ( )

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

1336 : string
1337 {
1338 return ilFileUtils::getWebspaceDir() . "/mobs/mm_" . $this->getId();
1339 }

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

+ Here is the call graph for this function:

◆ getExternalMetadata()

ilObjMediaObject::getExternalMetadata ( )

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

1826 : void
1827 {
1828 // see https://oembed.com/
1829 $st_item = $this->getMediaItem("Standard");
1830 if ($st_item->getLocationType() == "Reference") {
1831 if (ilExternalMediaAnalyzer::isVimeo($st_item->getLocation())) {
1832 $st_item->setFormat("video/vimeo");
1833 $par = ilExternalMediaAnalyzer::extractVimeoParameters($st_item->getLocation());
1835 $this->setTitle($meta["title"] ?? "");
1836 $description = str_replace("\n", "", $meta["description"] ?? "");
1837 $description = str_replace(["<br>", "<br />"], ["\n", "\n"], $description);
1838 $description = strip_tags($description);
1839 $this->setDescription($description);
1840 $st_item->setDuration((int) ($meta["duration"] ?? 0));
1841 $url = parse_url($meta["thumbnail_url"] ?? "");
1842 $file = basename($url["path"]);
1843 $ext = pathinfo($file, PATHINFO_EXTENSION);
1844 if ($ext == "") {
1845 $ext = "jpg";
1846 }
1847 copy(
1848 $meta["thumbnail_url"],
1849 ilObjMediaObject::_getDirectory($this->getId()) . "/mob_vpreview." .
1850 $ext
1851 );
1852 }
1853 if (ilExternalMediaAnalyzer::isYoutube($st_item->getLocation())) {
1854 $st_item->setFormat("video/youtube");
1855 $par = ilExternalMediaAnalyzer::extractYoutubeParameters($st_item->getLocation());
1856 try {
1858 $this->setTitle($meta["title"] ?? "");
1859 $description = str_replace("\n", "", $meta["description"] ?? "");
1860 } catch (Exception $e) {
1861 $this->setTitle($st_item->getLocation());
1862 $description = "";
1863 }
1864 $description = str_replace(["<br>", "<br />"], ["\n", "\n"], $description);
1865 $description = strip_tags($description);
1866 $this->setDescription($description);
1867 $st_item->setDuration((int) ($meta["duration"] ?? 0));
1868 $thumbnail_url = $meta["thumbnail_url"] ?? "";
1869 $url = parse_url($thumbnail_url);
1870 if ($thumbnail_url !== "") {
1871 $file = basename($url["path"]);
1872 copy(
1873 $meta["thumbnail_url"],
1874 ilObjMediaObject::_getDirectory($this->getId()) . "/mob_vpreview." .
1875 pathinfo($file, PATHINFO_EXTENSION)
1876 );
1877 }
1878 }
1879 }
1880 }
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
$url

References Vendor\Package\$e, $url, _getDirectory(), ilExternalMediaAnalyzer\extractVimeoParameters(), ILIAS\Survey\Mode\getId(), 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  $a_subdir = "")

Get files of directory.

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

463 : array {
464 $a_subdir = str_replace("..", "", $a_subdir);
465 $dir = ilObjMediaObject::_getDirectory($this->getId());
466 if ($a_subdir != "") {
467 $dir .= "/" . $a_subdir;
468 }
469
470 $files = array();
471 if (is_dir($dir)) {
472 $entries = ilFileUtils::getDir($dir);
473 foreach ($entries as $e) {
474 if (is_file($dir . "/" . $e["entry"]) && $e["entry"] != "." && $e["entry"] != "..") {
475 $files[] = $e["entry"];
476 }
477 }
478 }
479 return $files;
480 }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory

◆ getForbiddenFileTypes()

static ilObjMediaObject::getForbiddenFileTypes ( )
static

Get forbidden file types.

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

1550 : array
1551 {
1552 $mset = new ilSetting("mobs");
1553 if (trim((string) $mset->get("black_list_file_types")) === "") {
1554 return array();
1555 }
1556 return array_map(
1557 function ($v) {
1558 return strtolower(trim($v));
1559 },
1560 explode(",", $mset->get("black_list_file_types"))
1561 );
1562 }

Referenced by ilObjMediaObjectGUI\initForm().

+ Here is the caller graph for this function:

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

1512 : array {
1513 $linked = array();
1514
1515 // get linked media objects (map areas)
1516 $med_items = $this->getMediaItems();
1517
1518 foreach ($med_items as $med_item) {
1519 $int_links = ilMapArea::_getIntLinks($med_item->getId());
1520 foreach ($int_links as $k => $int_link) {
1521 if ($int_link["Type"] == "MediaObject") {
1522 $l_id = ilInternalLink::_extractObjIdOfTarget($int_link["Target"]);
1523 if (ilObject::_exists($l_id)) {
1524 if (!in_array($l_id, $linked) &&
1525 !in_array($l_id, $a_ignore)) {
1526 $linked[] = $l_id;
1527 }
1528 }
1529 }
1530 }
1531 }
1532 //var_dump($linked);
1533 return $linked;
1534 }
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

◆ getMediaItem()

ilObjMediaObject::getMediaItem ( string  $a_purpose)

get item for media purpose

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

197 : ?ilMediaItem {
198 foreach ($this->media_items as $media_item) {
199 if ($media_item->getPurpose() == $a_purpose) {
200 return $media_item;
201 }
202 }
203 return null;
204 }

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

+ Here is the caller graph for this function:

◆ getMediaItems()

& ilObjMediaObject::getMediaItems ( )

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

187 : array
188 {
189 return $this->media_items;
190 }

Referenced by ilObjMediaCastGUI\getMediaItems().

+ Here is the caller graph for this function:

◆ getMimeType()

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

◆ getMultiSrtFiles()

ilObjMediaObject::getMultiSrtFiles ( )

Get all srt files of srt multi upload.

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

1791 : array
1792 {
1793 $items = array();
1794
1796
1797 $dir = $this->getMultiSrtUploadDir();
1798 $files = ilFileUtils::getDir($dir);
1799 foreach ($files as $k => $i) {
1800 // check directory
1801 if ($i["type"] == "file" && !in_array($k, array(".", ".."))) {
1802 if (pathinfo($k, PATHINFO_EXTENSION) == "srt") {
1803 $lang = "";
1804 if (substr($k, strlen($k) - 7, 1) == "_") {
1805 $lang = substr($k, strlen($k) - 6, 2);
1806 if (!in_array($lang, $lang_codes)) {
1807 $lang = "";
1808 }
1809 }
1810 $items[] = array("filename" => $k, "lang" => $lang);
1811 }
1812 }
1813 }
1814 return $items;
1815 }
$lang
Definition: xapiexit.php:26

References $i, $lang, ilMDLanguageItem\_getPossibleLanguageCodes(), and ilFileUtils\getDir().

+ Here is the call graph for this function:

◆ getMultiSrtUploadDir()

ilObjMediaObject::getMultiSrtUploadDir ( )

Get directory for multi srt upload.

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

1755 : string
1756 {
1757 return ilObjMediaObject::_getDirectory($this->getId()) . "/srt/tmp";
1758 }

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

+ Here is the call graph for this function:

◆ getOriginID()

ilObjMediaObject::getOriginID ( )

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

276 : string
277 {
278 return $this->origin_id;
279 }

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

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

References $type.

Referenced by ilObjMediaObjectAccess\checkAccessMob(), and ilMediaObjectUsagesTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ getRestrictedFileTypes()

static ilObjMediaObject::getRestrictedFileTypes ( )
static

Get restricted file types (this is for the input form, this list will be empty, if "allowed list" is empty)

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

1540 : array
1541 {
1542 return array_filter(self::getAllowedFileTypes(), function ($v) {
1543 return !in_array($v, self::getForbiddenFileTypes());
1544 });
1545 }

Referenced by ilObjMediaObjectGUI\initForm().

+ Here is the caller graph for this function:

◆ getSrtFiles()

ilObjMediaObject::getSrtFiles ( )

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

1430 : array
1431 {
1432 $srt_dir = ilObjMediaObject::_getDirectory($this->getId()) . "/srt";
1433
1434 if (!is_dir($srt_dir)) {
1435 return array();
1436 }
1437
1438 $items = ilFileUtils::getDir($srt_dir);
1439
1440 $srt_files = array();
1441 foreach ($items as $i) {
1442 if (!in_array($i["entry"], array(".", "..")) && $i["type"] == "file") {
1443 $name = explode(".", $i["entry"]);
1444 if ($name[1] == "srt" && substr($name[0], 0, 9) == "subtitle_") {
1445 $srt_files[] = array("file" => $i["entry"],
1446 "full_path" => "srt/" . $i["entry"], "language" => substr($name[0], 9, 2));
1447 }
1448 }
1449 }
1450
1451 return $srt_files;
1452 }

References $i, $name, _getDirectory(), ilFileUtils\getDir(), and ILIAS\Survey\Mode\getId().

Referenced by ilMobSubtitleTableGUI\__construct().

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

◆ getThumbnailPath()

static ilObjMediaObject::getThumbnailPath ( int  $a_mob_id,
string  $a_thumbname 
)
static

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

1490 : string {
1491 $t_dir = ilObjMediaObject::_getThumbnailDirectory($a_mob_id);
1492 return $t_dir . "/" . $a_thumbname;
1493 }

Referenced by ilPCIIMOverlaysTableGUI\fillRow().

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

909 : array {
910 return self::lookupUsages($this->getId(), $a_include_history);
911 }
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 1718 of file class.ilObjMediaObject.php.

1720 : string {
1721 $dir = ilObjMediaObject::_getDirectory($this->getId());
1722 $ppics = array("mob_vpreview.jpg",
1723 "mob_vpreview.jpeg",
1724 "mob_vpreview.png");
1725 foreach ($ppics as $p) {
1726 if (is_file($dir . "/" . $p)) {
1727 if ($a_filename_only) {
1728 return $p;
1729 } else {
1730 return $dir . "/" . $p;
1731 }
1732 }
1733 }
1734 return "";
1735 }

Referenced by ilObjMediaCastGUI\extractPreviewImageObject(), and ilObjMediaCastGUI\updateCastItemObject().

+ Here is the caller graph for this function:

◆ getXML()

ilObjMediaObject::getXML ( int  $a_mode = IL_MODE_FULL,
int  $a_inst = 0,
bool  $a_sign_locals = 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 491 of file class.ilObjMediaObject.php.

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

References $i, $ilUser, $location, $name, $xml, ILIAS\Survey\Mode\getId(), 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 704 of file class.ilObjMediaObject.php.

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

◆ handleQuotaUpdate()

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

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

357 : void {
358 }

◆ hasFullscreenItem()

ilObjMediaObject::hasFullscreenItem ( )

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

231 : bool
232 {
233 return $this->hasPurposeItem("Fullscreen");
234 }
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 239 of file class.ilObjMediaObject.php.

239 : bool
240 {
241 if (is_object($this->getMediaItem($purpose))) {
242 return true;
243 } else {
244 return false;
245 }
246 }

◆ isAlias()

ilObjMediaObject::isAlias ( )

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

263 : bool
264 {
265 return $this->is_alias;
266 }

◆ isTypeAllowed()

static ilObjMediaObject::isTypeAllowed ( string  $a_type)
static

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

1583 : bool {
1584 if (in_array($a_type, self::getForbiddenFileTypes())) {
1585 return false;
1586 }
1587 if (count(self::getAllowedFileTypes()) == 0 || in_array($a_type, self::getAllowedFileTypes())) {
1588 return true;
1589 }
1590 return false;
1591 }

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

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

Referenced by ilLMObject\updateInternalLinks().

+ Here is the caller graph for this function:

◆ makeThumbnail()

ilObjMediaObject::makeThumbnail ( string  $a_file,
string  $a_thumbname,
string  $a_format = "png",
int  $a_size = 80 
)

Make thumbnail.

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

1462 : void {
1463 $size = (int) $a_size;
1464 $m_dir = ilObjMediaObject::_getDirectory($this->getId());
1466 $file = $m_dir . "/" . $a_file;
1467
1468 $mime = ilObjMediaObject::getMimeType($file);
1469 $wh = ilMediaImageUtil::getImageSize($file);
1470
1471 // see #8602
1472 if ($size > (int) $wh[0] && $size > $wh[1]) {
1473 $a_size = "";
1474 }
1475
1476 $m_dir = ilObjMediaObject::_getDirectory($this->getId());
1480 $m_dir . "/" . $a_file,
1481 $t_dir . "/" . $a_thumbname,
1482 $a_format,
1483 (string) $a_size
1484 );
1485 }
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
convert image

◆ modifyExportIdentifier()

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

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

742 : string {
743 if ($a_tag == "Identifier" && $a_param == "Entry") {
744 $a_value = ilUtil::insertInstIntoID($a_value);
745 }
746
747 return $a_value;
748 }
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 252 of file class.ilObjMediaObject.php.

252 : void
253 {
254 parent::read();
256 }
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 1495 of file class.ilObjMediaObject.php.

1497 : void {
1498 $file = str_replace("..", "", $a_file);
1499 $file = ilObjMediaObject::_getDirectory($this->getId()) . "/" . $file;
1500 if (is_file($file)) {
1501 unlink($file);
1502 }
1503 }

Referenced by ilObjMediaCastGUI\updateCastItemObject().

+ Here is the caller graph for this function:

◆ removeAllMediaItems()

ilObjMediaObject::removeAllMediaItems ( )

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

226 : void
227 {
228 $this->media_items = array();
229 }

◆ removeMediaItem()

ilObjMediaObject::removeMediaItem ( string  $a_purpose)

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

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

References ILIAS\LTI\ToolProvider\$key.

Referenced by ilObjMediaCastGUI\updateCastItemObject().

+ Here is the caller graph for this function:

◆ renameExecutables()

static ilObjMediaObject::renameExecutables ( string  $a_dir)
static

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

1819 : void {
1821 if (!self::isTypeAllowed("html")) {
1822 ilFileUtils::rRenameSuffix($a_dir, "html", "sec"); // see #20187
1823 }
1824 }
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().

Referenced by ilMediaObjectDataSet\importRecord(), and ilObjMediaObjectGUI\savePropertiesObject().

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

◆ setAlias()

ilObjMediaObject::setAlias ( bool  $a_is_alias)

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

258 : void
259 {
260 $this->is_alias = $a_is_alias;
261 }

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

761 : void {
762 $this->contains_int_link = $a_contains_link;
763 }

◆ setOriginID()

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

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

271 : void
272 {
273 $this->origin_id = $a_id;
274 }

◆ update()

ilObjMediaObject::update ( bool  $a_upload = false)

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

313 : bool
314 {
315 parent::update();
316
317 if (!$a_upload) {
318 $this->updateMetaData();
319 }
320
321 // iterate all items
322 $media_items = $this->getMediaItems();
324
325 $j = 1;
326 foreach ($media_items as $key => $val) {
327 $item = $val;
328 if (is_object($item)) {
329 $item->setMobId($this->getId());
330 $item->setNr($j);
331 if ($item->getLocationType() == "Reference") {
332 $item->extractUrlParameters();
333 }
334 $item->create();
335 $j++;
336 }
337 }
338
340 $ilAppEventHandler = $this->app_event_handler;
341 $ilAppEventHandler->raise(
342 'Services/MediaObjects',
343 'update',
344 array('object' => $this,
345 'obj_type' => 'mob',
346 'obj_id' => $this->getId())
347 );
348
349 return true;
350 }

References ILIAS\LTI\ToolProvider\$key, 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 1397 of file class.ilObjMediaObject.php.

1402 : void {
1403 $a_subdir = str_replace("..", "", $a_subdir);
1404 $dir = $mob_dir = ilObjMediaObject::_getDirectory($this->getId());
1405 if ($a_subdir != "") {
1406 $dir .= "/" . $a_subdir;
1407 }
1409 if ($a_mode == "rename") {
1410 ilFileUtils::rename($tmp_name, $dir . "/" . $a_name);
1411 } else {
1412 ilFileUtils::moveUploadedFile($tmp_name, $a_name, $dir . "/" . $a_name, true, $a_mode);
1413 }
1414 self::renameExecutables($mob_dir);
1415 ilMediaSvgSanitizer::sanitizeDir($mob_dir); // see #20339
1416 }
static rename(string $a_source, string $a_target)

◆ uploadMultipleSubtitleFile()

ilObjMediaObject::uploadMultipleSubtitleFile ( array  $a_file)

Upload multi srt file.

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

1766 : void {
1767 $lng = $this->lng;
1768
1769 if (!is_file($a_file["tmp_name"])) {
1770 throw new ilMediaObjectsException($lng->txt("mob_file_could_not_be_uploaded"));
1771 }
1772
1773 $dir = $this->getMultiSrtUploadDir();
1774 ilFileUtils::delDir($dir, true);
1776 ilFileUtils::moveUploadedFile($a_file["tmp_name"], "multi_srt.zip", $dir . "/" . "multi_srt.zip");
1777 ilFileUtils::unzip($dir . "/multi_srt.zip", true);
1778 }
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)

References $lng.

◆ uploadSrtFile()

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

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

1422 : bool {
1423 if (is_file($a_tmp_name) && $a_language != "") {
1424 $this->uploadAdditionalFile("subtitle_" . $a_language . ".srt", $a_tmp_name, "srt", $a_mode);
1425 return true;
1426 }
1427 return false;
1428 }
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 1628 of file class.ilObjMediaObject.php.

1630 : void {
1631 // remove old one
1632 if ($this->getVideoPreviewPic(true) != "") {
1633 $this->removeAdditionalFile($this->getVideoPreviewPic(true));
1634 }
1635
1636 $pi = pathinfo($a_prevpic["name"]);
1637 $ext = $pi["extension"];
1638 if (in_array($ext, array("jpg", "jpeg", "png"))) {
1639 $this->uploadAdditionalFile("mob_vpreview." . $ext, $a_prevpic["tmp_name"]);
1640 }
1641 }
getVideoPreviewPic(bool $a_filename_only=false)
removeAdditionalFile(string $a_file)

Referenced by ilObjMediaCastGUI\updateCastItemObject().

+ Here is the caller graph for this function:

Field Documentation

◆ $contains_int_link

bool ilObjMediaObject::$contains_int_link

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

◆ $is_alias

bool ilObjMediaObject::$is_alias

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

◆ $media_items

array ilObjMediaObject::$media_items

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

◆ $origin_id

string ilObjMediaObject::$origin_id

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

◆ $user

ilObjUser ilObjMediaObject::$user
protected

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


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