mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
file versions on index page fix
This commit is contained in:
@ -139,7 +139,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// get the file version by the history path
|
||||
public static int GetFileVersion(string historyPath)
|
||||
{
|
||||
if (!Directory.Exists(historyPath)) return 0; // if the history path doesn't exist, then the file version is 0
|
||||
if (!Directory.Exists(historyPath)) return 1; // if the history path doesn't exist, then the file version is 0
|
||||
return Directory.EnumerateDirectories(historyPath).Count() + 1; // take only directories from the history folder and count them
|
||||
}
|
||||
|
||||
|
||||
@ -182,10 +182,10 @@
|
||||
var canEdir = DocManagerHelper.EditedExts.Contains(Path.GetExtension(storedFile.Name).ToLower());
|
||||
%>
|
||||
|
||||
<tr class="tableRow" title="<%= storedFile.Name %>">
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress) %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name }) %>" target="_blank">
|
||||
<span title="<%= storedFile.Name %>"><%= storedFile.Name %></span>
|
||||
<span><%= storedFile.Name %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if (canEdir) { %>
|
||||
|
||||
@ -183,10 +183,10 @@
|
||||
var canEdit = EditedExts.Contains(Path.GetExtension(storedFile.Name).ToLower());
|
||||
%>
|
||||
|
||||
<tr class="tableRow" title="<%= storedFile.Name %>">
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress) %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= editUrl %>" target="_blank">
|
||||
<span title="<%= storedFile.Name %>"><%= storedFile.Name %></span>
|
||||
<span><%= storedFile.Name %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if (canEdit) { %>
|
||||
|
||||
@ -202,7 +202,7 @@ namespace OnlineEditorsExample
|
||||
// get the last file version by its history directory
|
||||
public static int GetFileVersion(string historyPath)
|
||||
{
|
||||
if (!Directory.Exists(historyPath)) return 0;
|
||||
if (!Directory.Exists(historyPath)) return 1;
|
||||
return Directory.EnumerateDirectories(historyPath).Count() + 1; // run through all the file versions and count them
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +199,7 @@ public class DocumentManager
|
||||
{
|
||||
File dir = new File(historyPath);
|
||||
|
||||
if (!dir.exists()) return 0; // if the history path doesn't exist, then the file version is 0
|
||||
if (!dir.exists()) return 1; // if the history path doesn't exist, then the file version is 0
|
||||
|
||||
File[] dirs = dir.listFiles(new FileFilter() { // take only directories from the history folder
|
||||
@Override
|
||||
|
||||
@ -177,11 +177,12 @@
|
||||
<% for (Integer i = 0; i < files.length; i++) {
|
||||
String docType = FileUtility.GetFileType(files[i].getName()).toString().toLowerCase();
|
||||
Boolean canEdit = DocumentManager.GetEditedExts().contains(FileUtility.GetFileExtension(files[i].getName()));
|
||||
String version=" ["+DocumentManager.GetFileVersion(DocumentManager.HistoryDir(DocumentManager.StoragePath(files[i].getName(), null)))+"]";
|
||||
%>
|
||||
<tr class="tableRow" title="<%= files[i].getName() %>">
|
||||
<tr class="tableRow" title="<%= files[i].getName() %><%= version %>">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>" target="_blank">
|
||||
<span title="<%= files[i].getName() %>"><%= files[i].getName() %></span>
|
||||
<span><%= files[i].getName() %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if (canEdit) { %>
|
||||
|
||||
@ -270,7 +270,7 @@ docManager.getStoredFiles = function () {
|
||||
|
||||
if (!stats.isDirectory()) { // if the element isn't a directory
|
||||
let historyPath = docManager.historyPath(storedFiles[i], userAddress); // get the path to the file history
|
||||
let version = 1;
|
||||
let version = 0;
|
||||
if (historyPath != "") { // if the history path exists
|
||||
version = docManager.countVersion(historyPath); // get the last file version
|
||||
}
|
||||
@ -281,7 +281,7 @@ docManager.getStoredFiles = function () {
|
||||
name: storedFiles[i],
|
||||
documentType: fileUtility.getFileType(storedFiles[i]),
|
||||
canEdit: configServer.get("editedDocs").indexOf(fileUtility.getFileExtension(storedFiles[i])) != -1,
|
||||
version: version
|
||||
version: version+1
|
||||
};
|
||||
|
||||
if (!result.length) { // if the result array is empty
|
||||
|
||||
@ -175,7 +175,7 @@
|
||||
<tr class="tableRow" title="<%= storedFiles[i].name %> [<%= storedFiles[i].version %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= storedFiles[i].documentType %>" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<span title="<%= storedFiles[i].name %> [<%= storedFiles[i].version %>]"><%= storedFiles[i].name %></span>
|
||||
<span><%= storedFiles[i].name %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if (storedFiles[i].canEdit) { %>
|
||||
@ -251,7 +251,7 @@
|
||||
<% } %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
@ -258,7 +258,7 @@ function getVersionDir($histDir, $version) {
|
||||
|
||||
// get a number of the last file version from the history directory
|
||||
function getFileVersion($histDir) {
|
||||
if (!file_exists($histDir) || !is_dir($histDir)) return 0; // check if the history directory exists
|
||||
if (!file_exists($histDir) || !is_dir($histDir)) return 1; // check if the history directory exists
|
||||
|
||||
$cdir = scandir($histDir);
|
||||
$ver = 1;
|
||||
|
||||
@ -175,10 +175,10 @@
|
||||
<table cellspacing="0" cellpadding="0" width="100%">
|
||||
<tbody>
|
||||
<?php foreach ($storedFiles as &$storeFile) {
|
||||
echo '<tr class="tableRow" title="'.$storeFile->name.'">';
|
||||
echo '<tr class="tableRow" title="'.$storeFile->name.' ['.getFileVersion(getHistoryDir(getStoragePath($storeFile->name))).']">';
|
||||
echo ' <td class="contentCells">';
|
||||
echo ' <a class="stored-edit '.$storeFile->documentType.'" href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.htmlentities($user).'" target="_blank">';
|
||||
echo ' <span title="'.$storeFile->name.'">'.$storeFile->name.'</span>';
|
||||
echo ' <span>'.$storeFile->name.'</span>';
|
||||
echo ' </a>';
|
||||
echo ' </td>';
|
||||
if ($storeFile->canEdit) {
|
||||
|
||||
@ -206,7 +206,7 @@ def getStoredFiles(req):
|
||||
|
||||
for f in files:
|
||||
if os.path.isfile(os.path.join(directory, f)):
|
||||
fileInfos.append({ 'type': fileUtils.getFileType(f), 'title': f, 'url': getFileUri(f, True, req), 'canEdit': isCanEdit(fileUtils.getFileExt(f))}) # write information about file type, title and url
|
||||
fileInfos.append({'version':historyManager.getFileVersion(historyManager.getHistoryDir(getStoragePath(f, req))), 'type': fileUtils.getFileType(f), 'title': f, 'url': getFileUri(f, True, req), 'canEdit': isCanEdit(fileUtils.getFileExt(f))}) # write information about file type, title and url
|
||||
|
||||
return fileInfos
|
||||
|
||||
|
||||
@ -142,10 +142,10 @@
|
||||
<table cellspacing="0" cellpadding="0" width="100%">
|
||||
<tbody>
|
||||
{% for file in files %}
|
||||
<tr class="tableRow" title="{{ file.title }}">
|
||||
<tr class="tableRow" title="{{ file.title }} [{{file.version}}]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit {{ file.type }}" href="edit?filename={{ file.title }}" target="_blank">
|
||||
<span title="{{ file.title }}">{{ file.title }}</span>
|
||||
<span>{{ file.title }}</span>
|
||||
</a>
|
||||
</td>
|
||||
{% if file.canEdit %}
|
||||
|
||||
@ -134,7 +134,7 @@ class DocumentHelper
|
||||
# get the last file version
|
||||
def get_file_version(hist_dir)
|
||||
if !Dir.exist?(hist_dir)
|
||||
return 0
|
||||
return 1
|
||||
end
|
||||
|
||||
ver = 1
|
||||
|
||||
@ -153,10 +153,10 @@
|
||||
editUrl = "editor?fileName=#{URI::encode(d)}"
|
||||
docType = FileUtility.get_file_type(d)
|
||||
canEdit = DocumentHelper.edited_exts.include?(File.extname(d).downcase) %>
|
||||
<tr class="tableRow" title="<%= d %>">
|
||||
<tr class="tableRow" title="<%= d %> [<%= DocumentHelper.get_file_version(DocumentHelper.history_dir(DocumentHelper.storage_path(d, nil))) %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= editUrl %>" target="_blank">
|
||||
<span title="<%= d %>"><%= d %></span>
|
||||
<span><%= d %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if canEdit %>
|
||||
|
||||
Reference in New Issue
Block a user