Blame view

app/mihaildev/elfinder/LocalPath.php 1.3 KB
bf807468   Alex Savenko   first commit
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
  <?php
  /**
   * Date: 23.01.14
   * Time: 22:47
   */
  
  namespace app\mihaildev\elfinder;
  
  use Yii;
  
  class LocalPath extends BasePath{
      public $path;
      public $baseUrl = '@web';
      public $basePath = '@webroot';
  
      public $name = 'Root';
  
      public $options = [];
  
      public $access = ['read' => '*', 'write' => '*'];
  
      public function getUrl(){
          return Yii::getAlias($this->baseUrl.'/'.trim($this->path,'/'));
      }
  
      public function getRealPath(){
          $path = Yii::getAlias($this->basePath.'/'.trim($this->path,'/'));
          if(!is_dir($path))
              mkdir($path, 0777, true);
  
          return $path;
      }
  
      public function getRoot(){
          $options['driver'] = $this->driver;
          $options['path'] = $this->getRealPath();
          $options['URL'] = $this->getUrl();
          $options['defaults'] = $this->getDefaults();
          $options['alias'] = $this->getAlias();
          $options['mimeDetect'] = 'internal';
          //$options['onlyMimes'] = ['image'];
          $options['imgLib'] = 'gd';
          $options['attributes'][] = [
              'pattern' => '#.*(\.tmb|\.quarantine)$#i',
              'read' => false,
              'write' => false,
              'hidden' => true,
              'locked' => false
          ];
  
          return \yii\helpers\ArrayHelper::merge($options, $this->options);
      }
  }