Sitellite Application Framework
Class Tree         Index         All Elements

Class: File

Source Location: Program_Root/File/File.php

Class Overview


File is a simple class to keep basic file information gathering structured and readable. Stores everything as a property of the class instead of as methods, so that it integrates easily with the Template class.


Author(s)

Version

  • 2.2, 2003-09-29, $Id: File.php,v 1.2 2005/07/06 15:30:56 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 78]
File is a simple class to keep basic file information gathering structured and readable. Stores everything as a property of the class instead of as methods, so that it integrates easily with the Template class.

New in 1.2:

  • Added $filemtime, $gid, $uid, $perms, $filesize, $formatted_perms, $group, and $owner properties, and a formatPerms() method.
New in 1.4:
  • Added setStatus(), getStatus(), and clearStatus() methods.
New in 1.6:
  • Added a $content property and a contents() method.
New in 1.8:
  • Happy St. Valentine's day!
  • Had a fling with a Windows bug today. :)
New in 2.0:
  • Removed getStatus(), setStatus(), and clearStatus(). The status functionality is now part of saf.App.Versioning.Rev.
New in 2.2:
  • Added overwrite() and append() methods, and functions file_overwrite() and file_append() as aliases to them.

1 <?php
2
3 $file = new File ('/absolute/path/to/file.txt', '/web/path');
4
5 // check if the file is a directory
6 if ($file->is_dir) {
7 // file is a directory
8 }
9
10 // output the file's name, size and date it was last modified
11 echo $file->name;
12 echo $file->size;
13 echo $file->last_modified;
14
15 ? >




Tags:

access:  public
version:  2.2, 2003-09-29, $Id: File.php,v 1.2 2005/07/06 15:30:56 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Variables

$absolute =  ""

[line 134]

The absolute path to the file, including its name.



Tags:

access:  public

Type:   mixed


[ Top ]

$content =  false

[line 242]

Stores the content of the file after a call to contents().



Tags:

access:  public

Type:   mixed


[ Top ]

$description =  "Unknown Document Type"

[line 85]

The description of the file.



Tags:

access:  public

Type:   mixed


[ Top ]

$extension =  ""

[line 126]

The file's extension (ie. the extension of 'file.gif' is 'gif').



Tags:

access:  public

Type:   mixed


[ Top ]

$filemtime =

[line 158]

The actual value returned by the filemtime() call on this file.



Tags:

access:  public

Type:   mixed


[ Top ]

$filesize =

[line 142]

The actual size of this file in bytes.



Tags:

access:  public

Type:   mixed


[ Top ]

$formatted_perms =

[line 199]

The permissions of the file formatted by the formatPerms() method.



Tags:

access:  public

Type:   mixed


[ Top ]

$gid =

[line 174]

The group id of the file.



Tags:

access:  public

Type:   mixed


[ Top ]

$group =  ''

[line 208]

The group name of the file. Not available if PHP is running in safe_mode.



Tags:

access:  public

Type:   mixed


[ Top ]

$icon =  "pix/icons/unknown.gif"

[line 93]

An icon to help describe the file visually.



Tags:

access:  public

Type:   mixed


[ Top ]

$is_dir =  false

[line 234]

Determines whether or not this file is a directory.



Tags:

access:  public

Type:   mixed


[ Top ]

$is_writeable =  false

[line 226]

Determines whether or not this file is writeable by the current script.



Tags:

access:  public

Type:   mixed


[ Top ]

$last_modified =  ""

[line 166]

The date and time the file was last modified, in a formatted string.



Tags:

access:  public

Type:   mixed


[ Top ]

$name =  ""

[line 110]

The file's name.



Tags:

access:  public

Type:   mixed


[ Top ]

$owner =  ''

[line 217]

The owner name of the file. Not available if PHP is running in safe_mode.



Tags:

access:  public

Type:   mixed


[ Top ]

$path =  ""

[line 118]

The web path to the file, beginning from the document root.



Tags:

access:  public

Type:   mixed


[ Top ]

$perms =

[line 190]

The octal permissions of the file.



Tags:

access:  public

Type:   mixed


[ Top ]

$size =  ""

[line 150]

The size of the file in a formatted string.



Tags:

access:  public

Type:   mixed


[ Top ]

$type =  "ascii"

[line 102]

Type can be either 'ascii', 'binary', or 'folder'. Sitellite treats files differently depending on their type.



Tags:

access:  public

Type:   mixed


[ Top ]

$uid =

[line 182]

The user id of the file.



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor File [line 254]

File File( [string $abs_file_path = ''], [string $www_file_path = ''])

Constructor method. $abs_file_path is the absolute directory path to the file, including its name. $www_file_path is the path from the web document root to same, minus the file name.



Tags:

access:  public


Parameters:

string   $abs_file_path  
string   $www_file_path  

[ Top ]

method append [line 558]

boolean append( string $data, [string $file = ''])

Append to the specified file (or the file contained in the $absolute property) with the specified $data.



Tags:

access:  public


Parameters:

string   $data  
string   $file  

[ Top ]

method contains [line 383]

boolean contains( string $string, [boolean $regex = 0], [string $file = ''], [boolean $count = false], [string $filter = false])

Opens a file and returns whether or not it contains a specified string or pattern. Can be called using the File::contains syntax, as well as through an instantiated object.



Tags:

access:  public


Parameters:

string   $string  
boolean   $regex  
string   $file  
boolean   $count  
string   $filter  

[ Top ]

method contents [line 357]

string contents( [string $file = ''])

Returns the contents of the file as a string. If the $file is not specified, it uses the $absolute property of the current File object. Also stores it in the $content property so you don't have to read it from the file system twice.



Tags:

access:  public


Parameters:

string   $file  

[ Top ]

method determine [line 621]

string determine( array $list, [string $path = false])

Selects the first file that exists from the specified list.

This can be used to cascade possible choices for displaying images, including templates, or other context-sensitive data.




Tags:

access:  public


Parameters:

array   $list  
string   $path  

[ Top ]

method formatPerms [line 472]

string formatPerms( integer $mode)

Reads an octal mode value and returns a string of the

format -rwxrwxrwx, similar to what is returned by an "ls -al" command on a Unix command prompt. This method was borrowed from the user-contributed notes at http://www.php.net/fileperms




Tags:

access:  public


Parameters:

integer   $mode  

[ Top ]

method format_filesize [line 304]

string format_filesize( [integer $size = 0])

Formats the size of the file into a string appropriate for human consumption.



Tags:

access:  public


Parameters:

integer   $size  

[ Top ]

method overwrite [line 531]

boolean overwrite( string $data, [string $file = ''])

Overwrite the specified file (or the file contained in the $absolute property) with the specified $data.



Tags:

access:  public


Parameters:

string   $data  
string   $file  

[ Top ]

method rand [line 586]

string rand( string $path, [mixed $ext = false])

Select a random file from the specified directory. The $ext is an optional extension, or array of extensions, to limit the selection to. Also automatically eliminates dot-files and folders.



Tags:

access:  public


Parameters:

string   $path  
mixed   $ext  

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:17:35 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2