b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.8) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Class: File

Source Location: /blogs/inc/MODEL/files/_file.class.php

Class File

Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From DataObject

DataObject::$delete_cascades
DataObject::$delete_restrictions
DataObject::$ID

Inherited From DataObject

DataObject::DataObject()
Constructor
DataObject::check_delete()
Check relations for restrictions before deleting
DataObject::check_relations()
Check relations for restrictions or cascades
DataObject::confirm_delete()
Displays form to confirm deletion of this object
DataObject::dbchange()
Records a change that will need to be updated in the db
DataObject::dbdelete()
Delete object from DB.
DataObject::dbinsert()
Insert object into DB based on previously recorded changes.
DataObject::dbsave()
Inserts or Updates depending on object state.
DataObject::dbupdate()
Update the DB based on previously recorded changes
DataObject::dget()
Get a ready-to-display member param by its name
DataObject::disp()
Display a member param by its name
DataObject::get()
Get a member param by its name
DataObject::history_info_icon()
Create icon with dataobject history
DataObject::ID()
Template function: Displays object ID.
DataObject::set()
Set param value
DataObject::set_from_Request()
Set a parameter from a Request form value.
DataObject::set_param()
Set param value.

[ Top ]
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   $_adfp_full_path   Full path for this file/folder, WITHOUT trailing slash.
string   $_dir   Directory path for this file/folder, including trailing slash.
boolean   $_exists   Does the File/folder exist on disk?
Fileroot   $_FileRoot   FileRoot of this file
string|NULL   $_fsgroup_name   File group.
string|NULL   $_fsowner_name   File owner.
boolean   $_is_dir   Is the File a directory?
NULL|boolean   $_is_image   Is the File an image?
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.

[ Top ]
Method Summary
mixed   File()   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).
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
void   edit_link()   Template function. Display link to edit file.
boolean   exists()   Does the File/folder exist on disk?
string   get_dir()   Get the File's directory.
string   get_ext()   Get the file's extension.
FileRoot   &get_FileRoot()   Get the File's FileRoot.
NULL|string   get_fsgroup_name()   Get the owner name of the file.
NULL|string   get_fsowner_name()   Get the owner name of the file.
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_lastmod_formatted()   Get date/time of last modification, formatted.
integer   get_lastmod_ts()   Get timestamp of last modification.
string   get_md5_ID()   Get the File's ID (MD5 of path and name)
string   get_name()   Get the File's name.
mixed   get_perms()   Get permissions
string   get_prefixed_name()   Get the name prefixed either with "Directory" or "File".
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.
void   get_root_and_rel_path()   Get location of file with its root (for display)
integer   get_size()   Get file 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.
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.
void   setSize()   Internally sets the file/directory size
boolean   unlink()   Unlink/Delete the file or folder from disk.

[ Top ]
Properties
string   $alt [line 64]

Meta data: ALT text for images


[ Top ]
string   $desc [line 70]

Meta data: Description


[ Top ]
Filetype   $Filetype [line 191]

Extension, Mime type, icon, viewtype and 'allowed extension' of the file


[ Top ]
string   $meta = 'unknown' [line 52]

Have we checked for meta data in the DB yet?


[ Top ]
string   $title [line 58]

Meta data: Long title


[ Top ]
string   $_adfp_full_path [line 91]

Full path for this file/folder, WITHOUT trailing slash.

API Tags:
Access:  protected


[ Top ]
string   $_dir [line 99]

Directory path for this file/folder, including trailing slash.

API Tags:
See:  File::get_dir()
Access:  protected


[ Top ]
boolean   $_exists [line 128]

Does the File/folder exist on disk?

API Tags:
See:  File::exists()
Access:  protected


[ Top ]
Fileroot   $_FileRoot [line 77]

FileRoot of this file

API Tags:
Access:  protected


[ Top ]
string|NULL   $_fsgroup_name [line 177]

File group.

API Tags:
See:  File::get_fsgroup_name()
Access:  protected


[ Top ]
string|NULL   $_fsowner_name [line 169]

File owner.

API Tags:
See:  File::get_fsowner_name()
Access:  protected


[ Top ]
boolean   $_is_dir [line 136]

Is the File a directory?

API Tags:
See:  File::is_dir()
Access:  protected


[ Top ]
NULL|boolean   $_is_image [line 185]

Is the File an image?

API Tags:
See:  File::is_image()
Access:  protected


[ Top ]
integer   $_lastmod_ts [line 153]

UNIX timestamp of last modification on disk.

API Tags:
See:  File::get_lastmod_ts()
See:  File::get_lastmod_formatted()
Access:  protected


[ Top ]
string   $_md5ID [line 120]

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:
See:  File::get_md5_ID()
Access:  protected

Information Tags:
Todo:  fplanque>> get rid of it

[ Top ]
string   $_name [line 107]

Name of this file/folder, without path.

API Tags:
See:  File::get_name()
Access:  protected


[ Top ]
integer   $_perms [line 161]

Filesystem file permissions.

API Tags:
See:  File::get_perms()
Access:  protected


[ Top ]
string   $_rdfp_rel_path [line 84]

