Index: openacs-4/packages/acs-templating/tcl/file-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/file-procs.tcl,v diff -u -r1.12.2.2 -r1.12.2.3 --- openacs-4/packages/acs-templating/tcl/file-procs.tcl 8 Jul 2019 12:14:07 -0000 1.12.2.2 +++ openacs-4/packages/acs-templating/tcl/file-procs.tcl 9 Jul 2019 17:01:57 -0000 1.12.2.3 @@ -25,50 +25,59 @@ @return the list { file_name temp_file_name content_mime_type }. } { - if {[ns_info name] eq "NaviServer"} { - # - # NaviServer - # - # Get the files information using 'ns_querygetall' - # - set filenames [ns_querygetall $element_id] - set tmpfiles [ns_querygetall $element_id.tmpfile] - set types [ns_querygetall $element_id.content-type] - } else { - # - # AOLserver - # - # ns_querygetall behaves differently in AOLserver, using the ns_queryget - # legacy version instead - # - set filenames [ns_queryget $element_id] - set tmpfiles [ns_queryget $element_id.tmpfile] - set types [ns_queryget $element_id.content-type] - } # - # No files, get out + # Check if these have already been converted, then return them as they are. # - if {$filenames eq ""} { - return "" - } + # This may happen, for instance, during the 'preview' action of a form. # - # Return the files info in a list per file - # - set files [list] - for {set file 0} {$file < [llength $filenames]} {incr file} { - set filename [lindex $filenames $file] - set tmpfile [lindex $tmpfiles $file] - set type [lindex $types $file] + if { [ns_queryget $element_id.tmpfile] eq "" } { + set files [ns_querygetall $element_id] + } else { + if {[ns_info name] eq "NaviServer"} { + # + # NaviServer + # + # Get the files information using 'ns_querygetall' + # + set filenames [ns_querygetall $element_id] + set tmpfiles [ns_querygetall $element_id.tmpfile] + set types [ns_querygetall $element_id.content-type] + } else { + # + # AOLserver + # + # ns_querygetall behaves differently in AOLserver, using the ns_queryget + # legacy version instead + # + set filenames [ns_queryget $element_id] + set tmpfiles [ns_queryget $element_id.tmpfile] + set types [ns_queryget $element_id.content-type] + } # - # Cleanup filenames + # No files, get out # - regsub -all {\\+} $filename {/} filename - regsub -all { +} $filename {_} filename - set filename [lindex [split $filename "/"] end] + if {$filenames eq ""} { + return "" + } # - # Append to the list of lists + # Return the files info in a list per file # - lappend files [list $filename $tmpfile $type] + set files [list] + for {set file 0} {$file < [llength $filenames]} {incr file} { + set filename [lindex $filenames $file] + set tmpfile [lindex $tmpfiles $file] + set type [lindex $types $file] + # + # Cleanup filenames + # + regsub -all {\\+} $filename {/} filename + regsub -all { +} $filename {_} filename + set filename [lindex [split $filename "/"] end] + # + # Append to the list of lists + # + lappend files [list $filename $tmpfile $type] + } } return $files