Documentation

Core_File
in package

File helper

Tags
subpackage

Core

version
7.x
author

Hostmake LLC

copyright

© 2005-2024 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru

Table of Contents

Properties

$resizeExtensions  : array<string|int, mixed>
File types with resize support

Methods

adminUpload()  : array<string|int, mixed>
Загрузка файлов в центре администрирования
clearCache()  : mixed
Clears file status cache
convertfileNameFromLocalEncoding()  : string
Convert file name from local encoding
convertfileNameToLocalEncoding()  : string
Convert file name to local encoding
copy()  : bool
Copies file
copyDir()  : bool
Copies directory
delete()  : mixed
Deletes a file
deleteDir()  : mixed
Deletes a directory with files and subdirectories
deleteEmptyDirs()  : mixed
Deletes empty directories
download()  : mixed
Вывод содержимого файла
filenameCorrection()  : string
File name corretion
filesize()  : mixed
Get filesize
flush()  : mixed
ob_flush()
getExtension()  : string
Get extension from path
getFileOwners()  : string
Получение строки владельцев к файлу
getFilePerms()  : string
Получение строки прав доступа к файлу
getIcon()  : string
Get icon
getNestingDirPath()  : mixed
Получение пути к директории определенного уровня вложенности по идентификатору сущности.
getResizeExtensions()  : array<string|int, mixed>
Get resize extensions
getUploadError()  : string|null
Get Upload Error by code
isDir()  : bool
Tells whether the filename is a directory
isFile()  : bool
Tells whether the filename is a regular file
isLink()  : bool
Tells whether the filename is a symbolic link
isValidExtension()  : bool
Checks if the extension is valid
mkdir()  : mixed
Makes directory
moveUploadedFile()  : mixed
Moves an uploaded file to a new location
pathCorrection()  : string
Path correction
read()  : string
Read all file content
rename()  : mixed
Renames a file or directory
upload()  : mixed
Copy or move uploaded file
write()  : mixed
Binary-safe file write

Properties

$resizeExtensions

File types with resize support

public static array<string|int, mixed> $resizeExtensions = array('JPG', 'JPEG', 'GIF', 'PNG', 'JFIF')

Methods

adminUpload()

Загрузка файлов в центре администрирования

public static adminUpload(array<string|int, mixed> $param) : array<string|int, mixed>
Parameters
$param : array<string|int, mixed>

массив параметров

  • $param['large_image_source'] путь к файлу-источнику большого изображения
  • $param['small_image_source'] путь к файлу-источнику малого изображения
  • $param['large_image_name'] оригинальное имя файла большого изображения
  • $param['small_image_name'] оригинальное имя файла малого изображения
  • $param['large_image_target'] путь к создаваемому файлу большого изображения
  • $param['small_image_target'] путь к создаваемому файлу малого изображения
  • $param['large_image_output_format'] формат создаваемого большого изображения
  • $param['small_image_output_format'] формат создаваемого малого изображения
  • $param['create_small_image_from_large'] использовать большое изображение для создания малого (TRUE - использовать (по умолчанию), FALSE - не использовать)
  • $param['large_image_max_width'] значение максимальной ширины большого изображения
  • $param['large_image_max_height'] значение максимальной высоты большого изображения
  • $param['small_image_max_width'] значение максимальной ширины малого изображения
  • $param['small_image_max_height'] значение максимальной высоты малого изображения
  • $param['watermark_file_path'] путь к файлу с "водяным знаком", если водяной знак не должен накладываться, не передавайте этот параметр
  • $param['watermark_position_x'] позиция "водяного знака" по оси X
  • $param['watermark_position_y'] позиция "водяного знака" по оси Y
  • $param['large_image_watermark'] наложить "водяной знак" на большое изображение (TRUE - наложить (по умолчанию), FALSE - не наложить)
  • $param['small_image_watermark'] наложить "водяной знак" на малое изображение (TRUE - наложить (по умолчанию), FALSE - не наложить)
  • $param['large_image_preserve_aspect_ratio'] сохранять пропорции изображения для большого изображения (TRUE - по умолчанию)
  • $param['small_image_preserve_aspect_ratio'] сохранять пропорции изображения для большого изображения (TRUE - по умолчанию)
Tags
hostcms-event

Core_File.onBeforeAdminUpload

hostcms-event

Core_File.onAfterAdminUpload

Return values
array<string|int, mixed>

$result

  • $result['large_image'] = TRUE в случае успешного создания большого изображения, FALSE - в противном случае
  • $result['small_image'] = TRUE в случае успешного создания малого изображения, FALSE - в противном случае

clearCache()

Clears file status cache

public static clearCache() : mixed

convertfileNameFromLocalEncoding()

Convert file name from local encoding

public static convertfileNameFromLocalEncoding(string $fileName) : string
Parameters
$fileName : string

file name

Return values
string

convertfileNameToLocalEncoding()

Convert file name to local encoding

public static convertfileNameToLocalEncoding(string $fileName) : string
Parameters
$fileName : string

file name

Return values
string

copy()

Copies file

public static copy(string $source, string $destination[, int $mode = CHMOD_FILE ]) : bool
Parameters
$source : string

The source path.

$destination : string

The destination path.

$mode : int = CHMOD_FILE

The mode parameter consists of three octal number components specifying access, e.g. 0644

Return values
bool

copyDir()

Copies directory

public static copyDir(string $source, string $target) : bool
Parameters
$source : string

The source directory.

$target : string

The destination directory.

Return values
bool

