ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjFile Class Reference

Class ilObjFile. More...

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

Public Member Functions

 appendStream (FileStream $stream, string $title)
 
 appendUpload (UploadResult $result, string $title)
 
 replaceWithStream (FileStream $stream, string $title)
 
 replaceWithUpload (UploadResult $result, string $title)
 
 getFile ($a_hist_entry_id=null)
 
 getDirectory ($a_version=0)
 
 getVersion ()
 
 setVersion ($a_version)
 
 getFileName ()
 
 setFileName ($a_name)
 
 setRating ($a_value)
 
 setResourceId (?string $resource_id)
 
 getResourceId ()
 
 getStorageID ()
 
 getMode ()
 
 setMode ($a_mode)
 
 getFileSize ()
 
 setFileSize ($a_size)
 
 getFileType ()
 
 setFileType ($a_type)
 
 hasRating ()
 
 getMaxVersion ()
 
 setMaxVersion ($a_max_version)
 
 getPageCount ()
 
 setPageCount ($page_count)
 
 getAction ()
 
 setAction ($a_action)
 
 handleChangedObjectTitle (string $new_title)
 
 initType ()
 
 createDirectory ()
 
 raiseUploadError ($raise=false)
 
 replaceFile ($a_upload_file, $a_filename)
 
 getUploadFile ($a_upload_file, string $title, bool $a_prevent_preview=false)
 This Method is used to append a fileupload by it's POST-name to the current ilObjFile More...
 
 isHidden ()
 
 clearDataDirectory ()
 
 deleteVersions ($a_hist_entry_ids=null)
 
 sendFile ($a_hist_entry_id=null)
 
 isInline ()
 
 export (string $target_dir)
 
 storeUnzipedFile ($a_upload_file, $a_filename)
 storeUnzipedFile Stores Files unzipped from uploaded archive in filesystem More...
 
 getVersions ($version_ids=null)
 
 rollback (int $version_id)
 Makes the specified version the current one. More...
 
 checkFileExtension ($new_filename, $new_title)
 
 getFileExtension ()
 
- Public Member Functions inherited from ilObject2
 __construct ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 
 read ()
 Read data from db. More...
 
 setRefId ($a_id)
 
 getRefId ()
 
 getType ()
 
 setType ($a_type)
 
 getPresentationTitle ()
 
 getTitle ()
 
 getUntranslatedTitle ()
 
 setTitle ($a_title)
 
 getDescription ()
 
 setDescription ($a_desc)
 
 getLongDescription ()
 
 getImportId ()
 
 setImportId ($a_import_id)
 
 getOwner ()
 
 getOwnerName ()
 
 setOwner ($a_owner)
 
 getCreateDate ()
 
 getLastUpdateDate ()
 
 create ($a_clone_mode=false)
 
 update ()
 
 MDUpdateListener ($a_element)
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 
 putInTree ($a_parent_ref)
 
 setPermissions ($a_parent_ref)
 
 createReference ()
 
 countReferences ()
 
 delete ()
 
 initDefaultRoles ()
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 
 cloneMetaData ($target_obj)
 
 cloneObject ($a_target_id, $a_copy_id=null, $a_omit_tree=false)
 
 cloneDependencies ($a_target_id, $a_copy_id)
 
- Public Member Functions inherited from ilObject
 __construct ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ()
 read object data from db into object More...
 
 getId ()
 get object id public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date public More...
 
 getLastUpdateDate ()
 get last update date public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 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 If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Data Fields

const MODE_FILELIST = "filelist"
 
const MODE_OBJECT = "object"
 
 $mode = self::MODE_OBJECT
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 

Protected Member Functions

 initImplementation ()
 
 doCreate ($a_upload=false)
 
 doUpdate ()
 
 beforeUpdate ()
 
 beforeDelete ()
 
 doDelete ()
 
