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 -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 -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 -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
Implements the richtext widget, which offers rich text editing options. - This version integrates support for the xinha and + This version integrates support for the xinha and tinymce editors out of the box, but other richtext editors can be used including and configuring them in your custom template. - If the acs-templating.UseHtmlAreaForRichtextP parameter is set to true (1), - this will use the WYSIWYG editor widget set in the acs-templating.RichTextEditor + If the acs-templating.UseHtmlAreaForRichtextP parameter is set to true (1), + this will use the WYSIWYG editor widget set in the acs-templating.RichTextEditor parameter. - Otherwise, it will use a normal textarea, with a drop-down to select a format. + Otherwise, it will use a normal textarea, with a drop-down to select a format. The available formats are:
- You can also parameterize the richtext widget with a 'htmlarea_p' attribute, + You can also parameterize the richtext widget with a 'htmlarea_p' attribute, which can be true or false, and which will override the parameter setting.
The richtext widget can be extended with several plugins, which are OpenACS @@ -332,7 +330,7 @@
GetHtml CharacterMap ContextMenu FullScreen
@@ -345,7 +343,7 @@
- folder_id: the folder from which files should be taken
for the file selector. Can be used alternative with fs_package_id, whatever
more handy in the application.
-
- fs_package_id: the package id of the file_storage package
+
- fs_package_id: the package id of the file_storage package
from which files should be taken
for the file selector. Can be used alternative with folder_id, whatever
more handy in the application. If nothing is specified, the
@@ -355,7 +353,7 @@
type of the field. E.g. a value of %text/% allows any kind of text
files to be selected, while %pdf% could be used for pdf-files. If
nothing is specified, all file-types are presented.
-
- javascript: provide javascript code to configure
+
- javascript: provide javascript code to configure
the xinha widget and its plugins. The configure object is called
xinha_config
.
- Example for the use of the xinha widget with options: + Example for the use of the xinha widget with options:
- text:richtext(richtext),nospell,optional - {label #xowiki.content#} + text:richtext(richtext),nospell,optional + {label #xowiki.content#} {options {editor xinha plugins OacsFs height 350px file_types %pdf%}} {html {rows 15 cols 50 style {width: 100%}}}
- Caveat: the three adp-files needed for the OpenACS file selector + Caveat: the three adp-files needed for the OpenACS file selector (insert-image, insert-ilink and file-selector) are currently part of the xowiki package, since acs-templating is per default not mounted. This is hopefully only a temporal situation and we find a better place.
- Example for the use of the tinymce widget with options: + Example for the use of the tinymce widget with options:
- text:richtext(richtext),nospell,optional - {label #acs-subsite.Biography#} + text:richtext(richtext),nospell,optional + {label #acs-subsite.Biography#} {options {theme simple plugins "oacsimage,oacslink,style"}} {html {rows 15 cols 50 style {width: 100%}}}
- See TinyMCE + See TinyMCE documentation for a full list of available options
- Caveat: the scripts needed for the oacsimage and oacslink plugins require - acs-templating to be mounted. This is a temporary situation until we find + Caveat: the scripts needed for the oacsimage and oacslink plugins require + acs-templating to be mounted. This is a temporary situation until we find a better way to handle plugins. - +
- Example for the use of a custom editor widget: + Example for the use of a custom editor widget:
- text:richtext(richtext),nospell,optional - {label #acs-subsite.Biography#} + text:richtext(richtext),nospell,optional + {label #acs-subsite.Biography#} {options {editor custom ...custom configuration...}} {html {rows 15 cols 50 style {width: 100%}}}
If provided with a WYSIWYG editor different than 'xinha' or 'tinymce', - system will just collect formfield ids and supplied options for the + system will just collect formfield ids and supplied options for the richtext field and will provide them as-is to the blank-master environment. - When using a custom editor, funcional meaning of the options is totally up + When using a custom editor, funcional meaning of the options is totally up to the user.
- Note that the richtext editors interact with blank-master.tcl
and
+ Note that the richtext editors interact with blank-master.tcl
and
blank-master.adp
.
Derived from the htmlarea richtext widget for htmlarea by lars@pinds.com
@@ -431,7 +429,7 @@
set output ""
#ns_log notice "widget::richtext: richtext-options? [info exists element(options)] HTML? [info exists element(html)]"
-
+
if { [info exists element(html)] } {
array set attributes $element(html)
}
@@ -454,7 +452,7 @@
set user_agent [string tolower [ns_set get [ns_conn headers] User-Agent]]
- if {[string first "safari" $user_agent] != -1} {
+ if {[string first "safari" $user_agent] != -1} {
if {[regexp {version/([0-9]+)[.]} $user_agent _ user_agent_version]
&& $user_agent_version < 3} {
set element(htmlarea_p) false
@@ -491,15 +489,15 @@
-parameter "RichTextEditor" \
-default "xinha"]}]
#
- # Tell the blank-master to include the special stuff
+ # Tell the blank-master to include the special stuff
# for the richtext widget in the page header
#
set ::acs_blank_master($richtextEditor) 1
#
# Collect ids of richtext form fields
#
- lappend ::acs_blank_master__htmlareas $attributes(id)
+ lappend ::acs_blank_master__htmlareas $attributes(id)
#
# Try to initialize the widget via richtext plugins
@@ -510,7 +508,7 @@
-editor $richtextEditor \
-options [array get options]]
ns_log debug "widget::richtext: ::template::util::richtext::initialize_widget -> $result"
-
+
if {[dict get $result success] == 1} {
#
# Everything is set-up via the editor plugin. In
@@ -519,47 +517,47 @@
# the interface, but that feature is not used yet.
#
} else {
- # Editor is custom. All options are passed as-is to
- # the blank master and their meaning will be defined
- # in a custom template.
+ # Editor is custom. All options are passed as-is to
+ # the blank master and their meaning will be defined
+ # in a custom template.
- set ::acs_blank_master(${richtextEditor}.options) [array get options]
- }
+ set ::acs_blank_master(${richtextEditor}.options) [array get options]
+ }
#
# The following trick with document.write is for providing
# reasonable behavior when javascript is turned completely
# off.
#
append output \
- "\n\n\n" \
- ""
+ "\n\n\n" \
+ ""
if { $spellcheck(render_p) } {
append output [subst {
-