Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
FileManager Class Reference
Inheritance diagram for FileManager:
PKPPublicFileManager PrivateFileManager PublicFileManager ContextFileManager PKPLibraryFileManager BaseSubmissionFileManager LibraryFileManager SimpleMonographFileManager

Public Member Functions

 copyDir ($source, $dest)
 
 copyFile ($source, $dest)
 
 deleteFile ($filePath)
 
 downloadFile ($filePath, $mediaType=null, $inline=false, $fileName=null)
 
 fileExists ($filePath, $type= 'file')
 
 FileManager ()
 
 getDocumentExtension ($type)
 
 getDocumentType ($type)
 
 getExtension ($fileName)
 
 getImageExtension ($type)
 
 getNiceFileSize ($size)
 
 getUploadedFileName ($fileName)
 
 getUploadedFilePath ($fileName)
 
 getUploadedFileType ($fileName)
 
 mkdir ($dirPath, $perms=null)
 
 mkdirtree ($dirPath, $perms=null)
 
 parseFileExtension ($fileName)
 
 readFile ($filePath, $output=false)
 
 rmdir ($dirPath)
 
 rmtree ($file)
 
 setMode ($path, $mask)
 
 truncateFileName ($fileName, $length=127)
 
 uploadedFileExists ($fileName)
 
 uploadError ($fileName)
 
 uploadFile ($fileName, $destFileName)
 
 writeFile ($dest, &$contents)
 

Detailed Description

Class defining basic operations for file management.

Definition at line 34 of file FileManager.inc.php.

Member Function Documentation

FileManager::copyDir (   $source,
  $dest 
)

Copy a directory. Adapted from code by gimmicklessgpt at gmail dot com, at http://php.net/manual/en/function.copy.php

Parameters
$sourcestring the path to the source directory
$deststring the path where the directory is to be saved
Returns
boolean returns true if successful

Definition at line 166 of file FileManager.inc.php.

References copyFile(), fileExists(), and mkdir().

FileManager::copyFile (   $source,
  $dest 
)

Copy a file.

Parameters
$sourcestring the source URL for the file
$deststring the path where the file is to be saved
Returns
boolean returns true if successful

Definition at line 147 of file FileManager.inc.php.

References fileExists(), mkdirtree(), and setMode().

Referenced by PKPPublicFileManager\copyContextFile(), and copyDir().

FileManager::deleteFile (   $filePath)

Delete a file.

Parameters
$filePathstring the location of the file to be deleted
Returns
boolean returns true if successful

Definition at line 291 of file FileManager.inc.php.

References fileExists().

Referenced by PKPPublicFileManager\removeContextFile(), and PKPPublicFileManager\removeSiteFile().

FileManager::downloadFile (   $filePath,
  $mediaType = null,
  $inline = false,
  $fileName = null 
)

Download a file. Outputs HTTP headers and file content for download

Parameters
$filePathstring the location of the file to be sent
$mediaTypestring the MIME type of the file, optional
$inlineprint file as inline instead of attachment, optional
Returns
boolean

Definition at line 235 of file FileManager.inc.php.

References HookRegistry\call(), HookRegistry\getHooks(), String\mime_content_type(), readFile(), and HookRegistry\setHooks().

Referenced by CatalogHandler\fullSize(), and CatalogHandler\thumbnail().

FileManager::fileExists (   $filePath,
  $type = 'file' 
)

Check if a file path is valid;

Parameters
$filePathstring the file/directory to check
$typestring (file|dir) the type of path

Definition at line 368 of file FileManager.inc.php.

Referenced by copyDir(), copyFile(), deleteFile(), uploadFile(), and writeFile().

FileManager::FileManager ( )

Constructor

Definition at line 38 of file FileManager.inc.php.

FileManager::getDocumentExtension (   $type)

Returns file extension associated with the given document type, or false if the type does not belong to a recognized document type.

Parameters
$typestring

Definition at line 418 of file FileManager.inc.php.

FileManager::getDocumentType (   $type)

Returns a file type, based on generic categories defined above

Parameters
$typeString
Returns
string (Enuemrated DOCUMENT_TYPEs)

Definition at line 384 of file FileManager.inc.php.

References getImageExtension().

FileManager::getExtension (   $fileName)

Parse file extension from file name.

Parameters
stringa valid file name
Returns
string extension

Definition at line 481 of file FileManager.inc.php.

Referenced by truncateFileName().

FileManager::getImageExtension (   $type)

Returns file extension associated with the given image type, or false if the type does not belong to a recognized image type.

Parameters
$typestring

Definition at line 436 of file FileManager.inc.php.