delete()

Deletes a file

public static delete(string $filePath) : mixed
Parameters
$filePath : string

Path to the file.

deleteDir()

Deletes a directory with files and subdirectories

public static deleteDir(string $dirname) : mixed
Parameters
$dirname : string

Path to the directory.

deleteEmptyDirs()

Deletes empty directories

public static deleteEmptyDirs(string $dirname) : mixed
Parameters
$dirname : string

Path to the directory.

download()

Вывод содержимого файла

public static download(string $file, string $fileName[, array<string|int, mixed> $param = array() ]) : mixed
Parameters
$file : string

путь к файлу

$fileName : string

имя файла

$param : array<string|int, mixed> = array()

массив дополнительных параметров

  • $param['content_disposition'] заголовок, определяющий вывод файла (inline - открывается в браузере (по умолчанию), attachment - скачивается)

filenameCorrection()

File name corretion

public static filenameCorrection(string $fileName) : string
Parameters
$fileName : string

file name

Return values
string

filesize()

Get filesize

public static filesize(string $fileName) : mixed
Parameters
$fileName : string

The file path.

Return values
mixed

filesize or NULL

flush()

ob_flush()

public static flush() : mixed

getExtension()

Get extension from path

public static getExtension(string $path) : string
Parameters
$path : string

path

Return values
string

getFileOwners()

Получение строки владельцев к файлу

public static getFileOwners(string $filename) : string
Parameters
$filename : string

имя файла

Return values
string

строка владельцев к файлу

getFilePerms()

Получение строки прав доступа к файлу

public static getFilePerms(string $filename[, int $octalValue = FALSE ]) : string
Parameters
$filename : string

имя файла

$octalValue : int = FALSE

тип строки (TRUE - "-rw-rw-rw-"; FALSE - "0755")

Return values
string

строка прав доступа к файлу

getIcon()

Get icon

public static getIcon(string $originalName) : string
Parameters
$originalName : string
Return values
string

getNestingDirPath()

Получение пути к директории определенного уровня вложенности по идентификатору сущности.

public static getNestingDirPath( $id[,  $level = 3 ][,  $type = 0 ]) : mixed

Например, для сущности с кодом 17 и уровнем вложенности 3 вернется строка 0/1/7 или массив из 3-х элементов - 0,1,7 Для сущности с кодом 23987 и уровнем вложенности 3 возвращается строка 2/3/9 или массив из 3-х элементов - 2,3,9.

Parameters
$id :

идентификатор сущности

$level : = 3

уровень вложенности, по умолчанию 3

$type : = 0

тип возвращаемого результата, 0 (по умолчанию) - строка, 1 - массив

Return values
mixed

строка или массив названий групп

getResizeExtensions()

Get resize extensions

public static getResizeExtensions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUploadError()

Get Upload Error by code

public static getUploadError(int $errorCode) : string|null
Parameters
$errorCode : int
Return values
string|null

isDir()

Tells whether the filename is a directory

public static isDir(string $filename) : bool
Parameters
$filename : string

Path to the dir.

Return values
bool

isFile()

Tells whether the filename is a regular file

public static isFile(string $filename) : bool
Parameters
$filename : string

Path to the file.

Return values
bool

Tells whether the filename is a symbolic link

public static isLink(string $filename) : bool
Parameters
$filename : string

Path to the file.

Return values
bool

isValidExtension()

Checks if the extension is valid

public static isValidExtension(string $path, array<string|int, mixed> $aExtensions[, bool $case = FALSE ]) : bool
Parameters
$path : string

file path

$aExtensions : array<string|int, mixed>

array of valid extensions

$case : bool = FALSE

case sensitivity

Return values
bool

mkdir()

Makes directory

public static mkdir(string $pathname[, int $mode = CHMOD ][, int $recursive = FALSE ]) : mixed
Parameters
$pathname : string

The directory path.

$mode : int = CHMOD

The mode parameter consists of three octal number components specifying access, e.g. 0644

$recursive : int = FALSE

Allows the creation of nested directories specified in the pathname. Defaults to FALSE.

moveUploadedFile()

Moves an uploaded file to a new location

public static moveUploadedFile(string $source, string $destination[, int $mode = CHMOD_FILE ]) : mixed
Parameters
$source : string

Path to the source file.

$destination : string

The destination path.

$mode : int = CHMOD_FILE

The mode parameter consists of three octal number components specifying access, e.g. 0644

pathCorrection()

Path correction

public static pathCorrection(string $path) : string
Parameters
$path : string

path

Return values
string

read()

Read all file content

public static read(string $fileName) : string
Parameters
$fileName : string

file name

Return values
string

rename()

Renames a file or directory

public static rename(string $oldname, string $newname) : mixed
Parameters
$oldname : string

The old name.

$newname : string

The new name.

upload()

Copy or move uploaded file

public static upload(string $source, string $destination[, int $mode = CHMOD_FILE ]) : mixed
Parameters
$source : string

The source path.

$destination : string

The destination path.

$mode : int = CHMOD_FILE

The mode parameter consists of three octal number components specifying access, e.g. 0644

Tags
see
Core_File::moveUploadedFile()
see
Core_File::copy()

write()

Binary-safe file write

public static write(string $fileName, string $content[, int $mode = CHMOD_FILE ]) : mixed
Parameters
$fileName : string

Path to the file.

$content : string

The string that is to be written.

$mode : int = CHMOD_FILE

The mode parameter consists of three octal number components specifying access, e.g. 0644


        
On this page

Search results