Index: openacs-4/packages/contacts/www/admin/full-organizations.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/full-organizations.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/contacts/www/admin/full-organizations.tcl 12 Aug 2018 12:30:06 -0000 1.4 +++ openacs-4/packages/contacts/www/admin/full-organizations.tcl 6 Nov 2024 12:59:29 -0000 1.5 @@ -48,7 +48,9 @@ -object_type organization -set output {"Organization ID","Name","Email","URL"} +set output [list] + +set headers {"Organization ID" "Name" "Email" "URL"} set extended_columns [list] template::multirow foreach ext { if { ( $type eq "organization" || $type eq "party" ) && [lsearch $preset_columns $key] >= 0 } { @@ -67,35 +69,30 @@ # - when there are many related organizations the size of the column # could be too big for programs like excel (which is one of # the primary programs this export will be looked at in) - append output ",\"[template::list::csv_quote "$type_pretty: $key_pretty"]\"" + lappend headers "$type_pretty: $key_pretty" - # for testing if you want to limit the number of columns you should do it here # you can simply say that if the count of extend columns > n then do not append # to the extend columns list lappend extended_columns "${type}__${key}" } } -set output "$output\n" +lappend output $headers contacts::multirow \ -extend $extended_columns \ -multirow organizations \ -select_query $select_query \ -format "text" - -# we create a command here because it more efficient then -# iterating over all the columns in the multirow foreach -set command [list] -foreach column [template::multirow columns organizations] { - lappend command "\[template::list::csv_quote \$${column}\]" -} -set command "append output \"\\\"[join $command {\",\"}]\\\"\\n\"" - +set __columns [template::multirow columns organizations] template::multirow foreach organizations { - eval $command + set __row [list] + foreach __column $__columns { + lappend __row [set $__column] + } + lappend output $__row } # we save the file to /tmp/full-export.csv @@ -106,7 +103,8 @@ # there is a report storage and queueing mechanism set output_file [open /tmp/full-organizations.csv "w+"] -puts $output_file $output +package require csv +puts $output_file [::csv::joinlist $output ,] close $output_file # now we return the file - just in case it didn't time out for the user