Referenced by getDocumentType().

FileManager::getNiceFileSize (   $size)

Return pretty file size string (in B, KB, MB, or GB units).

Parameters
$sizeint file size in bytes
Returns
string

Definition at line 505 of file FileManager.inc.php.

FileManager::getUploadedFileName (   $fileName)

Return the user-specific (not temporary) filename of an uploaded file.

Parameters
$fileNamestring the name of the file used in the POST form
Returns
string (boolean false if no such file)

Definition at line 80 of file FileManager.inc.php.

FileManager::getUploadedFilePath (   $fileName)

Return the (temporary) path to an uploaded file.

Parameters
$fileNamestring the name of the file used in the POST form
Returns
string (boolean false if no such file)

Definition at line 68 of file FileManager.inc.php.

FileManager::getUploadedFileType (   $fileName)

Return the type of an uploaded file.

Parameters
$fileNamestring the name of the file used in the POST form
Returns
string

Definition at line 92 of file FileManager.inc.php.

References String\mime_content_type().

FileManager::mkdir (   $dirPath,
  $perms = null 
)

Create a new directory.

Parameters
$dirPathstring the full path of the directory to be created
$permsstring the permissions level of the directory (optional)
Returns
boolean returns true if successful

Definition at line 305 of file FileManager.inc.php.

References setMode().

Referenced by copyDir(), and mkdirtree().

FileManager::mkdirtree (   $dirPath,
  $perms = null 
)

Create a new directory, including all intermediate directories if required (equivalent to "mkdir -p")

Parameters
$dirPathstring the full path of the directory to be created
$permsstring the permissions level of the directory (optional)
Returns
boolean returns true if successful

Definition at line 352 of file FileManager.inc.php.

References mkdir().

Referenced by copyFile(), uploadFile(), and writeFile().

FileManager::parseFileExtension (   $fileName)

Parse the file extension from a filename/path.

Parameters
$fileNamestring
Returns
string

Definition at line 531 of file FileManager.inc.php.

FileManager::readFile (   $filePath,
  $output = false 
)

Read a file's contents.

Parameters
$filePathstring the location of the file to be read
$outputboolean output the file's contents instead of returning a string
Returns
boolean

Definition at line 201 of file FileManager.inc.php.

Referenced by downloadFile().

FileManager::rmdir (   $dirPath)

Remove a directory.

Parameters
$dirPathstring the full path of the directory to be delete
Returns
boolean returns true if successful

Definition at line 320 of file FileManager.inc.php.

Referenced by rmtree().

FileManager::rmtree (   $file)

Delete all contents including directory (equivalent to "rm -r")

Parameters
$filestring the full path of the directory to be removed

Definition at line 328 of file FileManager.inc.php.

References rmdir().

FileManager::setMode (   $path,
  $mask 
)

Set file/directory mode based on the 'umask' config setting.

Parameters
$pathstring
$maskint
Returns
boolean

Definition at line 519 of file FileManager.inc.php.

References Config\getVar().

Referenced by copyFile(), mkdir(), uploadFile(), and writeFile().

FileManager::truncateFileName (   $fileName,
  $length = 127 
)

Truncate a filename to fit in the specified length.

Definition at line 493 of file FileManager.inc.php.

References getExtension(), String\strlen(), and String\substr().

FileManager::uploadedFileExists (   $fileName)

Return true if an uploaded file exists.

Parameters
$fileNamestring the name of the file used in the POST form
Returns
boolean

Definition at line 46 of file FileManager.inc.php.

FileManager::uploadError (   $fileName)

Return true iff an error occurred when trying to upload a file.

Parameters
$fileNamestring the name of the file used in the POST form
Returns
boolean

Definition at line 59 of file FileManager.inc.php.

FileManager::uploadFile (   $fileName,
  $destFileName 
)

Upload a file.

Parameters
$fileNamestring the name of the file used in the POST form
$deststring the path where the file is to be saved
Returns
boolean returns true if successful

Definition at line 107 of file FileManager.inc.php.

References fileExists(), mkdirtree(), and setMode().

Referenced by PKPPublicFileManager\uploadContextFile(), and PKPPublicFileManager\uploadSiteFile().

FileManager::writeFile (   $dest,
$contents 
)

Write a file.

Parameters
$deststring the path where the file is to be saved
$contentsstring the contents to write to the file
Returns
boolean returns true if successful

Definition at line 125 of file FileManager.inc.php.

References fileExists(), mkdirtree(), and setMode().

Referenced by PKPPublicFileManager\writeContextFile().


The documentation for this class was generated from the following file: