ImageFile
extends BaseFile
in package
implements
IFile
Class ImageFile
Tags
Interfaces, Classes and Traits
- IFile
- Interface IFile
Table of Contents
- MAX_FILES_DIR = 100
- Максимальное кол-во файлов в одной директории
- PERMITTED_CHARS = '0123456789_abcdefghijklmnopqrstuvwxyz'
- RESIZE_TYPE_EXACT = 8
- {@link resize()} fills given area exactly
- RESIZE_TYPE_FILL = 4
- {@link resize()} fills given area so its dimensions are greater than or equal to the required dimensions
- RESIZE_TYPE_FIT = 0
- {@link resize()} fits in given area so its dimensions are less than or equal to the required dimensions
- RESIZE_TYPE_SHRINK_ONLY = 1
- {@link resize()} only shrinks images
- RESIZE_TYPE_STRETCH = 2
- {@link resize()} will ignore aspect ratio
- $add_dt : mixed
- $content_type : mixed
- $file_name : mixed
- $id : mixed
- $new_dir : mixed
- $new_file_name : mixed
- $old_dir : mixed
- $old_file_name : mixed
- $original_name : mixed
- $size : mixed
- $sub_dir : mixed
- $uuid : mixed
- $database : Context
- $files_id : mixed
- $height : mixed
- $primary_key : mixed
- $props : mixed
- $table : mixed
- $table_tags_files : mixed
- $tempName : mixed
- $upload_dir : mixed
- $width : mixed
- __construct() : mixed
- convert() : bool
- createDir() : bool
- Создает директорию
- delete() : bool
- Удаляет файл
- get() : $this|false
- getChildDir() : array<string|int, mixed>
- Возвращает массив дочерних директорий
- getPath() : bool|string
- Возвращает путь до файла
- imageResizeDel() : bool
- isEmpty() : bool
- Проверяет директорию на пустоту
- move() : static
- Moves an uploaded file to a new location. If the destination file already exists, it will be overwritten.
- resizeImageGet() : bool|string
- Метод уменьшает картинку и размещает уменьшенную копию в папку self::CACHE_DIR.
- save() : $this
- Метод сохраняет файл и регистрирует его в таблице файлов (files).
- setAddDt() : mixed
- Задаёт дату добавления, на текущий момент
- setContentType() : $this|false
- Задаёт тип файла
- setFileName() : $this|false
- Задаёт имя файлу
- setHeight() : ImageFile
- setOriginalName() : $this|false
- Задаёт оригинальное имя
- setSize() : $this|false
- Задаёт размер файла
- setSubDir() : $this
- Задаёт расположение
- setUuid() : $this
- Задаёт uuid файла
- setWidth() : ImageFile
- absoluteResizeDir() : string
- absoluteUploadDir() : string
- add() : false|ImageFile
- relativeResizeDir() : string
- relativeUploadDir() : string
- replace() : $this|BaseFile|bool
- update() : $this|BaseFile|bool
- validate() : bool|false
- __buildFileArray() : array<string|int, mixed>
- Строит массив атрибутов файла
- __changeDir() : mixed
- *
- __checkMaxCountFilesDir() : bool
- Проверяет заполнена ли директори
- __deleteOld() : bool
- __findDirToSave() : mixed|string
- Выполняет поиск подходящей директории для сохранения файла.
- __genOnlyDirName() : string
- Создает уникальное имя директории
- __genOnlyFileName() : bool|string
- Создает уникальное имя файла в указанной директории
- __imageResizeRename() : void
- __prepareDirToSave() : false|mixed|string
- __prepareSysDir() : bool
- __rename() : void
- переименовывает файл
- callManager() : FileManager
- Возвращает экземпляр класса FileManager
- getPropsToArray() : array<string|int, mixed>
- Преобразует свойства файла в массив
- setProps() : mixed
- Сохраняет свойство файла в объект
Constants
MAX_FILES_DIR
Максимальное кол-во файлов в одной директории
public
mixed
MAX_FILES_DIR
= 100
PERMITTED_CHARS
public
mixed
PERMITTED_CHARS
= '0123456789_abcdefghijklmnopqrstuvwxyz'
RESIZE_TYPE_EXACT
{@link resize()} fills given area exactly
public
mixed
RESIZE_TYPE_EXACT
= 8
RESIZE_TYPE_FILL
{@link resize()} fills given area so its dimensions are greater than or equal to the required dimensions
public
mixed
RESIZE_TYPE_FILL
= 4
RESIZE_TYPE_FIT
{@link resize()} fits in given area so its dimensions are less than or equal to the required dimensions
public
mixed
RESIZE_TYPE_FIT
= ""
RESIZE_TYPE_SHRINK_ONLY
{@link resize()} only shrinks images
public
mixed
RESIZE_TYPE_SHRINK_ONLY
= 1
RESIZE_TYPE_STRETCH
{@link resize()} will ignore aspect ratio
public
mixed
RESIZE_TYPE_STRETCH
= 2
Properties
$add_dt
public
mixed
$add_dt
$content_type
public
mixed
$content_type
$file_name
public
mixed
$file_name
$id
public
mixed
$id
$new_dir
public
mixed
$new_dir
$new_file_name
public
mixed
$new_file_name
$old_dir
public
mixed
$old_dir
$old_file_name
public
mixed
$old_file_name
$original_name
public
mixed
$original_name
$size
public
mixed
$size
$sub_dir
public
mixed
$sub_dir
$uuid
public
mixed
$uuid
$database
private
Context
$database
$files_id
private
mixed
$files_id
$height
private
mixed
$height
$primary_key
private
mixed
$primary_key
= 'files_id'
$props
private
mixed
$props
= array('files_id', 'width', 'height')
$table
private
mixed
$table
= 'files_image'
$table_tags_files
private
mixed
$table_tags_files
= 'tags_files'
$tempName
private
mixed
$tempName
$upload_dir
private
mixed
$upload_dir
$width
private
mixed
$width
Methods
__construct()
public
__construct(mixed $upload_dir, Context $database) : mixed
Parameters
- $upload_dir : mixed
- $database : Context
Return values
mixed —convert()
public
convert() : bool
Return values
bool —createDir()
Создает директорию
public
createDir( $path[, int $mode = 755 ][, bool $recursive = true ]) : bool
Parameters
Tags
Return values
bool —delete()
Удаляет файл
public
delete() : bool
Tags
Return values
bool —get()
public
get(int $file_id) : $this|false
Parameters
- $file_id : int
Tags
Return values
$this|false —getChildDir()
Возвращает массив дочерних директорий
public
getChildDir( $path) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —getPath()
Возвращает путь до файла
public
getPath() : bool|string
Return values
bool|string —imageResizeDel()
public
imageResizeDel() : bool
Return values
bool —isEmpty()
Проверяет директорию на пустоту
public
isEmpty( $path) : bool
Parameters
Return values
bool —move()
Moves an uploaded file to a new location. If the destination file already exists, it will be overwritten.
public
move(string $dest, string $tempName) : static
Parameters
- $dest : string
- $tempName : string
Return values
static —resizeImageGet()
Метод уменьшает картинку и размещает уменьшенную копию в папку self::CACHE_DIR.
public
resizeImageGet([int $width = 200 ][, int $height = 200 ][, int $resizeType = self::RESIZE_TYPE_FIT ][, int $quality = 100 ]) : bool|string
Один раз уменьшив изображение получаем физический файл, который позволяет при последующих обращениях не проводить операции по уменьшению изображения. При следующем вызове метод вернет путь к уменьшенному файлу. Статический метод.
Parameters
- $width : int = 200
-
- Ширина
- $height : int = 200
-
- Высота
- $resizeType : int = self::RESIZE_TYPE_FIT
-
- Тип масштабирования
- $quality : int = 100
-
- Число, устанавливающее в процентах качество изображения при масштабировании.
Tags
Return values
bool|string —save()
Метод сохраняет файл и регистрирует его в таблице файлов (files).
public
save([array<string|int, mixed> $arFile = array() ]) : $this
Parameters
- $arFile : array<string|int, mixed> = array()
Tags
Return values
$this —setAddDt()
Задаёт дату добавления, на текущий момент
public
setAddDt() : mixed
Return values
mixed —setContentType()
Задаёт тип файла
public
setContentType(string $content_type) : $this|false
Parameters
- $content_type : string
Return values
$this|false —setFileName()
Задаёт имя файлу
public
setFileName(string $file_name) : $this|false
Parameters
- $file_name : string
Return values
$this|false —setHeight()
public
setHeight(mixed $height) : ImageFile
Parameters
- $height : mixed
Return values
ImageFile —setOriginalName()
Задаёт оригинальное имя
public
setOriginalName(string $original_name) : $this|false
Parameters
- $original_name : string
Return values
$this|false —setSize()
Задаёт размер файла
public
setSize(int $size) : $this|false
Parameters
- $size : int
Return values
$this|false —setSubDir()
Задаёт расположение
public
setSubDir(string $sub_dir) : $this
Parameters
- $sub_dir : string
Return values
$this —setUuid()
Задаёт uuid файла
public
setUuid() : $this
Tags
Return values
$this —setWidth()
public
setWidth(mixed $width) : ImageFile
Parameters
- $width : mixed
Return values
ImageFile —absoluteResizeDir()
protected
absoluteResizeDir() : string
Return values
string —absoluteUploadDir()
protected
absoluteUploadDir() : string
Return values
string —add()
protected
add( $arFile) : false|ImageFile
Parameters
Tags
Return values
false|ImageFile —relativeResizeDir()
protected
relativeResizeDir() : string
Return values
string —relativeUploadDir()
protected
relativeUploadDir() : string
Return values
string —replace()
protected
replace( $arFile) : $this|BaseFile|bool
Parameters
Tags
Return values
$this|BaseFile|bool —update()
protected
update() : $this|BaseFile|bool
Tags
Return values
$this|BaseFile|bool —validate()
protected
validate() : bool|false
Return values
bool|false —__buildFileArray()
Строит массив атрибутов файла
private
__buildFileArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —__changeDir()
*
private
__changeDir() : mixed
Tags
Return values
mixed —__checkMaxCountFilesDir()
Проверяет заполнена ли директори
private
__checkMaxCountFilesDir(string $file) : bool
Parameters
- $file : string
-
Полное имя файла
Return values
bool —__deleteOld()
private
__deleteOld( $file_id_old) : bool
Parameters
Tags
Return values
bool —__findDirToSave()
Выполняет поиск подходящей директории для сохранения файла.
private
__findDirToSave( $path) : mixed|string
Parameters
Return values
mixed|string —__genOnlyDirName()
Создает уникальное имя директории
private
__genOnlyDirName([string $path = '' ]) : string
Parameters
- $path : string = ''
Return values
string —__genOnlyFileName()
Создает уникальное имя файла в указанной директории
private
__genOnlyFileName([string $path = '' ][, string $fname = '' ]) : bool|string
Parameters
- $path : string = ''
-
- полный путь до директории
- $fname : string = ''
-
- имя файла
Return values
bool|string —__imageResizeRename()
private
__imageResizeRename() : void
Tags
Return values
void —__prepareDirToSave()
private
__prepareDirToSave() : false|mixed|string
Tags
Return values
false|mixed|string —__prepareSysDir()
private
__prepareSysDir() : bool
Tags
Return values
bool —__rename()
переименовывает файл
private
__rename() : void
Tags
Return values
void —callManager()
Возвращает экземпляр класса FileManager
private
callManager() : FileManager
Return values
FileManager —getPropsToArray()
Преобразует свойства файла в массив
private
getPropsToArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —setProps()
Сохраняет свойство файла в объект
private
setProps( $file) : mixed