- Protected Member Functions inherited from ilObject2
 initType ()
 
 doRead ()
 
 doCreate ()
 
 beforeCreate ()
 If overwritten this method should return true, there is currently no "abort" handling for cases where "false" is returned. More...
 
 doUpdate ()
 
 beforeUpdate ()
 
 doMDUpdateListener ($a_element)
 
 beforeMDUpdateListener ($a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDelete ()
 
 beforeDelete ()
 
 doCloneObject ($new_obj, $a_target_id, $a_copy_id=null)
 
 beforeCloneObject ()
 

Protected Attributes

 $implementation
 
 $page_count = 0
 
 $rating = false
 
 $log
 
 $filename = ''
 
 $filetype = ''
 
 $filesize
 
 $version = 1
 
 $max_version = 1
 
 $action
 
 $resource_id
 
 $manager
 
 $upload
 
 $stakeholder
 
- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

Private Member Functions

 updateObjectFromRevision (Revision $r, bool $create_previews=true)
 
 appendSuffixToTitle (string $title, string $filename)
 
 getArrayForDatabase ()
 
 prepareUpload ()
 

Additional Inherited Members

- Static Public Member Functions inherited from ilObject2
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupOwnerName ($a_owner_id)
 
static _getIdForImportId ($a_import_id)
 
static _getAllReferences ($a_id)
 
static _lookupTitle ($a_id)
 
static _lookupOwner ($a_id)
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 
static _getLastUpdateOfObjects ($a_objs)
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id, $a_deleted_by)
 
static _resetDeletedDate ($a_ref_id)
 
static _lookupDeletedDate ($a_ref_id)
 
static _writeTitle ($a_obj_id, $a_title)
 
static _writeDescription ($a_obj_id, $a_desc)
 
static _writeImportId ($a_obj_id, $a_import_id)
 
static _lookupType ($a_id, $a_reference=false)
 
static _isInTrash ($a_ref_id)
 
static _hasUntrashedReference ($a_obj_id)
 
static _lookupObjectId ($a_ref_id)
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $a_show_path=true)
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id, $a_deleted_by)
 
static setDeletedDates ($a_ref_ids, $a_user_id)
 Set deleted date. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon ( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Detailed Description

Member Function Documentation

◆ appendStream()

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

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

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

182  : int
183  {
184  if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
185  $revision = $this->manager->appendNewRevisionFromStream($i, $stream, $this->stakeholder, $title);
186  } else {
187  $i = $this->manager->stream($stream, $this->stakeholder, $title);
188  $revision = $this->manager->getCurrentRevision($i);
189  $this->setResourceId($i->serialize());
190  $this->initImplementation();
191  }
192  $this->updateObjectFromRevision($revision);
193 
194  return $revision->getVersionNumber();
195  }
updateObjectFromRevision(Revision $r, bool $create_previews=true)
setResourceId(?string $resource_id)
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ appendSuffixToTitle()

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

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

Referenced by appendUpload(), and replaceWithUpload().

167  : string
168  {
169  // bugfix mantis 0026160 && 0030391 and 0032340
170  $title_info = new SplFileInfo($title);
171  $filename_info = new SplFileInfo($filename);
172 
173  $filename = str_replace('.' . $title_info->getExtension(), '', $title_info->getPathname());
174  $extension = $filename_info->getExtension();
175 
176  return $this->secure($filename . '.' . $extension);
177  }
+ Here is the caller graph for this function:

◆ appendUpload()

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

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

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

Referenced by getUploadFile().

200  : int
201  {
202  $title = $this->appendSuffixToTitle($title, $result->getName());
203  if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
204  $revision = $this->manager->appendNewRevision($i, $result, $this->stakeholder, $title);
205  } else {
206  $i = $this->manager->upload($result, $this->stakeholder, $title);
207  $revision = $this->manager->getCurrentRevision($i);
208  $this->setResourceId($i->serialize());
209  $this->initImplementation();
210  }
213  }
214  $this->updateObjectFromRevision($revision);
215 
216  return $revision->getVersionNumber();
217  }
appendSuffixToTitle(string $title, string $filename)
updateObjectFromRevision(Revision $r, bool $create_previews=true)
setPageCount($page_count)
setResourceId(?string $resource_id)
$i
Definition: metadata.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ beforeDelete()

ilObjFile::beforeDelete ( )
protected

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

562  {
563  // check, if file is used somewhere
564  $usages = $this->getUsages();
565  if (count($usages) == 0) {
566  return true;
567  }
568 
569  return false;
570  }

◆ beforeUpdate()

ilObjFile::beforeUpdate ( )
protected

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

References getMode(), and ilObject2\updateMetaData().

552  {
553  // no meta data handling for file list files
554  if ($this->getMode() != self::MODE_FILELIST) {
555  $this->updateMetaData();
556  }
557 
558  return true;
559  }
+ Here is the call graph for this function:

