|
1
|
|
|
<?php |
|
2
|
|
|
namespace PlaygroundCore\Controller\Admin; |
|
3
|
|
|
|
|
4
|
|
|
use Zend\Mvc\Controller\AbstractActionController; |
|
5
|
|
|
use Zend\View\Model\ViewModel; |
|
6
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
7
|
|
|
|
|
8
|
|
|
class ElfinderController extends AbstractActionController |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
protected $Config; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* |
|
15
|
|
|
* @var ServiceManager |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $serviceLocator; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct(ServiceLocatorInterface $locator) |
|
20
|
|
|
{ |
|
21
|
|
|
$this->serviceLocator = $locator; |
|
|
|
|
|
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function getServiceLocator() |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
return $this->serviceLocator; |
|
|
|
|
|
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return array|\Zend\View\Model\ViewModel |
|
32
|
|
|
*/ |
|
33
|
|
View Code Duplication |
public function indexAction() |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
$view = new ViewModel(); |
|
36
|
|
|
$this->getConfig(); |
|
37
|
|
|
$view->BasePath = $this->Config['BasePath']; |
|
38
|
|
|
$view->ConnectorPath = '/admin/elfinder/connector'; |
|
39
|
|
|
|
|
40
|
|
|
return $view; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return \Zend\View\Model\ViewModel |
|
45
|
|
|
*/ |
|
46
|
|
View Code Duplication |
public function ckeditorAction() |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$view = new ViewModel(); |
|
49
|
|
|
$this->getConfig(); |
|
50
|
|
|
$view->BasePath = $this->Config['BasePath']; |
|
51
|
|
|
$view->ConnectorPath = '/admin/elfinder/connector'; |
|
52
|
|
|
$view->setTerminal(true); |
|
53
|
|
|
|
|
54
|
|
|
return $view; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return \Zend\View\Model\ViewModel |
|
59
|
|
|
*/ |
|
60
|
|
|
public function connectorAction() |
|
61
|
|
|
{ |
|
62
|
|
|
$view = new ViewModel(); |
|
63
|
|
|
$this->getConfig(); |
|
64
|
|
|
|
|
65
|
|
|
$root = array(); |
|
66
|
|
|
if (isset($this->Config['QuRoots'])) { |
|
67
|
|
|
$root = $this->Config['QuRoots']; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
$opts = array( |
|
71
|
|
|
'debug' => false, |
|
72
|
|
|
'roots' => array($root) |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
|
|
$connector = new \elFinderConnector(new \elFinder($opts)); |
|
76
|
|
|
$connector->run(); |
|
77
|
|
|
|
|
78
|
|
|
$view->setTerminal(true); |
|
79
|
|
|
|
|
80
|
|
|
return $view; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param $attr |
|
85
|
|
|
* @param $path |
|
86
|
|
|
* @param $data |
|
87
|
|
|
* @param $volume |
|
88
|
|
|
* |
|
89
|
|
|
* @return bool|null |
|
90
|
|
|
*/ |
|
91
|
|
|
public function access($attr, $path, $data, $volume) |
|
|
|
|
|
|
92
|
|
|
{ |
|
93
|
|
|
return strpos(basename($path), '.') === 0 |
|
94
|
|
|
? !($attr == 'read' || $attr == 'write') |
|
95
|
|
|
: null; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return mixed |
|
100
|
|
|
*/ |
|
101
|
|
|
public function getConfig() |
|
102
|
|
|
{ |
|
103
|
|
|
if (!$this->Config) { |
|
104
|
|
|
$config = $this->getServiceLocator()->get('config'); |
|
105
|
|
|
if (isset($config['playgroundcore']) && isset($config['playgroundcore']['QuConfig']) && isset($config['playgroundcore']['QuConfig']['QuElFinder'])) { |
|
106
|
|
|
$this->Config = $config['playgroundcore']['QuConfig']['QuElFinder']; |
|
107
|
|
|
} else { |
|
108
|
|
|
$this->Config = array(); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
return $this->Config; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..