Posix subpath for this file/folder, relative the associated root (No trailing slash)

API Tags:
Access:  protected


[ Top ]
integer   $_size [line 144]

File size in bytes.

API Tags:
See:  File::get_size()
Access:  protected


[ Top ]
Methods
Constructor File  [line 205]

  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


[ Top ]
chmod  [line 1119]

  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


[ Top ]
copy_to  [line 1030]

  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


[ Top ]
create  [line 305]

  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


[ Top ]
dbinsert  [line 1151]

  boolean dbinsert( )

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.

[ Top ]
dbupdate  [line 1187]

  boolean dbupdate( )

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

[ Top ]
edit_link  [line 1295]

  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


[ Top ]
exists  [line 375]

  boolean exists( )

Does the File/folder exist on disk?


API Tags:
Return:  true, if the file or dir exists; false if not


[ Top ]
get_dir  [line 457]

  string get_dir( )

Get the File's directory.



[ Top ]
get_ext  [line 558]

  string get_ext( )

Get the file's extension.


API Tags:
Return:  the extension


[ Top ]
get_FileRoot  [line 547]

  FileRoot &get_FileRoot( )

Get the File's FileRoot.



[ Top ]
get_fsgroup_name  [line 733]

  NULL|string get_fsgroup_name( )

Get the owner name of the file.



[ Top ]
get_fsowner_name  [line 759]

  NULL|string get_fsowner_name( )

Get the owner name of the file.



[ Top ]
get_full_path  [line 492]

  string get_full_path( )

Get the full path (directory and name) to the file.

If the File is a directory, the Path ends with a /


API Tags:
Return:  full path


[ Top ]
get_icon  [line 787]

  string get_icon( )

Get icon for this file.

Looks at the file's extension.


API Tags:
Return:  img tag
Uses:  $map_iconfiles


[ Top ]
get_image_size  [line 815]

  false|mixed get_image_size( [string $param = 'widthxheight']  )

Get size of an image or false if not an image

Parameters:
string   $param:  imgsize()

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!)

[ Top ]
get_lastmod_formatted  [line 628]

  string get_lastmod_formatted( [ $format = '#']  )

Get date/time of last modification, formatted.

Parameters:
   $format: 

API Tags:
Return:  locale formatted date/time


[ Top ]
get_lastmod_ts  [line 616]

  integer get_lastmod_ts( )

Get timestamp of last modification.


API Tags:
Return:  Timestamp


[ Top ]
get_md5_ID  [line 415]

  string get_md5_ID( )

Get the File's ID (MD5 of path and name)



[ Top ]
get_name  [line 426]

  string get_name( )

Get the File's name.



[ Top ]
get_perms  [line 664]

  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:
Return:  permissions


[ Top ]
get_prefixed_name  [line 439]

  string get_prefixed_name( )

Get the name prefixed either with "Directory" or "File".

Returned string is localized.



[ Top ]
get_rdfp_rel_path  [line 468]

  string get_rdfp_rel_path( )

Get the file posix path relative to it's root (no trailing /)


API Tags:
Return:  full path


[ Top ]
get_rdfs_rel_path  [line 479]

  string get_rdfs_rel_path( )

Get the file path relative to it's root, WITH trailing slash.


API Tags:
Return:  full path


[ Top ]
get_root_and_rel_path  [line 536]

  void get_root_and_rel_path( )

Get location of file with its root (for display)



[ Top ]
get_size  [line 605]

  integer get_size( )

Get file size in bytes.


API Tags:
Return:  bytes


[ Top ]
get_size_formatted  [line 827]

  string get_size_formatted( )

Get size of the file, formatted to nearest unit (kb, mb, etc.)


API Tags:
Return:  size as b/kb/mb/gd; or '<dir>'
Uses:  bytesreadable()


[ Top ]
get_tag  [line 843]

  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: 


[ Top ]
get_type  [line 576]

  string get_type( )

Get the file type as a descriptive localized string.


API Tags:
Return:  localized type name or 'Directory' or 'Unknown'


[ Top ]
get_url  [line 502]

  void get_url( )

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



[ Top ]
get_view_link  [line 1243]

  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: 


[ Top ]
get_view_url  [line 1202]

  void get_view_url( )

Get URL to view the file (either with viewer of with browser, etc...)



[ Top ]
is_dir  [line 386]

  boolean is_dir( )

Is the File a directory?


API Tags:
Return:  true if the object is a directory, false if not


[ Top ]
is_image  [line 399]

  boolean is_image( )

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


[ Top ]
load_meta  [line 251]

  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.


[ Top ]
load_properties  [line 346]

  void load_properties( )

Initializes or refreshes file properties (type, size, perms...)



[ Top ]
move_to  [line 975]

  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


[ Top ]
rename_to  [line 908]

  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


[ Top ]
setSize  [line 893]

  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:
integer   $bytes: 

API Tags:
Access:  public

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.

[ Top ]
unlink  [line 1075]

  boolean unlink( )

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


[ Top ]

Documentation generated on Tue, 18 Dec 2007 23:12:59 +0100 by phpDocumentor 1.4.0