PHP Class Files

Inheritance: extends Controller
Mostra file Open project: sourcefabric/newscoop Class Usage Examples

Public Methods

Method Description
copyFile ( string $source, string $destination_dir, string $destination_file, boolean $unique = true ) : string Copy a file from source to destination. If unique == true, then if the destination exists, it will be renamed by appending an increamenting counting number.
createFolder ( string $newFolder ) : boolean Create a new folder.
delFile ( string $file ) : boolean Delete a file.
delFolder ( string $folder, boolean $recursive = false ) : boolean Delete folder(s), can delete recursively.
escape ( string $filename ) : string Escape the filenames, any non-word characters will be replaced by an underscore.
fixPath ( string $path ) : string Append a / to the path if required.
formatSize ( integer $size ) : string Format the file size, limits to Mb.
makeFile ( string $pathA, string $pathB ) : string Similar to makePath, but the second parameter is not only a path, it may contain say a file ending.
makePath ( string $pathA, string $pathB ) : string Concat two paths together. Basically $pathA+$pathB

Method Details

copyFile() public method

Copy a file from source to destination. If unique == true, then if the destination exists, it will be renamed by appending an increamenting counting number.
public copyFile ( string $source, string $destination_dir, string $destination_file, boolean $unique = true ) : string
$source string where the file is from, full path to the files required
$destination_dir string where the files, just the destination dir, e.g., /www/html/gallery/
$destination_file string name of the new file, just the filename
$unique boolean create unique destination file if true.
return string the new copied filename, else error if anything goes bad.

createFolder() public method

Create a new folder.
public createFolder ( string $newFolder ) : boolean
$newFolder string specifiy the full path of the new folder.
return boolean true if the new folder is created, false otherwise.

delFile() public method

Delete a file.
public delFile ( string $file ) : boolean
$file string file to be deleted
return boolean true if deleted, false otherwise.

delFolder() public method

Delete folder(s), can delete recursively.
public delFolder ( string $folder, boolean $recursive = false ) : boolean
$folder string the folder to be deleted.
$recursive boolean if true, all files and sub-directories are delete. If false, tries to delete the folder, can throw error if the directory is not empty.
return boolean true if deleted.

escape() public method

Escape the filenames, any non-word characters will be replaced by an underscore.
public escape ( string $filename ) : string
$filename string the orginal filename
return string the escaped safe filename

fixPath() public method

Append a / to the path if required.
public fixPath ( string $path ) : string
$path string the path
return string path with trailing /

formatSize() public method

Format the file size, limits to Mb.
public formatSize ( integer $size ) : string
$size integer the raw filesize
return string formated file size.

makeFile() public method

Similar to makePath, but the second parameter is not only a path, it may contain say a file ending.
public makeFile ( string $pathA, string $pathB ) : string
$pathA string the leading path
$pathB string the ending path with file
return string combined file path.

makePath() public method

Concat two paths together. Basically $pathA+$pathB
public makePath ( string $pathA, string $pathB ) : string
$pathA string path one
$pathB string path two
return string a trailing slash combinded path.