ILIAS  release_8 Revision v8.24
ilObjFile Class Reference

Class ilObjFile. More...

+ Inheritance diagram for ilObjFile:
+ Collaboration diagram for ilObjFile:

Public Member Functions

 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 updateObjectFromCurrentRevision ()
 
 appendSuffixToTitle (string $title, string $filename)
 
 appendStream (FileStream $stream, string $title)
 
 appendUpload (UploadResult $result, string $title)
 
 replaceWithStream (FileStream $stream, string $title)
 
 replaceWithUpload (UploadResult $result, string $title)
 
 getFile (?int $a_hist_entry_id=null)
 
 getDirectory ($a_version=0)
 
 getVersion ()
 
 setVersion (int $a_version)
 
 getFileName ()
 
 setFileName (string $a_name)
 
 setRating (bool $a_value)
 
 setResourceId (?string $resource_id)
 
 getResourceId ()
 
 getStorageID ()
 
 getMode ()
 
 setMode (string $a_mode)
 
 getFileSize ()
 
 setFileSize (int $a_size)
 
 getFileType ()
 
 setFileType (string $a_type)
 
 hasRating ()
 
 getMaxVersion ()
 
 setMaxVersion (int $a_max_version)
 
 getPageCount ()
 
 setPageCount (int $page_count)
 
 getAction ()
 
 setAction (string $a_action)
 
 handleChangedObjectTitle (string $new_title)
 
 replaceFile ($a_upload_file, $a_filename)
 
 getUploadFile ($a_upload_file, string $title, bool $a_prevent_preview=false)
 @description This Method is used to append a fileupload by it's POST-name to the current ilObjFile More...
 
 isHidden ()
 
 clearDataDirectory ()
 @ineritdoc More...
 
 deleteVersions ($a_hist_entry_ids=null)
 @ineritdoc More...
 
 sendFile (?int $a_hist_entry_id=null, bool $inline=true)
 
 export (string $a_target_dir)
 
 getVersions ($version_ids=null)
 
 rollback (int $version_id)
 Makes the specified version the current one. More...
 
 checkFileExtension (string $new_filename, string $new_title)
 
 getFileExtension ()
 
- Public Member Functions inherited from ilObject2
 __construct (int $a_id=0, bool $a_reference=true)
 Constructor. More...
 
 read ()
 
 create (bool $a_clone_mode=false)
 
 update ()
 
 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...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 cloneObject (int $target_id, int $copy_id=0, bool $omit_tree=false)
 
- 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...
 
- Public Member Functions inherited from ilObjFileImplementationInterface
 getDirectory (int $a_version=0)
 
 deleteVersions (?array $a_hist_entry_ids=null)
 Deletes the specified history entries or all entries if no ids are specified. More...
 
 getFileType ()
 
 getStorageID ()
 
 getFileSize ()
 
 getFile (?int $a_hist_entry_id=null)
 
 getVersion ()
 
 getMaxVersion ()
 
 sendFile (?int $a_hist_entry_id=null, bool $inline=true)
 
 handleChangedObjectTitle (string $new_title)
 
 getFileExtension ()
 Returns the extension of the file name converted to lower-case. More...
 
 getVersions (?array $version_ids=null)
 Gets the file versions for this object. More...
 

Data Fields

const MODE_FILELIST = "filelist"
 
const MODE_OBJECT = "object"
 
const OBJECT_TYPE = "file"
 
string $mode = self::MODE_OBJECT
 
- 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

 initFileInfo (int $id, bool $is_ref_id)
 
 initImplementation ()
 
 doCreate (bool $clone_mode=false)
 
 doCloneObject (ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=0)
 
 doUpdate ()
 
 beforeUpdate ()
 
 beforeDelete ()
 
 doDelete ()
 
 initType ()
 
- Protected Member Functions inherited from ilObject2
 initType ()
 
 doRead ()
 
 doCreate (bool $clone_mode=false)
 
 beforeCreate ()
 If overwritten this method should return true, there is currently no "abort" handling for cases where "false" is returned. More...
 
 doUpdate ()
 
 beforeUpdate ()
 
 doDelete ()
 
 beforeDelete ()
 
 doCloneObject (ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=null)
 
 beforeCloneObject ()
 
- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Protected Attributes

ilObjFileInfo $file_info
 
ilObjFileImplementationInterface $implementation
 
int $page_count = 0
 
bool $rating = false
 
ilLogger $log
 
string $filename = ''
 
string $filetype = ''
 
int $filesize
 
int $version = 1
 
int $max_version = 1
 
string $action = ''
 
string $resource_id = null
 
Manager $manager
 
FileUpload $upload
 
ilObjFileStakeholder $stakeholder
 
- 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
 

Private Member Functions

 updateObjectFromRevision (Revision $r, bool $create_previews=true)
 
 getArrayForDatabase ()
 
 prepareUpload ()
 

Additional Inherited Members

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

Detailed Description

Member Function Documentation

◆ appendStream()

ilObjFile::appendStream ( FileStream  $stream,
string  $title 
)
Exceptions
FileNamePolicyException

Definition at line 153 of file class.ilObjFile.php.

153 : int
154 {
155 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
156 $revision = $this->manager->appendNewRevisionFromStream($i, $stream, $this->stakeholder, $title);
157 } else {
158 $i = $this->manager->stream($stream, $this->stakeholder, $title);
159 $revision = $this->manager->getCurrentRevision($i);
160 $this->setResourceId($i->serialize());
161 $this->initImplementation();
162 }
163 $this->updateObjectFromRevision($revision);
164
165 return $revision->getVersionNumber();
166 }
updateObjectFromRevision(Revision $r, bool $create_previews=true)
setResourceId(?string $resource_id)
string $title
$i
Definition: metadata.php:41

References $i, ilObject\$title, getResourceId(), initImplementation(), setResourceId(), and updateObjectFromRevision().

+ Here is the call graph for this function:

◆ appendSuffixToTitle()

ilObjFile::appendSuffixToTitle ( string  $title,
string  $filename 
)

Definition at line 137 of file class.ilObjFile.php.

137 : string
138 {
139 $suffix = $this->file_info->getSuffix();
140 $filename_suffix = $this->extractSuffixFromFilename($filename);
141 if (empty($suffix) || $suffix !== $filename_suffix) {
142 $suffix = $filename_suffix;
143 }
144
145 $title = $this->ensureSuffix($title, $suffix);
146
147 return $title;
148 }
string $filename
ensureSuffix(string $title, ?string $suffix=null)
extractSuffixFromFilename(string $filename)

References ilObject\$title, ensureSuffix(), and extractSuffixFromFilename().

Referenced by appendUpload(), checkFileExtension(), and replaceWithUpload().

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

◆ appendUpload()

ilObjFile::appendUpload ( UploadResult  $result,
string  $title 
)
Exceptions
FileNamePolicyException

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

171 : int
172 {
173 $title = $this->appendSuffixToTitle($title, $result->getName());
174 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
175 $revision = $this->manager->appendNewRevision($i, $result, $this->stakeholder, $title);
176 } else {
177 $i = $this->manager->upload($result, $this->stakeholder, $title);
178 $revision = $this->manager->getCurrentRevision($i);
179 $this->setResourceId($i->serialize());
180 $this->initImplementation();
181 }
184 }
185 $this->updateObjectFromRevision($revision);
186
187 return $revision->getVersionNumber();
188 }
appendSuffixToTitle(string $title, string $filename)
setPageCount(int $page_count)

References $i, ilObject\$title, appendSuffixToTitle(), ILIAS\FileUpload\DTO\UploadResult\getMetaData(), ILIAS\FileUpload\DTO\UploadResult\getName(), getResourceId(), initImplementation(), ilCountPDFPagesPreProcessors\PAGE_COUNT, setPageCount(), setResourceId(), and updateObjectFromRevision().

Referenced by getUploadFile().

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

◆ beforeDelete()

ilObjFile::beforeDelete ( )
protected

Reimplemented from ilObject2.

Definition at line 458 of file class.ilObjFile.php.

458 : bool
459 {
460 // check, if file is used somewhere
461 $usages = $this->getUsages();
462 return count($usages) === 0;
463 }

◆ beforeUpdate()

ilObjFile::beforeUpdate ( )
protected

Reimplemented from ilObject2.

Definition at line 446 of file class.ilObjFile.php.

446 : bool
447 {
448 $this->setTitle($this->ensureSuffix($this->getTitle(), $this->file_info->getSuffix()));
449
450 // no meta data handling for file list files
451 if ($this->getMode() !== self::MODE_FILELIST) {
452 $this->updateMetaData();
453 }
454
455 return true;
456 }
setTitle(string $title)

References ensureSuffix(), getMode(), ilObject\getTitle(), ilObject\setTitle(), and ilObject\updateMetaData().

+ Here is the call graph for this function:

◆ checkFileExtension()

ilObjFile::checkFileExtension ( string  $new_filename,
string  $new_title 
)
Deprecated:

Definition at line 617 of file class.ilObjFile.php.

617 : string
618 {
619 return $this->appendSuffixToTitle($new_title, $new_filename);
620 }

References appendSuffixToTitle().

+ Here is the call graph for this function:

◆ clearDataDirectory()

ilObjFile::clearDataDirectory ( )

@ineritdoc

Deprecated:

Definition at line 560 of file class.ilObjFile.php.

560 : void
561 {
562 $this->implementation->clearDataDirectory();
563 }

◆ deleteVersions()

ilObjFile::deleteVersions (   $a_hist_entry_ids = null)

@ineritdoc

Deprecated:

Definition at line 569 of file class.ilObjFile.php.

569 : void
570 {
571 $this->implementation->deleteVersions($a_hist_entry_ids);
572 }

◆ doCloneObject()

ilObjFile::doCloneObject ( ilObject2  $new_obj,
int  $a_target_id,
?int  $a_copy_id = 0 
)
protected

Reimplemented from ilObject2.

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

392 : void
393 {
394 assert($new_obj instanceof ilObjFile);
395 $identification = $this->manager->find($this->resource_id);
396 if ($identification === null) {
397 throw new RuntimeException('Cannot clone file since no corresponding resource identification was found');
398 }
399
400 $this->cloneMetaData($new_obj);
401 // object created now copy other settings
402 $new_obj->updateFileData();
403
404 // Copy Resource
405 $cloned_title = $new_obj->getTitle();
406 $new_resource_identification = $this->manager->clone($identification);
407 $new_current_revision = $this->manager->getCurrentRevision($new_resource_identification);
408 $new_obj->setResourceId($new_resource_identification->serialize());
409 $new_obj->initImplementation();
410 $new_obj->updateObjectFromRevision($new_current_revision, false); // Previews are already copied in 453
411 $new_obj->setTitle($cloned_title); // see https://mantis.ilias.de/view.php?id=31375
412 $new_obj->setPageCount($this->getPageCount());
413 $new_obj->update();
414
415 // Copy learning progress settings
416 $obj_settings = new ilLPObjSettings($this->getId());
417 $obj_settings->cloneSettings($new_obj->getId());
418 unset($obj_settings);
419 }
Class ilObjFile.
cloneMetaData(ilObject $target_obj)
Copy meta data.

References ilObject2\cloneMetaData(), ilObject\getId(), getPageCount(), ilObject\getTitle(), ilObject\setTitle(), and ilObject2\update().

+ Here is the call graph for this function:

◆ doCreate()

ilObjFile::doCreate ( bool  $clone_mode = false)
protected

Reimplemented from ilObject2.

Definition at line 362 of file class.ilObjFile.php.

362 : void
363 {
364 $this->createProperties(true);
365 $this->notifyCreation($this->getId(), $this->getDescription());
366 }
createProperties(bool $a_upload=false)
The basic properties of a file object are stored in table object_data.
notifyCreation(int $obj_id, string $additional_message=null)

References createProperties(), ilObject\getDescription(), ilObject\getId(), and notifyCreation().

+ Here is the call graph for this function:

◆ doDelete()

ilObjFile::doDelete ( )
protected

Reimplemented from ilObject2.

