Index: openacs-4/packages/acs-templating/tcl/list-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/list-procs.tcl,v diff -u -r1.99 -r1.100 --- openacs-4/packages/acs-templating/tcl/list-procs.tcl 6 Nov 2024 12:37:39 -0000 1.99 +++ openacs-4/packages/acs-templating/tcl/list-procs.tcl 6 Nov 2024 12:59:29 -0000 1.100 @@ -895,10 +895,14 @@ } } -ad_proc -public template::list::csv_quote { +ad_proc -deprecated template::list::csv_quote { string } { Quote a string for inclusion as a csv element + + Obsolete when one uses tcllib csv package. + + @see https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/csv/csv.md } { regsub -all -- {\"} $string {""} result return $result 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 Index: openacs-4/packages/contacts/www/admin/full-people.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/full-people.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/contacts/www/admin/full-people.tcl 12 Aug 2018 12:30:06 -0000 1.4 +++ openacs-4/packages/contacts/www/admin/full-people.tcl 6 Nov 2024 12:59:29 -0000 1.5 @@ -49,7 +49,9 @@ -object_type person -set output {"Person ID","First Names","Last Name","Email","URL"} +set output [list] + +set headers {"Person ID" "First Names" "Last Name" "Email" "URL"} set extended_columns [list] template::multirow foreach ext { if { ( $type eq "person" || $type eq "party" ) && [lsearch $preset_columns $key] >= 0 } { @@ -68,17 +70,16 @@ # - when there are many related people 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 \ @@ -87,16 +88,13 @@ -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 people] { - lappend command "\[template::list::csv_quote \$${column}\]" -} -set command "append output \"\\\"[join $command {\",\"}]\\\"\\n\"" - +set __columns [template::multirow columns people] template::multirow foreach people { - eval $command + set __row [list] + foreach __column $__columns { + lappend __row [set $__column] + } + lappend output $__row } # we save the file to /tmp/full-export.csv @@ -107,7 +105,8 @@ # there is a report storage and queueing mechanism set output_file [open /tmp/full-people.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 Index: openacs-4/packages/contacts/www/admin/full-rels.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/full-rels.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/contacts/www/admin/full-rels.tcl 27 Apr 2006 06:45:00 -0000 1.1 +++ openacs-4/packages/contacts/www/admin/full-rels.tcl 6 Nov 2024 12:59:29 -0000 1.2 @@ -10,8 +10,10 @@ } -set output {"Relation ID","Relation Type","Role One","Contact ID One","Role Two","Contact ID Two"} -append output "\n" +set output [list] + +lappend output {"Relation ID" "Relation Type" "Role One" "Contact ID One" "Role Two" "Contact ID Two"} + db_foreach get_rels " select acs_rels.rel_id, acs_rels.rel_type, @@ -32,19 +34,15 @@ and acs_rels.object_id_two in ( select member_id from group_approved_member_map where group_id in ([template::util::tcl_to_sql_list [contacts::default_groups]])) order by acs_rels.rel_type, acs_rels.rel_id " { - set rel_type [template::list::csv_quote $rel_type] - set role_one [template::list::csv_quote [lang::util::localize $role_one]] - set role_two [template::list::csv_quote [lang::util::localize $role_two]] - append output "\"${rel_id}\",\"${rel_type}\",\"${role_one}\",\"${object_id_one}\",\"${role_two}\",\"${object_id_two}\"\n" + set role_one [lang::util::localize $role_one] + set role_two [lang::util::localize $role_two] + lappend output $rel_id $rel_type $role_one $object_id_one $role_two $object_id_two } - -set output "$output\n" - - set output_file [open /tmp/full-rels.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