◆ checkFileExtension()

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

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

References ilObjFileAccess\_getFileExtension(), and getFileName().

779  {
780  $fileExtension = ilObjFileAccess::_getFileExtension($new_filename);
781  $titleExtension = ilObjFileAccess::_getFileExtension($new_title);
782  if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
783  // remove old extension
784  $pi = pathinfo($this->getFileName());
785  $suffix = $pi["extension"];
786  if ($suffix != "") {
787  if (substr($new_title, strlen($new_title) - strlen($suffix) - 1) == "." . $suffix) {
788  $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
789  }
790  }
791  $new_title .= '.' . $fileExtension;
792  }
793 
794  return $new_title;
795  }
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
+ Here is the call graph for this function:

◆ clearDataDirectory()

ilObjFile::clearDataDirectory ( )

Deprecated:

Implements ilObjFileImplementationInterface.

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

682  {
683  $this->implementation->clearDataDirectory();
684  }

◆ createDirectory()

ilObjFile::createDirectory ( )
Returns
void
Deprecated:

Implements ilObjFileImplementationInterface.

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

625  {
626  // we no longer create directories
627  }

◆ deleteVersions()

ilObjFile::deleteVersions (   $a_hist_entry_ids = null)

Deprecated:

Implements ilObjFileImplementationInterface.

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

691  {
692  $this->implementation->deleteVersions($a_hist_entry_ids);
693  }

◆ doCreate()

ilObjFile::doCreate (   $a_upload = false)
protected
Parameters
false$a_upload

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

References $DIC, CLIENT_DATA_DIR, ilObject2\cloneMetaData(), ilPreview\copyPreviews(), createProperties(), ilObject2\doCloneObject(), ilObject2\doRead(), ilObject2\getDescription(), getDirectory(), getFileName(), getFileSize(), getFileType(), ilObject\getId(), getMode(), ilObject2\getTitle(), getVersion(), hasRating(), initImplementation(), notifyCreation(), setFileName(), setFileSize(), setFileType(), setMaxVersion(), ilFileObjectToStorageMigrationRunner\setMigrateToNewObjectId(), setMode(), setPageCount(), setRating(), setResourceId(), and setVersion().

432  {
433  $this->createProperties($a_upload);
434  $this->notifyCreation($this->getId(), $this->getDescription());
435  }
getId()
get object id public
notifyCreation(int $obj_id, string $additional_message=null)
createProperties($a_upload=false)
The basic properties of a file object are stored in table object_data.
+ Here is the call graph for this function:

◆ doDelete()

ilObjFile::doDelete ( )
protected

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

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

573  {
574  global $DIC;
575 
576  // delete file data entry
577  $DIC->database()->manipulateF("DELETE FROM file_data WHERE file_id = %s", ['integer'], [$this->getId()]);
578 
579  // delete history entries
581 
582  // delete meta data
583  if ($this->getMode() != self::MODE_FILELIST) {
584  $this->deleteMetaData();
585  }
586 
587  // delete preview
588  $this->deletePreview();
589 
590  // delete resource
591  $identification = $this->getResourceId();
592  if ($identification && $identification != '-') {
593  $resource = $this->manager->find($identification);
594  if ($resource !== null) {
595  $this->manager->remove($resource, $this->stakeholder);
596  }
597  }
598  }
getId()
get object id public
global $DIC
Definition: goto.php:24
static _removeEntriesForObject($a_obj_id)
remove all history entries for an object
+ Here is the call graph for this function:

◆ doUpdate()

ilObjFile::doUpdate ( )
protected

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

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

526  {
527  global $DIC;
528 
529  $a_columns = $this->getArrayForDatabase();
530  $DIC->database()->update('file_data', $a_columns, [
531  'file_id' => [
532  'integer',
533  $this->getId(),
534  ],
535  ]);
536 
537  // update metadata with the current file version
538  $meta_version_column = ['meta_version' => ['integer', (int) $this->getVersion()]];
539  $DIC->database()->update('il_meta_lifecycle', $meta_version_column, [
540  'rbac_id' => [
541  'integer',
542  $this->getId(),
543  ],
544  ]);
545 
546  $this->notifyUpdate($this->getId(), $this->getDescription());
547 
548  return true;
549  }
getId()
get object id public
global $DIC
Definition: goto.php:24
notifyUpdate(int $obj_id, string $additional_message=null)
+ Here is the call graph for this function:

