Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
FileManager Class Reference
Inheritance diagram for FileManager:
ArticleFileManager IssueFileManager JournalFileManager PKPPublicFileManager PrivateFileManager PublicFileManager PKPTemporaryFileManager TemporaryFileManager

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 32 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 164 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 145 of file FileManager.inc.php.

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

Referenced by copyDir(), PublicFileManager\copyJournalFile(), ArticleFileManager\handleCopy(), and ArticleFileManager\temporaryFileToArticleFile().

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 288 of file FileManager.inc.php.

References fileExists().

Referenced by PublicFileManager\removeJournalFile(), 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 233 of file FileManager.inc.php.

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

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 365 of file FileManager.inc.php.

Referenced by TemporaryFileManager\articleToTemporaryFile(), ArticleFileManager\copyAndRenameFile(), copyDir(), copyFile(), deleteFile(), PKPTemporaryFileManager\handleUpload(), uploadFile(), and writeFile().

FileManager::FileManager ( )

Constructor

Definition at line 36 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 415 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 381 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 478 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 433 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 502 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 78 of file FileManager.inc.php.

Referenced by IssueFileManager\_handleUpload(), PKPTemporaryFileManager\handleUpload(), and ArticleFileManager\handleUpload().

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 66 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 90 of file FileManager.inc.php.

References String\mime_content_type().

Referenced by IssueFileManager\_handleUpload(), and ArticleFileManager\handleUpload().

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 302 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 349 of file FileManager.inc.php.

References mkdir().

Referenced by TemporaryFileManager\articleToTemporaryFile(), ArticleFileManager\copyAndRenameFile(), copyFile(), PKPTemporaryFileManager\handleUpload(), uploadFile(), and writeFile().

FileManager::parseFileExtension (   $fileName)

Parse the file extension from a filename/path.

Parameters
$fileNamestring
Returns
string

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

Referenced by IssueFileManager\_handleUpload(), TemporaryFileManager\articleToTemporaryFile(), ArticleFileManager\copyAndRenameFile(), ArticleFileManager\generateFilename(), and PKPTemporaryFileManager\handleUpload().

& 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 199 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 317 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 325 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 516 of file FileManager.inc.php.

References Config\getVar().

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

FileManager::truncateFileName (   $fileName,
  $length = 127 
)
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 44 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 57 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 105 of file FileManager.inc.php.

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

Referenced by IssueFileManager\_handleUpload(), PKPTemporaryFileManager\handleUpload(), ArticleFileManager\handleUpload(), PublicFileManager\uploadJournalFile(), 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 123 of file FileManager.inc.php.

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

Referenced by ArticleFileManager\handleWrite(), and PublicFileManager\writeJournalFile().


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