Definition at line 465 of file class.ilObjFile.php.

465 : void
466 {
467 global $DIC;
468
469 // delete file data entry
470 $DIC->database()->manipulateF("DELETE FROM file_data WHERE file_id = %s", ['integer'], [$this->getId()]);
471
472 // delete history entries
474
475 // delete meta data
476 if ($this->getMode() != self::MODE_FILELIST) {
477 $this->deleteMetaData();
478 }
479
480 // delete preview
481 $this->deletePreview();
482
483 // delete resource
484 $identification = $this->getResourceId();
485 if ($identification && $identification != '-') {
486 $resource = $this->manager->find($identification);
487 if ($resource !== null) {
488 $this->manager->remove($resource, $this->stakeholder);
489 }
490 }
491 }
static _removeEntriesForObject(int $a_obj_id)
remove all history entries for an object
global $DIC
Definition: feed.php:28

References $DIC, ilHistory\_removeEntriesForObject(), ilObject\deleteMetaData(), ilObject\getId(), getMode(), and getResourceId().

+ Here is the call graph for this function:

◆ doUpdate()

ilObjFile::doUpdate ( )
protected

Reimplemented from ilObject2.

Definition at line 421 of file class.ilObjFile.php.

421 : void
422 {
423 global $DIC;
424
425 $a_columns = $this->getArrayForDatabase();
426 $DIC->database()->update('file_data', $a_columns, [
427 'file_id' => [
428 'integer',
429 $this->getId(),
430 ],
431 ]);
432
433 // update metadata with the current file version
434 $meta_version_column = ['meta_version' => ['integer', $this->getVersion()]];
435 $DIC->database()->update('il_meta_lifecycle', $meta_version_column, [
436 'rbac_id' => [
437 'integer',
438 $this->getId(),
439 ],
440 ]);
441
442 $this->notifyUpdate($this->getId(), $this->getDescription());
443 $this->initImplementation();
444 }
notifyUpdate(int $obj_id, string $additional_message=null)

References $DIC, getArrayForDatabase(), ilObject\getDescription(), ilObject\getId(), getVersion(), initImplementation(), and notifyUpdate().

+ Here is the call graph for this function:

◆ export()

ilObjFile::export ( string  $a_target_dir)
Deprecated:
no longer available since it's unclear/unspecified how to export

Definition at line 584 of file class.ilObjFile.php.

584 : void
585 {
586 //
587 }

◆ getAction()

ilObjFile::getAction ( )
Deprecated:

Definition at line 340 of file class.ilObjFile.php.

340 : string
341 {
342 return $this->action;
343 }
string $action

References $action.

◆ getArrayForDatabase()

ilObjFile::getArrayForDatabase ( )
private

Definition at line 493 of file class.ilObjFile.php.

493 : array
494 {
495 return [
496 'file_id' => ['integer', $this->getId()],
497 'file_name' => ['text', $this->getFileName()],
498 'f_mode' => ['text', $this->getMode()],
499 'page_count' => ['text', $this->getPageCount()],
500 'rating' => ['integer', $this->hasRating()],
501 'rid' => ['text', $this->resource_id ?? ''],
502 ];
503 }

References getFileName(), ilObject\getId(), getMode(), getPageCount(), and hasRating().

Referenced by doUpdate().

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

◆ getDirectory()

ilObjFile::getDirectory (   $a_version = 0)

Definition at line 233 of file class.ilObjFile.php.

233 : string
234 {
235 return $this->implementation->getDirectory($a_version);
236 }

◆ getFile()

ilObjFile::getFile ( ?int  $a_hist_entry_id = null)
Deprecated:

Implements ilObjFileImplementationInterface.

Definition at line 227 of file class.ilObjFile.php.

227 : string
228 {
229 $this->initImplementation();
230 return $this->implementation->getFile($a_hist_entry_id);
231 }

References initImplementation().

+ Here is the call graph for this function:

◆ getFileExtension()

ilObjFile::getFileExtension ( )
Deprecated:

Implements ilObjFileImplementationInterface.

Definition at line 625 of file class.ilObjFile.php.

