Stud.IP  6.0
LibraryFile Class Reference
Inheritance diagram for LibraryFile:
StandardFile FileType StandardFileInterface

Public Member Functions

 __construct ($fileref, $file=null)
 
 getFile ()
 
 getFileRef ()
 
 updateFromLibraryDocument (LibraryDocument $document)
 
 getIcon ($role)
 
 getFilename ()
 
 getSize ()
 
 getDownloadURL ()
 
 getPath ()
 
 getDownloads ()
 
 getActionmenu ()
 
 getInfoDialogButtons (array $extra_link_params=[])
 
 isEditable ($user_id=null)
 
 getInfoTemplate (bool $include_downloadable_infos=false)
 
 attachFile (File $file)
 
 hasFileAttached ()
 
 hasURL ()
 
 removeDataFile ()
 
- Public Member Functions inherited from StandardFile
 __construct ($fileref, $file=null)
 
 __get ($name)
 
 __set ($name, $value)
 
 __isset ($name)
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 getIcon ($role)
 
 getId ()
 
 getFilename ()
 
 getUserId ()
 
 getUserName ()
 
 getAccessibility ()
 
 getUser ()
 
 getSize ()
 
 getMimeType ()
 
 getDownloadURL ()
 
 getDownloads ()
 
 getPath ()
 
 getLastChangeDate ()
 
 getMakeDate ()
 
 getDescription ()
 
 getTermsOfUse ()
 
 getActionmenu ()
 
 getInfoDialogButtons (array $extra_link_params=[])
 
 delete ()
 
 getFolderType ()
 
 isVisible ($user_id=null)
 
 isDownloadable ($user_id=null)
 
 isEditable ($user_id=null)
 
 isWritable ($user_id=null)
 
 convertToStandardFile ()
 
 addToFolder (FolderType $standard_folder, $filename, $user_id=null)
 
 getFileRef ()
 
 getContentForAdditionalColumn ($column_index)
 
 getAdditionalColumnOrderWeigh ($column_index)
 
 getInfoTemplate (bool $include_downloadable_infos=false)
 

Static Public Member Functions

static createFromLibraryDocument (LibraryDocument $document, $folder_id=null, $user_id=null)
 
- Static Public Member Functions inherited from StandardFile
static create ($data, $user_id=null)
 

Data Fields

 $library_document = null
 

Static Protected Member Functions

static getFileNameFromDocument (LibraryDocument $document)
 

Additional Inherited Members

- Protected Attributes inherited from StandardFile
 $fileref = null
 
 $file = null
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $fileref,
  $file = null 
)

StandardFile constructor.

Parameters
$fileref
null$file: (optional) Is set if fileref and file are both new and not connected with each other in the database.

Implements StandardFileInterface.

Member Function Documentation

◆ attachFile()

attachFile ( File  $file)

This is a method special to the LibraryFile class. It handles the attachment of a (real) File object to this LibraryFile. In that case, the library metadata must be transferred from the (virtual) file that is attached to the LibraryFile to the specified file that shall be attached.

Parameters
File$fileThe file to attach to this LibraryFile.
Exceptions
ExceptionIn case of an error, an exception with an error message is thrown.

◆ createFromLibraryDocument()

static createFromLibraryDocument ( LibraryDocument  $document,
  $folder_id = null,
  $user_id = null 
)
static

◆ getActionmenu()

getActionmenu ( )

Returns an instance of ActionMenu.

Returns
ActionMenu|null

Implements FileType.

◆ getDownloads()

getDownloads ( )

Returns the number of downloads this file already has. Returns null if information is not available.

Returns
integer|null

Implements FileType.

◆ getDownloadURL()

getDownloadURL ( )

Returns the URL to download the file. May be sendfile.php?... or an external link.

Returns
string|null

Implements FileType.

◆ getFile()

getFile ( )

◆ getFilename()

getFilename ( )

Filename of the FileType-object.

Returns
mixed

Implements FileType.

◆ getFileNameFromDocument()

static getFileNameFromDocument ( LibraryDocument  $document)
staticprotected

Extracts a file name from a LibraryDocument instance. This is an internal helper method.

Parameters
LibraryDocument$documentThe document from which a file name shall be extracted.
Returns
string The extracted file name.

◆ getFileRef()

getFileRef ( )

◆ getIcon()

getIcon (   $role)

Returns the name of the icon shape that shall be used with the FileType implementation.

Parameters
string$rolerole of icon
Returns
Icon icon for the FileType implementation.

Implements FileType.

◆ getInfoDialogButtons()

getInfoDialogButtons ( array  $extra_link_params = [])

Returns a list of Stud.IP button objects that represent actions that shall be visible for the file type in the info dialog.

Parameters
array$extra_link_paramsAn optional array of URL parameters that should be added to Button URLs, if reasonable. The parameter names are the keys of the array while their values are also the array item values.
Returns
Interactable[] A list of Stud.IP buttons (LinkButton or Button).

Implements FileType.

◆ getInfoTemplate()

getInfoTemplate ( bool  $include_downloadable_infos = false)

Generates a Flexi containing additional information that are displayes in the information dialog of a file.

Parameters
bool$include_downloadable_infosWhether to include information like file previews that can be downloaded (true) or to not include them (false). Defaults to false.
Returns
Flexi|null Either a Flexi containing additional information or null if no such information shall be displayed in the information dialog.

Implements FileType.

◆ getPath()

getPath ( )

Returns the (real) file system path for the file. This is only relevant for FileType implementations storing real files on the server disk. Other implementations shall just return an empty string.

Returns
The file system path for the file or an empty string if the file doesn't have a path in the file system.

Implements FileType.

◆ getSize()

getSize ( )

Returns the size of the file in bytes. If this is null, the file doesn't exist physically - is probably only a weblink or a request for libraries.

Returns
integer|null

Implements FileType.

◆ hasFileAttached()

hasFileAttached ( )

This method checks if a real file is attached to this library file.

Returns
bool True, if a real file is attached, false otherwise.

◆ hasURL()

hasURL ( )

◆ isEditable()

isEditable (   $user_id = null)

Determines if a user may edit the file.

Parameters
string$user_idThe user who wishes to edit the file.
Returns
boolean True, if the user is permitted to edit the file, false otherwise.

Implements FileType.

◆ removeDataFile()

removeDataFile ( )

◆ updateFromLibraryDocument()

updateFromLibraryDocument ( LibraryDocument  $document)

Updates the LibraryFile by using a LibraryDocument instance.

Parameters
LibraryDocument$documentThe document containing the new data.
Returns
bool True, if the update was successful, false otherwise.

Field Documentation

◆ $library_document

$library_document = null

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