diff --git a/application/index/controller/Share.php b/application/index/controller/Share.php index 59f2902d..1f9d051b 100644 --- a/application/index/controller/Share.php +++ b/application/index/controller/Share.php @@ -47,8 +47,9 @@ class Share extends Controller{ 'fileData' => $shareObj->fileData, 'shareData' => $shareObj->shareData, 'loginStatus' => $this->userObj->loginStatus, - 'userData' => $this->userObj->userSQLData, + 'userData' => $this->userObj->getInfo(), 'allowPreview' => Option::getValue("allowdVisitorDownload"), + 'path' => empty(input("get.path"))?"/":input("get.path"), ]); } }else{ @@ -67,7 +68,7 @@ class Share extends Controller{ public function getDownloadUrl(){ $shareId = input('key'); $shareObj = new ShareHandler($shareId,false); - return $shareObj->getDownloadUrl($this->userObj); + return json($shareObj->getDownloadUrl($this->userObj)); } public function Download(){ @@ -91,9 +92,9 @@ class Share extends Controller{ $filePath = input('get.path'); $shareObj = new ShareHandler($shareId,false); if(empty($filePath)){ - //todo 单文件时 + $contentHandller = $shareObj->getContent($this->userObj,$filePath,false); }else{ - $contentHandller = $shareObj->getContent($this->userObj,$filePath); + $contentHandller = $shareObj->getContent($this->userObj,$filePath,true); } if(!$contentHandller[0]){ return json(["result"=>["success"=>false,"error"=>$contentHandller[1]]]); @@ -167,9 +168,9 @@ class Share extends Controller{ $filePath = urldecode(input('get.path')); $shareObj = new ShareHandler($shareId,false); if(empty($filePath)){ - //TODO 单文件时 + $Redirect = $shareObj->getDocPreview($this->userObj,$filePath,false); }else{ - $Redirect = $shareObj->getDocPreview($this->userObj,$filePath); + $Redirect = $shareObj->getDocPreview($this->userObj,$filePath,true); } if($Redirect[0]){ diff --git a/application/index/controller/Viewer.php b/application/index/controller/Viewer.php index 94ae7a39..dd77076f 100644 --- a/application/index/controller/Viewer.php +++ b/application/index/controller/Viewer.php @@ -30,6 +30,8 @@ class Viewer extends Controller{ $url = "/File/Preview?action=preview&path=".$path; if(input("get.share")==true){ $url = "/Share/Preview/".input("get.shareKey")."/?path=".$path; + }else if(input("get.single")==true){ + $url = "/Share/Preview/".input("get.shareKey"); } return view('video', [ 'options' => Option::getValues(['basic']), @@ -49,6 +51,8 @@ class Viewer extends Controller{ $url = "/File/Content?action=preview&path=".$path; if(input("get.share")==true){ $url = "/Share/Content/".input("get.shareKey")."/?path=".$path; + }else if(input("get.single")==true){ + $url = "/Share/Content/".input("get.shareKey"); } return view('markdown', [ 'options' => Option::getValues(['basic']), diff --git a/application/index/model/ShareHandler.php b/application/index/model/ShareHandler.php index 3305e076..5e4823dc 100644 --- a/application/index/model/ShareHandler.php +++ b/application/index/model/ShareHandler.php @@ -95,24 +95,44 @@ class ShareHandler extends Model{ return $fileObj->getThumb(); } - public function getDocPreview($user,$path){ + public function getDocPreview($user,$path,$inFolder){ $checkStatus = $this->checkSession($user); if(!$checkStatus[0]){ return [$checkStatus[0],$checkStatus[1]]; } - $reqPath = Db::name('folders')->where('position_absolute',$this->shareData["source_name"])->find(); - $fileObj = new FileManage($reqPath["position_absolute"].$path,$this->shareData["owner"]); + if($inFolder){ + $reqPath = Db::name('folders')->where('position_absolute',$this->shareData["source_name"])->find(); + $fileObj = new FileManage($reqPath["position_absolute"].$path,$this->shareData["owner"]); + }else{ + $reqPath = Db::name('files')->where('id',$this->shareData["source_name"])->find(); + if($reqPath["dir"] == "/"){ + $reqPath["dir"] = $reqPath["dir"].$reqPath["orign_name"]; + }else{ + $reqPath["dir"] = $reqPath["dir"]."/".$reqPath["orign_name"]; + } + $fileObj = new FileManage($reqPath["dir"],$this->shareData["owner"]); + } $tmpUrl = $fileObj->signTmpUrl(); return[true,"http://view.officeapps.live.com/op/view.aspx?src=".urlencode($tmpUrl)]; } - public function getContent($user,$path=null){ + public function getContent($user,$path=null,$inFolder){ $checkStatus = $this->checkSession($user); if(!$checkStatus[0]){ return [$checkStatus[0],$checkStatus[1]]; } - $reqPath = Db::name('folders')->where('position_absolute',$this->shareData["source_name"])->find(); - $fileObj = new FileManage($reqPath["position_absolute"].$path,$this->shareData["owner"]); + if($inFolder){ + $reqPath = Db::name('folders')->where('position_absolute',$this->shareData["source_name"])->find(); + $fileObj = new FileManage($reqPath["position_absolute"].$path,$this->shareData["owner"]); + }else{ + $reqPath = Db::name('files')->where('id',$this->shareData["source_name"])->find(); + if($reqPath["dir"] == "/"){ + $reqPath["dir"] = $reqPath["dir"].$reqPath["orign_name"]; + }else{ + $reqPath["dir"] = $reqPath["dir"]."/".$reqPath["orign_name"]; + } + $fileObj = new FileManage($reqPath["dir"],$this->shareData["owner"]); + } $fileObj->getContent(); exit(); } diff --git a/application/index/view/home/home.html b/application/index/view/home/home.html index 06a53f5d..a59ab323 100644 --- a/application/index/view/home/home.html +++ b/application/index/view/home/home.html @@ -64,6 +64,7 @@ } }; isHomePage = true; + pageId=""; isSharePage = false; uploadConfig = { saveType: "{$policyData.policy_type}", @@ -118,10 +119,11 @@ + + - - + \ No newline at end of file diff --git a/application/index/view/share/share_dir.html b/application/index/view/share/share_dir.html index 8337ff77..8403abd5 100644 --- a/application/index/view/share/share_dir.html +++ b/application/index/view/share/share_dir.html @@ -65,6 +65,7 @@ }; isHomePage = false; isSharePage = true; + pageId=""; apiURL = { imgThumb: "/Share/Thumb/{$shareData.share_key}", preview: "/Share/Preview/{$shareData.share_key}", @@ -129,13 +130,12 @@ --> - - - - - - + + + + + \ No newline at end of file diff --git a/application/index/view/share/share_single.html b/application/index/view/share/share_single.html index 5b39c099..e0df9d2d 100644 --- a/application/index/view/share/share_single.html +++ b/application/index/view/share/share_single.html @@ -1,131 +1,96 @@ -{extend name="header_public" /} -{block name="title"}{$fileData.orign_name} - {$options.siteName}{/block} -{block name="content"} - - - - - - - - -