|
|
|
|
Extends class: HammerKit_BasicFile
Implements interface: HammerKit_MultilevelObjectInterface
This class describes and contains the functionality for adding, removing and managing files, directories and their attributes. A file is uniquely identified by its id or path attribute value. When a reference to a file is saved it should always be the id value that is saved and not the path value, because the path value changes when a file is moved in the file system to another folder but the id value stays the same. If a file is not yet registered in the database and has no id number, then the file can be fetched by using the path. This will automatically register the file in the database and the file will get an id number.
The File object can also be created through dynamic specials, which basically are global variables containing the value of a file's id or path attributes. All special values are expressed in valid HammerScript.
Examples: file(user(thisUser).folder) gets the currently logged-in user's folder and file(cgi.file_id) gets the file which id is in the cgi variable file_id.
NOTE! If the special refers to a non-existent folder then the folder will be created if possible.
--- OLD 3.3 METHOD ---
The File object can also be created through dynamic specials, which basically are global variables containing the value of a file's id or path attributes. All the specials have the following format: [special_type]:[special_value]. The recognized special types are:
- cgi: cgi variable name
- componentFolder: component id or component special such as thisComponent
- userFolder: user id or user special such as thisUser
- messageFolder: this special has no value, cgi.__msg_id__ is allways used as the value
--- OLD METHOD END ---
unique string abspath
Description: The absolute path of the file in the file system, including the file's name.
Settable: no
integer access_count
Description: The number of times the file has been accesses through the site, safe files only.
Settable: no
time access_first_time
Description: The time of the first access.
Settable: no
time access_last_time
Description: The time of the last access.
Settable: no
HammerKit_ObjectList(HammerKit_File) ancestors
Description: A HammerKit_ObjectList of file ids ordered as they appear in the file hierarchy from top to bottom.
Settable: no
time creation_time
Description: The time the file was added to the database.
Settable: no
string contents
Description: The contents of the file as a text string.
Settable: no
string creator
Description: The name of the creator of the file.
Settable: yes
string datapath
Description: The path of the file under the file's data root, not including the file's name.
Settable: no
string description
Description:
Settable: yes
array exif
Description: EXIF data of an image file.
Settable: no
integer file_type
Description: Tells if the file is a directory or a file. A directory has the value 0 and a file has the value 1.
Settable: no
string folder_type
Description: Either "web" or "safe" depending on the data root the file is located under.
Settable: no
integer height
Description: The height of an image file in pixels.
Settable: no (except in file upload forms where this attribute defines the maximum height of the uploaded image)
unique integer(HammerKit_File) id
Description: The database id number of the file.
Settable: no
array metafiles
Description: An array of metafiles defined for the file.
Settable: no
array metafiles_formatted
Description: An array of formatted metafiles defined for the file. If the metafile, specified by the metaname, is not found then a metafile is produced with formatting options defined in the file module's "Define formatted metafile behaviour" mode.
Settable: no
string mime_type
Description: The mime-type of the file.
Settable: no
time modification_time
Description: The time the file was last modified in the file system.
Settable: no
string name
Description: The name of the file/directory in the file system.
Settable: yes
integer(HammerKit_File) parent_id
Description: The id of the file's folder.
Settable: no
unique string path
Description: The file system path of a file of form [folder_type]:[datapath][name].
Settable: no
string short_description
Description: A short description of the file.
Settable: yes
string searchwords
Description: Search words that describe the file, used in file searches.
Settable: yes
bytesize size
Description: The size of the file or the size of the entire contents of a directory in the file system.
Settable: no
unique string url
Description: The URL of the file.
Settable: no
unique string url_relative
Description: The URL of the file relative to the site's URL.
Settable: no
integer(HammerKit_User) user_id
Description: The database id number of the user that owns the file.
Settable: yes
time valid_from
Description: The time from which the file is valid.
Settable: yes
time valid_to
Description: The time to which the file is valid.
Settable: yes
array variables
Description: An array of user defined key-value pairs.
Settable: yes
integer visible
Description: The visibility of a file.
Settable: yes (with admin rights)
Possible: 0, 1 and 2
integer width
Description: The width of an image file in pixels.
Settable: no (except in file upload forms where this attribute defines the maximum width of the uploaded image)
constructor __construct(integer id) OR File(string path)
Description: Creates a file object.
Arguments: id is the id or a special of the file to create an object for
HammerKit_File addDirectory(array attributes)
Description: Creates a new directory under the current directory.
Arguments: attributes is an array of file attributes
Returns: on success the File object of the new directory otherwise FALSE
HammerKit_File/HammerKit_File[] addFile(string file_abspath [, array attributes [, array options]])
Description: Creates a new file or metafile under the current directory.
Arguments: file_abspath is the path to the file to save, attributes is an array of file attributes, options is an array of options (UNPACK_ARCHIVE|REMOVE_ORIGINAL)
Returns: on success the HammerKit_File object (or array of HammerKit_File objects if unpacking an archive) of the new file otherwise FALSE
boolean canDo(string operation [, integer user_id])
Description: Check if a user can do an operation on a file.
Arguments: operation can have the values view, modify, setvisible, setaccess and remove, user_id is by default the id of the logged in user
Returns: TRUE if the user can do the operation on the file, otherwise FALSE
mixed getAttribute(string attribute [, boolean formatted [, array format_options]])
Description: Gets the value of a file attribute.
Arguments: attribute is the name of a file attribute
Returns: the value of the attribute and FALSE if the given attribute is invalid
string[string[]] getAttributeList([string property])
Description: Returns an array describing all the possible attributes for a file object.
Arguments:
Returns: the array of attributes where the keys are the attribute names and the values are arrays containing the properties of the attributes
string getChooser(string name [, string value [, array specials [, array settings [, array options]]]])
Description: See the description of the HammerkitObject interface.
array getFileList([string sort_attribute [, boolean reverse_order [, array options]]])
Description: Get a list of all the files in the current directory.
Arguments: sort_attribute is the file attribute by which to sort the color list - default value is "name" - can also get the value "random" which returns the lists in a random order, reverse_order determines if the list is returned in reverse order - default value FALSE
Returns: an array where key 0 is an array of directory ids and key 1 is an array of file ids both sorted by the sorting arguments
integer[](HammerKit_Keyword) getKeywords(void)
Description: Get the keywords that are linked to the file.
Returns: an array of keyword ids
HammerKit_ObjectList(HammerKit_File) getList([array where])
Description: see the description of the HammerkitObject interface
HammerKit_File getMetafile(string metaname [, boolean formatted [, array format_options]])
Description: Get a metafile for the current file.
Arguments: metaname defines the metaname of the metafile to get, formatted defines if formatting is to be attempted if the actual metafile is not found, format_options defines the methods in which to try to find a substitute for a missing metafile
Returns: A file object.
boolean remove(void)
Description: See the description of the HammerkitObject interface.
array search([string sort_attribute [, boolean reverse_order [, array options [, array search_parameters]]]])
Description: Get a list of all the files in the current directory.
Arguments: sort_attribute is the file attribute by which to sort the color list - default value is "name", reverse_order determines if the list is returned in reverse order - default value FALSE
Returns: an array where key 0 is an array of directory ids and key 1 is an array of file ids both sorted by the sorting arguments
boolean setAttributes(array attributes)
Description: Sets the values of settable file attributes to the database.
Arguments: attributes is an array where the kays are valid file object attribute names and the values are the corresponding values of the attributes
Returns: TRUE on success and FALSE otherwise |
� HammerKit Oy 2008 |
UPDATED: 03.12.2008 15:15 |
|