◆ export()

ilObjFile::export ( string  $target_dir)
Parameters
string$target_dir
Deprecated:

Implements ilObjFileImplementationInterface.

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

717  : void
718  {
719  $this->implementation->export($target_dir);
720  }

◆ getAction()

ilObjFile::getAction ( )
Returns
string
Deprecated:

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

References $action.

406  {
407  return $this->action;
408  }

◆ getArrayForDatabase()

ilObjFile::getArrayForDatabase ( )
private
Returns
array

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

References getFileName(), getFileSize(), getFileType(), ilObject\getId(), getMaxVersion(), getMode(), getPageCount(), getVersion(), and hasRating().

Referenced by doUpdate().

603  : array
604  {
605  return [
606  'file_id' => ['integer', $this->getId()],
607  'file_name' => ['text', $this->getFileName()],
608  'file_type' => ['text', $this->getFileType()],
609  'file_size' => ['integer', (int) $this->getFileSize()],
610  'version' => ['integer', (int) $this->getVersion()],
611  'max_version' => ['integer', (int) $this->getMaxVersion()],
612  'f_mode' => ['text', $this->getMode()],
613  'page_count' => ['text', $this->getPageCount()],
614  'rating' => ['integer', $this->hasRating()],
615  'rid' => ['text', $this->resource_id ?? ''],
616  ];
617  }
getId()
get object id public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDirectory()

ilObjFile::getDirectory (   $a_version = 0)
Parameters
int$a_version
Returns
string
Deprecated:

Implements ilObjFileImplementationInterface.

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

Referenced by doCreate(), and storeUnzipedFile().

264  {
265  return $this->implementation->getDirectory($a_version);
266  }
+ Here is the caller graph for this function:

◆ getFile()

ilObjFile::getFile (   $a_hist_entry_id = null)
Parameters
null$a_hist_entry_id
Returns
string
Deprecated:

Implements ilObjFileImplementationInterface.

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

Referenced by ilCollectWorkspaceFilesJob\getFileDirs().

259  {
260  return $this->implementation->getFile($a_hist_entry_id);
261  }
+ Here is the caller graph for this function:

◆ getFileExtension()

ilObjFile::getFileExtension ( )
Returns
string
Deprecated:

Implements ilObjFileImplementationInterface.

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

802  {
803  return $this->implementation->getFileExtension();
804  }

◆ getFileName()

ilObjFile::getFileName ( )
Returns
string

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

References $filename.

Referenced by checkFileExtension(), doCreate(), getArrayForDatabase(), and initImplementation().

282  {
283  return $this->filename;
284  }
+ Here is the caller graph for this function:

◆ getFileSize()

ilObjFile::getFileSize ( )

Implements ilObjFileImplementationInterface.

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

References $filesize.

Referenced by doCreate(), and getArrayForDatabase().

339  {
340  return $this->filesize;
341  }
+ Here is the caller graph for this function:

◆ getFileType()

ilObjFile::getFileType ( )
Returns
string

Implements ilObjFileImplementationInterface.

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

References $filetype.

Referenced by doCreate(), and getArrayForDatabase().

355  {
356  return $this->filetype;
357  }
+ Here is the caller graph for this function:

◆ getMaxVersion()

ilObjFile::getMaxVersion ( )

Implements ilObjFileImplementationInterface.

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

References $max_version.

Referenced by getArrayForDatabase().

376  {
377  return $this->max_version;
378  }
+ Here is the caller graph for this function:

◆ getMode()

ilObjFile::getMode ( )
Returns
string

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

References $mode.

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

326  {
327  return $this->mode;
328  }
+ Here is the caller graph for this function:

◆ getPageCount()

ilObjFile::getPageCount ( )
Returns
int

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

References $page_count.

Referenced by getArrayForDatabase().

389  {
390  return $this->page_count;
391  }
+ Here is the caller graph for this function:

◆ getResourceId()

ilObjFile::getResourceId ( )

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

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

312  : ?string
313  {
314  return $this->resource_id ?? '-';
315  }
+ Here is the caller graph for this function:

◆ getStorageID()

ilObjFile::getStorageID ( )

