Blame view

vendor/mihaildev/yii2-elfinder/Controller.php 1.29 KB
ad2e91f7   Mihail   move multyparser ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  <?php
  /**
   * Created by PhpStorm.
   * User: Администратор
   * Date: 20.01.14
   * Time: 13:26
   */
  
  namespace mihaildev\elfinder;
  
  use Yii;
  use yii\helpers\ArrayHelper;
  
  
  
  /**
   * Class Controller
   * @package mihaildev\elfinder
   * @property array $options
   */
  
  
  class Controller extends BaseController{
  	public $roots = [];
  	public $disabledCommands = ['netmount'];
  	public $watermark;
  
  	private $_options;
  
  	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'] = 'mihaildev\elfinder\LocalPath';
  
  			$root = Yii::createObject($root);
  
  			/** @var \mihaildev\elfinder\LocalPath $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;
  	}
  }