條件: php
實現 原理: html
須要修改的文件及內容 web
xampp\zentao\module\file\control.php 瀏覽器
xampp\zentao\module\file\view\printfiles.html.php 服務器
xampp\zentao\module\group\lang\resource.php session
xampp\zentao\module\file\lang\zh-cn.php app
control.php this
增長方法 url
public function cloudview($fileID, $mouse = '') spa
{
$file = $this->file->getById($fileID);
/* Judge the mode, down or open. */
$mode = 'view';
$fileTypes = 'txt|jpg|jpeg|gif|png|bmp|xml|html|pdf|dwg';
if(stripos($fileTypes, $file->extension) !== false and $mouse == 'left') $mode = 'open';
if($mode == 'open')
{
if(file_exists($file->realPath))$this->locate($file->webPath);
$this->app->triggerError("The file you visit $fileID not found.", __FILE__, __LINE__, true);
}
else
if(file_exists($file->realPath))
{
$fileName = $file->title . '.' . $file->extension;
$fileData = file_get_contents($file->realPath);
$md5data=md5( $fileData);
$this->locate( 'http://192.168.118.136:9345/?url=' . common::getSysURL() . $file-> webPath . '&' . 'fileName=' . $fileName . '&' . 'md5=' . $md5data );
}
else
{
$this->app->triggerError("The file you visit $fileID not found.", __FILE__, __LINE__, true);
}
}
printfiles.html.php
修改方法downloadFile
新增方法viewFile
增長超連接指向
function downloadFile(fileID)
{
if(!fileID) return;
var sessionString = '<?php echo $sessionString;?>';
var url = createLink('file', 'cloudview', 'mfileID=' + fileID + '&mouse=left&mode=open') + sessionString;
window.open(url, '_blank');
return false;
}
function viewFile(fileID)
{
if(!fileID) return;
var sessionString = '<?php echo $sessionString;?>';
var url = createLink('file', 'cloudview', 'mfileID=' + fileID + '&mouse=left&mode=open') + sessionString;
window.open(url, '_blank');
return false;
}
增長連接
$fileTitle = "<li class='list-group-item'><i class='icon-file-text text-muted icon'></i> " . $file->title .'.' . $file->extension;
echo html::a($this->createLink('file', 'download', "fileID=$file->id") . $sessionString, $fileTitle, '_blank', "onclick='return viewFile($file->id)'");
echo "<span class='right-icon'>";
common::printLink('file', 'download', "fileID=$file->id", "<i class='icon-download'></i>", '', "class='edit btn-icon' title='{$lang->file->download}'");
common::printLink('file', 'edit', "fileID=$file->id", "<i class='icon-pencil'></i>", '', "class='edit btn-icon' title='{$lang->file->edit}'");
if(common::hasPriv('file', 'delete')) echo html::a('###', "<i class='icon-remove'></i>", '', "class='btn-icon' onclick='deleteFile($file->id)' title='$lang->delete'");
echo '</span>';
echo '</li>';
resource.php
$lang->resource->file = new stdclass();
$lang->resource->file->download = 'download';
$lang->resource->file->cloudview = 'cloudview';
$lang->resource->file->edit = 'edit';
zh-cn.php
$lang->file->uploadImages = '多圖上傳';
$lang->file->cloudview = '雲預覽';
$lang->file->download = '下載附件';
執行效果
權限
附件管理