* Finish task #60383.

This commit is contained in:
zhouxudong
2022-07-28 07:04:40 +00:00
parent d505caff81
commit f85e8c2df5
+95 -94
View File
@@ -51,18 +51,21 @@
return false;
}
/* Show edit box for editing file name. */
function showRenameBox(fileID)
{
$('#renameFile' + fileID).closest('li').addClass('hidden');
$('#renameBox' + fileID).removeClass('hidden');
}
/* Show File. */
function showFile(fileID)
{
$('#renameBox' + fileID).addClass('hidden');
$('#renameFile' + fileID).closest('li').removeClass('hidden');
}
/* Smooth refresh file name. */
function setFileName(fileID)
{
var fileName = $('#fileName' + fileID).val();
@@ -86,115 +89,113 @@
}
</script>
<ul class="files-list">
<?php
foreach($files as $file)
{
if(common::hasPriv('file', 'download'))
<?php foreach($files as $file):?>
<?php if(common::hasPriv('file', 'download')):?>
<?php
$uploadDate = $lang->file->uploadDate . substr($file->addedDate, 0, 10);
$fileTitle = "<i class='icon icon-file-text'></i> &nbsp;" . $file->title;
if(strpos($file->title, ".{$file->extension}") === false && $file->extension != 'txt') $fileTitle .= ".{$file->extension}";
$imageWidth = 0;
if(stripos('jpg|jpeg|gif|png|bmp', $file->extension) !== false)
{
$uploadDate = $lang->file->uploadDate . substr($file->addedDate, 0, 10);
$fileTitle = "<i class='icon icon-file-text'></i> &nbsp;" . $file->title;
if(strpos($file->title, ".{$file->extension}") === false && $file->extension != 'txt') $fileTitle .= ".{$file->extension}";
$imageWidth = 0;
if(stripos('jpg|jpeg|gif|png|bmp', $file->extension) !== false)
$imageSize = $this->file->getImageSize($file);
$imageWidth = $imageSize ? $imageSize[0] : 0;
}
$fileSize = 0;
/* Show size info. */
if($file->size < 1024)
{
$fileSize = $file->size . 'B';
}
elseif($file->size < 1024 * 1024)
{
$file->size = round($file->size / 1024, 2);
$fileSize = $file->size . 'K';
}
elseif($file->size < 1024 * 1024 * 1024)
{
$file->size = round($file->size / (1024 * 1024), 2);
$fileSize = $file->size . 'M';
}
else
{
$file->size = round($file->size / (1024 * 1024 * 1024), 2);
$fileSize = $file->size . 'G';
}
$downloadLink = $this->createLink('file', 'download', "fileID=$file->id");
$downloadLink .= strpos($downloadLink, '?') === false ? '?' : '&';
$downloadLink .= $sessionString;
echo "<li class='file' title='{$uploadDate}'>" . html::a($downloadLink, $fileTitle . " <span class='text-muted'>({$fileSize})</span>", '_blank', "id='fileTitle$file->id' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title')\"");
$objectType = zget($this->config->file->objectType, $file->objectType);
if(common::hasPriv($objectType, 'edit', $object))
{
echo "<span class='right-icon'>&nbsp; ";
/* Determines whether the file supports preview. */
if($file->extension == 'txt')
{
$imageSize = $this->file->getImageSize($file);
$imageWidth = $imageSize ? $imageSize[0] : 0;
$extension = 'txt';
if(($postion = strrpos($file->title, '.')) !== false) $extension = substr($file->title, $postion + 1);
if($extension != 'txt') $mode = 'down';
$file->extension = $extension;
}
$fileSize = 0;
/* Show size info. */
if($file->size < 1024)
/* For the open source version of the file judgment. */
if(stripos('txt|jpg|jpeg|gif|png|bmp', $file->extension) !== false)
{
$fileSize = $file->size . 'B';
}
elseif($file->size < 1024 * 1024)
{
$file->size = round($file->size / 1024, 2);
$fileSize = $file->size . 'K';
}
elseif($file->size < 1024 * 1024 * 1024)
{
$file->size = round($file->size / (1024 * 1024), 2);
$fileSize = $file->size . 'M';
}
else
{
$file->size = round($file->size / (1024 * 1024 * 1024), 2);
$fileSize = $file->size . 'G';
echo html::a($downloadLink, $lang->file->preview, '_blank', "class='fileAction btn btn-link text-primary' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title')\"");
}
$downloadLink = $this->createLink('file', 'download', "fileID=$file->id");
$downloadLink .= strpos($downloadLink, '?') === false ? '?' : '&';
$downloadLink .= $sessionString;
echo "<li class='file' title='{$uploadDate}'>" . html::a($downloadLink, $fileTitle . " <span class='text-muted'>({$fileSize})</span>", '_blank', "id='fileTitle$file->id' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title')\"");
$objectType = zget($this->config->file->objectType, $file->objectType);
if(common::hasPriv($objectType, 'edit', $object))
/* For the max version of the file judgment. */
if(isset($this->config->file->libreOfficeTurnon) and $this->config->file->libreOfficeTurnon == 1)
{
echo "<span class='right-icon'>&nbsp; ";
/* Determines whether the file supports preview. */
if($file->extension == 'txt')
{
$extension = 'txt';
if(($postion = strrpos($file->title, '.')) !== false) $extension = substr($file->title, $postion + 1);
if($extension != 'txt') $mode = 'down';
$file->extension = $extension;
}
/* For the open source version of the file judgment. */
if(stripos('txt|jpg|jpeg|gif|png|bmp', $file->extension) !== false)
$officeTypes = 'doc|docx|xls|xlsx|ppt|pptx|pdf';
if(stripos($officeTypes, $file->extension) !== false)
{
echo html::a($downloadLink, $lang->file->preview, '_blank', "class='fileAction btn btn-link text-primary' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title')\"");
}
/* For the max version of the file judgment. */
if(isset($this->config->file->libreOfficeTurnon) and $this->config->file->libreOfficeTurnon == 1)
{
$officeTypes = 'doc|docx|xls|xlsx|ppt|pptx|pdf';
if(stripos($officeTypes, $file->extension) !== false)
{
echo html::a($downloadLink, $lang->file->preview, '_blank', "class='fileAction btn btn-link text-primary' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title')\"");
}
}
common::printLink('file', 'download', "fileID=$file->id", $lang->file->downloadFile, '_blank', "class='fileAction btn btn-link text-primary' title='{$lang->file->downloadFile}'");
if(common::hasPriv('file', 'edit')) echo html::a('###', $lang->file->edit, '', "id='renameFile$file->id' class='fileAction btn btn-link edit text-primary' onclick='showRenameBox($file->id)' title='{$lang->file->edit}'");
if(common::hasPriv('file', 'delete')) echo html::a('###', $lang->delete, '', "class='fileAction btn btn-link text-primary' onclick='deleteFile($file->id)' title='$lang->delete'");
echo '</span>';
}
echo '</li>';?>
<li class='file'>
<div>
<?php
if(strrpos($file->title, '.') !== false)
{
/* Fix the file name exe.exe */
$title = explode('.', $file->title);
$extension = end($title);
if($file->extension == 'txt' && $extension != $file->extension) $file->extension = $extension;
array_pop($title);
$file->title = join('.', $title);
common::printLink('file', 'download', "fileID=$file->id", $lang->file->downloadFile, '_blank', "class='fileAction btn btn-link text-primary' title='{$lang->file->downloadFile}'");
if(common::hasPriv('file', 'edit')) echo html::a('###', $lang->file->edit, '', "id='renameFile$file->id' class='fileAction btn btn-link edit text-primary' onclick='showRenameBox($file->id)' title='{$lang->file->edit}'");
if(common::hasPriv('file', 'delete')) echo html::a('###', $lang->delete, '', "class='fileAction btn btn-link text-primary' onclick='deleteFile($file->id)' title='$lang->delete'");
echo '</span>';
}
?>
<div class='hidden renameFile w-300px' id='renameBox<?php echo $file->id;?>'>
<i class='icon icon-file-text'></i>
<div class='input-group'>
<?php echo html::input('fileName' . $file->id, $file->title, "class='form-control' size='40'");?>
<input type="hidden" name="extension" id="extension<?php echo $file->id?>" value="<?php echo $file->extension;?>"/>
<strong class='input-group-addon'>.<?php echo $file->extension;?></strong>
</div>
<div class="input-group-btn">
<button type="button" class="btn btn-success file-name-confirm" onclick="setFileName(<?php echo $file->id;?>)" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-check"></i></button>
<button type="button" class="btn btn-gray file-name-cancel" onclick="showFile(<?php echo $file->id;?>)" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-close"></i></button>
</div>
</div>
</div>
</li>
echo '</li>';?>
<?php }
}?>
<li class='file'>
<div>
<?php
if(strrpos($file->title, '.') !== false)
{
/* Fix the file name exe.exe */
$title = explode('.', $file->title);
$extension = end($title);
if($file->extension == 'txt' && $extension != $file->extension) $file->extension = $extension;
array_pop($title);
$file->title = join('.', $title);
}
?>
<div class='hidden renameFile w-300px' id='renameBox<?php echo $file->id;?>'>
<i class='icon icon-file-text'></i>
<div class='input-group'>
<?php echo html::input('fileName' . $file->id, $file->title, "class='form-control' size='40'");?>
<input type="hidden" name="extension" id="extension<?php echo $file->id?>" value="<?php echo $file->extension;?>"/>
<strong class='input-group-addon'>.<?php echo $file->extension;?></strong>
</div>
<div class="input-group-btn">
<button type="button" class="btn btn-success file-name-confirm" onclick="setFileName(<?php echo $file->id;?>)" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-check"></i></button>
<button type="button" class="btn btn-gray file-name-cancel" onclick="showFile(<?php echo $file->id;?>)" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-close"></i></button>
</div>
</div>
</div>
</li>
<?php endif;
endforeach;?>
</ul>
<?php if($fieldset == 'true'):?>
</div>