Implements ilObjFileImplementationInterface.

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

317  : ?string
318  {
319  return $this->implementation->getStorageID();
320  }

◆ getUploadFile()

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

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 656 of file class.ilObjFile.php.

References $results, $upload, appendUpload(), and prepareUpload().

656  : bool
657  {
658  $this->prepareUpload();
659 
660  $results = $this->upload->getResults();
661  $upload = $results[$a_upload_file];
662 
663  $this->appendUpload($upload, $title);
664 
665  return true;
666  }
appendUpload(UploadResult $result, string $title)
$results
+ Here is the call graph for this function:

◆ getVersion()

ilObjFile::getVersion ( )

Implements ilObjFileImplementationInterface.

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

References $version.

Referenced by ILIAS\File\Sanitation\FilePathSanitizer\__construct(), doCreate(), doUpdate(), getArrayForDatabase(), initImplementation(), and storeUnzipedFile().

269  {
270  return $this->version;
271  }
+ Here is the caller graph for this function:

◆ getVersions()

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

Implements ilObjFileImplementationInterface.

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

752  : array
753  {
754  return $this->implementation->getVersions($version_ids);
755  }

◆ handleChangedObjectTitle()

ilObjFile::handleChangedObjectTitle ( string  $new_title)

Implements ilObjFileImplementationInterface.

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

References ilObject2\setTitle().

420  {
421  $this->setTitle($new_title);
422  $this->implementation->handleChangedObjectTitle($new_title);
423  }
setTitle($a_title)
+ Here is the call graph for this function:

◆ hasRating()

ilObjFile::hasRating ( )
Returns
bool

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

References $rating.

Referenced by doCreate(), and getArrayForDatabase().

371  {
372  return $this->rating;
373  }
+ Here is the caller graph for this function:

◆ initImplementation()

ilObjFile::initImplementation ( )
protected

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

References ilObject\$id, getFileName(), ilObject\getId(), getVersion(), setMaxVersion(), and setVersion().

Referenced by appendStream(), appendUpload(), and doCreate().

132  : void
133  {
134  if ($this->resource_id && ($id = $this->manager->find($this->resource_id)) !== null) {
135  $resource = $this->manager->getResource($id);
136  $this->implementation = new ilObjFileImplementationStorage(
137  $resource,
138  (int) $this->getId()
139  );
140  $this->setMaxVersion($resource->getMaxRevision());
141  $this->setVersion($resource->getMaxRevision());
142  } else {
143  $this->implementation = new ilObjFileImplementationLegacy(
144  (int) $this->getId(),
145  (int) $this->getVersion(),
146  (string) $this->getFileName()
147  );
148  $s = new FilePathSanitizer($this);
149  $s->sanitizeIfNeeded();
150  }
151  }
Class ilObjFileImplementationLegacy.
Class ilObjFileImplementationStorage.
setVersion($a_version)
getId()
get object id public
setMaxVersion($a_max_version)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initType()

ilObjFile::initType ( )

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

620  {
621  $this->type = "file";
622  }

◆ isHidden()

ilObjFile::isHidden ( )
Returns
bool
Deprecated:

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

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

673  {
674  return ilObjFileAccess::_isFileHidden($this->getTitle());
675  }
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
+ Here is the call graph for this function:

◆ isInline()

ilObjFile::isInline ( )
Returns
bool
Deprecated:

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

References ilObjFileAccess\_isFileInline(), and ilObject2\getTitle().

709  {
710  return ilObjFileAccess::_isFileInline($this->getTitle());
711  }
static _isFileInline($a_file_name)
Returns true, if the specified file shall be displayed inline in the browser.
+ Here is the call graph for this function:

◆ prepareUpload()

ilObjFile::prepareUpload ( )
private

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

Referenced by getUploadFile().

640  : void
641  {
642  if (true !== $this->upload->hasBeenProcessed()) {
643  if (defined('PATH_TO_GHOSTSCRIPT') && PATH_TO_GHOSTSCRIPT !== "") {
644  $this->upload->register(new ilCountPDFPagesPreProcessors());
645  }
646 
647  $this->upload->process();
648  }
649  }
Class ilCountPDFPagesPreProcessors.
+ Here is the caller graph for this function:

◆ raiseUploadError()

ilObjFile::raiseUploadError (   $raise = false)

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

