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.38.2.1 -r1.38.2.2
--- openacs-4/packages/file-storage/file-storage.info 18 Jul 2005 19:05:22 -0000 1.38.2.1
+++ openacs-4/packages/file-storage/file-storage.info 21 Jul 2005 18:44:41 -0000 1.38.2.2
@@ -7,40 +7,43 @@
f
f
-
+
OpenACS
Collaborative document storage
2004-07-21
OpenACS
Provides a versioned document store with storage in the filesystem or database (depending on configuration). Documents and folders can be permissioned and folders downloaded.
+ 0
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
+
+
+
-
-
-
+
+
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.48.2.2 -r1.48.2.3
--- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 15 Jul 2005 14:38:54 -0000 1.48.2.2
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 21 Jul 2005 18:44:41 -0000 1.48.2.3
@@ -653,13 +653,14 @@
ad_proc -public fs::add_file {
-name
-parent_id
- -tmp_filename
-package_id
{-item_id ""}
{-creation_user ""}
{-creation_ip ""}
{-title ""}
{-description ""}
+ {-tmp_filename ""}
+ {-mime_type ""}
-no_callback:boolean
} {
Create a new file storage item or add a new revision if
@@ -675,8 +676,9 @@
set indbp "f"
set storage_type "file"
}
-
- set mime_type [cr_filename_to_mime_type -create -- $name]
+ if {[string equal "" $mime_type]} {
+ set mime_type [cr_filename_to_mime_type -create -- $name]
+ }
# we have to do this here because we create the object before
# calling cr_import_content
@@ -696,7 +698,6 @@
} else {
set do_notify_here_p "f"
}
-
set revision_id [fs::add_version \
-name $name \
-tmp_filename $tmp_filename \
@@ -707,7 +708,8 @@
-title $title \
-description $description \
-suppress_notify_p $do_notify_here_p \
- -storage_type $storage_type
+ -storage_type $storage_type \
+ -mime_type $mime_type
]
if {[string is true $do_notify_here_p]} {
@@ -732,6 +734,7 @@
{-description ""}
{-suppress_notify_p "f"}
{-storage_type ""}
+ {-mime_type ""}
} {
Create a new version of a file storage item
@return revision_id
@@ -740,7 +743,10 @@
if {[string equal "" $storage_type]} {
set storage_type [db_string get_storage_type ""]
}
- set mime_type [cr_filename_to_mime_type -create -- $name]
+ if {[string equal "" $mime_type]} {
+ set mime_type [cr_filename_to_mime_type -create -- $name]
+ }
+
set tmp_size [file size $tmp_filename]
set parent_id [get_parent -item_id $item_id]
set revision_id [cr_import_content \
Index: openacs-4/packages/file-storage/www/file-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file-add.tcl,v
diff -u -r1.12.2.1 -r1.12.2.2
--- openacs-4/packages/file-storage/www/file-add.tcl 21 Jun 2005 22:26:28 -0000 1.12.2.1
+++ openacs-4/packages/file-storage/www/file-add.tcl 21 Jul 2005 18:44:41 -0000 1.12.2.2
@@ -10,6 +10,7 @@
upload_file:trim,optional
return_url:optional
upload_file.tmpfile:tmpfile,optional
+ content_body:optional
{title ""}
{lock_title_p 0}
@@ -61,6 +62,36 @@
{upload_file:file {label \#file-storage.Upload_a_file\#} {html "size 30"}}
}
+if {[parameter::get -parameter AllowTextEdit -default 0]} {
+ if {[ad_form_new_p -key file_id]} {
+
+ # To allow the creation of files
+ ad_form -extend -form {
+ {content_body:richtext(richtext),optional
+ {label "Create a file"}
+ {html "rows 20 cols 70" }
+ {htmlarea_p 1}
+ }
+ }
+ } else {
+ # To make content editable
+ set revision_id [content::item::get_live_revision -item_id $file_id]
+ set mime_type [db_string get_mime_type "select mime_type from cr_revisions where revision_id = :revision_id"]
+ if { [string equal $mime_type "text/html"] } {
+ ad_form -extend -form {
+ {edit_content:richtext(richtext),optional
+ {label "Content"}
+ {html "rows 20 cols 70" }
+ {htmlarea_p 1}
+ }
+ {mime_type:text(hidden)
+ {value $mime_type}
+ }
+ }
+ }
+ }
+}
+
if {[exists_and_not_null return_url]} {
ad_form -extend -form {
{return_url:text(hidden) {value $return_url}}
@@ -69,11 +100,11 @@
if {$lock_title_p} {
ad_form -extend -form {
- {title:text(inform) {value $title}}
+ {title:text(hidden) {value $title}}
}
} else {
ad_form -extend -form {
- {title:text,optional {label \#file-storage.Title\#} {html {size 30}} {value $title} }
+ {title:text,optional {label \#file-storage.Title\#} {html {size 30}} }
}
}
@@ -117,6 +148,23 @@
set upload_files [list [template::util::file::get_property filename $upload_file]]
set upload_tmpfiles [list [template::util::file::get_property tmp_filename $upload_file]]
}
+ set mime_type ""
+ if { [empty_string_p [lindex $upload_files 0]]} {
+ if {[empty_string_p [template::util::richtext::get_property html_value $content_body]] } {
+ ad_return_complaint 1 "You have to upload a file or create a new one"
+ ad_script_abort
+ }
+ # create a tmp file to import from user entered HTML
+ set content_body [template::util::richtext::get_property html_value $content_body]
+ set mime_type text/html
+ set tmp_filename [ns_tmpnam]
+ set fd [open $tmp_filename w]
+ puts $fd $content_body
+ close $fd
+ set upload_files [list $title]
+ set upload_tmpfiles [list $tmp_filename]
+ }
+ ns_log notice "file_add mime_type='${mime_type}'"
set i 0
set number_upload_files [llength $upload_files]
foreach upload_file $upload_files tmpfile $upload_tmpfiles {
@@ -152,7 +200,8 @@
-creation_ip [ad_conn peeraddr] \
-title $this_title \
-description $description \
- -package_id $package_id
+ -package_id $package_id \
+ -mime_type $mime_type
file delete $tmpfile
incr i
@@ -172,6 +221,7 @@
-title $title \
-description $description \
-package_id $package_id \
+ -mime_type $mime_type
} -after_submit {