Index: openacs-4/packages/acs-templating/tcl/currency-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/currency-procs.tcl,v diff -u -N -r1.17 -r1.18 --- openacs-4/packages/acs-templating/tcl/currency-procs.tcl 1 Oct 2017 12:16:05 -0000 1.17 +++ openacs-4/packages/acs-templating/tcl/currency-procs.tcl 24 Apr 2018 21:19:43 -0000 1.18 @@ -1,6 +1,6 @@ ad_library { Currency widgets for the OpenACS Templating System - + @author Don Baccus (dhogaza@pacifier.com) } @@ -9,7 +9,7 @@ # DRB: This was totally non-functional in ACS 4.2 Classic. It's now partly # functional in that we accept and process currency values. We really need # to tie this in with the acs-lang money database as this code's far too -# simplistic. +# simplistic. # This is free software distributed under the terms of the GNU Public # License. Full text of the license is available from the GNU Project: @@ -23,7 +23,7 @@ namespace eval template::data::transform::currency {} namespace eval template::util::currency::set_property {} namespace eval template::widget::currency {} - + ad_proc -public template::util::currency { command args } { Dispatch procedure for the currency object } { @@ -50,7 +50,7 @@ character in their normal representation @param format The actual format to use in list form - @return The parameters joined in a six-element list + @return The parameters joined in a six-element list } { return [list $leading_symbol $whole_part $separator $fractional_part $trailing_money $format] } @@ -89,16 +89,9 @@ # a currency is a 6 element list supporting, for example, the following forms: "$2.03" "Rs 50.42" "12.52L" "Y5,13c" # equivalent of date::unpack - set leading_symbol [lindex $value 0] - set whole_part [lindex $value 1] - set separator [lindex $value 2] - set fractional_part [lindex $value 3] - set trailing_money [lindex $value 4] - set format [lindex $value 5] + lassign $value leading_symbol whole_part separator fractional_part trailing_money format + lassign $format . format_whole_part . format_fractional_part - set format_whole_part [lindex $format 1] - set format_fractional_part [lindex $format 3] - set whole_part_valid_p [template::data::validate integer whole_part message] if { $fractional_part ne "" } { set fractional_part_valid_p [template::data::validate integer fractional_part message] @@ -107,10 +100,10 @@ } if { ! $whole_part_valid_p || ! $fractional_part_valid_p } { - set message "[_ acs-templating.Invalid_currency] [join [lrange $value 0 4] ""]" - return 0 + set message "[_ acs-templating.Invalid_currency] [join [lrange $value 0 4] ""]" + return 0 } else { - return 1 + return 1 } } @@ -136,33 +129,33 @@ set have_values 0 for { set i 0 } { $i <= 4 } { incr i } { - set key "$element_id.$i" - if { [ns_queryexists $key] } { - set value [ns_queryget $key] + set key "$element_id.$i" + if { [ns_queryexists $key] } { + set value [ns_queryget $key] - # let's put a leading zero if the whole part is empty - if { $i == 1 } { - if {$value eq ""} { - set value 0 - } else { + # let's put a leading zero if the whole part is empty + if { $i == 1 } { + if {$value eq ""} { + set value 0 + } else { set have_values 1 } - } + } - # and let's fill in the zeros at the end up to the precision - if { $i == 3 } { - if { $value ne "" } { + # and let's fill in the zeros at the end up to the precision + if { $i == 3 } { + if { $value ne "" } { set have_values 1 } - set fractional_part_format [lindex $format 3] - for { set j [string length $value] } { $j < $fractional_part_format } { incr j } { - append $value 0 - } - } + set fractional_part_format [lindex $format 3] + for { set j [string length $value] } { $j < $fractional_part_format } { incr j } { + append $value 0 + } + } - lappend the_amount $value + lappend the_amount $value - } else { + } else { lappend the_amount "" } } @@ -172,9 +165,9 @@ ns_log debug "template::data::transform::currency: the_amount: $the_amount length: [llength $the_amount]" if { $have_values } { - return [list $the_amount] + return [list $the_amount] } else { - return [list] + return [list] } } @@ -194,7 +187,7 @@ @param value The value to set currency_list to @return currency_list set to value - + } { # Erase leading zeroes from the value, but make sure that 00 @@ -231,7 +224,7 @@ currency_list } { - Return a property of a currency list which was created by a + Return a property of a currency list which was created by a currency widget. The most useful properties that can be returned are sql_number (compatible with @@ -245,14 +238,8 @@ } { # There's no internal error checking, just like the date version ... and # of course whole_part might be pounds and fractional_part pfennings ... + lassign $currency_list leading_symbol whole_part separator fractional_part trailing_money format - set leading_symbol [lindex $currency_list 0] - set whole_part [lindex $currency_list 1] - set separator [lindex $currency_list 2] - set fractional_part [lindex $currency_list 3] - set trailing_money [lindex $currency_list 4] - set format [lindex $currency_list 5] - switch -- $what { leading_symbol { return $leading_symbol @@ -326,27 +313,27 @@ upvar $element_reference element if { [info exists element(html)] } { - array set attributes $element(html) + array set attributes $element(html) } if { ! [info exists element(format)] } { - set element(format) "$ 5 . 2" + set element(format) "$ 5 . 2" } set format [split $element(format) " "] for { set i [llength $format] } { $i < 5 } { incr i } { lappend format "" } if { [info exists element(value)] } { - set values $element(value) + set values $element(value) } else { set values [list "" "" "" "" "" $element(format)] } set i 0 foreach format_property $format { - set value [lindex $values 0] - set values [lrange $values 1 end] + # Assign the first element of $values to 'value', and the rest to 'values' again + set values [lassign $values value] set trailing_zero "" if { $i == 3 } { set trailing_zero [string range [string repeat "0" $format_property] [string length $value] end] Index: openacs-4/packages/acs-templating/tcl/filter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/filter-procs.tcl,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/acs-templating/tcl/filter-procs.tcl 19 Jan 2018 14:16:01 -0000 1.19 +++ openacs-4/packages/acs-templating/tcl/filter-procs.tcl 24 Apr 2018 21:19:43 -0000 1.20 @@ -2,7 +2,7 @@ Filter procedures for the ArsDigita Templating System @author Karl Goldstein (karlg@arsdigita.com) - + @cvs-id $Id$ } @@ -37,21 +37,20 @@ ad_cache_returnredirect $url $persistent_p $excluded_vars } else { - ad_returnredirect $url + ad_returnredirect $url } ad_script_abort } ad_proc -public template::filter { command args } { Run any filter procedures that have been registered with the - templating system. The signature of a filter procedure is + templating system. The signature of a filter procedure is a reference (not the value) to a variable containing the URL of the template to parse. The filter procedure may modify this. } { variable filter_list - set arg1 [lindex $args 0] - set arg2 [lindex $args 1] + lassign $args arg1 arg2 switch -exact $command { @@ -87,7 +86,7 @@ set timeElapsed [expr ([clock clicks -milliseconds] - $beginTime)] ns_log debug "cmp_page_filter: Time elapsed: $timeElapsed" - + } on error {errorMsg} { set output
[ns_quotehtml $::errorInfo]
} @@ -107,7 +106,7 @@ set code_stub "$::acs::rootdir/packages/$package_key/www$rest" set beginTime [clock clicks -milliseconds] - set file_stub [template::resource_path -type messages -style $datasources] + set file_stub [template::resource_path -type messages -style $datasources] set output [template::adp_parse $file_stub [list code_stub $code_stub]] Index: openacs-4/packages/acs-templating/tcl/richtext-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/richtext-procs.tcl,v diff -u -N -r1.60 -r1.61 --- openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 27 Mar 2018 12:22:17 -0000 1.60 +++ openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 24 Apr 2018 21:19:43 -0000 1.61 @@ -77,8 +77,8 @@ lassign $richtext_list contents format if { $contents ne "" && [lsearch -exact [template::util::richtext::formats] $format] == -1 } { - set message "Invalid format, '$format'." - return 0 + set message "Invalid format, '$format'." + return 0 } # enhanced text and HTML needs to be security checked @@ -92,7 +92,7 @@ } return 1 -} +} ad_proc -public template::data::transform::richtext { element_ref @@ -112,7 +112,7 @@ set format [ns_queryget $element_id.format] if { $contents eq "" } { - # We need to return the empty list in order for form builder to think of it + # We need to return the empty list in order for form builder to think of it # as a non-value in case of a required element. return [list] } else { @@ -121,7 +121,7 @@ } ad_proc -public template::util::richtext::set_property { what richtext_list value } { - Set a property of the richtext datatype. + Set a property of the richtext datatype. @param what One of