19 require_once(BASE.
"wcmf/lib/presentation/class.Controller.php");
20 require_once(BASE.
"wcmf/lib/util/class.URIUtil.php");
21 require_once(BASE.
"wcmf/lib/util/class.GraphicsUtil.php");
23 include_once(BASE.
"wcmf/3rdparty/elfinder/php/elFinderConnector.class.php");
24 include_once(BASE.
"wcmf/3rdparty/elfinder/php/elFinder.class.php");
25 include_once(BASE.
"wcmf/3rdparty/elfinder/php/elFinderVolumeDriver.class.php");
26 include_once(BASE.
"wcmf/3rdparty/elfinder/php/elFinderVolumeLocalFileSystem.class.php");
64 parent::initialize($request, $response);
69 $this->_directory = $baseDir;
73 if ($session->exist($this->DIRECTORY_VARNAME)) {
74 $this->_directory = $session->get($this->DIRECTORY_VARNAME);
78 if ($request->hasValue(
'directory') && strpos($request->getValue(
'directory'), $baseDir) === 0) {
79 $this->_directory = $request->getValue(
'directory');
83 $session->set($this->DIRECTORY_VARNAME, $this->_directory);
91 if (in_array($this->_request->getAction(), array(
"browseresources",
"crop"))) {
112 if ($this->_request->hasValue(
'fieldName')) {
113 $this->_response->setValue(
'fieldName', $this->_request->getValue(
'fieldName'));
115 $this->_response->setValue(
'rootUrl', $rootUrl);
116 $this->_response->setValue(
'rootPath', $rootPath);
117 $this->_response->setValue(
'type', $this->_request->getValue(
'type',
'image'));
118 $this->_response->setValue(
'subtype', $this->_request->getValue(
'subtype',
'resource'));
119 $this->_response->setValue(
'CKEditorFuncNum', $this->_request->getValue(
'CKEditorFuncNum'));
121 if (!in_array($this->_request->getAction(), array(
"browseresources",
"crop"))) {
126 'driver' =>
'LocalFileSystem',
130 'startPath' => $this->_directory
134 'rename rm paste' => array($this,
'onFileMoved')
139 $connector =
new elFinderConnector(
new elFinder($opts));
142 $this->_response->setAction(
'ok');
147 if ($this->_request->getAction() ==
'crop') {
148 $file = $this->_request->getValue(
'oid');
149 $this->_response->setValue(
'oid', $file);
150 if ($this->_request->hasValue(
'cropX') && $this->_request->hasValue(
'cropY') &&
151 $this->_request->hasValue(
'cropWidth') && $this->_request->hasValue(
'cropHeight')) {
153 $x = $this->_request->getValue(
'cropX');
154 $y = $this->_request->getValue(
'cropY');
155 $w = $this->_request->getValue(
'cropWidth');
156 $h = $this->_request->getValue(
'cropHeight');
159 $cropInfo =
'x'.$x.
'y'.$y.
'w'.$w.
'h'.$h;
160 $pathParts = pathinfo($file);
161 $targetFile = $pathParts[
'dirname'].
'/'.$pathParts[
'filename'].
'_'.$cropInfo.
'.'.$pathParts[
'extension'];
165 $graphicsUtil->cropImage($file, $targetFile, $w, $h, $x, $y);
166 $this->_response->setValue(
'fieldName', $this->_request->getValue(
'fieldName'));
167 $this->_response->setAction(
'browseresources');
172 $this->_response->setAction(
'ok');
187 $addedFiles = $result[
'added'];
188 $removedFiles = $result[
'removed'];
189 for ($i=0, $count=
sizeof($removedFiles); $i<$count; $i++) {
190 $source = $removedFiles[$i][
'realpath'];
191 $target = $elfinder->realpath($addedFiles[$i][
'hash']);
193 Log::debug($cmd.
" file: ".$source.
" -> ".$target, __CLASS__);
206 if(($uploadDir = $parser->getValue(
'uploadDir',
'media')) !==
false)
209 if (substr($uploadDir, -1) ==
'/')
210 $uploadDir = substr($uploadDir, 0, -1);
GraphicsUtil provides support for graphic manipulation.
debug($message, $category)
ResourceListController is a controller used to manage resources from the server and displays it using...
makeAbsolute($rel_uri, $base, $REMOVE_LEADING_DOTS=true)
onFileMoved($cmd, $result, $args, $elfinder)
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
initialize(&$request, &$response)