Index: openacs-4/packages/file-storage/www/download-zip.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/download-zip.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/www/download-zip.tcl 16 Jan 2007 17:44:55 -0000 1.1 @@ -0,0 +1,54 @@ +ad_page_contract { + delete items +} { + object_id:notnull,multiple + {confirm_p:optional,boolean 0} + {return_url ""} +} -errors {object_id:,notnull,integer,multiple {Please select at least one item to delete.} +} + +set user_id [ad_conn user_id] + +# publish the object to the file system +set in_path [ns_tmpnam] +file mkdir $in_path + +if {[llength $object_id] eq 1} { + set download_name [fs::get_file_system_safe_object_name -object_id $object_id] +} else { + set download_name [fs::get_file_system_safe_object_name -object_id [fs::get_parent -item_id [lindex $object_id 0]]] +} + +set ext [fs::get_archive_extension] +if {![empty_string_p $ext]} { + append download_name ".${ext}" +} + +foreach fs_object_id $object_id { + set file [fs::publish_object_to_file_system -object_id $fs_object_id -path $in_path -user_id $user_id] +} + +# create a temp dir to put the archive in +set out_path [ns_tmpnam] +file mkdir $out_path + +set out_file [file join "${out_path}" "${download_name}"] + +# get the archive command +set cmd "zip -r \"$out_file\" ." + +# create the archive +with_catch errmsg { + exec bash -c "cd $in_path; $cmd; cd -" +} { + # some day we'll do something useful here + error $errmsg +} + +# return the archive to the connection. +ns_set put [ad_conn outputheaders] Content-Disposition "attachment;filename=\"$download_name\"" +ns_returnfile 200 application/octet-stream $out_file + +# clean everything up +file delete -force $in_path +file delete -force $out_path Index: openacs-4/packages/file-storage/www/folder-chunk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-chunk.adp,v diff -u -N -r1.26 -r1.27 --- openacs-4/packages/file-storage/www/folder-chunk.adp 15 Dec 2006 22:45:33 -0000 1.26 +++ openacs-4/packages/file-storage/www/folder-chunk.adp 16 Jan 2007 17:44:55 -0000 1.27 @@ -2,7 +2,7 @@

- + #file-storage.lt_Download_an_archive_o#
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 -N -r1.35 -r1.36 --- openacs-4/packages/file-storage/www/folder-chunk.tcl 15 Dec 2006 22:45:33 -0000 1.35 +++ openacs-4/packages/file-storage/www/folder-chunk.tcl 16 Jan 2007 17:44:55 -0000 1.36 @@ -145,7 +145,7 @@ set vars_to_export [list return_url] if {$allow_bulk_actions} { - set bulk_actions [list "[_ file-storage.Move]" "${fs_url}move" "[_ file-storage.lt_Move_Checked_Items_to]" "[_ file-storage.Copy]" "${fs_url}copy" "[_ file-storage.lt_Copy_Checked_Items_to]" "[_ file-storage.Delete]" "${fs_url}delete" "[_ file-storage.Delete_Checked_Items]"] + set bulk_actions [list "[_ file-storage.Move]" "${fs_url}move" "[_ file-storage.lt_Move_Checked_Items_to]" "[_ file-storage.Copy]" "${fs_url}copy" "[_ file-storage.lt_Copy_Checked_Items_to]" "[_ file-storage.Delete]" "${fs_url}delete" "[_ file-storage.Delete_Checked_Items]" "[_ file-storage.Download_ZIP]" "${fs_url}download-zip" "[_ file-storage.Download_ZIP_Checked_Items]"] callback fs::folder_chunk::add_bulk_actions \ -bulk_variable "bulk_actions" \ -folder_id $folder_id \ @@ -217,7 +217,6 @@ set name [lang::util::localize $name] - switch -- $type { folder { set properties_link "" @@ -228,7 +227,7 @@ set alt_icon #file-storage.folder# set file_url "${fs_url}index?[export_vars {{folder_id $object_id}}]" set download_link [_ file-storage.Download] - set download_url "${fs_url}download-archive/index?[export_vars {object_id}]" + set download_url "[export_vars -base "${fs_url}download-zip" -url {object_id}]" } url { set properties_link [_ file-storage.properties] @@ -316,4 +315,7 @@ db_multirow feeds select_subscrs {} } +if {$content_size_total > 0} { + set compressed_url [export_vars -base "${fs_url}download-zip" -url {{object_id $folder_id}}] +} ad_return_template