template::data::transform::spellcheck (public)
template::data::transform::spellcheck -element_ref element_ref \ -values values
Defined in packages/acs-templating/tcl/spellcheck-procs.tcl
Transform submitted and previously validated input into a spellcheck datastructure.
- Switches:
- -element_ref (required)
- Reference variable to the form element.
- -values (required)
- The set of values for that element.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: upvar $element_ref element # case 1, initial submission of non-checked text: returns {}. # case 2, submission of the page showing errors: returns the corrected text. set merge_text [template::util::spellcheck::merge_text $element(id)] set richtext_p [expr {$element(datatype) eq "richtext"}] if { $richtext_p } { # special treatment for the "richtext" datatype. set format [template::util::richtext::get_property format [lindex $values 0]] if { $merge_text ne "" } { set richtext_value [lindex [template::data::transform::richtext element] 0] return [list [template::util::richtext::set_property contents $richtext_value $merge_text]] } set contents [template::util::richtext::get_property contents [lindex $values 0]] } else { if { $merge_text ne "" } { return [list $merge_text] } set contents [lindex $values 0] } if { $contents eq "" } { return $values } # if language is empty or :nospell: string don't spellcheck set language [ns_queryget $element(id).spellcheck] set spellcheck_p [expr {$language ni {":nospell:" ""}}] # perform spellchecking or not? if { $spellcheck_p } { template::util::spellcheck::get_element_formtext -text $contents -var_to_spellcheck $element(id) -language $language -error_num_ref error_num -formtext_to_display_ref formtext_to_display -just_the_errwords_ref {} -html if { $error_num > 0 } { # there was at least one error. # disable element validation since that will conflict with # the spellchecking DAVEB template::element::set_properties $element(form_id) $element(id) -validate [list] template::element::set_error $element(form_id) $element(id) " [expr {$error_num == 1 ? "Found one error." : "Found $error_num errors."}] Please correct, if necessary." # switch to display mode so we can show our inline mini-form with suggestions. template::element::set_properties $element(form_id) $element(id) mode display if { $richtext_p } { # mutate datatype to prevent validation of spellcheck # form data by richtext validation DAVEB template::element::set_properties $element(form_id) $element(id) -datatype text append formtext_to_display " <input type=\"hidden\" name=\"$element(id).format\" value=\"$format\" >" } # This is needed in order to display the form text noquoted in the "show errors" page ... template::element::set_properties $element(form_id) $element(id) -display_value $formtext_to_display set contents $formtext_to_display } } # no spellchecking was to take place, or there were no errors. if { $richtext_p } { return [list [template::util::richtext::set_property contents [lindex $values 0] $contents]] } else { return [list $contents] }XQL Not present: Generic, PostgreSQL, Oracle