From 342be3bf655dde3647fd7125d15a2d61f8a4208f Mon Sep 17 00:00:00 2001 From: pavel Date: Sun, 7 Aug 2016 10:28:20 +0300 Subject: [PATCH] Determination of preview path is moved to a connector side. --- changelog | 2 +- connectors/php/LocalFilemanager.php | 8 ++++---- scripts/filemanager.config.default.json | 1 - scripts/filemanager.js | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/changelog b/changelog index 8db3838d..9ac6c7f4 100644 --- a/changelog +++ b/changelog @@ -49,7 +49,7 @@ Version 1.0.4 Version 1.0.5 --------------------------- - Improved path processing at the client-side. Absolute path used whenever it is possible. Normalization of the preview path -- New "outsideServerRoot" option which allows to preview images and media files for the case when the root folder is located beyond server root directory +- Changed a way of path creation in PHP connector: builds either connector-related path to preview files for the case when the root folder is located beyond server root directory OR direct path otherwise - Improved a way of automatically determination of `baseUrl` based on page URL - Fixed bug: Copy URL to clipboard does not work - #5 - Fixed bug: Path issue upon file selection in WYSIWYG editor diff --git a/connectors/php/LocalFilemanager.php b/connectors/php/LocalFilemanager.php index 346b7483..c5c8f776 100644 --- a/connectors/php/LocalFilemanager.php +++ b/connectors/php/LocalFilemanager.php @@ -842,7 +842,7 @@ protected function get_file_info($relative_path, $thumbnail = false) $filemtime = filemtime($current_path); $iconsFolder = $this->getFmUrl($this->config['icons']['path']); - $outsideRoot = $this->config['options']['outsideServerRoot']; + $beyondDocRoot = stripos(realpath($this->path_to_files), realpath($this->doc_root)) !== 0; $getImageMode = $this->connector_script_url . '?mode=getimage&path=' . rawurlencode($relative_path) . '&time=' . time(); $readFileMode = $this->connector_script_url . '?mode=readfile&path=' . rawurlencode($relative_path) . '&time=' . time(); @@ -864,11 +864,11 @@ protected function get_file_info($relative_path, $thumbnail = false) // svg should not be previewed as raster formats images if($fileType === 'svg') { - $imagePath = $outsideRoot ? $readFileMode : $dynamic_path; + $imagePath = $beyondDocRoot ? $readFileMode : $dynamic_path; } else if($thumbnail && $this->config['options']['showThumbs']) { $imagePath = $getImageMode . '&thumbnail=true'; } else { - $imagePath = $outsideRoot ? $getImageMode : $dynamic_path; + $imagePath = $beyondDocRoot ? $getImageMode : $dynamic_path; } if($item['Properties']['Size']) { @@ -890,7 +890,7 @@ protected function get_file_info($relative_path, $thumbnail = false) $item['File Type'] = $fileType; $item['Protected'] = $protected; $item['Image Path'] = $imagePath; - $item['Dynamic Path'] = $outsideRoot ? $readFileMode : $dynamic_path; + $item['Dynamic Path'] = $beyondDocRoot ? $readFileMode : $dynamic_path; $item['Properties']['Date Modified'] = $this->formatDate($filemtime); //$item['Properties']['Date Created'] = $this->formatDate(filectime($current_path)); // PHP cannot get create timestamp $item['Properties']['filemtime'] = $filemtime; diff --git a/scripts/filemanager.config.default.json b/scripts/filemanager.config.default.json index 1e09e84c..6e6ae384 100644 --- a/scripts/filemanager.config.default.json +++ b/scripts/filemanager.config.default.json @@ -24,7 +24,6 @@ "fileRoot": false, "fileConnector": false, "fileRootSizeLimit": false, - "outsideServerRoot": false, "baseUrl": false, "capabilities": ["select", "upload", "download", "rename", "move", "replace", "delete"], "logger": false, diff --git a/scripts/filemanager.js b/scripts/filemanager.js index c6840bd2..6dd742e5 100644 --- a/scripts/filemanager.js +++ b/scripts/filemanager.js @@ -522,7 +522,7 @@ var isDocumentFile = function(filename) { // Build url to preview files var createPreviewUrl = function(path, encode) { encode = encode || false; - // already an absolute path or or a relative path to connector action + // already an absolute path or a relative path to connector action if(path.substr(0,4) === 'http' || path.substr(0,3) === 'ftp' || path.indexOf(langConnector) !== -1) { return path; }