-
Notifications
You must be signed in to change notification settings - Fork 5
/
ElFinderConnectorAction.php
57 lines (51 loc) · 2.11 KB
/
ElFinderConnectorAction.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
52
53
54
55
56
57
<?php
Yii::import("ext.ezzeelfinder.ElFinderWidget");
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "php" . DIRECTORY_SEPARATOR . "elFinderConnector.class.php";
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "php" . DIRECTORY_SEPARATOR . "elFinder.class.php";
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "php" . DIRECTORY_SEPARATOR . "elFinderVolumeDriver.class.php";
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "php" . DIRECTORY_SEPARATOR . "elFinderVolumeLocalFileSystem.class.php";
/**
* Implements ElFinder connector's construction.
*
* @author Dmitriy Pushkov <ezze@ezze.org>
* @version 0.0.5
*/
class ElFinderConnectorAction extends CAction
{
/**
* A name of get parameter used to pass ElFinder connector's configuration options.
*/
const GET_PARAM_ELFINDER_CONNECTOR_OPTIONS = "elfinder_connector_options";
/**
* Retrieves connector's configuration from URL parameter and creates
* an instance of ElFinder connector.
*/
public function run()
{
// Defining default connector options
$connectorOptions = array(
'roots' => array(
array(
'driver' => "LocalFileSystem",
'path' => realpath(Yii::app()->basePath . "/../files"),
'URL' => "/files",
'accessControl' => "access"
)
)
);
// Retrieving connector's options from GET-request
$connectorOptionsEncoded = Yii::app()->request->getParam(self::GET_PARAM_ELFINDER_CONNECTOR_OPTIONS);
if ($connectorOptionsEncoded)
{
$connectorOptionsSerialized = base64_decode($connectorOptionsEncoded);
$connectorOptionsUnserialized = unserialize($connectorOptionsSerialized);
if (is_array($connectorOptionsUnserialized))
{
$connectorOptions = array_merge($connectorOptions, $connectorOptionsUnserialized);
}
}
// Running ElFinder
$connector = new elFinderConnector(new elFinder($connectorOptions));
$connector->run();
}
}