Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rest-fs-openacs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-rest-fs-openacs
Commits
8758d809
Commit
8758d809
authored
Jan 21, 2019
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Added the list of versions per file
parent
bef79b00
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
125 additions
and
89 deletions
+125
-89
file-tree.json.tcl
www/file-tree.json.tcl
+125
-89
No files found.
www/file-tree.json.tcl
View file @
8758d809
...
...
@@ -55,30 +55,28 @@ set top_level [db_string top_level "select tree_level(tree_sortkey) from cr_item
set
sql
"
select
ci.item_id as file_id,
ci.live_revision as live_version_id,
ci.parent_id,
cr.revision_id, -- CR revision (OpenACS and PO files)
fv.version_id, -- CR revision (only PO files)
ci.name as file_name,
cr.revision_id as version_id,
tree_level(ci.tree_sortkey) - :top_level as level,
fv.version_sha1 as sha1,
fv.version_creation_date as creation_date,
fv.version_modification_date as modification_date,
(select count(*) from cr_items child where child.parent_id = ci.item_id) as num_children,
ci.*,
cr.*,
CASE WHEN bts.open_p = 'o' THEN 'true' ELSE 'false' END as expanded,
CASE
WHEN ci.content_type::text = 'content_folder' THEN 'folder'
CASE WHEN ci.content_type::text = 'content_folder' THEN 'folder'
WHEN ci.content_type::text = 'content_extlink' THEN 'url'
WHEN ci.content_type::text = 'content_symlink' THEN 'symlink'
WHEN ci.content_type::text = 'file_storage_object' THEN 'file'
ELSE ci.content_type
END AS type
from cr_items parent_ci,
END AS type,
CASE WHEN bts.open_p = 'o' THEN 'true' ELSE 'false' END as expanded,
ci.*,
cr.*,
fv.*
from
cr_items parent_ci,
cr_items ci
LEFT JOIN cr_extlinks ce ON ci.item_id = ce.extlink_id
LEFT JOIN cr_folders cf ON ci.item_id = cf.folder_id
LEFT JOIN cr_revisions cr ON ci.live_revision = cr.revision_id
LEFT OUTER JOIN im_file_versions fv ON (cr.revision_id = fv.version_id)
LEFT JOIN cr_mime_types cm ON cr.mime_type = cm.mime_type
JOIN acs_objects o ON ci.item_id = o.object_id
LEFT OUTER JOIN im_biz_object_tree_status bts ON (
ci.item_id = bts.object_id and
...
...
@@ -86,28 +84,69 @@ set sql "
bts.user_id = :current_user_id
)
LEFT OUTER JOIN im_files f ON (ci.item_id = f.file_id)
-- add cr_revisions = file_versions using OUTER JOIN
LEFT OUTER JOIN cr_revisions cr ON (cr.item_id = ci.item_id)
LEFT OUTER JOIN im_file_versions fv ON (cr.revision_id = fv.version_id)
where
parent_ci.item_id = :folder_id and
ci.tree_sortkey between parent_ci.tree_sortkey and tree_right(parent_ci.tree_sortkey)
and tree_level(ci.tree_sortkey) > :top_level
order by
ci.tree_sortkey
ci.tree_sortkey,
cr.revision_id
"
# ad_return_complaint 1 [im_ad_hoc_query -subtotals_p 0 -format html $sql
]
# Read the query into a Multirow, so that we can order
# it according to sort_order within the individual sub-levels.
db_multirow file_multirow file_list
$sql
{
# By default open the top-level file-storage
if
{
0 eq
$level
}
{
set expanded
"true"
}
# Write the list of files to a multirow,
# while storing the versions in a hash
multirow create file_multirow file_id parent_id revision_id version_id file_name level num_children type expanded
set
file_id
""
set
old_file_id
""
db_foreach files
$sql
{
# Collect file versions in a hash
if
{
""
eq
$version
_status_id
}
{
set version_status_id
[
im_file_status_active
]
}
if
{
""
eq
$version
_type_id
}
{
set version_type_id
[
im_file_type_default
]
}
if
{
""
eq
$revision
_id
}
{
set revision_id 0
}
if
{
""
eq
$content
_length
}
{
set content_length 0
}
set version_list
[
list
]
if
{[
info
exists version_hash
(
$file
_id
)]}
{
set version_list
$version
_hash
(
$file
_id
)
}
lappend version_list
"
{
\"
version_id
\"
:
$revision
_id,
\"
content_length
\"
:
$content
_length,
\"
mime_type
\"
:
\"
$mime
_type
\"
,
\"
title
\"
:
\"
[
im_quotejson
$title
]
\"
,
\"
description
\"
:
\"
[
im_quotejson
$description
]
\"
,
\"
status_id
\"
:
$version
_status_id,
\"
type_id
\"
:
$version
_type_id,
\"
creation_date
\"
:
\"
$version
_creation_date
\"
,
\"
modification_date
\"
:
\"
$version
_modification_date
\"
,
\"
sha1
\"
:
\"
$version
_sha1
\"
,
\"
upload_comment
\"
:
\"
[
im_quotejson
$version
_upload_comment
]
\"
}"
set version_hash
(
$file
_id
)
$version
_list
# write out the multirow entry for the file
if
{
$old
_file_id ne
$file
_id
}
{
multirow append file_multirow
$file
_id
$parent
_id
$revision
_id
$version
_id
$file
_name
$level
$num
_children
$type
$expanded
set old_file_id
$file
_id
}
}
# Write out the last file multirow
if
{
""
ne
$file
_id
}
{
multirow append file_multirow
$file
_id
$parent
_id
$revision
_id
$version
_id
$file
_name
$level
$num
_children
$type
$expanded
}
#ad_return_complaint 1 [array get version_hash
]
# --------------------------------------------
# Get all the extra variables for a file ci_item:
# fraber 2018-08-22: No meta-variables yet...
set
valid_vars
[
list
level
version_id type publish_date mime_type content_length sha1 title creation_date modification_date description
]
set
valid_vars
[
list
level
type
]
set
valid_vars
[
lsort
-unique
$valid
_vars
]
# needed to calculate sha1
...
...
@@ -162,27 +201,24 @@ template::multirow foreach file_multirow {
set quoted_char_map
{
"
\n
"
"
\\
n"
"
\r
"
"
\\
r"
"
\"
"
"
\\\"
"
"
\\
"
"
\\\\
"
}
set quoted_file_name
[
string
map
$quoted
_char_map
$file
_name
]
# Get the list of versions from hash
set version_list
{}
if
{[
info
exists version_hash
(
$file
_id
)]}
{
set version_list
$version
_hash
(
$file
_id
)
}
append file_json
"
${indent}
\{
${indent}
\t\"
id
\"
:
$file
_id,
${indent}
\t\"
live_version_id
\"
:
$live
_version_id,
${indent}
\t\"
name
\"
:
\"
$quoted
_file_name
\"
,
${indent}
\t\"
iconCls
\"
:
\"
icon-
$type
\"
,
${indent}
\t\"
expanded
\"
:
$expanded
,
${indent}
\t\"
versions
\"
:
\[
[
join
$version
_list
", "
]
${indent}
\t\]
,
"
if
{
"folder"
==
$type
&& 0 ==
$num
_children
}
{
append file_json
"
${indent}
\t\"
children
\"
:
\[\]
,
\n
"
}
# version_id is empty for directories
if
{
""
eq
$version
_id
}
{
set sha1
""
}
else
{
if
{
""
eq
$sha1
}
{
set filename
[
db_string filename
"select :storage_area_path || content from cr_revisions where revision_id = :version_id"
]
set sha1
[
string
range
[
exec
/usr/bin/sha1sum
"
$filename
"
]
0 39
]
}
}
foreach var
$valid
_vars
{
# Skip xml_* variables
(
only used by MS-File
)
if
{[
regexp
{
^xml_
}
$var
match
]}
{
continue
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment