Version
class Version implements ObjectInterface (View source)
Represents a version of a file.
Traits
Constants
UT_REPLACE_FILE |
Update type: file replaced. |
UT_TITLE |
Update type: title updated. |
UT_DESCRIPTION |
Update type: description updated. |
UT_TAGS |
Update type: tags modified. |
UT_EXTENDED_ATTRIBUTE |
Update type: extended attributes changed. |
UT_CONTENTS |
Update type: contents changed. |
UT_RENAME |
Update type: file version renamed. |
Properties
protected File | $file | The associated File instance. |
|
protected int | $fvID | The progressive file version identifier. |
|
protected string | $fvFilename | The name of the file. |
|
protected string | $fvPrefix | The path prefix used to store the file in the file system. |
|
protected DateTime | $fvDateAdded | The date/time when the file version has been added. |
|
protected DateTime | $fvActivateDateTime | The date/time when the file version has been approved. |
|
protected bool | $fvIsApproved | Is this version the approved one for the associated file? |
|
protected int | $fvAuthorUID | The ID of the user that created the file version. |
|
protected int | $fvApproverUID | The ID of the user that approved the file version. |
|
protected int | $fvSize | The size (in bytes) of the file version. |
|
protected string|null | $fvTitle | The title of the file version. |
|
protected string|null | $fvDescription | The description of the file version. |
|
protected string|null | $fvExtension | The extension of the file version. |
|
protected string|null | $fvTags | The tags assigned to the file version (separated by a newline character - '\n'). |
|
protected int | $fvType | The type of the file version. |
|
protected bool | $fvHasListingThumbnail | Does this file version has a thumbnail to be used for file listing? |
|
protected bool | $fvHasDetailThumbnail | Does this file version has a thumbnail to be used used for details? |
|
private ImageInterface|false|null | $imagineImage | The currently loaded Image instance. |
Methods
No description
No description
Sets the attribute of a user info object to the specified value, and saves it in the database.
Initialize the instance.
Normalize the tags separator, remove empty tags.
Get the ID of the associated file instance.
Set the progressive file version identifier.
Get the progressive file version identifier.
Rename the file.
Update the filename and the path prefix of the file.
Set the name of the file.
Get the name of the file.
Get the path prefix used to store the file in the file system.
Get the date/time when the file version has been added.
Get the date/time when the file version has been activated (or NULL if the file version is not approved).
Mark this file version as approved (and disapprove all the other versions of the file).
Mark this file version as not approved.
Is this version the approved one for the associated file?
Get the ID of the user that created the file version.
Get the username of the user that created the file version (or "Unknown").
Get the ID of the user that approved the file version.
Get the username of the user that approved the file version (or "Unknown").
Get the file size of the file (in bytes).
Get the formatted file size.
Update the title of the file.
Get the title of the file version.
Update the description of the file.
Get the description of the file version.
Get the extension of the file version.
Update the tags associated to the file.
Get the tags assigned to the file version (as a list of strings).
Get the tags assigned to the file version (one tag per line - lines are separated by '\n').
Get the mime type of the file if known.
Get the type of the file.
Get the name of the file type.
Get the localized name of the file type.
Get the localized name of the generic category type.
Log updates to files.
Get an array containing human-readable descriptions of everything that happened to this file version.
Get the path to the file relative to the webroot (may not exist).
Get an URL that points to the file on disk (if not available, you'll get the result of the getDownloadURL method).
Get an URL that can be used to download the file.
Get an URL that can be used to download the file (it will force the download of all file types, even if the browser can display them).
Get a Response instance that will force the browser to download the file, even if the browser can display it.
Check if there is a viewer for the type of the file.
Check if there is an editor for the type of the file.
Duplicate the underlying file and assign its new position to this instance.
Delete this version of the file.
Get an abstract object to work with the actual file resource (note: this is NOT a concrete5 File object).
Update the contents of the file.
Get the contents of the file.
Rescan all the attributes of this file version.
Get the list of attributes associated to this file version.
Get an \Imagine\Image\ImageInterface representing the image.
Does the \Imagine\Image\ImageInterface instance have already been loaded?
Unload the loaded Image instance.
Create missing thumbnails (or re-create all the thumbnails).
Import an existing file as a thumbnail type version.
Get the list of all the thumbnails.
Get the HTML that renders the thumbnail for the details (a generic type icon if the thumbnail does not exist).
Get the HTML that renders the thumbnail for the file listing (a generic type icon if the thumbnail does not exist).
Move the thumbnail of a specific thumbnail type version to a new storage location.
Copy the thumbnail of a specific thumbnail type version from another file version (useful for instance when duplicating a file).
Get a representation of this Version instance that's easily serializable.
Save the instance changes.
Details
CategoryInterface
getObjectAttributeCategory()
No description
AttributeValueInterface|null
getAttributeValueObject(AttributeKeyInterface|string $ak, bool $createIfNotExists = false)
No description
getAttribute($ak, $mode = false)
No description
Value
getAttributeValue($ak)
No description
clearAttribute($ak)
No description
Value
setAttribute($ak, mixed $value)
Sets the attribute of a user info object to the specified value, and saves it in the database.
__construct()
Initialize the instance.
static Version
add(File $file, string $filename, string $prefix, array $data = [])
Add a new file version.
You should call refreshAttributes in order to update the size, extension, type and other attributes.
static string
cleanTags(string $tagsStr)
Normalize the tags separator, remove empty tags.
setFile(File $file)
Set the associated File instance.
File
getFile()
Get the associated File instance.
int
getFileID()
Get the ID of the associated file instance.
setFileVersionID(int $fvID)
Set the progressive file version identifier.
int
getFileVersionID()
Get the progressive file version identifier.
rename(string $filename)
Rename the file.
updateFile(string $filename, string $prefix)
Update the filename and the path prefix of the file.
setFilename(string $filename)
Set the name of the file.
string
getFileName()
Get the name of the file.
string
getPrefix()
Get the path prefix used to store the file in the file system.
DateTime
getDateAdded()
Get the date/time when the file version has been added.
DateTime|null
getActivateDateTime()
Get the date/time when the file version has been activated (or NULL if the file version is not approved).
approve()
Mark this file version as approved (and disapprove all the other versions of the file).
The currently logged in user (if any) will be stored as the approver.
deny()
Mark this file version as not approved.
bool
isApproved()
Is this version the approved one for the associated file?
int
getAuthorUserID()
Get the ID of the user that created the file version.
string
getAuthorName()
Get the username of the user that created the file version (or "Unknown").
int
getApproverUserID()
Get the ID of the user that approved the file version.
string
getApproverName()
Get the username of the user that approved the file version (or "Unknown").
int
getFullSize()
Get the file size of the file (in bytes).
string
getSize()
Get the formatted file size.
updateTitle(string $title)
Update the title of the file.
null|string
getTitle()
Get the title of the file version.
updateDescription(string $descr)
Update the description of the file.
null|string
getDescription()
Get the description of the file version.
null|string
getExtension()
Get the extension of the file version.
updateTags(string $tags)
Update the tags associated to the file.
string[]
getTagsList()
Get the tags assigned to the file version (as a list of strings).
null|string
getTags()
Get the tags assigned to the file version (one tag per line - lines are separated by '\n').
string|false
getMimeType()
Get the mime type of the file if known.
Type
getTypeObject()
Get the type of the file.
string
getType()
Get the name of the file type.
string
getDisplayType()
Get the localized name of the file type.
string
getGenericTypeText()
Get the localized name of the generic category type.
logVersionUpdate(int $updateTypeID, int $updateTypeAttributeID = 0)
Log updates to files.
string[]
getVersionLogComments()
Get an array containing human-readable descriptions of everything that happened to this file version.
string|null
getRelativePath()
Get the path to the file relative to the webroot (may not exist).
Return NULL if the file storage location is invalid. If the storage location does not support relative paths, you'll get the URL to the file (or the download URL if the file is not directly accessible).
string|null
getURL()
Get an URL that points to the file on disk (if not available, you'll get the result of the getDownloadURL method).
Return NULL if the file storage location is invalid. If the file is not directly accessible, you'll get the download URL.
URLInterface
getDownloadURL()
Get an URL that can be used to download the file.
This passes through the download_file single page.
URLInterface
getForceDownloadURL()
Get an URL that can be used to download the file (it will force the download of all file types, even if the browser can display them).
Response
buildForceDownloadResponse()
Get a Response instance that will force the browser to download the file, even if the browser can display it.
bool
canView()
Check if there is a viewer for the type of the file.
bool
canEdit()
Check if there is an editor for the type of the file.
Version
duplicate()
Create a new (unapproved) copy of this file version.
The new Version instance will have the current user as the author (if available), and a new version ID.
duplicateUnderlyingFile()
Duplicate the underlying file and assign its new position to this instance.
delete(bool $deleteFilesAndThumbnails = false)
Delete this version of the file.
File
getFileResource()
Get an abstract object to work with the actual file resource (note: this is NOT a concrete5 File object).
updateContents(string $contents, bool $rescanThumbnails = true)
Update the contents of the file.
string|null
getFileContents()
Get the contents of the file.
null|int
refreshAttributes(bool $rescanThumbnails = true)
Rescan all the attributes of this file version.
This will run any type-based import routines, and store those attributes, generate thumbnails, etc...
FileValue[]
getAttributes()
Get the list of attributes associated to this file version.
ImageInterface|null
getImagineImage()
Get an \Imagine\Image\ImageInterface representing the image.
bool
hasImagineImage()
Does the \Imagine\Image\ImageInterface instance have already been loaded?
releaseImagineImage()
Unload the loaded Image instance.
bool
refreshThumbnails(bool $deleteExistingThumbnails)
Create missing thumbnails (or re-create all the thumbnails).
generateThumbnail(Version $type)
Generate a thumbnail for a specific thumbnail type version.
importThumbnail(Version $version, string $path)
Import an existing file as a thumbnail type version.
string|null
getThumbnailURL(Version|string $type)
Get the URL of a thumbnail type.
If the thumbnail is smaller than the image (or if the file does not satisfy the Conditional Thumbnail criterias) you'll get the URL of the image itself.
Please remark that the path is resolved using the default core path resolver: avoid using this method when you have access to the resolver instance.
Thumbnail[]
getThumbnails()
Get the list of all the thumbnails.
string
getDetailThumbnailImage()
Get the HTML that renders the thumbnail for the details (a generic type icon if the thumbnail does not exist).
Return the thumbnail for an image or a generic type icon for a file.
string
getListingThumbnailImage()
Get the HTML that renders the thumbnail for the file listing (a generic type icon if the thumbnail does not exist).
deleteThumbnail(Version|string $type)
Delete the thumbnail for a specific thumbnail type version.
updateThumbnailStorageLocation(Version|string $type, StorageLocation $location)
Move the thumbnail of a specific thumbnail type version to a new storage location.
duplicateUnderlyingThumbnailFiles(Version|string $type, Version $source)
Copy the thumbnail of a specific thumbnail type version from another file version (useful for instance when duplicating a file).
stdClass
getJSONObject()
Get a representation of this Version instance that's easily serializable.
forceDownload()
deprecated
deprecated
No description
bool
hasThumbnail(int $level)
deprecated
deprecated
No description
bool
rescanThumbnails()
deprecated
deprecated
No description
protected
save(bool $flush = true)
Save the instance changes.