Skip to content

Commit

Permalink
drivers inner api changedgit status! elFinderVolumeDriver::_save(, , …
Browse files Browse the repository at this point in the history
…, , , ) -> elFinderVolumeDriver::_save(, , , )
  • Loading branch information
dio-el-claire committed Sep 11, 2012
1 parent cc36708 commit 6638eae
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 61 deletions.
83 changes: 42 additions & 41 deletions php/connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,14 @@ function validName($name) {
// 'path' => '/',
// 'tmpPath' => '../files/ftp',
// ),
// array(
// 'driver' => 'FTP',
// 'host' => '192.168.1.35',
// 'user' => 'frontrow',
// 'pass' => 'frontrow',
// 'path' => '/'
// ),
array(
'driver' => 'FTP',
'host' => '10.0.1.3',
'user' => 'frontrow',
'pass' => 'frontrow',
'path' => '/',
'tmpPath' => '../files/ftp',
),

// array(
// 'driver' => 'LocalFileSystem',
Expand All @@ -358,40 +359,40 @@ function validName($name) {
// )
// ),

// array(
// 'driver' => 'MySQL',
// 'path' => 1,
// // 'treeDeep' => 2,
// // 'socket' => '/opt/local/var/run/mysql5/mysqld.sock',
// 'user' => 'root',
// 'pass' => 'hane',
// 'db' => 'elfinder',
// 'user_id' => 1,
// // 'accessControl' => 'access',
// // 'separator' => ':',
// 'tmbCrop' => true,
// // thumbnails background color (hex #rrggbb or 'transparent')
// 'tmbBgColor' => '#000000',
// 'files_table' => 'elfinder_file',
// // 'imgLib' => 'imagick',
// // 'uploadOverwrite' => false,
// // 'copyTo' => false,
// // 'URL' => 'http://localhost/git/elfinder',
// 'tmpPath' => '../filesdb/tmp',
// 'tmbPath' => '../filesdb/tmb',
// 'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../filesdb/tmb/',
// // 'attributes' => array(
// // array(),
// // array(
// // 'pattern' => '/\.jpg$/',
// // 'read' => false,
// // 'write' => false,
// // 'locked' => true,
// // 'hidden' => true
// // )
// // )
//
// )
array(
'driver' => 'MySQL',
'path' => 1,
// 'treeDeep' => 2,
// 'socket' => '/opt/local/var/run/mysql5/mysqld.sock',
'user' => 'root',
'pass' => 'hane',
'db' => 'elfinder',
'user_id' => 1,
// 'accessControl' => 'access',
// 'separator' => ':',
'tmbCrop' => true,
// thumbnails background color (hex #rrggbb or 'transparent')
'tmbBgColor' => '#000000',
'files_table' => 'elfinder_file',
// 'imgLib' => 'imagick',
// 'uploadOverwrite' => false,
// 'copyTo' => false,
// 'URL' => 'http://localhost/git/elfinder',
'tmpPath' => '../filesdb/tmp',
'tmbPath' => '../filesdb/tmb',
'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../filesdb/tmb/',
// 'attributes' => array(
// array(),
// array(
// 'pattern' => '/\.jpg$/',
// 'read' => false,
// 'write' => false,
// 'locked' => true,
// 'hidden' => true
// )
// )

)
)

);
Expand Down
37 changes: 20 additions & 17 deletions php/elFinderVolumeDriver.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1420,13 +1420,19 @@ public function upload($fp, $dst, $name, $tmpname) {
}
}

$w = $h = 0;
$stat = array(
'mime' => $mime,
'w' => 0,
'h' => 0,
'size' => filesize($tmpname));

// $w = $h = 0;
if (strpos($mime, 'image') === 0 && ($s = getimagesize($tmpname))) {
$w = $s[0];
$h = $s[1];
$stat['w'] = $s[0];
$stat['h'] = $s[1];
}
// $this->clearcache();
if (($path = $this->_save($fp, $dstpath, $name, $mime, $w, $h)) == false) {
if (($path = $this->_save($fp, $dstpath, $name, $stat)) == false) {
return false;
}

Expand Down Expand Up @@ -2537,16 +2543,16 @@ protected function copyFrom($volume, $src, $destination, $name) {
}

} else {
$mime = $source['mime'];
$w = $h = 0;
if (strpos($mime, 'image') === 0 && ($dim = $volume->dimensions($src))) {
$s = explode('x', $dim);
$w = $s[0];
$h = $s[1];
}
// $mime = $source['mime'];
// $w = $h = 0;
// if (strpos($mime, 'image') === 0 && ($dim = $volume->dimensions($src))) {
// $s = explode('x', $dim);
// $w = $s[0];
// $h = $s[1];
// }

if (($fp = $volume->open($src)) == false
|| ($path = $this->_save($fp, $destination, $name, $mime, $w, $h, $source)) == false) {
|| ($path = $this->_save($fp, $destination, $name, $source)) == false) {
$fp && $volume->close($fp, $src);
return $this->setError(elFinder::ERROR_COPY, $errpath);
}
Expand Down Expand Up @@ -3430,14 +3436,11 @@ abstract protected function _rmdir($path);
* @param resource $fp file pointer
* @param string $dir target dir path
* @param string $name file name
* @param string $mime file mime type
* @param integer $w image width
* @param integer $h image height
* @param array $stat file stat (optional)
* @param array $stat file stat (required by some virtual fs)
* @return bool|string
* @author Dmitry (dio) Levashov
**/
abstract protected function _save($fp, $dir, $name, $mime, $w, $h);
abstract protected function _save($fp, $dir, $name, $stat);

/**
* Get file contents
Expand Down
3 changes: 2 additions & 1 deletion php/elFinderVolumeFTP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,11 @@ protected function _rmdir($path) {
* @param resource $fp file pointer
* @param string $dir target dir path
* @param string $name file name
* @param array $stat file stat (required by some virtual fs)
* @return bool|string
* @author Dmitry (dio) Levashov
**/
protected function _save($fp, $dir, $name, $mime, $w, $h) {
protected function _save($fp, $dir, $name, $stat) {
$path = $dir.'/'.$name;
return ftp_fput($this->connect, $path, $fp, $this->ftpMode($path))
? $path
Expand Down
3 changes: 2 additions & 1 deletion php/elFinderVolumeLocalFileSystem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,11 @@ protected function _rmdir($path) {
* @param resource $fp file pointer
* @param string $dir target dir path
* @param string $name file name
* @param array $stat file stat (required by some virtual fs)
* @return bool|string
* @author Dmitry (dio) Levashov
**/
protected function _save($fp, $dir, $name, $mime, $w, $h) {
protected function _save($fp, $dir, $name, $stat) {
$path = $dir.DIRECTORY_SEPARATOR.$name;

if (!($target = @fopen($path, 'wb'))) {
Expand Down
7 changes: 6 additions & 1 deletion php/elFinderVolumeMySQL.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,17 @@ protected function _setContent($path, $fp) {
* @param resource $fp file pointer
* @param string $dir target dir path
* @param string $name file name
* @param array $stat file stat (required by some virtual fs)
* @return bool|string
* @author Dmitry (dio) Levashov
**/
protected function _save($fp, $dir, $name, $mime, $w, $h) {
protected function _save($fp, $dir, $name, $stat) {
$this->clearcache();

$mime = $stat['mime'];
$w = !empty($stat['w']) ? $stat['w'] : 0;
$h = !empty($stat['h']) ? $stat['h'] : 0;

$id = $this->_joinPath($dir, $name);
rewind($fp);
$stat = fstat($fp);
Expand Down

0 comments on commit 6638eae

Please sign in to comment.