CKFinder 3 – PHP Connector Documentation
File Class Reference
Inheritance diagram for File:
ExistingFile UploadedFile CopiedFile DeletedFile DownloadedFile EditedFile RenamedFile MovedFile EditedImage

Public Member Functions

 __construct ($fileName, CKFinder $app)
 
 hasValidFilename ()
 
 getFilename ()
 
 getExtension ()
 
 getExtensions ($newFileName=null)
 
 autorename (Backend $backend=null, $path='')
 
 isImage ()
 
 getCache ()
 

Static Public Member Functions

static isValidName ($fileName, $disallowUnsafeCharacters=true)
 
static secureName ($fileName, $disallowUnsafeCharacters=true, $forceAscii=false)
 
static convertToAscii ($str)
 

Public Attributes

const NO_EXTENSION = 'NO_EXT'
 

Protected Attributes

 $fileName
 
 $config
 
 $app
 

Detailed Description

The File class.

Base class for processed files.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $fileName,
CKFinder  $app 
)

Constructor.

Parameters
string$fileName

Reimplemented in DownloadedFile.

Member Function Documentation

◆ autorename()

autorename ( Backend  $backend = null,
  $path = '' 
)

Renames the current file by adding a number to the file name.

Renaming is done by adding a number in parenthesis provided that the file name does not collide with any other file existing in the target backend/path. For example, if the target backend path contains a file named foo.txt and the current file name is foo.txt, this method will change the current file name to foo(1).txt.

Parameters
Backend$backendtarget backend
string$pathtarget backend-relative path
Returns
bool true if file was renamed

Reimplemented in CopiedFile, and UploadedFile.

◆ convertToAscii()

static convertToAscii (   $str)
static

Replace accented UTF-8 characters with unaccented ASCII-7 "equivalents". The purpose of this function is to replace characters commonly found in Latin alphabets with something more or less equivalent from the ASCII range. This can be useful for example for converting UTF-8 to something ready for a file name. After the use of this function, you would probably also pass the string through utf8_strip_non_ascii to clean out any other non-ASCII characters.

For a more complete implementation of transliteration, see the utf8_to_ascii package available from the phputf8 project downloads: http://prdownloads.sourceforge.net/phputf8

Parameters
string$str
Returns
string Accented chars replaced with ASCII equivalents
Author
Andreas Gohr andi@.nosp@m.spli.nosp@m.tbrai.nosp@m.n.or.nosp@m.g
See also
http://sourceforge.net/projects/phputf8/

◆ getCache()

getCache ( )
Returns
CacheManager

◆ getExtension()

getExtension ( )

Returns current file extension.

Returns
string

◆ getExtensions()

getExtensions (   $newFileName = null)

Returns a list of current file extensions.

For example for a file named file.foo.bar.baz it will return an array containing ‘['foo’, 'bar', 'baz']`.

Parameters
null$newFileNamethe file name to check if it is different than the current file name (for example for validation of a new file name in edited files)
Returns
array

◆ getFilename()

getFilename ( )

Returns current file name.

Returns
string

◆ hasValidFilename()

hasValidFilename ( )

Validates current file name.

Returns
bool true if the file name is valid

◆ isImage()

isImage ( )

Checks if the current file has an image extension.

Returns
bool true if the file name has an image extension

◆ isValidName()

static isValidName (   $fileName,
  $disallowUnsafeCharacters = true 
)
static

Check whether $fileName is a valid file name. Returns true on success.

Parameters
string$fileName
bool$disallowUnsafeCharacters
Returns
bool true if $fileName is a valid file name

◆ secureName()

static secureName (   $fileName,
  $disallowUnsafeCharacters = true,
  $forceAscii = false 
)
static

Secures the file name from unsafe characters.

Parameters
string$fileName
bool$disallowUnsafeCharacters
mixed$forceAscii
Returns
string

Member Data Documentation

◆ NO_EXTENSION

const NO_EXTENSION = 'NO_EXT'

Constant used to mark files without extension.


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