From a1a9f7cdb05f59061bd4ad63046528cef37b2853 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sun, 1 Jul 2018 21:45:02 +0800 Subject: [PATCH] complete thumb preivew in folder shareing page --- application/index/controller/Share.php | 9 ++++++--- application/index/model/FileManage.php | 2 +- application/index/model/ShareHandler.php | 14 ++++++++++++++ static/css/share_dir.css | 7 +++++++ static/js/filemanager_share.js | 10 ++++++++-- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/application/index/controller/Share.php b/application/index/controller/Share.php index a7c1756e..7376dc2f 100644 --- a/application/index/controller/Share.php +++ b/application/index/controller/Share.php @@ -133,14 +133,17 @@ class Share extends Controller{ } public function Thumb(){ - $filePath = input("get.path"); + $shareId = input('get.shareKey'); + $filePath = input('get.path'); if(input("get.isImg") != "true"){ return ""; } - $fileObj = new FileManage($filePath,$this->userObj->uid); - $Redirect = $fileObj->getThumb(); + $shareObj = new ShareHandler($shareId,false); + $Redirect = $shareObj->getThumb($this->userObj,$filePath); if($Redirect[0]){ $this->redirect($Redirect[1],302); + }else{ + $this->error($Redirect[1],403,$this->siteOptions); } } diff --git a/application/index/model/FileManage.php b/application/index/model/FileManage.php index 9bd26255..acf92592 100644 --- a/application/index/model/FileManage.php +++ b/application/index/model/FileManage.php @@ -1104,7 +1104,7 @@ class FileManage extends Model{ ->where('uid',$uid) ->where('dlay_time',">",time()) ->sum('pack_size'); - return (int)$addOnStorage+(int)$basicStronge["max_storage"]; + return $addOnStorage+$basicStronge["max_storage"]; } static function getUsedStorage($uid){ diff --git a/application/index/model/ShareHandler.php b/application/index/model/ShareHandler.php index ebbd27cd..876c17b9 100644 --- a/application/index/model/ShareHandler.php +++ b/application/index/model/ShareHandler.php @@ -81,6 +81,20 @@ class ShareHandler extends Model{ } } + public function getThumb($user,$path,$folder=false){ + $checkStatus = $this->checkSession($user); + if(!$checkStatus[0]){ + return [$checkStatus[0],$checkStatus[1]]; + } + $reqPath = Db::name('folders')->where('position_absolute',$this->shareData["source_name"])->find(); + if($folder){ + $fileObj = new FileManage($path,$this->shareData["owner"]); + }else{ + $fileObj = new FileManage($reqPath["position_absolute"].$path,$this->shareData["owner"]); + } + return $fileObj->getThumb(); + } + public function checkSession($user){ if($this->lockStatus){ return [false,"会话过期,请刷新页面"]; diff --git a/static/css/share_dir.css b/static/css/share_dir.css index 95ae6405..0ba34753 100644 --- a/static/css/share_dir.css +++ b/static/css/share_dir.css @@ -1040,4 +1040,11 @@ video { } .btn-group-vertical.open>.dropdown-toggle.btn, .btn-group-vertical.open>.dropdown-toggle.btn.btn-default, .btn-group.open>.dropdown-toggle.btn, .btn-group.open>.dropdown-toggle.btn.btn-default { background-color: #5468d6; +} +.smallImg { + max-width: 90px; + max-height: 39px; +} +.item-icon{ + min-height: 39px; } \ No newline at end of file diff --git a/static/js/filemanager_share.js b/static/js/filemanager_share.js index 00dc4e6d..473bbaee 100644 --- a/static/js/filemanager_share.js +++ b/static/js/filemanager_share.js @@ -570,6 +570,9 @@ function(e) { fullPath: function() { var e = this.path.filter(Boolean); return ("/" + e.join("/") + "/" + this.name).replace(/\/\//, "/") + }, + encodedPath:function(){ + return encodeURI(this.fullPath()) } }; this.error = "", @@ -593,7 +596,10 @@ function(e) { i.prototype.isImage = function() { return r.isImageFilePattern.test(this.model.name) }, - i.prototype.isVideo = function() { + i.prototype.getShareKey = function() { + return shareInfo.shareId + }, + i.prototype.isVideo = function() { return r.isVideoFilePattern.test(this.model.name) }, @@ -1430,7 +1436,7 @@ angular.module("FileManagerApp").run(["$templateCache", function(e) { e.put("src/templates/current-folder-breadcrumb.html", ''), e.put("src/templates/item-context-menu.html", ''), - e.put("src/templates/main-icons.html", '
\r\n
\r\n \r\n
\r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n {{"no_files_in_folder" | translate}}...\r\n
\r\n \r\n
\r\n {{ fileNavigator.error }}\r\n
\r\n
'), + e.put("src/templates/main-icons.html", '
\r\n
\r\n \r\n
\r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n {{"no_files_in_folder" | translate}}...\r\n
\r\n \r\n
\r\n {{ fileNavigator.error }}\r\n
\r\n
'), e.put("src/templates/main-table-modal.html", '\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n {{"name" | translate}}\r\n \r\n \r\n
\r\n
\r\n
\r\n {{"no_folders_in_folder" | translate}}...\r\n \r\n \r\n
\r\n {{ fileNavigator.error }}\r\n
\r\n \r\n \r\n {{item.model.name | strLimit : 32}}\r\n \r\n \r\n \r\n
'), e.put("src/templates/main-table.html", '\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n {{"name" | translate}}\r\n \r\n \r\n
\r\n
\r\n
\r\n {{"no_files_in_folder" | translate}}...\r\n
\r\n {{ fileNavigator.error }}\r\n
\r\n \r\n \r\n \r\n {{item.model.name | strLimit : 64}}\r\n \r\n
\r\n'), e.put("src/templates/main.html", '
\r\n
\r\n\r\n
\r\n
\r\n\r\n \r\n\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n'),