630  {
631  // we no longer support that
632  }

◆ replaceFile()

ilObjFile::replaceFile (   $a_upload_file,
  $a_filename 
)
Parameters
$a_upload_file
$a_filename
Returns
Exceptions

Implements ilObjFileImplementationInterface.

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

636  {
637  return null;
638  }

◆ replaceWithStream()

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

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

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

222  : int
223  {
224  if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
225  $revision = $this->manager->replaceWithStream($i, $stream, $this->stakeholder, $title);
226  } else {
227  throw new LogicException('only files with existing resource and revision can be replaced');
228  }
229  $this->updateObjectFromRevision($revision);
230 
231  return $revision->getVersionNumber();
232  }
updateObjectFromRevision(Revision $r, bool $create_previews=true)
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ replaceWithUpload()

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

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

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

237  : int
238  {
239  $title = $this->appendSuffixToTitle($title, $result->getName());
240  if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
241  $revision = $this->manager->replaceWithUpload($i, $result, $this->stakeholder, $title);
242  } else {
243  throw new LogicException('only files with existing resource and revision can be replaced');
244  }
247  }
248  $this->updateObjectFromRevision($revision);
249 
250  return $revision->getVersionNumber();
251  }
appendSuffixToTitle(string $title, string $filename)
updateObjectFromRevision(Revision $r, bool $create_previews=true)
setPageCount($page_count)
$i
Definition: metadata.php:24
+ 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 761 of file class.ilObjFile.php.

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

761  : void
762  {
763  if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
764  $this->manager->rollbackRevision($i, $version_id);
765  $latest_revision = $this->manager->getCurrentRevision($i);
766  $this->updateObjectFromRevision($latest_revision);
767  } else {
768  throw new LogicException('only files with existing resource and revision can be replaced');
769  }
770  }
updateObjectFromRevision(Revision $r, bool $create_previews=true)
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ sendFile()

ilObjFile::sendFile (   $a_hist_entry_id = null)
Parameters
null$a_hist_entry_id
Returns
bool

Implements ilObjFileImplementationInterface.

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

699  : void
700  {
701  $this->implementation->sendFile($a_hist_entry_id);
702  }

◆ setAction()

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

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

415  {
416  $this->action = $a_action;
417  }

◆ setFileName()

ilObjFile::setFileName (   $a_name)
Parameters
string$a_name

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

Referenced by doCreate(), and updateObjectFromRevision().

290  {
291  $this->filename = $a_name;
292  }
+ Here is the caller graph for this function:

◆ setFileSize()

ilObjFile::setFileSize (   $a_size)
Parameters
$a_size

Implements ilObjFileImplementationInterface.

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

Referenced by doCreate(), and updateObjectFromRevision().

347  {
348  $this->filesize = $a_size;
349  }
+ Here is the caller graph for this function:

◆ setFileType()

ilObjFile::setFileType (   $a_type)
Parameters
string$a_type

Implements ilObjFileImplementationInterface.

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

Referenced by doCreate(), and updateObjectFromRevision().

363  {
364  $this->filetype = $a_type;
365  }
+ Here is the caller graph for this function:

◆ setMaxVersion()

ilObjFile::setMaxVersion (   $a_max_version)
Parameters
$a_max_version
Deprecated:

Implements ilObjFileImplementationInterface.

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

Referenced by doCreate(), initImplementation(), and updateObjectFromRevision().

381  {
382  $this->max_version = $a_max_version;
383  }
+ Here is the caller graph for this function:

◆ setMode()

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

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

Referenced by doCreate().

334  {
335  $this->mode = $a_mode;
336  }
+ Here is the caller graph for this function:

◆ setPageCount()

ilObjFile::setPageCount (   $page_count)
Parameters
int$page_count

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

References $page_count.

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

397  {
398  $this->page_count = $page_count;
399  }
+ Here is the caller graph for this function:

◆ setRating()

ilObjFile::setRating (   $a_value)
Parameters
bool$a_value

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

Referenced by doCreate().

298  {
299  $this->rating = (bool) $a_value;
300  }
+ Here is the caller graph for this function:

◆ setResourceId()

ilObjFile::setResourceId ( ?string  $resource_id)
Parameters
string | null$resource_id
Returns
ilObjFile

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

References $resource_id.