625 : string
626 {
627 return $this->implementation->getFileExtension();
628 }

◆ getFileName()

ilObjFile::getFileName ( )

Definition at line 248 of file class.ilObjFile.php.

248 : string
249 {
250 return $this->filename;
251 }

References $filename.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getFileSize()

ilObjFile::getFileSize ( )

Implements ilObjFileImplementationInterface.

Definition at line 292 of file class.ilObjFile.php.

292 : int
293 {
294 return $this->implementation->getFileSize();
295 }

◆ getFileType()

ilObjFile::getFileType ( )

Implements ilObjFileImplementationInterface.

Definition at line 302 of file class.ilObjFile.php.

302 : string
303 {
304 return $this->implementation->getFileType();
305 }

◆ getMaxVersion()

ilObjFile::getMaxVersion ( )

Implements ilObjFileImplementationInterface.

Definition at line 317 of file class.ilObjFile.php.

317 : int
318 {
319 return $this->max_version;
320 }

References $max_version.

◆ getMode()

ilObjFile::getMode ( )

Definition at line 279 of file class.ilObjFile.php.

279 : string
280 {
281 return $this->mode;
282 }

References $mode.

Referenced by beforeUpdate(), doDelete(), and getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getPageCount()

ilObjFile::getPageCount ( )

Definition at line 327 of file class.ilObjFile.php.

327 : int
328 {
329 return $this->page_count;
330 }

References $page_count.

Referenced by doCloneObject(), and getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getPresentationTitle()

ilObjFile::getPresentationTitle ( )

get presentation title Normally same as title Overwritten for sessions

Reimplemented from ilObject.

Definition at line 97 of file class.ilObjFile.php.

97 : string
98 {
99 return $this->file_info->getHeaderTitle();
100 }

◆ getResourceId()

ilObjFile::getResourceId ( )

Definition at line 269 of file class.ilObjFile.php.

269 : string
270 {
271 return $this->resource_id ?? '-';
272 }

Referenced by appendStream(), appendUpload(), doDelete(), replaceWithStream(), replaceWithUpload(), and rollback().

+ Here is the caller graph for this function:

◆ getStorageID()

ilObjFile::getStorageID ( )

Implements ilObjFileImplementationInterface.

Definition at line 274 of file class.ilObjFile.php.

274 : ?string
275 {
276 return $this->implementation->getStorageID();
277 }

◆ getUploadFile()

ilObjFile::getUploadFile (   $a_upload_file,
string  $title,
bool  $a_prevent_preview = false 
)

@description This Method is used to append a fileupload by it's POST-name to the current ilObjFile

Deprecated:
See also
appendUpload(), appendStream()

Definition at line 536 of file class.ilObjFile.php.

536 : bool
537 {
538 $this->prepareUpload();
539
540 $results = $this->upload->getResults();
541 $upload = $results[$a_upload_file];
542
543 $this->appendUpload($upload, $title);
544
545 return true;
546 }
FileUpload $upload
appendUpload(UploadResult $result, string $title)
$results

References $results, ilObject\$title, appendUpload(), prepareUpload(), and ILIAS\Repository\upload().

+ Here is the call graph for this function:

◆ getVersion()

ilObjFile::getVersion ( )

Implements ilObjFileImplementationInterface.

Definition at line 238 of file class.ilObjFile.php.

238 : int
239 {
240 return $this->implementation->getVersion();
241 }

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getVersions()

ilObjFile::getVersions (   $version_ids = null)
Parameters
null$version_ids
Returns
array|ilObjFileVersion[]

Definition at line 594 of file class.ilObjFile.php.

594 : array
595 {
596 return $this->implementation->getVersions($version_ids);
597 }

◆ handleChangedObjectTitle()

ilObjFile::handleChangedObjectTitle ( string  $new_title)

Implements ilObjFileImplementationInterface.

Definition at line 354 of file class.ilObjFile.php.

354 : void
355 {
356 $new_title = $this->ensureSuffix($new_title, $this->file_info->getSuffix());
357 $this->setTitle($new_title);
358 $this->implementation->handleChangedObjectTitle($new_title);
359 }

