The File class.
Base class for processed files.
◆ __construct()
__construct |
( |
|
$fileName, |
|
|
CKFinder |
$app |
|
) |
| |
◆ 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 | $backend | target backend |
string | $path | target 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
-
- 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()
◆ 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 | $newFileName | the 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()
Returns current file name.
- Returns
- string
◆ hasValidFilename()
Validates current file name.
- Returns
- bool
true
if the file name is valid
◆ 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
◆ 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: