From bfb35ff2951ee162bd56b36335329847763531d5 Mon Sep 17 00:00:00 2001 From: Mihail Date: Wed, 11 May 2016 17:20:43 +0300 Subject: [PATCH] version 1.2.0 --- Controller.php | 7 ++-- FtpPath.php | 63 ---------------------------- PathController.php | 5 ++- S3Path.php | 65 ----------------------------- views/connect.php | 2 + BasePath.php => volume/Base.php | 15 ++++--- LocalPath.php => volume/Local.php | 8 ++-- UserPath.php => volume/UserPath.php | 4 +- 8 files changed, 23 insertions(+), 146 deletions(-) delete mode 100644 FtpPath.php delete mode 100644 S3Path.php rename BasePath.php => volume/Base.php (88%) rename LocalPath.php => volume/Local.php (80%) rename UserPath.php => volume/UserPath.php (89%) diff --git a/Controller.php b/Controller.php index 46cf3a0..5221a10 100644 --- a/Controller.php +++ b/Controller.php @@ -1,13 +1,12 @@ $root]; if(!isset($root['class'])) - $root['class'] = 'mihaildev\elfinder\LocalPath'; + $root['class'] = Local::className(); $root = Yii::createObject($root); - /** @var \mihaildev\elfinder\LocalPath $root*/ + /** @var \mihaildev\elfinder\volume\Local $root*/ if($root->isAvailable()) $this->_options['roots'][] = $root->getRoot(); diff --git a/FtpPath.php b/FtpPath.php deleted file mode 100644 index 96040f8..0000000 --- a/FtpPath.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. -*/ - -namespace mihaildev\elfinder; - -/** - * Class FtpPath - * - * @package mihaildev\elfinder - */ -class FtpPath extends BasePath{ - public $driver = 'FTP'; - - public $baseUrl = ''; - - public $basePath = ''; - - public $host = 'localhost'; - public $port = 21; - - public $user = ''; - public $pass = ''; - - public $path = '/'; - public $mode = 'passive'; - - public $iss = false; - - public function getUrl(){ - return rtrim($this->baseUrl,'/').'/'.trim($this->path,'/'); - } - - public function getRealPath(){ - return rtrim($this->basePath,'/').'/'.trim($this->path,'/'); - } - - public function getRoot(){ - if($this->iss) - $this->driver = 'FTPIIS'; - - $options = parent::getRoot(); - - $options['host'] = $this->host; - $options['port'] = $this->port; - $options['user'] = $this->user; - $options['pass'] = $this->pass; - $options['mode'] = $this->mode; - $options['path'] = $this->getRealPath(); - $options['URL'] = $this->getUrl(); - - return $options; - } -} \ No newline at end of file diff --git a/PathController.php b/PathController.php index d6dacca..692f70f 100644 --- a/PathController.php +++ b/PathController.php @@ -12,6 +12,7 @@ */ namespace mihaildev\elfinder; +use mihaildev\elfinder\volume\Local; use yii\helpers\ArrayHelper; use yii\helpers\Url; use Yii; @@ -49,7 +50,7 @@ public function getOptions() $root = ['path' => $root]; if(!isset($root['class'])) - $root['class'] = 'mihaildev\elfinder\LocalPath'; + $root['class'] = Local::className(); if(!empty($subPath)){ if(preg_match("/\./i", $subPath)){ @@ -64,7 +65,7 @@ public function getOptions() $root = Yii::createObject($root); - /** @var \mihaildev\elfinder\LocalPath $root*/ + /** @var Local $root*/ if($root->isAvailable()) $this->_options['roots'][] = $root->getRoot(); diff --git a/S3Path.php b/S3Path.php deleted file mode 100644 index e8ee96d..0000000 --- a/S3Path.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. -*/ - -namespace mihaildev\elfinder; -use yii\helpers\ArrayHelper; - -/** - * Class S3Path - * - */ -class S3Path extends BasePath{ - public $driver = 'S3'; - public $accessKey = ''; - public $secretKey = ''; - public $bucket = ''; - public $region = ''; - public $path = ''; - - public function getRoot(){ - $options = parent::getRoot(); - $options['separator'] = '/'; - - if(empty($options['s3'])) - $options['s3'] = []; - - $options['s3'] = ArrayHelper::merge([ - 'key' => $this->accessKey, - 'secret' => $this->secretKey, - 'region' => $this->region, - 'scheme' => 'http', - 'ssl.certificate_authority' => false - ], $options['s3']); - - $options['bucket'] = $this->bucket; - - if(empty($this->path)) { - $options['path'] = './'; - $options['URL'] = 'http://' . $this->bucket . '.s3-website-' . $this->region . '.amazonaws.com/'; - }else{ - $this->path = trim($this->path, '/'); - $options['path'] = $this->path; - $options['URL'] = 'http://' . $this->bucket . '.s3-website-' . $this->region . '.amazonaws.com/'.$this->path; - } - - $options['acl'] = 'public'; - - if($options['defaults']['read']) - $options['acl'] .= '-read'; - - if($options['defaults']['write']) - $options['acl'] .= '-write'; - - return $options; - } -} \ No newline at end of file diff --git a/views/connect.php b/views/connect.php index 02a3fad..4c16c38 100644 --- a/views/connect.php +++ b/views/connect.php @@ -3,6 +3,8 @@ * @var array $options */ +define('ELFINDER_IMG_PARENT_URL', \mihaildev\elfinder\Assets::getPathUrl()); + // run elFinder $connector = new elFinderConnector(new elFinder($options)); $connector->run(); \ No newline at end of file diff --git a/BasePath.php b/volume/Base.php similarity index 88% rename from BasePath.php rename to volume/Base.php index c46c800..af0a581 100644 --- a/BasePath.php +++ b/volume/Base.php @@ -4,17 +4,18 @@ * Time: 10:39 */ -namespace mihaildev\elfinder; +namespace mihaildev\elfinder\volume; use Yii; -use yii\base\Component as BaseComponent; +use yii\base\Object; +use yii\helpers\ArrayHelper; use yii\helpers\FileHelper; /** * @property array defaults */ -class BasePath extends BaseComponent{ +class Base extends Object{ public $driver = 'LocalFileSystem'; @@ -65,6 +66,10 @@ public function getDefaults(){ return $this->_defaults; } + protected function optionsModifier($options){ + return $options; + } + public function getRoot(){ $options['driver'] = $this->driver; $options['defaults'] = $this->getDefaults(); @@ -94,8 +99,8 @@ public function getRoot(){ 'locked' => false ]; - //var_export($options);exit; + $options = $this->optionsModifier($options); - return \yii\helpers\ArrayHelper::merge($options, $this->options); + return ArrayHelper::merge($options, $this->options); } } \ No newline at end of file diff --git a/LocalPath.php b/volume/Local.php similarity index 80% rename from LocalPath.php rename to volume/Local.php index d29b410..ca7fae8 100644 --- a/LocalPath.php +++ b/volume/Local.php @@ -4,11 +4,11 @@ * Time: 22:47 */ -namespace mihaildev\elfinder; +namespace mihaildev\elfinder\volume; use Yii; -class LocalPath extends BasePath{ +class Local extends Base{ public $path; public $baseUrl = '@web'; @@ -28,9 +28,7 @@ public function getRealPath(){ return $path; } - public function getRoot(){ - - $options = parent::getRoot(); + protected function optionsModifier($options){ $options['path'] = $this->getRealPath(); $options['URL'] = $this->getUrl(); diff --git a/UserPath.php b/volume/UserPath.php similarity index 89% rename from UserPath.php rename to volume/UserPath.php index 45c8f40..c4553a7 100644 --- a/UserPath.php +++ b/volume/UserPath.php @@ -4,11 +4,11 @@ * Time: 14:13 */ -namespace mihaildev\elfinder; +namespace mihaildev\elfinder\volume; use Yii; -class UserPath extends LocalPath{ +class UserPath extends Local{ public function isAvailable(){ if(Yii::$app->user->isGuest) return false;