Inheritance: extends Base
Beispiel #1
0
 public function getOptions()
 {
     if ($this->_options !== null) {
         return $this->_options;
     }
     $this->_options['roots'] = [];
     foreach ($this->roots as $root) {
         if (is_string($root)) {
             $root = ['path' => $root];
         }
         if (!isset($root['class'])) {
             $root['class'] = Local::className();
         }
         $root = Yii::createObject($root);
         /** @var \mihaildev\elfinder\volume\Local $root*/
         if ($root->isAvailable()) {
             $this->_options['roots'][] = $root->getRoot();
         }
     }
     if (!empty($this->watermark)) {
         $this->_options['bind']['upload.presave'] = 'Plugin.Watermark.onUpLoadPreSave';
         if (is_string($this->watermark)) {
             $watermark = ['source' => $this->watermark];
         } else {
             $watermark = $this->watermark;
         }
         $this->_options['plugin']['Watermark'] = $watermark;
     }
     $this->_options = ArrayHelper::merge($this->_options, $this->connectOptions);
     return $this->_options;
 }
Beispiel #2
0
 public function isAvailable()
 {
     if (Yii::$app->user->isGuest) {
         return false;
     }
     return parent::isAvailable();
 }
 public function getOptions()
 {
     if ($this->_options !== null) {
         return $this->_options;
     }
     $subPath = Yii::$app->request->getQueryParam('path', '');
     $this->_options['roots'] = [];
     $root = $this->root;
     if (is_string($root)) {
         $root = ['path' => $root];
     }
     if (!isset($root['class'])) {
         $root['class'] = Local::className();
     }
     if (!isset($root['path'])) {
         $root['path'] = '';
     }
     if (!empty($subPath)) {
         if (preg_match("/\\./i", $subPath)) {
             $root['path'] = rtrim($root['path'], '/');
         } else {
             $root['path'] = rtrim($root['path'], '/');
             $root['path'] .= '/' . trim($subPath, '/');
         }
     }
     $root = Yii::createObject($root);
     /** @var Local $root*/
     if ($root->isAvailable()) {
         $this->_options['roots'][] = $root->getRoot();
     }
     if (!empty($this->watermark)) {
         $this->_options['bind']['upload.presave'] = 'Plugin.Watermark.onUpLoadPreSave';
         if (is_string($this->watermark)) {
             $watermark = ['source' => $this->watermark];
         } else {
             $watermark = $this->watermark;
         }
         $this->_options['plugin']['Watermark'] = $watermark;
     }
     $this->_options = ArrayHelper::merge($this->_options, $this->connectOptions);
     return $this->_options;
 }