Index: openacs-4/packages/acs-templating/tcl/widget-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/widget-procs.tcl,v
diff -u -r1.37 -r1.38
--- openacs-4/packages/acs-templating/tcl/widget-procs.tcl 18 Mar 2005 18:10:39 -0000 1.37
+++ openacs-4/packages/acs-templating/tcl/widget-procs.tcl 3 May 2005 10:26:04 -0000 1.38
@@ -191,57 +191,57 @@
or a text box which on submit changes to a select widget.
} {
- upvar $element_reference element
+ upvar $element_reference element
- if { ! [info exists element(options)] } {
+ if { ! [info exists element(options)] } {
- # initial submission or no data (no options): a text box
- set output [input text element $tag_attributes]
+ # initial submission or no data (no options): a text box
+ set output [input text element $tag_attributes]
- } else {
+ } else {
- # options provided so use a select list
- # include an extra hidden element to indicate that the
- # value is being selected as opposed to entered
+ # options provided so use a select list
+ # include an extra hidden element to indicate that the
+ # value is being selected as opposed to entered
- set output "\n"
- append output [select element $tag_attributes]
+ set output "\n"
+ append output [select element $tag_attributes]
- }
+ }
- return $output
+ return $output
}
ad_proc -public template::widget::textarea { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- if { [info exists element(html)] } {
- array set attributes $element(html)
- }
- array set attributes $tag_attributes
+ if { [info exists element(html)] } {
+ array set attributes $element(html)
+ }
+ array set attributes $tag_attributes
- if { [info exists element(value)] } {
- set value $element(value)
- } else {
- set value {}
- }
+ if { [info exists element(value)] } {
+ set value $element(value)
+ } else {
+ set value {}
+ }
- if { [info exists element(mode)] } {
- set mode $element(mode)
- } else {
- set mode {}
- }
+ if { [info exists element(mode)] } {
+ set mode $element(mode)
+ } else {
+ set mode {}
+ }
- set output [textarea_internal $element(name) attributes $value $mode]
+ set output [textarea_internal $element(name) attributes $value $mode]
- # Spell-checker
- array set spellcheck [template::util::spellcheck::spellcheck_properties -element_ref element]
-
- if { [string equal $element(mode) "edit"] && $spellcheck(render_p) } {
- append output "
[_ acs-templating.Spellcheck]:
+ # Spell-checker
+ array set spellcheck [template::util::spellcheck::spellcheck_properties -element_ref element]
+
+ if { [string equal $element(mode) "edit"] && $spellcheck(render_p) } {
+ append output "
[_ acs-templating.Spellcheck]:
[menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] $spellcheck(selected_option) {}]"
}
@@ -254,28 +254,28 @@
{value {}}
{mode edit}
} {
- upvar $attribute_reference attributes
+ upvar $attribute_reference attributes
- if { ![string equal $mode "edit"] } {
- set output {}
- if { ![empty_string_p $value] } {
- append output "[ad_quotehtml $value]"
+ if { ![string equal $mode "edit"] } {
+ set output {}
+ if { ![empty_string_p $value] } {
+ append output "[ad_quotehtml $value]"
+ }
+ } else {
+ set output ""
}
- } else {
- set output ""
- }
-
- return $output
+ return $output
}
@@ -284,75 +284,75 @@
A static information widget that does not submit any data
} {
- upvar $element_reference element
+ upvar $element_reference element
- if { [info exists element(value)] } {
- return "$element(value)[input hidden element $tag_attributes]"
- } else {
- return [input hidden element $tag_attributes]
- }
+ if { [info exists element(value)] } {
+ return "$element(value)[input hidden element $tag_attributes]"
+ } else {
+ return [input hidden element $tag_attributes]
+ }
}
ad_proc -public template::widget::input { type element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- if { [info exists element(html)] } {
- array set attributes $element(html)
- }
+ if { [info exists element(html)] } {
+ array set attributes $element(html)
+ }
- array set attributes $tag_attributes
+ array set attributes $tag_attributes
- if { ( [string equal $type "checkbox"] || [string equal $type "radio"] ) && [info exists element(value)] } {
- # This can be used in the form template in a tag.
- set attributes(id) "$element(form_id):elements:$element(name):$element(value)"
- }
-
- # Handle display mode of visible normal form elements, i.e. not hidden, not submit, not button, not clear
- if { ![string equal $element(mode) "edit"] && [lsearch -exact { hidden submit button clear checkbox radio } $type] == -1 } {
- set output ""
- if { [info exists element(value)] } {
- append output [ad_quotehtml $element(value)]
- append output ""
- }
- } else {
- set output "... tag.
+ set attributes(id) "$element(form_id):elements:$element(name):$element(value)"
+ }
+
+ # Handle display mode of visible normal form elements, i.e. not hidden, not submit, not button, not clear
+ if { ![string equal $element(mode) "edit"] && [lsearch -exact { hidden submit button clear checkbox radio } $type] == -1 } {
+ set output ""
+ if { [info exists element(value)] } {
+ append output [ad_quotehtml $element(value)]
+ append output ""
+ }
+ } else {
+ set output ""
}
-
- append output " />"
- }
- return $output
+ return $output
}
ad_proc -public template::widget::text { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- # Spell-checker
- array set spellcheck [template::util::spellcheck::spellcheck_properties -element_ref element]
-
- if { [string equal $element(mode) "edit"] && $spellcheck(render_p) } {
- return "[input text element $tag_attributes]
[_ acs-templating.Spellcheck]:
+ # Spell-checker
+ array set spellcheck [template::util::spellcheck::spellcheck_properties -element_ref element]
+
+ if { [string equal $element(mode) "edit"] && $spellcheck(render_p) } {
+ return "[input text element $tag_attributes]
[_ acs-templating.Spellcheck]:
[menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] $spellcheck(selected_option) {}]"
} else {
return [input text element $tag_attributes]
@@ -363,36 +363,36 @@
ad_proc -public template::widget::file { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- return [input file element $tag_attributes]
+ return [input file element $tag_attributes]
}
ad_proc -public template::widget::password { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- return [input password element $tag_attributes]
+ return [input password element $tag_attributes]
}
ad_proc -public template::widget::hidden { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- return [input hidden element $tag_attributes]
+ return [input hidden element $tag_attributes]
}
ad_proc -public template::widget::submit { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- # always ignore value for submit widget
- set element(value) $element(label)
+ # always ignore value for submit widget
+ set element(value) $element(label)
- return [input submit element $tag_attributes]
+ return [input submit element $tag_attributes]
}
ad_proc -public template::widget::attachment { element_reference tag_attributes } {
@@ -412,23 +412,23 @@
ad_proc -public template::widget::checkbox { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- return [input checkbox element $tag_attributes]
+ return [input checkbox element $tag_attributes]
}
ad_proc -public template::widget::radio { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- return [input radio element $tag_attributes]
+ return [input radio element $tag_attributes]
}
ad_proc -public template::widget::button { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- return [input button element $tag_attributes]
+ return [input button element $tag_attributes]
}
ad_proc -public template::widget::menu {
@@ -439,200 +439,199 @@
{mode edit}
} {
- upvar $attribute_reference attributes
-
- # Create an array for easier testing of selected values
- template::util::list_to_lookup $values_list values
+ upvar $attribute_reference attributes
- if { ![string equal $mode "edit"] } {
- set selected_list [list]
- set output {}
-
- foreach option $options_list {
-
- set label [lindex $option 0]
- set value [lindex $option 1]
-
- if { [info exists values($value)] } {
- lappend selected_list $label
- append output ""
- }
- }
-
- append output [join $selected_list ", "]
- } else {
- set output ""
}
-
- append output ""
- }
- return $output
+ return $output
}
ad_proc -public template::widget::select { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- if { [info exists element(html)] } {
- array set attributes $element(html)
- }
+ if { [info exists element(html)] } {
+ array set attributes $element(html)
+ }
- array set attributes $tag_attributes
+ array set attributes $tag_attributes
- return [template::widget::menu \
- $element(name) $element(options) $element(values) attributes $element(mode)]
+ return [template::widget::menu \
+ $element(name) $element(options) $element(values) attributes $element(mode)]
}
ad_proc -public template::widget::multiselect { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- if { [info exists element(html)] } {
- array set attributes $element(html)
- }
+ if { [info exists element(html)] } {
+ array set attributes $element(html)
+ }
- array set attributes $tag_attributes
+ array set attributes $tag_attributes
- set attributes(multiple) {}
+ set attributes(multiple) {}
- # Determine the size automatically for a multiselect
- if { ! [info exists attributes(size)] } {
-
- set size [llength $element(options)]
- if { $size > 8 } {
- set size 8
+ # Determine the size automatically for a multiselect
+ if { ! [info exists attributes(size)] } {
+
+ set size [llength $element(options)]
+ if { $size > 8 } {
+ set size 8
+ }
+ set attributes(size) $size
}
- set attributes(size) $size
- }
- return [template::widget::menu \
- $element(name) $element(options) $element(values) attributes $element(mode)]
+ return [template::widget::menu \
+ $element(name) $element(options) $element(values) attributes $element(mode)]
}
ad_proc -public template::data::transform::search { element_ref } {
- upvar $element_ref element
- set element_id $element(id)
+ upvar $element_ref element
+ set element_id $element(id)
- set value [ns_queryget $element_id]
+ set value [ns_queryget $element_id]
- # there will no value for the initial request or if the form
- # is submitted with no search criteria (text box blank)
- if { [string equal $value {}] } { return [list] }
+ # there will no value for the initial request or if the form
+ # is submitted with no search criteria (text box blank)
+ if { [string equal $value {}] } { return [list] }
- if { [string equal $value ":search:"] } {
- if { [info exists element(options)] } {
- unset element(options)
- }
- template::element::set_error $element(form_id) $element_id "
+ if { [string equal $value ":search:"] } {
+ if { [info exists element(options)] } {
+ unset element(options)
+ }
+ template::element::set_error $element(form_id) $element_id "
Please enter a search string."
- return [list]
- }
+ return [list]
+ }
- # check for a value that has been entered rather than selected
- if { ! [ns_queryexists $element_id:select] } {
+ # check for a value that has been entered rather than selected
+ if { ! [ns_queryexists $element_id:select] } {
- # perform a search based on the value
- if { ! [info exists element(search_query)] } {
- error "No search query specified for search widget"
- }
+ # perform a search based on the value
+ if { ! [info exists element(search_query)] } {
+ error "No search query specified for search widget"
+ }
- set query $element(search_query)
+ set query $element(search_query)
- set options [db_list_of_lists get_options $query]
+ set options [db_list_of_lists get_options $query]
- set option_count [llength $options]
+ set option_count [llength $options]
- if { $option_count == 0 } {
+ if { $option_count == 0 } {
- # no search results so return text entry back to the user
+ # no search results so return text entry back to the user
- if { [info exists element(options)] } {
- unset element(options)
- }
+ if { [info exists element(options)] } {
+ unset element(options)
+ }
- template::element::set_error $element(form_id) $element_id "
+ template::element::set_error $element(form_id) $element_id "
No matches were found for \"$value\".
Please
try again."
- } elseif { $option_count == 1 } {
+ } elseif { $option_count == 1 } {
- # only one option so just reset the value
- set value [lindex [lindex $options 0] 1]
+ # only one option so just reset the value
+ set value [lindex [lindex $options 0] 1]
- } else {
+ } else {
- # need to return a select list
- set element(options) [concat $options { { "Search again..." ":search:" } }]
- template::element::set_error $element(form_id) $element_id "
+ # need to return a select list
+ set element(options) [concat $options { { "Search again..." ":search:" } }]
+ template::element::set_error $element(form_id) $element_id "
More than one match was found for \"$value\".
Please
choose one from the list."
- set value [lindex [lindex $options 0] 1]
+ set value [lindex [lindex $options 0] 1]
+ }
}
- }
- if { [info exists element(result_datatype)] &&
- [ns_queryexists $element_id:select] } {
- set element(datatype) $element(result_datatype)
- }
+ if { [info exists element(result_datatype)] &&
+ [ns_queryexists $element_id:select] } {
+ set element(datatype) $element(result_datatype)
+ }
- return [list $value]
+ return [list $value]
}
ad_proc -public template::widget::comment { element_reference tag_attributes } {
- upvar $element_reference element
+ upvar $element_reference element
- if { [info exists element(html)] } {
- array set attributes $element(html)
- }
+ if { [info exists element(html)] } {
+ array set attributes $element(html)
+ }
- array set attributes $tag_attributes
+ array set attributes $tag_attributes
- set output {}
+ set output {}
- if { [info exists element(history)] } {
- append output "$element(history)"
- }
+ if { [info exists element(history)] } {
+ append output "$element(history)"
+ }
- if { [string equal $element(mode) "edit"] } {
- if { [info exists element(header)] } {
- append output "
$element(header)
" - } - - append output [textarea $element_reference $tag_attributes] + if { [string equal $element(mode) "edit"] } { + if { [info exists element(header)] } { + append output "$element(header)
" + } + + append output [textarea $element_reference $tag_attributes] - if { [info exists element(format_element)] && [info exists element(format_options)] } { - append output "