Referenced by appendStream(), appendUpload(), and doCreate().

306  : ilObjFile
307  {
308  $this->resource_id = $resource_id;
309  return $this;
310  }
+ Here is the caller graph for this function:

◆ setVersion()

ilObjFile::setVersion (   $a_version)
Parameters
$a_version
Deprecated:

Implements ilObjFileImplementationInterface.

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

Referenced by doCreate(), initImplementation(), storeUnzipedFile(), and updateObjectFromRevision().

274  {
275  $this->version = $a_version;
276  }
+ Here is the caller graph for this function:

◆ storeUnzipedFile()

ilObjFile::storeUnzipedFile (   $a_upload_file,
  $a_filename 
)

storeUnzipedFile Stores Files unzipped from uploaded archive in filesystem

Parameters
string$a_upload_file
string$a_filename
Deprecated:

Implements ilObjFileImplementationInterface.

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

References getDirectory(), ilFileUtils\getValidFilename(), getVersion(), ilUtil\makeDir(), ilFileUtils\rename(), and setVersion().

731  {
732  $this->setVersion($this->getVersion() + 1);
733 
734  if (@!is_dir($this->getDirectory($this->getVersion()))) {
735  ilUtil::makeDir($this->getDirectory($this->getVersion()));
736  }
737 
738  $file = $this->getDirectory($this->getVersion()) . "/" . $a_filename;
739 
740  $file = ilFileUtils::getValidFilename($file);
741 
742  ilFileUtils::rename($a_upload_file, $file);
743 
744  // create preview
745  $this->createPreview();
746  }
setVersion($a_version)
getDirectory($a_version=0)
static rename($a_source, $a_target)
Rename a file.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getValidFilename($a_filename)
Get valid filename.
+ Here is the call graph for this function:

◆ updateObjectFromRevision()

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

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

References ILIAS\ResourceStorage\Revision\Revision\getInformation(), ILIAS\ResourceStorage\Revision\Revision\getTitle(), ILIAS\ResourceStorage\Revision\Revision\getVersionNumber(), setFileName(), setFileSize(), setFileType(), setMaxVersion(), ilObject2\setTitle(), setVersion(), and ilObject2\update().

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

153  : void
154  {
155  $this->setTitle($r->getTitle());
156  $this->setFileName($r->getInformation()->getTitle());
157  $this->setVersion($r->getVersionNumber());
158  $this->setMaxVersion($r->getVersionNumber());
159  $this->setFileSize($r->getInformation()->getSize());
160  $this->setFileType($r->getInformation()->getMimeType());
161  $this->update();
162  if ($create_previews) {
163  $this->createPreview(true);
164  }
165  }
setFileType($a_type)
setFileName($a_name)
setVersion($a_version)
setFileSize($a_size)
setTitle($a_title)
setMaxVersion($a_max_version)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $action

ilObjFile::$action
protected

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

Referenced by getAction().

◆ $filename

ilObjFile::$filename = ''
protected

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

Referenced by getFileName().

◆ $filesize

ilObjFile::$filesize
protected

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

Referenced by getFileSize().

◆ $filetype

ilObjFile::$filetype = ''
protected

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

Referenced by getFileType().

◆ $implementation

ilObjFile::$implementation
protected

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

◆ $log

ilObjFile::$log
protected

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

◆ $manager

ilObjFile::$manager
protected

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

◆ $max_version

ilObjFile::$max_version = 1
protected

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

Referenced by getMaxVersion().

◆ $mode

ilObjFile::$mode = self::MODE_OBJECT

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

Referenced by getMode().

◆ $page_count

ilObjFile::$page_count = 0
protected

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

Referenced by getPageCount(), and setPageCount().

◆ $rating

ilObjFile::$rating = false
protected

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

Referenced by hasRating().

◆ $resource_id

ilObjFile::$resource_id
protected

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

Referenced by setResourceId().

◆ $stakeholder

ilObjFile::$stakeholder
protected

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

◆ $upload

ilObjFile::$upload
protected

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

Referenced by getUploadFile().

◆ $version

ilObjFile::$version = 1
protected

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

Referenced by getVersion().

◆ MODE_FILELIST

const ilObjFile::MODE_FILELIST = "filelist"

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

◆ MODE_OBJECT

const ilObjFile::MODE_OBJECT = "object"

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


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