References ensureSuffix(), and ilObject\setTitle().

+ Here is the call graph for this function:

◆ hasRating()

ilObjFile::hasRating ( )

Definition at line 312 of file class.ilObjFile.php.

312 : bool
313 {
314 return $this->rating;
315 }

References $rating.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ initFileInfo()

ilObjFile::initFileInfo ( int  $id,
bool  $is_ref_id 
)
protected

Definition at line 87 of file class.ilObjFile.php.

87 : void
88 {
89 $repository = new ilObjFileInfoRepository(true);
90 if ($is_ref_id) {
91 $this->file_info = $repository->getByRefId($id);
92 } else {
93 $this->file_info = ($repository)->getByObjectId($id);
94 }
95 }

References ilObject\$id.

Referenced by initImplementation(), and updateObjectFromRevision().

+ Here is the caller graph for this function:

◆ initImplementation()

ilObjFile::initImplementation ( )
protected

Definition at line 102 of file class.ilObjFile.php.

102 : void
103 {
104 if ($this->resource_id && ($id = $this->manager->find($this->resource_id)) !== null) {
105 $resource = $this->manager->getResource($id);
106 $this->implementation = new ilObjFileImplementationStorage($resource);
107 $this->max_version = $resource->getMaxRevision();
108 $this->version = $resource->getMaxRevision();
109 }
110 $this->initFileInfo($this->getId(), false);
111 }
Class ilObjFileImplementationStorage.
initFileInfo(int $id, bool $is_ref_id)

References ilObject\$id, ilObject\getId(), and initFileInfo().

Referenced by appendStream(), appendUpload(), doUpdate(), and getFile().

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

◆ initType()

ilObjFile::initType ( )
protected

Reimplemented from ilObject2.

Definition at line 505 of file class.ilObjFile.php.

505 : void
506 {
507 $this->type = self::OBJECT_TYPE;
508 }
const OBJECT_TYPE

References OBJECT_TYPE.

◆ isHidden()

ilObjFile::isHidden ( )
Deprecated:

Definition at line 551 of file class.ilObjFile.php.

551 : bool
552 {
554 }
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user.

References ilObjFileAccess\_isFileHidden(), and ilObject\getTitle().

+ Here is the call graph for this function:

◆ prepareUpload()

ilObjFile::prepareUpload ( )
private

Definition at line 520 of file class.ilObjFile.php.

520 : void
521 {
522 if (!$this->upload->hasBeenProcessed()) {
523 if (defined('PATH_TO_GHOSTSCRIPT') && PATH_TO_GHOSTSCRIPT !== "") {
524 $this->upload->register(new ilCountPDFPagesPreProcessors());
525 }
526
527 $this->upload->process();
528 }
529 }
Class ilCountPDFPagesPreProcessors.

References ILIAS\Repository\upload().

Referenced by getUploadFile().

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

◆ replaceFile()

ilObjFile::replaceFile (   $a_upload_file,
  $a_filename 
)
Returns
null

Definition at line 515 of file class.ilObjFile.php.

516 {
517 return null;
518 }

◆ replaceWithStream()

ilObjFile::replaceWithStream ( FileStream  $stream,
string  $title 
)
Exceptions
FileNamePolicyException

Definition at line 193 of file class.ilObjFile.php.

193 : int
194 {
195 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
196 $revision = $this->manager->replaceWithStream($i, $stream, $this->stakeholder, $title);
197 } else {
198 throw new LogicException('only files with existing resource and revision can be replaced');
199 }
200 $this->updateObjectFromRevision($revision);
201
202 return $revision->getVersionNumber();
203 }

References $i, ilObject\$title, getResourceId(), and updateObjectFromRevision().

+ Here is the call graph for this function:

◆ replaceWithUpload()

ilObjFile::replaceWithUpload ( UploadResult  $result,
string  $title 
)
Exceptions
FileNamePolicyException

Definition at line 208 of file class.ilObjFile.php.

