PHP 클래스 ImageManager

파일 보기 프로젝트 열기: sourcefabric/newscoop 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$config Configuration array.
$dirs Array of directory information.

공개 메소드들

메소드 설명
ImageManager ( array $config ) Constructor. Create a new Image Manager instance.
_delDir ( string $relative ) : boolean Delete directories recursively.
_delFile ( string $relative ) : boolean Delete the relative file, and any thumbnails.
_dirs ( string $base, string $path ) : array Recursively travese the directories to get a list of accessable directories.
_processFiles ( string $relative, array $file ) : boolean Process upload files. The file must be an uploaded file. If 'validate_images' is set to true, only images will be processed. Any duplicate file will be renamed. See Files::copyFile for details on renaming.
countFiles ( $path ) Count the number of files and directories in a given folder minus the thumbnail folders and thumbnails.
deleteDirs ( ) : boolean Delete and specified directories.
deleteFiles ( ) : boolean Delete and specified files.
getBaseDir ( ) : string Get the base directory.
getBaseURL ( ) : string Get the base URL.
getDefaultThumb ( ) : string Get the default thumbnail.
getDirs ( ) : array Get the sub directories in the base dir.
getFileURL ( string $relative ) : string Get the URL of the relative file.
getFiles ( string $path, $articleId ) : array Get all the files and directories of a relative path.
getFullPath ( string $relative ) : string Get the fullpath to a relative file.
getImageByNumber ( $articleId, $imageNumber )
getImageInfo ( string $file ) : array Get image size information.
getThumbName ( string $fullpathfile ) : string For a given image file, get the respective thumbnail filename no file existence check is done.
getThumbURL ( string $relative ) : string Similar to getThumbName, but returns the URL, base on the given base_url in config.inc.php
getThumbnail ( string $relative ) : string Get the thumbnail url to be displayed.
getTmpPrefix ( ) : string Get the tmp file prefix.
isThumb ( string $file ) : true Check if the file contains the thumbnail prefix.
isThumbDir ( string $entry ) : true Check if the given directory is a thumbnail directory.
isTmpFile ( string $file ) : boolean Check if the given file is a tmp file.
isValidBase ( )
processNewDir ( ) : boolean Create new directories.
processUploads ( ) : null Process uploaded files, assumes the file is in $_FILES['upload'] and $_POST['dir'] is set.
validRelativePath ( string $path ) : boolean Check if the given path is part of the subdirectories under the base_dir.

메소드 상세

ImageManager() 공개 메소드

Constructor. Create a new Image Manager instance.
public ImageManager ( array $config )
$config array configuration array, see config.inc.php

_delDir() 공개 메소드

Delete directories recursively.
public _delDir ( string $relative ) : boolean
$relative string the relative path to be deleted.
리턴 boolean true if deleted, false otherwise.

_delFile() 공개 메소드

Delete the relative file, and any thumbnails.
public _delFile ( string $relative ) : boolean
$relative string the relative file.
리턴 boolean true if deleted, false otherwise.

_dirs() 공개 메소드

Recursively travese the directories to get a list of accessable directories.
public _dirs ( string $base, string $path ) : array
$base string the full path to the current directory
$path string the relative path name
리턴 array of accessiable sub-directories array('path name' => 'full directory path', ...)

_processFiles() 공개 메소드

Process upload files. The file must be an uploaded file. If 'validate_images' is set to true, only images will be processed. Any duplicate file will be renamed. See Files::copyFile for details on renaming.
public _processFiles ( string $relative, array $file ) : boolean
$relative string the relative path where the file should be copied to.
$file array the uploaded file from $_FILES
리턴 boolean true if the file was processed successfully, false otherwise

countFiles() 공개 메소드

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

deleteDirs() 공개 메소드

Delete and specified directories.
public deleteDirs ( ) : boolean
리턴 boolean true if delete, false otherwise

deleteFiles() 공개 메소드

Delete and specified files.
public deleteFiles ( ) : boolean
리턴 boolean true if delete, false otherwise

getBaseDir() 공개 메소드

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

getBaseURL() 공개 메소드

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

getDefaultThumb() 공개 메소드

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

getDirs() 공개 메소드

Each array element contain the relative path (relative to the base dir) as key and the full path as value.
public getDirs ( ) : array
리턴 array of sub directries array('path name' => 'full directory path', ...)

getFileURL() 공개 메소드

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
리턴 string the URL of the relative file.

getFiles() 공개 메소드

Get all the files and directories of a relative path.
public getFiles ( string $path, $articleId ) : array
$path string relative path to be base path.
리턴 array of file and path information. array(0 => array('relative'=>'fullpath',...), 1 => array('filename'=>fileinfo array(),...) fileinfo array: array('url'=>'full url', 'relative'=>'relative to base', 'fullpath'=>'full file path', 'image'=>imageInfo array() false if not image, 'stat' => filestat)

getFullPath() 공개 메소드

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

getImageByNumber() 공개 메소드

public getImageByNumber ( $articleId, $imageNumber )

getImageInfo() 공개 메소드

Get image size information.
public getImageInfo ( string $file ) : array
$file string the image file
리턴 array of getImageSize information, false if the file is not an image.

getThumbName() 공개 메소드

For a given image file, get the respective thumbnail filename no file existence check is done.
public getThumbName ( string $fullpathfile ) : string
$fullpathfile string the full path to the image file
리턴 string of the thumbnail file

getThumbURL() 공개 메소드

Similar to getThumbName, but returns the URL, base on the given base_url in config.inc.php
public getThumbURL ( string $relative ) : string
$relative string the relative image file name, relative to the base_dir path
리턴 string the url of the thumbnail

getThumbnail() 공개 메소드

If the thumbnail exists, and it is up-to-date the thumbnail url will be returns. If the file is not an image, a default image will be returned. If it is an image file, and no thumbnail exists or the thumbnail is out-of-date (i.e. the thumbnail modified time is less than the original file) then a thumbs.php?img=filename.jpg is returned. The thumbs.php url will generate a new thumbnail on the fly. If the image is less than the dimensions of the thumbnails, the image will be display instead.
public getThumbnail ( string $relative ) : string
$relative string the relative image file.
리턴 string the url of the thumbnail, be it actually thumbnail or a script to generate the thumbnail on the fly.

getTmpPrefix() 공개 메소드

Get the tmp file prefix.
public getTmpPrefix ( ) : string
리턴 string tmp file prefix.

isThumb() 공개 메소드

Check if the file contains the thumbnail prefix.
public isThumb ( string $file ) : true
$file string filename to be checked
리턴 true if the file contains the thumbnail prefix, false otherwise.

isThumbDir() 공개 메소드

Check if the given directory is a thumbnail directory.
public isThumbDir ( string $entry ) : true
$entry string directory name
리턴 true if it is a thumbnail directory, false otherwise

isTmpFile() 공개 메소드

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

isValidBase() 공개 메소드

public isValidBase ( )

processNewDir() 공개 메소드

If in safe_mode, nothing happens.
public processNewDir ( ) : boolean
리턴 boolean true if created, false otherwise.

processUploads() 공개 메소드

The dir must be relative to the base_dir and exists. If 'validate_images' is set to true, only file with image dimensions will be accepted.
public processUploads ( ) : null
리턴 null

validRelativePath() 공개 메소드

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
리턴 boolean true if the path exists, false otherwise

프로퍼티 상세

$config 공개적으로 프로퍼티

Configuration array.
public $config

$dirs 공개적으로 프로퍼티

Array of directory information.
public $dirs