Class: File
Source Location: /qp_inc/files/model/_file.class.php
Class File
Inherited Properties, Constants, and Methods
Property Summary
| string |
$alt |
Meta data: ALT text for images |
| string |
$desc |
Meta data: Description |
| Filetype |
$Filetype |
Extension, Mime type, icon, viewtype and 'allowed extension' of the file |
| string |
$meta |
Have we checked for meta data in the DB yet? |
| string |
$title |
Meta data: Long title |
| string |
$_dir |
Directory path for this file/folder, including trailing slash. |
| boolean |
$_exists |
Does the File/folder exist on disk? |
| boolean |
$_is_dir |
Is the File a directory? |
| boolean |
$_is_image |
Is the File an image? NULL if unknown |
| integer |
$_lastmod_ts |
UNIX timestamp of last modification on disk. |
| string |
$_md5ID |
MD5 hash of full pathname. |
| string |
$_name |
Name of this file/folder, without path. |
| integer |
$_perms |
Filesystem file permissions. |
| string |
$_rdfp_rel_path |
Posix subpath for this file/folder, relative the associated root (No trailing slash) |
| integer |
$_size |
File size in bytes. |
Method Summary
| mixed |
File() |
Constructor, not meant to be called directly. Use FileCache::get_by_root_and_path() instead, which provides caching and checks that only one object for a unique file exists (references). |
| mixed |
chmod() |
Change file permissions on disk. |
| boolean |
copy_to() |
Copy this file to a new location |
| boolean |
create() |
Create the file/folder on disk, if it does not exist yet. |
| boolean |
dbinsert() |
Insert object into DB based on previously recorded changes |
| boolean |
dbupdate() |
Update the DB based on previously recorded changes |
| boolean |
exists() |
Does the File/folder exist on disk? |
| mixed |
get() |
Get a member param by its name |
| string |
get_ads_cache() |
Get the full path to the thumbnail cache for this file. |
| string |
get_dir() |
Get the File's directory. |
| string |
get_ext() |
Get the file's extension. |
| Filetype |
&get_Filetype() |
Get the File's Filetype object (or NULL). |
| string |
get_full_path() |
Get the full path (directory and name) to the file. |
| string |
get_icon() |
Get icon for this file. |
| false|mixed |
get_image_size() |
Get size of an image or false if not an image |
| string |
get_md5_ID() |
Get the File's ID (MD5 of path and name) |
| string |
get_preview_thumb() |
Displays a preview thumbnail which is clickable and opens a view popup |
| string |
get_rdfp_rel_path() |
Get the file posix path relative to it's root (no trailing /) |
| string |
get_rdfs_rel_path() |
Get the file path relative to it's root, WITH trailing slash. |
| integer |
get_recursive_size() |
Get the "full" size of a file/dir (recursive for directories). |
| integer |
get_size() |
Get file/dir size in bytes. |
| string |
get_size_formatted() |
Get size of the file, formatted to nearest unit (kb, mb, etc.) |
| void |
get_tag() |
Get a complete tag (IMG or A HREF) pointing to this file. |
| void |
get_thumb_imgtag() |
Generate the IMG THUMBNAIL tag with all the alt & title if available |
| string |
get_type() |
Get the file type as a descriptive localized string. |
| void |
get_url() |
Get the absolute file url if the file is public |
| void |
get_view_link() |
Get Link to view the file (either with viewer of with browser, etc...) |
| void |
get_view_url() |
Get URL to view the file (either with viewer of with browser, etc...) |
| boolean |
is_dir() |
Is the File a directory? |
| boolean |
is_image() |
Is the File an image? |
| boolean |
load_meta() |
Attempt to load meta data. |
| void |
load_properties() |
Initializes or refreshes file properties (type, size, perms...) |
| boolean |
move_to() |
Move the file to another location |
| boolean |
rename_to() |
Rename the file in its current directory on disk. |
| boolean |
thumbnail() |
This will spit out a content-type header followed by a thumbnail for this file. |
| boolean |
unlink() |
Unlink/Delete the file or folder from disk. |
Properties
Meta data: ALT text for images
Extension, Mime type, icon, viewtype and 'allowed extension' of the file
API Tags:
| See: | File::get_Filetype |
| Access: | protected |
Have we checked for meta data in the DB yet?
Full path for this file/folder, WITHOUT trailing slash.
API Tags:
Directory path for this file/folder, including trailing slash.
API Tags:
Does the File/folder exist on disk?
API Tags:
FileRoot of this file
API Tags:
File group. NULL if unknown
API Tags:
File owner. NULL if unknown
API Tags:
Is the File a directory?
API Tags:
Is the File an image? NULL if unknown
API Tags:
UNIX timestamp of last modification on disk.
API Tags:
MD5 hash of full pathname.
This is useful to refer to files in hidden form fields, but might be replaced by the root_ID+relpath. API Tags:
Information Tags:
| Todo: | (legacy): fplanque>> get rid of it |
Name of this file/folder, without path.
API Tags:
Filesystem file permissions.
API Tags:
Posix subpath for this file/folder, relative the associated root (No trailing slash)
API Tags:
Recursive directory size in bytes.
API Tags:
File size in bytes.
API Tags:
Methods
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_root_and_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 |
void cb_delete_restrictions_detail(
$params
)
|
|
Callback function called by DataObject::check_relations().
Parameters:
API Tags:
Information Tags:
| Todo: | Tblue> Offer to delete links if all items can be edited by the user (this would require checking for item edit and not view perms, obviously). |
| Todo: | Tblue> It looks like links don't necessarily need to point to items... Not sure if this feature is actually being used in the app. |
mixed chmod(
[string
$chmod = NULL]
)
|
|
Change file permissions on disk.
Parameters:
|
string |
$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
Does the File/folder exist on disk?
API Tags:
| Return: | true, if the file or dir exists; false if not |
mixed get(
mixed
$parname
)
|
|
Get a member param by its name
Parameters:
|
mixed |
$parname: |
Name of parameter |
API Tags:
| Return: | Value of parameter |
Redefinition of:
- DataObject::get()
- Get a member param by its name
string get_ads_cache(
[boolean
$create_if_needed = false]
)
|
|
Get the full path to the thumbnail cache for this file.
ads = Absolute Directory Slash
Parameters:
|
boolean |
$create_if_needed: |
shall we create the dir if it doesn't exist? |
API Tags:
| Return: | absolute path or !error |
string get_af_thumb_path(
string
$size_name, [string
$thumb_mimetype = NULL], [boolean
$create_cache_if_needed = false]
)
|
|
Get the full path to the thumbnail for this file.
af = Absolute File
Parameters:
|
string |
$size_name: |
size name |
|
string |
$thumb_mimetype: |
mimetype of thumbnail (NULL if we're ready to take wathever is available) |
|
boolean |
$create_cache_if_needed: |
shall we create the dir if it doesn't exist? |
API Tags:
| Return: | absolute filename or !error |
Get the File's directory.
Get the file's extension.
API Tags:
Filetype &get_Filetype(
)
|
|
Get the File's Filetype object (or NULL).
API Tags:
| Return: | The Filetype object or NULL |
NULL|string get_fsgroup_name(
)
|
|
Get the owner name of the file.
Information Tags:
| Todo: | (legacy): Can this be fixed for windows? filegroup() might only return 0 or 1 nad posix_getgrgid() is not available.. |
NULL|string get_fsowner_name(
)
|
|
Get the owner name of the file.
Information Tags:
| Todo: | (legacy): Can this be fixed for windows? fileowner() might only return 0 or 1 nad posix_getpwuid() is not available.. |
Get the full path (directory and name) to the file.
If the File is a directory, the Path ends with a /
API Tags:
string get_getfile_url(
)
|
|
Get the URL to access a file through getfile.php.
Get icon for this file.
Looks at the file's extension.
API Tags:
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: | (legacy): 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:
void get_linkedit_link(
[integer
$link_itm_ID = NULL], [string
$text = NULL], [string
$title = NULL], [string
$no_access_text = NULL], [string
$actionurl = '#'], [
$target = '']
)
|
|
Get link to edit linked 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 |
|
|
$target: |
|
string get_linkedit_url(
[integer
$link_itm_ID = NULL], [
$actionurl = '#']
)
|
|
Parameters:
|
integer |
$link_itm_ID: |
ID of item to link to => will open the FM in link mode |
|
|
$actionurl: |
|
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_preview_thumb(
[string
$format_for_non_images = '']
)
|
|
Displays a preview thumbnail which is clickable and opens a view popup
Parameters:
|
string |
$format_for_non_images: |
what do do with files that are not images? 'fulltype' |
API Tags:
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:
integer get_recursive_size(
)
|
|
Get the "full" size of a file/dir (recursive for directories).
This is used by the FileList.
API Tags:
| Return: | Recursive size of the dir or the size alone for a file. |
void get_root_and_rel_path(
)
|
|
Get location of file with its root (for display)
Get file/dir size in bytes.
For the recursive size of a directory see get_recursive_size().
API Tags:
string get_size_formatted(
)
|
|
Get size of the file, formatted to nearest unit (kb, mb, etc.)
API Tags:
void get_tag(
[string
$before_image = '<div class="image_block">'], [string
$before_image_legend = '<div class="image_legend">'], [string
$after_image_legend = '</div>'], [string
$after_image = '</div>'], [string
$size_name = 'original'], [string
$image_link_to = 'original'], [string
$image_class = false]
)
|
|
Get a complete tag (IMG or A HREF) pointing to this file.
Parameters:
|
string |
$before_image: |
before_image |
|
string |
$before_image_legend: |
before_image_legend NULL for no legend |
|
string |
$after_image_legend: |
after_image_legend |
|
string |
$after_image: |
after_image |
|
string |
$size_name: |
size_name |
|
string |
$image_link_to: |
image_link_to 'original' |
|
string |
$image_class: |
image_class |
void get_thumb_imgtag(
[
$size_name = 'fit-80x80'], [
$class = ''], [
$align = '']
)
|
|
Generate the IMG THUMBNAIL tag with all the alt & title if available
Parameters:
|
|
$size_name: |
|
|
|
$class: |
|
|
|
$align: |
|
void get_thumb_url(
[string
$size_name = 'fit-80x80']
)
|
|
Get the thumbnail URL for this file
Parameters:
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: |
|
void get_view_url(
[
$always_open_dirs_in_fm = true]
)
|
|
Get URL to view the file (either with viewer of with browser, etc...)
Parameters:
Is the File a directory?
API Tags:
| Return: | true if the object is a directory, false if not |
void is_editable(
[boolean
$allow_locked = false]
)
|
|
Is the file editable?
Parameters:
|
boolean |
$allow_locked: |
allow locked file types? |
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 |
void link_to_Item(
Item
&$edited_Item
)
|
|
Parameters:
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 |
void output_cached_thumb(
string
$size_name, string
$thumb_mimetype, string
2
)
|
|
Output previously saved thumbnail for file
Parameters:
|
string |
2: |
short error code |
|
string |
$size_name: |
size name |
|
string |
$thumb_mimetype: |
mimetype of thumbnail |
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 save_thumb_to_cache(
resource
$thumb_imh, string
$size_name, string
$thumb_mimetype, [integer
$thumb_quality = 90]
)
|
|
Save thumbnail for file
Parameters:
|
resource |
$thumb_imh: |
|
|
string |
$size_name: |
size name |
|
string |
$thumb_mimetype: |
mimetype of thumbnail |
|
integer |
$thumb_quality: |
JPEG image quality |
boolean thumbnail(
string
$req_size
)
|
|
This will spit out a content-type header followed by a thumbnail for this file.
Parameters:
|
string |
$req_size: |
requested size: 'thumbnail' |
API Tags:
| Return: | True on success, false on failure. |
Information Tags:
| Todo: | (legacy): a million things (fp) but you get the idea... The generated thumb will be saved to a cached file here (fp) The cache will be accessed through the File object (fp) |
| Todo: | (legacy): cleanup memory resources |
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 |
|
|