85 lines
2.2 KiB
PHP
85 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Простой слой загрузки файлов на сервер - "голая" версия
|
|
* Версия 2018-01-14
|
|
* (c) Виталий Филиппов 2018
|
|
*/
|
|
|
|
class File
|
|
{
|
|
const ONLY_BINARY = 1;
|
|
const ONLY_IMAGES = 2;
|
|
const ONLY_SWF = 4;
|
|
const ONLY_VIDEO = 8;
|
|
const IMAGES_VIDEO = 10;
|
|
const ANY_MEDIA = 14;
|
|
const ANYTHING = 15;
|
|
|
|
const CROP_XY = 1;
|
|
const CROP_Y = 2;
|
|
const CROP_X = 3;
|
|
|
|
public static $table = 'files';
|
|
|
|
public static function getDiskPath($file)
|
|
{
|
|
return FileHandler::getPath(false, $file);
|
|
}
|
|
|
|
public static function getUrl($file)
|
|
{
|
|
return FileHandler::getPath(true, $file);
|
|
}
|
|
|
|
public static function getThumbPath($file, $type)
|
|
{
|
|
return FileHandler::getThumbPath(false, $file, $type);
|
|
}
|
|
|
|
public static function getGPS($file)
|
|
{
|
|
return FileHandler::getGPS($file);
|
|
}
|
|
|
|
public static function getSizeString($file, $lang = 'ru')
|
|
{
|
|
return FileUtils::sizeString($file['size'], $lang);
|
|
}
|
|
|
|
public static function getThumb($file, $width, $height, $force = false, $crop = false, $alignY = 0.5)
|
|
{
|
|
return FileHandler::getThumb($file, $width, $height, $force, $crop, $alignY);
|
|
}
|
|
|
|
public static function cropThumb($file, $width, $height, $alignY = 0.5)
|
|
{
|
|
return FileHandler::getThumb($file, $width, $height, false, self::CROP_XY, $alignY);
|
|
}
|
|
|
|
public static function cropYThumb($file, $width, $max_height, $alignY = 0.5)
|
|
{
|
|
return FileHandler::getThumb($file, $width, $max_height, false, self::CROP_Y, $alignY);
|
|
}
|
|
|
|
public static function cropXThumb($file, $max_width, $height)
|
|
{
|
|
return FileHandler::getThumb($file, $max_width, $height, false, self::CROP_X);
|
|
}
|
|
|
|
public static function upload(LocalFile $localFile, $allowedFormats = File::ANYTHING)
|
|
{
|
|
return FileHandler::upload($localFile, $allowedFormats);
|
|
}
|
|
|
|
public static function uploadUrl($url, $allowedFormats = File::ONLY_IMAGES, $curl_options = [])
|
|
{
|
|
return FileHandler::uploadUrl($url, $allowedFormats, $curl_options);
|
|
}
|
|
|
|
public static function deleteFiles($where)
|
|
{
|
|
return FileHandler::deleteFiles($where);
|
|
}
|
|
}
|