Index: openacs-4/packages/dotlrn/www/folder-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/Attic/folder-chunk.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/dotlrn/www/folder-chunk.tcl 4 Apr 2002 03:01:45 -0000 1.5 +++ openacs-4/packages/dotlrn/www/folder-chunk.tcl 22 May 2002 16:42:33 -0000 1.6 @@ -39,7 +39,7 @@ set n_past_days -1 } -set folder_name [fs_get_folder_name $folder_id] +set folder_name [fs::get_object_name -object_id $folder_id] set rows [fs::get_folder_contents \ -folder_id $folder_id \ Index: openacs-4/packages/file-storage/file-storage.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/file-storage.info,v diff -u -r1.15 -r1.16 --- openacs-4/packages/file-storage/file-storage.info 22 May 2002 08:50:52 -0000 1.15 +++ openacs-4/packages/file-storage/file-storage.info 22 May 2002 16:42:31 -0000 1.16 @@ -55,6 +55,7 @@ + @@ -146,7 +147,8 @@ - + + Index: openacs-4/packages/file-storage/tcl/file-storage-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 22 May 2002 08:50:52 -0000 1.14 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 22 May 2002 16:42:31 -0000 1.15 @@ -290,12 +290,12 @@ return [db_exec_plsql new_folder {}] } - ad_proc -public get_folder_name { - {-folder_id:required} + ad_proc -public get_object_name { + {-object_id:required} } { - Select the name of this folder. + Select the name of this object. } { - return [db_string select_folder_name {} -default $folder_id] + return [db_string select_object_name {} -default $object_id] } ad_proc -public folder_p { @@ -373,6 +373,31 @@ return [db_string select_folder_contents_count {}] } + ad_proc -public publish_object_to_file_system { + {-object_id:required} + {-path ""} + {-file_name ""} + {-user_id ""} + } { + publish a file storage object to the file system + } { + if {[empty_string_p $path]} { + set path [ns_tmpnam] + } + + db_1row select_object_info {} + + if {[string match folder $type]} { + set result [publish_folder_to_file_system -folder_id $object_id -path $path -folder_name $name -user_id $user_id] + } elseif {[string match url $type]} { + set result [publish_simple_object_to_file_system -object_id $object_id -path $path -file_name $file_name] + } else { + set result [publish_versioned_object_to_file_system -object_id $object_id -path $path] + } + + return $result + } + ad_proc -public publish_folder_to_file_system { {-folder_id:required} {-path ""} @@ -386,75 +411,80 @@ } if {[empty_string_p $folder_name]} { - set folder_name [get_folder_name -folder_id $folder_id] + set folder_name [get_object_name -object_id $folder_id] } set dir "${path}/${folder_name}" file mkdir $dir - # lets truncate the file that stores URLs - set url_file "${folder_name} URLs.txt" - file delete -force "${dir}/${url_file}" - foreach object [get_folder_contents -folder_id $folder_id -user_id $user_id] { - set object_id [ns_set get $object object_id] - set name [ns_set get $object name] - set type [ns_set get $object type] - - if {[string match folder $type]} { - file mkdir "${dir}/${name}" - publish_folder_to_file_system -folder_id $object_id -path $dir -folder_name $name -user_id $user_id - } elseif {[string match url $type]} { - publish_simple_object_to_file_system -object_id $object_id -path $dir -file_name $url_file - } else { - publish_object_to_file_system -object_id $object_id -path $dir - } - + publish_object_to_file_system \ + -object_id [ns_set get $object object_id] \ + -path $dir \ + -file_name [ns_set get $object name] \ + -user_id $user_id } return $dir } ad_proc -public publish_simple_object_to_file_system { {-object_id:required} - {-path:required} + {-path ""} {-file_name:required} } { publish a simple object to the file system; you must implement a proc named 'fs::publish_simple__to_file_system', where is the fs_simple_object type that you create, for each new simple file storage object you create. } { - set object [db_list_of_ns_sets select_object_content {}] + if {[empty_string_p $path]} { + set path [ns_tmpnam] + file mkdir $path + } - publish_simple_[ns_set get $object type]_to_file_system -object $object -path $path -file_name $file_name + set object [db_list_of_ns_sets select_object_info {}] + + return [publish_simple_[ns_set get $object type]_to_file_system -object $object -path $path -file_name $file_name] } ad_proc -public publish_simple_url_to_file_system { {-object:required} - {-path:required} + {-path ""} {-file_name ""} } { publish a url object to the file system } { + if {[empty_string_p $path]} { + set path [ns_tmpnam] + file mkdir $path + } + set object [lindex $object 0] if {[empty_string_p $file_name]} { - set $file_name [ns_set get $object name] + set file_name [ns_set get $object name] } - set fp [open "${path}/${file_name}" a+] - puts $fp "[ns_set get $object name] ([ns_set get $object url])" + set fp [open "${path}/${file_name}" w] + puts $fp [ns_set get $object url] close $fp + + return "${path}/${file_name}" } - ad_proc -public publish_object_to_file_system { + ad_proc -public publish_versioned_object_to_file_system { {-object_id:required} - {-path:required} + {-path ""} {-file_name ""} } { publish an object to the file system } { + if {[empty_string_p $path]} { + set path [ns_tmpnam] + file mkdir $path + } + db_1row select_object_metadata {} if {[empty_string_p $file_name]} { @@ -486,26 +516,38 @@ close $ofp } } + + return "${path}/${file_name}" } - ad_proc -public get_archive_cmd { + ad_proc -public get_archive_command { {-in_file ""} {-out_file ""} } { return the archive command after replacing {in_file} and {out_file} with their respective values. } { - set archive_cmd [parameter::get -parameter ArchiveCmd -default "cat `find {in_file} -type f` > {out_file}"] + set cmd [parameter::get -parameter ArchiveCommand -default "cat `find {in_file} -type f` > {out_file}"] regsub -all {(\W)} $in_file {\\\1} in_file regsub -all {\\/} $in_file {/} in_file + regsub -all {\\\.} $in_file {.} in_file + regsub -all {(\W)} $out_file {\\\1} out_file regsub -all {\\/} $out_file {/} out_file + regsub -all {\\\.} $out_file {.} out_file - regsub -all {{in_file}} $archive_cmd $in_file archive_cmd - regsub -all {{out_file}} $archive_cmd $out_file archive_cmd + regsub -all {{in_file}} $cmd $in_file cmd + regsub -all {{out_file}} $cmd $out_file cmd - return $archive_cmd + return $cmd } + ad_proc -public get_archive_extension {} { + return the archive extension that should be added to the output file of + an archive command + } { + return [parameter::get -parameter ArchiveExtension -default "txt"] + } + } Index: openacs-4/packages/file-storage/tcl/file-storage-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.xql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/file-storage/tcl/file-storage-procs.xql 22 May 2002 08:50:52 -0000 1.7 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.xql 22 May 2002 16:42:31 -0000 1.8 @@ -43,11 +43,11 @@ - + select name - from fs_folders - where folder_id = :folder_id + from fs_objects + where object_id = :object_id @@ -69,16 +69,24 @@ - + select fs_objects.* from fs_objects where fs_objects.object_id = :object_id - + + select fs_objects.* + from fs_objects + where fs_objects.object_id = :object_id + + + + + select fs_objects.*, cr_items.storage_type, cr_items.storage_area_key, @@ -92,15 +100,15 @@ - + select content from cr_revisions where revision_id = $live_revision - + select filename from cr_revisions Index: openacs-4/packages/file-storage/www/folder-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-chunk.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/file-storage/www/folder-chunk.tcl 4 Apr 2002 03:01:06 -0000 1.4 +++ openacs-4/packages/file-storage/www/folder-chunk.tcl 22 May 2002 16:42:31 -0000 1.5 @@ -23,7 +23,7 @@ set n_past_days -1 } -set folder_name [fs_get_folder_name $folder_id] +set folder_name [fs::get_object_name -object_id $folder_id] set rows [fs::get_folder_contents \ -folder_id $folder_id \ Index: openacs-4/packages/file-storage/www/folder-contents.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/folder-contents.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/file-storage/www/folder-contents.tcl 22 May 2002 08:50:52 -0000 1.5 +++ openacs-4/packages/file-storage/www/folder-contents.tcl 22 May 2002 16:42:31 -0000 1.6 @@ -103,14 +103,14 @@ set table [ad_table \ -Torderby $orderby \ - -Tmissing_text "
Folder [fs::get_folder_name -folder_id $folder_id] is empty.
" \ + -Tmissing_text "
Folder [fs::get_object_name -object_id $folder_id] is empty.
" \ -Ttable_extra_html {width="95%"} \ select_folder_contents \ $sql \ $table_def ] -set folder_name [fs::get_folder_name -folder_id $folder_id] +set folder_name [fs::get_object_name -object_id $folder_id] set context_bar [fs_context_bar_list -final Contents $folder_id] ad_return_template Index: openacs-4/packages/file-storage/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/index.adp,v diff -u -r1.11 -r1.12 --- openacs-4/packages/file-storage/www/index.adp 2 May 2002 20:38:46 -0000 1.11 +++ openacs-4/packages/file-storage/www/index.adp 22 May 2002 16:42:31 -0000 1.12 @@ -42,6 +42,17 @@
  • + + Download an archive of the contents of this folder + +
    + Note: This may take a while, so please be patient. + + +
    + +
  • + Show files modified in the past days as new. Index: openacs-4/packages/file-storage/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/index.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/file-storage/www/index.tcl 2 May 2002 20:38:46 -0000 1.13 +++ openacs-4/packages/file-storage/www/index.tcl 22 May 2002 16:42:31 -0000 1.14 @@ -36,7 +36,12 @@ # set templating datasources set folder_name [fs_get_folder_name $folder_id] -set context_bar [fs_context_bar_list $folder_id] +set ext [fs::get_archive_extension] +set download_name $folder_name +if {![empty_string_p $ext]} { + append download_name ".${ext}" +} +set download_name [ns_urlencode $download_name] set user_id [ad_conn user_id] set write_p [ad_permission_p $folder_id write] @@ -78,4 +83,6 @@ form get_values n_past_days_form n_past_days folder_id } +set context_bar [fs_context_bar_list $folder_id] + ad_return_template Index: openacs-4/packages/file-storage/www/download-archive/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/download-archive/index.vuh,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/www/download-archive/index.vuh 22 May 2002 16:42:31 -0000 1.1 @@ -0,0 +1,61 @@ +# file-storage/www/download-archive/index.vuh + +ad_page_contract { + + @author yon@openforce.net + @creation-date 2002-05-21 + @version $Id: index.vuh,v 1.1 2002/05/22 16:42:31 yon Exp $ + +} -query { + {object_id:integer,optional} +} + +if {[exists_and_not_null object_id]} { + set download_name [fs::get_object_name -object_id $object_id] + set ext [fs::get_archive_extension] + if {![empty_string_p $ext]} { + append download_name ".${ext}" + } + + ad_returnredirect "${object_id}/${download_name}" + ad_script_abort +} + +# convenient way to get the values out of a list +foreach {object_id download_name} [split [ad_conn path_info] /] {break} + +set user_id [ad_conn user_id] +if {$user_id == 0} { + set user_id "" +} + +# publish the object to the file system +set in_path [ns_tmpnam] +file mkdir $in_path + +set file [fs::publish_object_to_file_system -object_id $object_id -path $in_path -user_id $user_id] +set file_name [file tail $file] + +# create a temp dir to put the archive in +set out_path [ns_tmpnam] +file mkdir $out_path + +set out_file "${out_path}/${download_name}" + +# get the archive command +set cmd [fs::get_archive_command -in_file $file_name -out_file $out_file] + +# create the archive +with_catch errmsg { + exec /bin/sh -c "cd $in_path; $cmd; cd -" +} { + # some day we'll do something useful here + error $errmsg +} + +# return the archive to the connection. +ns_returnfile 200 application/octet-stream $out_file + +# clean everything up +file delete -force $in_path +file delete -force $out_path