toArray(); } if (false === $field) { return static::$_config; } return (array_key_exists($field, static::$_config)) ? static::$_config[$field] : $default; } /** * Returns non quoted relative target file name * Example: userfiles/files/notes(18).pdf * * @static * @param $name * @return string */ protected static function _getFullName($name) { if (!empty($name)) { if ('.' === dirname($name)) { $name = Qs_ImageFs::WEB_PATH . '/' . $name; } $fullName = WWW_PATH . '/' . $name; if (file_exists($fullName)) { return $name; } } return null; } public static function getFileFullName($name) { return constant('WWW_PATH') . '/' . self::WEB_PATH . '/' . $name; } /** * @static * @param string $fullName * @return string */ public static function quotePath($fullName) { $parts = explode('/', $fullName); return implode('/', array_map('rawurlencode', $parts)); } /** * Returns quoted full file name * Example: userfiles/notes(18).pdf * * @static * @param string $name * @return string */ public static function get($name) { $fullName = static::_getFullName($name); return static::quotePath($fullName); } public static function getFullPath($name) { $name = $name ? static::_getFullName($name) : null; return $name ? WWW_PATH . '/' . $name : null; } public static function getUrl($name) { $name = static::get($name); if ($name) { $name = BASE_URL_LANGUAGE . '/' . $name; } return $name; } /** * @param string $fullName * @return bool */ public static function delete($fullName) { return unlink($fullName); } public static function getMimeType($file) { if (class_exists('finfo', false)) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; $zendMime = new Zend_Validate_File_MimeType(''); $mimeFile = $zendMime->getMagicFile(); if (!empty($mimeFile)) { $mime = new finfo($const, $mimeFile); } else { $mime = new finfo($const); } if ($mime !== false) { $type = $mime->file($file); } unset($mime); } if (empty($type) && (function_exists('mime_content_type') && ini_get('mime_magic.magicfile'))) { $type = mime_content_type($file); } return $type; } }