mixed File(
string
$root_type, integer
$root_ID, string
$rdfp_rel_path, [boolean
$load_meta = false]
)
|
|
Constructor, not meant to be called directly. Use FileCache::get_by_path() instead, which provides caching and checks that only one object for a unique file exists (references).
Parameters:
|
string |
$root_type: |
Root type: 'user', 'group', 'collection' or 'absolute' |
|
integer |
$root_ID: |
ID of the user, the group or the collection the file belongs to... |
|
string |
$rdfp_rel_path: |
Posix subpath for this file/folder, relative to the associated root (no trailing slash) |
|
boolean |
$load_meta: |
check for meta data? |
API Tags:
| Return: | false on failure, File object on success |
mixed chmod(
[string|NULL
$chmod = NULL]
)
|
|
Change file permissions on disk.
Parameters:
|
string|NULL |
$chmod: |
chmod (octal three-digit-format, eg '777'), uses $Settings for NULL (fm_default_chmod_dir, fm_default_chmod_file) |
API Tags:
| Return: | new permissions on success (octal format), false on failure |
| Access: | public |
boolean copy_to(
File
&$dest_File
)
|
|
Copy this file to a new location
Also copy meta data in Object
Parameters:
|
File |
&$dest_File: |
the target file (expected to not exist) |
API Tags:
| Return: | true on success, false on failure |
boolean create(
[string
$type = 'file'], [string
$chmod = NULL]
)
|
|
Create the file/folder on disk, if it does not exist yet.
Also sets file permissions. Also inserts meta data into DB (if file/folder was successfully created).
Parameters:
|
string |
$type: |
type ('dir'|'file') |
|
string |
$chmod: |
optional permissions (octal format), otherwise the default from $Settings gets used |
API Tags:
| Return: | true if file/folder was created, false on failure |
Insert object into DB based on previously recorded changes
API Tags:
| Return: | true on success, false on failure |
Redefinition of:
- DataObject::dbinsert()
- Insert object into DB based on previously recorded changes.
Update the DB based on previously recorded changes
API Tags:
| Return: | true on success, false on failure / no changes |
Redefinition of:
- DataObject::dbupdate()
- Update the DB based on previously recorded changes
void edit_link(
[integer
$link_itm_ID = NULL], [string
$text = NULL], [string
$title = NULL], [string
$no_access_text = NULL], [string
$actionurl = 'admin.php?ctrl=files']
)
|
|
Template function. Display link to edit file.
Parameters:
|
integer |
$link_itm_ID: |
ID of item to link to => will open the FM in link mode |
|
string |
$text: |
link text |
|
string |
$title: |
link title |
|
string |
$no_access_text: |
text to display if access denied |
|
string |
$actionurl: |
page url for the edit action |
Does the File/folder exist on disk?
API Tags:
| Return: | true, if the file or dir exists; false if not |
Get the File's directory.
Get the file's extension.
API Tags:
NULL|string get_fsgroup_name(
)
|
|
Get the owner name of the file.
NULL|string get_fsowner_name(
)
|
|
Get the owner name of the file.
Get the full path (directory and name) to the file.
If the File is a directory, the Path ends with a /
API Tags:
Get icon for this file.
Looks at the file's extension.
API Tags:
| Return: | img tag |
| Uses: | $map_iconfiles |
false|mixed get_image_size(
[string
$param = 'widthxheight']
)
|
|
Get size of an image or false if not an image
Parameters:
API Tags:
| Return: | false if the File is not an image, the requested data otherwise |
| Uses: | imgsize() |
Information Tags:
| Todo: | cache this data (NOTE: we have different params here! - imgsize() does caching already!) |
string get_lastmod_formatted(
[
$format = '#']
)
|
|
Get date/time of last modification, formatted.
Parameters:
API Tags:
| Return: | locale formatted date/time |
integer get_lastmod_ts(
)
|
|
Get timestamp of last modification.
API Tags:
Get the File's ID (MD5 of path and name)
mixed get_perms(
[string
$type = NULL]
)
|
|
Get permissions
Possible return formats are:
- 'raw'=integer
- 'lsl'=string like 'ls -l'
- 'octal'=3 digits
Default value: - 'r'/'r+w' for windows
- 'octal' for other OS
Parameters:
|
string |
$type: |
type, see desc above. |
API Tags:
string get_prefixed_name(
)
|
|
Get the name prefixed either with "Directory" or "File".
Returned string is localized.
string get_rdfp_rel_path(
)
|
|
Get the file posix path relative to it's root (no trailing /)
API Tags:
string get_rdfs_rel_path(
)
|
|
Get the file path relative to it's root, WITH trailing slash.
API Tags:
void get_root_and_rel_path(
)
|
|
Get location of file with its root (for display)
Get file size in bytes.
API Tags:
string get_size_formatted(
)
|
|
Get size of the file, formatted to nearest unit (kb, mb, etc.)
API Tags:
void get_tag(
[
$before_image = '<div class="image_block">'], [
$before_image_legend = '<div class="image_legend">'], [
$after_image_legend = '</div>'], [
$after_image = '</div>']
)
|
|
Get a complete tag (IMG or A HREF) pointing to this file.
Parameters:
|
|
$before_image: |
|
|
|
$before_image_legend: |
|
|
|
$after_image_legend: |
|
|
|
$after_image: |
|
Get the file type as a descriptive localized string.
API Tags:
| Return: | localized type name or 'Directory' or 'Unknown' |
Get the absolute file url if the file is public
Get the getfile.php url if we need to check permission before delivering the file
void get_view_link(
[
$text = NULL], [
$title = NULL], [
$no_access_text = NULL]
)
|
|
Get Link to view the file (either with viewer of with browser, etc...)
Parameters:
|
|
$text: |
|
|
|
$title: |
|
|
|
$no_access_text: |
|
Get URL to view the file (either with viewer of with browser, etc...)
Is the File a directory?
API Tags:
| Return: | true if the object is a directory, false if not |
Is the File an image?
Tries to determine if it is and caches the info.
API Tags:
| Return: | true if the object is an image, false if not |
boolean load_meta(
[boolean
$force_creation = false], [object database
$row = NULL]
)
|
|
Attempt to load meta data.
Will attempt only once and cache the result.
Parameters:
|
boolean |
$force_creation: |
create meta data in DB if it doesn't exist yet? (generates a $File->ID) |
|
object database |
$row: |
row containing all fields needed to initialize meta data |
API Tags:
| Return: | true if meta data has been loaded/initialized. |
Initializes or refreshes file properties (type, size, perms...)
boolean move_to(
string
$root_type, integer
$root_ID, string
$rdfp_rel_path
)
|
|
Move the file to another location
Also updates meta data in DB
Parameters:
|
string |
$root_type: |
Root type: 'user', 'group', 'collection' or 'absolute' |
|
integer |
$root_ID: |
ID of the user, the group or the collection the file belongs to... |
|
string |
$rdfp_rel_path: |
Subpath for this file/folder, relative the associated root (no trailing slash) |
API Tags:
| Return: | true on success, false on failure |
boolean rename_to(
string
$newname
)
|
|
Rename the file in its current directory on disk.
Also update meta data in DB.
Parameters:
|
string |
$newname: |
new name (without path!) |
API Tags:
| Return: | true on success, false on failure |
| Access: | public |
void setSize(
integer
$bytes
)
|
|
Internally sets the file/directory size
This is used when the FileList wants to set the recursive size of a directory!
Parameters:
API Tags:
Information Tags:
| Todo: | store the recursive size separately (in another member), to avoid confusion |
| Todo: | pass a param to the constructor telling it we want to store a recursive size for the direcrory. |
Unlink/Delete the file or folder from disk.
Also removes meta data from DB.
API Tags:
| Return: | true on success, false on failure |
| Access: | public |