208 : int
209 {
210 $title = $this->appendSuffixToTitle($title, $result->getName());
211 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
212 $revision = $this->manager->replaceWithUpload($i, $result, $this->stakeholder, $title);
213 } else {
214 throw new LogicException('only files with existing resource and revision can be replaced');
215 }
218 }
219 $this->updateObjectFromRevision($revision);
220
221 return $revision->getVersionNumber();
222 }

References $i, ilObject\$title, appendSuffixToTitle(), ILIAS\FileUpload\DTO\UploadResult\getMetaData(), ILIAS\FileUpload\DTO\UploadResult\getName(), getResourceId(), ilCountPDFPagesPreProcessors\PAGE_COUNT, setPageCount(), and updateObjectFromRevision().

+ Here is the call graph for this function:

◆ rollback()

ilObjFile::rollback ( int  $version_id)

Makes the specified version the current one.

Parameters
int$version_idThe id of the version to make the current one.

Definition at line 603 of file class.ilObjFile.php.

603 : void
604 {
605 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
606 $this->manager->rollbackRevision($i, $version_id);
607 $latest_revision = $this->manager->getCurrentRevision($i);
608 $this->updateObjectFromRevision($latest_revision);
609 } else {
610 throw new LogicException('only files with existing resource and revision can be replaced');
611 }
612 }

References $i, getResourceId(), and updateObjectFromRevision().

+ Here is the call graph for this function:

◆ sendFile()

ilObjFile::sendFile ( ?int  $a_hist_entry_id = null,
bool  $inline = true 
)
Parameters
bool$inline
Deprecated:

Implements ilObjFileImplementationInterface.

Definition at line 574 of file class.ilObjFile.php.

574 : void
575 {
576 $info = (new ilObjFileInfoRepository())->getByObjectId($this->getId());
577
578 $this->implementation->sendFile($a_hist_entry_id, $info->shouldDeliverInline());
579 }

References ilObject\getId().

+ Here is the call graph for this function:

◆ setAction()

ilObjFile::setAction ( string  $a_action)
Parameters
$a_action
Deprecated:

Definition at line 349 of file class.ilObjFile.php.

349 : void
350 {
351 throw new LogicException('cannot change action');
352 }

◆ setFileName()

ilObjFile::setFileName ( string  $a_name)

Definition at line 253 of file class.ilObjFile.php.

253 : void
254 {
255 $this->filename = $a_name;
256 }

Referenced by updateObjectFromRevision().

+ Here is the caller graph for this function:

◆ setFileSize()

ilObjFile::setFileSize ( int  $a_size)

Definition at line 297 of file class.ilObjFile.php.

297 : void
298 {
299 throw new LogicException('cannot change filesize');
300 }

◆ setFileType()

ilObjFile::setFileType ( string  $a_type)

Definition at line 307 of file class.ilObjFile.php.

307 : void
308 {
309 throw new LogicException('cannot change filetype');
310 }

◆ setMaxVersion()

ilObjFile::setMaxVersion ( int  $a_max_version)

Definition at line 322 of file class.ilObjFile.php.

322 : void
323 {
324 throw new LogicException('cannot change max-version');
325 }

◆ setMode()

ilObjFile::setMode ( string  $a_mode)
Parameters
string$a_modeself::MODE_FILELIST or self::MODE_OBJECT

Definition at line 287 of file class.ilObjFile.php.

287 : void
288 {
289 $this->mode = $a_mode;
290 }

◆ setPageCount()

ilObjFile::setPageCount ( int  $page_count)

Definition at line 332 of file class.ilObjFile.php.

332 : void
333 {
334 $this->page_count = $page_count;
335 }

References $page_count.

Referenced by appendUpload(), and replaceWithUpload().

+ Here is the caller graph for this function:

◆ setRating()

ilObjFile::setRating ( bool  $a_value)

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

258 : void
259 {
260 $this->rating = $a_value;
261 }

◆ setResourceId()

ilObjFile::setResourceId ( ?string  $resource_id)

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

263 : self
264 {
265 $this->resource_id = $resource_id;
266 return $this;
267 }
string $resource_id

References $resource_id.

Referenced by appendStream(), and appendUpload().

+ Here is the caller graph for this function:

◆ setVersion()

