Skip to content

Commit

Permalink
Determination of preview path is moved to a connector side.
Browse files Browse the repository at this point in the history
  • Loading branch information
psolom committed Aug 7, 2016
1 parent 8b52ab8 commit 342be3b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions connectors/php/LocalFilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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']) {
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion scripts/filemanager.config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"fileRoot": false,
"fileConnector": false,
"fileRootSizeLimit": false,
"outsideServerRoot": false,
"baseUrl": false,
"capabilities": ["select", "upload", "download", "rename", "move", "replace", "delete"],
"logger": false,
Expand Down
2 changes: 1 addition & 1 deletion scripts/filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 342be3b

Please sign in to comment.