PHP Class AttachmentManager

Mostra file Open project: sourcefabric/newscoop Class Usage Examples

Public Properties

Property Type Description
$m_config Configuration array.
$m_dirs Array of directory information.

Public Methods

Method Description
__construct ( $p_config ) Constructor. Create a new Attachment Manager instance.
countFiles ( $path ) Count the number of files and directories in a given folder minus the thumbnail folders and thumbnails.
getBaseDir ( ) : string Get the base directory.
getBaseURL ( ) : string Get the base URL.
getDefaultThumb ( ) : string Get the default thumbnail.
getFileURL ( string $relative ) : string Get the URL of the relative file.
getFiles ( string $p_articleId, $p_languageId = null ) : array Get all the files and directories of a relative path.
getFiles ( string $p_articleId, $p_languageId = null, $p_filter = true ) : array Get all the files and directories of a relative path.
getFullPath ( string $relative ) : string Get the fullpath to a relative file.
isTmpFile ( string $file ) : boolean Check if the given file is a tmp file.
isValidBase ( )
validRelativePath ( string $path ) : boolean Check if the given path is part of the subdirectories under the base_dir.

Method Details

__construct() public method

Constructor. Create a new Attachment Manager instance.
public __construct ( $p_config )

countFiles() public method

Count the number of files and directories in a given folder minus the thumbnail folders and thumbnails.
public countFiles ( $path )

getBaseDir() public method

Get the base directory.
public getBaseDir ( ) : string
return string base dir, see config.inc.php

getBaseURL() public method

Get the base URL.
public getBaseURL ( ) : string
return string base url, see config.inc.php

getDefaultThumb() public method

Get the default thumbnail.
public getDefaultThumb ( ) : string
return string default thumbnail, empty string if the thumbnail doesn't exist.

getFileURL() public method

basically appends the relative file to the base_url given in config.inc.php
public getFileURL ( string $relative ) : string
$relative string a file the relative to the base_dir
return string the URL of the relative file.

getFiles() public method

Get all the files and directories of a relative path.
public getFiles ( string $p_articleId, $p_languageId = null ) : array
$p_articleId string
return array of file and path information. array('url'=>'full url', 'storage'=>'full file path')

getFiles() public method

Get all the files and directories of a relative path.
public getFiles ( string $p_articleId, $p_languageId = null, $p_filter = true ) : array
$p_articleId string
return array of file and path information. array('url'=>'full url', 'storage'=>'full file path')

getFullPath() public method

Get the fullpath to a relative file.
public getFullPath ( string $relative ) : string
$relative string the relative file.
return string the full path, .ie. the base_dir + relative.

isTmpFile() public method

Check if the given file is a tmp file.
public isTmpFile ( string $file ) : boolean
$file string file name
return boolean true if it is a tmp file, false otherwise

isValidBase() public method

public isValidBase ( )

validRelativePath() public method

Check if the given path is part of the subdirectories under the base_dir.
public validRelativePath ( string $path ) : boolean
$path string the relative path to be checked
return boolean true if the path exists, false otherwise

Property Details

$m_config public_oe property

Configuration array.
public $m_config

$m_dirs public_oe property

Array of directory information.
public $m_dirs