ilObjFile::setVersion ( int  $a_version)

Definition at line 243 of file class.ilObjFile.php.

243 : void
244 {
245 $this->version = $a_version;
246 }

◆ updateObjectFromCurrentRevision()

ilObjFile::updateObjectFromCurrentRevision ( )

Definition at line 113 of file class.ilObjFile.php.

113 : void
114 {
116 $this->manager->getCurrentRevision($this->manager->find($this->getResourceId())),
117 false
118 );
119 }

References updateObjectFromRevision().

+ Here is the call graph for this function:

◆ updateObjectFromRevision()

ilObjFile::updateObjectFromRevision ( Revision  $r,
bool  $create_previews = true 
)
private

Definition at line 121 of file class.ilObjFile.php.

121 : void
122 {
123 $this->initFileInfo($this->getId(), false);
124 $this->setTitle(
125 $this->ensureSuffix(
126 $r->getTitle(),
127 $this->extractSuffixFromFilename($r->getInformation()->getTitle())
128 )
129 );
130 $this->setFileName($r->getInformation()->getTitle());
131 $this->update();
132 if ($create_previews) {
133 $this->createPreview(true);
134 }
135 }
setFileName(string $a_name)

References ensureSuffix(), ilObject\getId(), ILIAS\ResourceStorage\Revision\Revision\getInformation(), ILIAS\ResourceStorage\Revision\Revision\getTitle(), initFileInfo(), setFileName(), ilObject\setTitle(), and ilObject2\update().

Referenced by appendStream(), appendUpload(), replaceWithStream(), replaceWithUpload(), rollback(), and updateObjectFromCurrentRevision().

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

Field Documentation

◆ $action

string ilObjFile::$action = ''
protected

Definition at line 57 of file class.ilObjFile.php.

Referenced by getAction().

◆ $file_info

ilObjFileInfo ilObjFile::$file_info
protected

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

◆ $filename

string ilObjFile::$filename = ''
protected

Definition at line 52 of file class.ilObjFile.php.

Referenced by getFileName().

◆ $filesize

int ilObjFile::$filesize
protected

Definition at line 54 of file class.ilObjFile.php.

◆ $filetype

string ilObjFile::$filetype = ''
protected

Definition at line 53 of file class.ilObjFile.php.

◆ $implementation

ilObjFileImplementationInterface ilObjFile::$implementation
protected

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

◆ $log

ilLogger ilObjFile::$log
protected

Definition at line 51 of file class.ilObjFile.php.

◆ $manager

Manager ilObjFile::$manager
protected

Definition at line 60 of file class.ilObjFile.php.

◆ $max_version

int ilObjFile::$max_version = 1
protected

Definition at line 56 of file class.ilObjFile.php.

Referenced by getMaxVersion().

◆ $mode

string ilObjFile::$mode = self::MODE_OBJECT

Definition at line 59 of file class.ilObjFile.php.

Referenced by getMode().

◆ $page_count

int ilObjFile::$page_count = 0
protected

Definition at line 49 of file class.ilObjFile.php.

Referenced by getPageCount(), and setPageCount().

◆ $rating

bool ilObjFile::$rating = false
protected

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

Referenced by hasRating().

◆ $resource_id

string ilObjFile::$resource_id = null
protected

Definition at line 58 of file class.ilObjFile.php.

Referenced by setResourceId().

◆ $stakeholder

ilObjFileStakeholder ilObjFile::$stakeholder
protected

Definition at line 62 of file class.ilObjFile.php.

◆ $upload

FileUpload ilObjFile::$upload
protected

Definition at line 61 of file class.ilObjFile.php.

◆ $version

int ilObjFile::$version = 1
protected

Definition at line 55 of file class.ilObjFile.php.

◆ MODE_FILELIST

const ilObjFile::MODE_FILELIST = "filelist"

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

Referenced by ilModulesFileTest\testAppendStream().

◆ MODE_OBJECT

const ilObjFile::MODE_OBJECT = "object"

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

Referenced by ilDclFileuploadRecordFieldModel\parseValue().

◆ OBJECT_TYPE


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