forked from MihailDev/yii2-elfinder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LocalPath.php
51 lines (40 loc) · 1.21 KB
/
LocalPath.php
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
<?php
/**
* Date: 23.01.14
* Time: 22:47
*/
namespace mihaildev\elfinder;
use Yii;
class LocalPath extends BasePath{
public $path;
public $name = 'Root';
public $options = [];
public $access = ['read' => '*', 'write' => '*'];
public function getUrl(){
return Yii::getAlias('@web/'.trim($this->path,'/'));
}
public function getRealPath(){
$path = Yii::getAlias('@webroot/'.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' => true
];
return \yii\helpers\ArrayHelper::merge($options, $this->options);
}
}