src build elFinder-2.1-d7fe38b

This commit is contained in:
nao-pon
2016-04-10 23:34:11 +09:00
parent 07ce08b602
commit 3cbcfa3c69
15 changed files with 1020 additions and 838 deletions
+277 -258
View File
@@ -476,7 +476,7 @@ abstract class elFinderVolumeDriver {
'rb' => 'text/x-ruby',
'sh' => 'text/x-shellscript',
'pl' => 'text/x-perl',
'xml' => 'text/xml',
//'xml' => 'text/xml',
'sql' => 'text/x-sql',
'c' => 'text/x-csrc',
'h' => 'text/x-chdr',
@@ -496,7 +496,7 @@ abstract class elFinderVolumeDriver {
'tiff' => 'image/tiff',
'tga' => 'image/x-targa',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'image/vnd.adobe.photoshop',
//'ai' => 'image/vnd.adobe.photoshop',
'xbm' => 'image/xbm',
'pxm' => 'image/pxm',
//audio
@@ -795,16 +795,17 @@ abstract class elFinderVolumeDriver {
clearstatcache();
$this->cache = $this->dirsCache = array();
}
/**
* "Mount" volume.
* Return true if volume available for read or write,
* false - otherwise
*
* @return bool
* @author Dmitry (dio) Levashov
* @author Alexey Sukhotin
**/
/**
* "Mount" volume.
* Return true if volume available for read or write,
* false - otherwise
*
* @param array $opts
* @return bool
* @author Dmitry (dio) Levashov
* @author Alexey Sukhotin
*/
public function mount(array $opts) {
if (!isset($opts['path']) || $opts['path'] === '') {
return $this->setError('Path undefined.');
@@ -1173,14 +1174,15 @@ abstract class elFinderVolumeDriver {
public function root() {
return $this->encode($this->root);
}
/**
* Return target path hash
*
* @param string $path
* @param string $name
* @author Naoki Sawada
*/
/**
* Return target path hash
*
* @param string $path
* @param string $name
* @author Naoki Sawada
* @return string
*/
public function getHash($path, $name = '') {
if ($name !== '') {
$path = $this->joinPathCE($path, $name);
@@ -1197,13 +1199,14 @@ abstract class elFinderVolumeDriver {
public function defaultPath() {
return $this->encode($this->startPath ? $this->startPath : $this->root);
}
/**
* Return volume options required by client:
*
* @return array
* @author Dmitry (dio) Levashov
**/
/**
* Return volume options required by client:
*
* @param $hash
* @return array
* @author Dmitry (dio) Levashov
*/
public function options($hash) {
$create = $createext = array();
if (isset($this->archivers['create']) && is_array($this->archivers['create'])) {
@@ -1369,15 +1372,15 @@ abstract class elFinderVolumeDriver {
public function closest($hash, $attr, $val) {
return ($path = $this->closestByAttr($this->decode($hash), $attr, $val)) ? $this->encode($path) : false;
}
/**
* Return file info or false on error
*
* @param string $hash file hash
* @param bool $realpath add realpath field to file info
* @return array|false
* @author Dmitry (dio) Levashov
**/
/**
* Return file info or false on error
*
* @param string $hash file hash
* @return array|false
* @internal param bool $realpath add realpath field to file info
* @author Dmitry (dio) Levashov
*/
public function file($hash) {
$path = $this->decode($hash);
$isRoot = ($path == $this->root);
@@ -1390,15 +1393,16 @@ abstract class elFinderVolumeDriver {
return ($file) ? $file : $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
}
/**
* Return folder info
*
* @param string $hash folder hash
* @param bool $hidden return hidden file info
* @return array|false
* @author Dmitry (dio) Levashov
**/
/**
* Return folder info
*
* @param string $hash folder hash
* @param bool $resolveLink
* @return array|false
* @internal param bool $hidden return hidden file info
* @author Dmitry (dio) Levashov
*/
public function dir($hash, $resolveLink=false) {
if (($dir = $this->file($hash)) == false) {
return $this->setError(elFinder::ERROR_DIR_NOT_FOUND);
@@ -1430,13 +1434,14 @@ abstract class elFinderVolumeDriver {
: $this->setError(elFinder::ERROR_PERM_DENIED);
}
/**
* Return dir files names list
*
* @param string $hash file hash
* @return array
* @author Dmitry (dio) Levashov
**/
/**
* Return dir files names list
*
* @param string $hash file hash
* @param null $intersect
* @return array
* @author Dmitry (dio) Levashov
*/
public function ls($hash, $intersect = null) {
if (($dir = $this->dir($hash)) == false || !$dir['read']) {
return false;
@@ -1514,13 +1519,14 @@ abstract class elFinderVolumeDriver {
return $tree ? $tree : array($current);
}
/**
* Create thumbnail for required file and return its name of false on failed
*
* @return string|false
* @author Dmitry (dio) Levashov
**/
/**
* Create thumbnail for required file and return its name of false on failed
*
* @param $hash
* @return false|string
* @author Dmitry (dio) Levashov
*/
public function tmb($hash) {
$path = $this->decode($hash);
$stat = $this->stat($path);
@@ -1725,19 +1731,20 @@ abstract class elFinderVolumeDriver {
? false
: $this->stat($path);
}
/**
* Save uploaded file.
* On success return array with new file stat and with removed file hash (if existed file was replaced)
*
* @param Resource $fp file pointer
* @param string $dst destination folder hash
* @param string $src file name
* @param string $tmpname file tmp name - required to detect mime type
* @param array $hashes exists files hash array with filename as key
* @return array|false
* @author Dmitry (dio) Levashov
**/
/**
* Save uploaded file.
* On success return array with new file stat and with removed file hash (if existed file was replaced)
*
* @param Resource $fp file pointer
* @param string $dst destination folder hash
* @param $name
* @param string $tmpname file tmp name - required to detect mime type
* @param array $hashes exists files hash array with filename as key
* @return array|false
* @internal param string $src file name
* @author Dmitry (dio) Levashov
*/
public function upload($fp, $dst, $name, $tmpname, $hashes = array()) {
if ($this->commandDisabled('upload')) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -1822,17 +1829,19 @@ abstract class elFinderVolumeDriver {
return $stat;
}
/**
* Paste files
*
* @param Object $volume source volume
* @param string $source file hash
* @param string $dst destination dir hash
* @param bool $rmSrc remove source after copy?
* @return array|false
* @author Dmitry (dio) Levashov
**/
/**
* Paste files
*
* @param Object $volume source volume
* @param $src
* @param string $dst destination dir hash
* @param bool $rmSrc remove source after copy?
* @param array $hashes
* @return array|false
* @internal param string $source file hash
* @author Dmitry (dio) Levashov
*/
public function paste($volume, $src, $dst, $rmSrc = false, $hashes = array()) {
$err = $rmSrc ? elFinder::ERROR_MOVE : elFinder::ERROR_COPY;
@@ -2070,15 +2079,16 @@ abstract class elFinderVolumeDriver {
$this->clearcache();
return $this->convEncOut($this->_filePutContents($this->convEncIn($path), $content)) ? $this->stat($path) : false;
}
/**
* Extract files from archive
*
* @param string $hash archive hash
* @return array|bool
* @author Dmitry (dio) Levashov,
* @author Alexey Sukhotin
**/
/**
* Extract files from archive
*
* @param string $hash archive hash
* @param null $makedir
* @return array|bool
* @author Dmitry (dio) Levashov,
* @author Alexey Sukhotin
*/
public function extract($hash, $makedir = null) {
if ($this->commandDisabled('extract')) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -2119,11 +2129,14 @@ abstract class elFinderVolumeDriver {
}
}
/**
* Add files to archive
*
* @return void
**/
/**
* Add files to archive
*
* @param $hashes
* @param $mime
* @param string $name
* @return array|bool
*/
public function archive($hashes, $mime, $name = '') {
if ($this->commandDisabled('archive')) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
@@ -2145,17 +2158,17 @@ abstract class elFinderVolumeDriver {
foreach ($hashes as $hash) {
if (($file = $this->file($hash)) == false) {
return $this->error(elFinder::ERROR_FILE_NOT_FOUND, '#'+$hash);
return $this->setError(elFinder::ERROR_FILE_NOT_FOUND, '#'+$hash);
}
if (!$file['read']) {
return $this->error(elFinder::ERROR_PERM_DENIED);
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
$path = $this->decode($hash);
if (!isset($dir)) {
$dir = $this->dirnameCE($path);
$stat = $this->stat($dir);
if (!$stat['write']) {
return $this->error(elFinder::ERROR_PERM_DENIED);
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
}
@@ -2291,15 +2304,16 @@ abstract class elFinderVolumeDriver {
? $this->setError(elFinder::ERROR_PERM_DENIED)
: $this->remove($this->decode($hash));
}
/**
* Search files
*
* @param string $q search string
* @param array $mimes
* @return array
* @author Dmitry (dio) Levashov
**/
/**
* Search files
*
* @param string $q search string
* @param array $mimes
* @param null $hash
* @return array
* @author Dmitry (dio) Levashov
*/
public function search($q, $mimes, $hash = null) {
$dir = null;
if ($hash) {
@@ -2622,15 +2636,16 @@ abstract class elFinderVolumeDriver {
protected function inpathCE($path, $parent) {
return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
}
/**
* Open file and return file pointer (with convert encording)
*
* @param string $path file path
* @param bool $write open file for writing
* @return resource|false
* @author Naoki Sawada
**/
/**
* Open file and return file pointer (with convert encording)
*
* @param string $path file path
* @param string $mode
* @return false|resource
* @internal param bool $write open file for writing
* @author Naoki Sawada
*/
protected function fopenCE($path, $mode='rb') {
return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
}
@@ -2730,6 +2745,7 @@ abstract class elFinderVolumeDriver {
// append volume id to make hash unique
return $this->id.$hash;
}
//TODO: Add return statement here
}
/**
@@ -2751,6 +2767,7 @@ abstract class elFinderVolumeDriver {
// append ROOT to path after it was cut in encode
return $this->abspathCE($path);//$this->root.($path == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR.$path);
}
//TODO: Add return statement here
}
/**
@@ -2799,15 +2816,19 @@ abstract class elFinderVolumeDriver {
}
return true;
}
/**
* Return new unique name based on file name and suffix
*
* @param string $path file path
* @param string $suffix suffix append to name
* @return string
* @author Dmitry (dio) Levashov
**/
/**
* Return new unique name based on file name and suffix
*
* @param $dir
* @param $name
* @param string $suffix suffix append to name
* @param bool $checkNum
* @param int $start
* @return string
* @internal param string $path file path
* @author Dmitry (dio) Levashov
*/
public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
$ext = '';
@@ -2862,17 +2883,18 @@ abstract class elFinderVolumeDriver {
public function convEncOut($var = null, $restoreLocale = true, $unknown = '_') {
return (!$this->encoding)? $var : $this->convEnc($var, $this->encoding, 'UTF-8', $this->options['locale'], $restoreLocale, $unknown);
}
/**
* Converts character encoding (base function)
*
* @param mixed $var target string or array var
* @param string $from from character encoding
* @param string $to to character encoding
* @param string $locale local locale
* @param string $unknown replaces character for unknown
* @return mixed
*/
/**
* Converts character encoding (base function)
*
* @param mixed $var target string or array var
* @param string $from from character encoding
* @param string $to to character encoding
* @param string $locale local locale
* @param $restoreLocale
* @param string $unknown replaces character for unknown
* @return mixed
*/
protected function convEnc($var, $from, $to, $locale, $restoreLocale, $unknown = '_') {
if (strtoupper($from) !== strtoupper($to)) {
if ($locale) {
@@ -3120,15 +3142,16 @@ abstract class elFinderVolumeDriver {
return $perm === null ? (is_null($val)? $this->defaults[$name] : $val) : !!$perm;
}
/**
* Return true if file with given name can be created in given folder.
*
* @param string $dir parent dir path
* @param string $name new file name
* @return bool
* @author Dmitry (dio) Levashov
**/
/**
* Return true if file with given name can be created in given folder.
*
* @param string $dir parent dir path
* @param string $name new file name
* @param null $isDir
* @return bool
* @author Dmitry (dio) Levashov
*/
protected function allowCreate($dir, $name, $isDir = null) {
$path = $this->joinPathCE($dir, $name);
$perm = null;
@@ -3418,14 +3441,15 @@ abstract class elFinderVolumeDriver {
unset($this->sessionCache['rootstat'][md5($this->root)]);
$this->session->set($this->id, $this->sessionCache);
}
/**
* Return file mimetype
*
* @param string $path file path
* @return string
* @author Dmitry (dio) Levashov
**/
/**
* Return file mimetype
*
* @param string $path file path
* @param string $name
* @return string
* @author Dmitry (dio) Levashov
*/
protected function mimetype($path, $name = '') {
$type = '';
@@ -3646,16 +3670,17 @@ abstract class elFinderVolumeDriver {
return $files;
}
/**
* Return subdirs tree
*
* @param string $path parent dir path
* @param int $deep tree deep
* @return array
* @author Dmitry (dio) Levashov
**/
/**
* Return subdirs tree
*
* @param string $path parent dir path
* @param int $deep tree deep
* @param string $exclude
* @return array
* @author Dmitry (dio) Levashov
*/
protected function gettree($path, $deep, $exclude='') {
$dirs = array();
@@ -4009,15 +4034,16 @@ abstract class elFinderVolumeDriver {
protected function canResize($path, $stat) {
return $this->canCreateTmb($path, $stat, false);
}
/**
* Create thumnbnail and return it's URL on success
*
* @param string $path file path
* @param string $mime file mime type
* @return string|false
* @author Dmitry (dio) Levashov
**/
/**
* Create thumnbnail and return it's URL on success
*
* @param string $path file path
* @param $stat
* @return false|string
* @internal param string $mime file mime type
* @author Dmitry (dio) Levashov
*/
protected function createTmb($path, $stat) {
if (!$stat || !$this->canCreateTmb($path, $stat)) {
return false;
@@ -4321,21 +4347,21 @@ abstract class elFinderVolumeDriver {
return false;
}
/**
* Put image to square
*
* @param string $path image file
* @param int $width square width
* @param int $height square height
* @param int $align reserved
* @param int $valign reserved
* @param string $bgcolor square background color in #rrggbb format
* @param string $destformat image destination format
* @param int $jpgQuality JEPG quality (1-100)
* @return string|false
* @author Dmitry (dio) Levashov
* @author Alexey Sukhotin
**/
/**
* Put image to square
*
* @param string $path image file
* @param int $width square width
* @param int $height square height
* @param int|string $align reserved
* @param int|string $valign reserved
* @param string $bgcolor square background color in #rrggbb format
* @param string $destformat image destination format
* @param int $jpgQuality JEPG quality (1-100)
* @return false|string
* @author Dmitry (dio) Levashov
* @author Alexey Sukhotin
*/
protected function imgSquareFit($path, $width, $height, $align = 'center', $valign = 'middle', $bgcolor = '#0000ff', $destformat = null, $jpgQuality = null) {
if (($s = @getimagesize($path)) == false) {
return false;
@@ -4516,16 +4542,16 @@ abstract class elFinderVolumeDriver {
return false;
}
/**
* Execute shell command
*
* @param string $command command line
* @param array $output stdout strings
* @param array $return_var process exit code
* @param array $error_output stderr strings
* @return int exit code
* @author Alexey Sukhotin
**/
/**
* Execute shell command
*
* @param string $command command line
* @param array $output stdout strings
* @param array|int $return_var process exit code
* @param array $error_output stderr strings
* @return int exit code
* @author Alexey Sukhotin
*/
protected function procExec($command , array &$output = null, &$return_var = -1, array &$error_output = null) {
if (! function_exists('proc_open')) {
@@ -4619,15 +4645,16 @@ abstract class elFinderVolumeDriver {
return false;
}
/**
* Output gd image to file
*
* @param resource $image gd image resource
* @param string $filename The path to save the file to.
* @param string $destformat The Image type to use for $filename
* @param string $mime The original image mime type
* @param int $jpgQuality JEPG quality (1-100)
*/
/**
* Output gd image to file
*
* @param resource $image gd image resource
* @param string $filename The path to save the file to.
* @param string $destformat The Image type to use for $filename
* @param string $mime The original image mime type
* @param int $jpgQuality JEPG quality (1-100)
* @return bool
*/
protected function gdImage($image, $filename, $destformat, $mime, $jpgQuality = null ){
if (!$jpgQuality) {
@@ -4644,14 +4671,15 @@ abstract class elFinderVolumeDriver {
return imagepng($image, $filename, 7);
}
/**
* Output imagick image to file
*
* @param resource $img imagick image resource
* @param string $filename The path to save the file to.
* @param string $destformat The Image type to use for $filename
* @param int $jpgQuality JEPG quality (1-100)
*/
/**
* Output imagick image to file
*
* @param resource $img imagick image resource
* @param string $filename The path to save the file to.
* @param string $destformat The Image type to use for $filename
* @param int $jpgQuality JEPG quality (1-100)
* @return bool
*/
protected function imagickImage($img, $filename, $destformat, $jpgQuality = null ){
if (!$jpgQuality) {
@@ -4687,18 +4715,6 @@ abstract class elFinderVolumeDriver {
}
return $result;
if ($destformat == 'jpg' || ($destformat == null && $mime == 'image/jpeg')) {
return imagejpeg($image, $filename, $jpgQuality);
}
if ($destformat == 'gif' || ($destformat == null && $mime == 'image/gif')) {
return imagegif($image, $filename, 7);
}
return imagepng($image, $filename, 7);
}
/**
@@ -5030,14 +5046,15 @@ abstract class elFinderVolumeDriver {
}
$remove && unlink($path);
}
/**
* Return files of target directory that is dotfiles excludes.
*
* @param string $dir target directory path
* @return array
* @author Naoki Sawada
**/
/**
* Return files of target directory that is dotfiles excludes.
*
* @param string $dir target directory path
* @return array
* @throws Exception
* @author Naoki Sawada
*/
protected static function localScandir($dir) {
// PHP function scandir() is not work well in specific environment. I dont know why.
// ref. https://github.com/Studio-42/elFinder/issues/1248
@@ -5061,7 +5078,7 @@ abstract class elFinderVolumeDriver {
* @param string $dir target dir
* @param array $files files names list
* @param string|object $zipPath Zip archive name
* @return void
* @return bool
* @author Naoki Sawada
*/
protected static function zipArchiveZip($dir, $files, $zipPath) {
@@ -5312,28 +5329,30 @@ abstract class elFinderVolumeDriver {
* @author Dmitry (dio) Levashov
**/
abstract protected function _symlink($source, $targetDir, $name);
/**
* Copy file into another file (only inside one volume)
*
* @param string $source source file path
* @param string $target target dir path
* @param string $name file name
* @return string|bool
* @author Dmitry (dio) Levashov
**/
/**
* Copy file into another file (only inside one volume)
*
* @param string $source source file path
* @param $targetDir
* @param string $name file name
* @return bool|string
* @internal param string $target target dir path
* @author Dmitry (dio) Levashov
*/
abstract protected function _copy($source, $targetDir, $name);
/**
* Move file into another parent dir.
* Return new file path or false.
*
* @param string $source source file path
* @param string $target target dir path
* @param string $name file name
* @return string|bool
* @author Dmitry (dio) Levashov
**/
/**
* Move file into another parent dir.
* Return new file path or false.
*
* @param string $source source file path
* @param $targetDir
* @param string $name file name
* @return bool|string
* @internal param string $target target dir path
* @author Dmitry (dio) Levashov
*/
abstract protected function _move($source, $targetDir, $name);
/**