Index: openacs-4/packages/acs-templating/acs-templating.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/acs-templating.info,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/acs-templating/acs-templating.info 4 Oct 2003 12:12:01 -0000 1.19 +++ openacs-4/packages/acs-templating/acs-templating.info 5 Oct 2003 17:55:55 -0000 1.20 @@ -7,7 +7,7 @@ t t - + Karl Goldstein @@ -19,7 +19,7 @@ template system provides a way to use a single layout specification for many physical pages, so the overall layout of a site can be more easily administered. - + @@ -33,7 +33,7 @@ - + Index: openacs-4/packages/acs-templating/tcl/element-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/element-procs.tcl,v diff -u -N -r1.16 -r1.17 --- openacs-4/packages/acs-templating/tcl/element-procs.tcl 30 Sep 2003 19:27:49 -0000 1.16 +++ openacs-4/packages/acs-templating/tcl/element-procs.tcl 5 Oct 2003 17:55:55 -0000 1.17 @@ -527,10 +527,12 @@ set values [template::data::transform::$datatype element] } - if { [lindex [template::util::spellcheck::spellcheck_properties -element_ref element] 0] } { + set spellcheck [lindex [template::util::spellcheck::spellcheck_properties -element_ref element] 0] + + if { ![string equal ":nospell:" $spellcheck] } { - set values [template::data::transform::spellcheck -element_ref element -values $values] - } + set values [template::data::transform::spellcheck -element_ref element -values $values] + } return $values } 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.9 -r1.10 --- openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 30 Sep 2003 19:27:49 -0000 1.9 +++ openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 5 Oct 2003 17:55:55 -0000 1.10 @@ -188,15 +188,12 @@ append output "
Format: [menu "$element(id).format" [template::util::richtext::format_options] $format {}]" set spellcheck_properties [template::util::spellcheck::spellcheck_properties -element_ref element] - set spellcheck_p [lindex $spellcheck_properties 0] + set spellcheck [lindex $spellcheck_properties 0] - if { $spellcheck_p } { - set yes_checked [lindex $spellcheck_properties 1] - set no_checked [lindex $spellcheck_properties 2] - append output " Spellcheck? - Yes \n - No" + if { ![string equal ":nospell:" $spellcheck] } { + set selected_option [lindex $spellcheck_properties 1] + append output " Spellcheck: [menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] $selected_option {}]" } } else { Index: openacs-4/packages/acs-templating/tcl/spellcheck-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/spellcheck-init.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/acs-templating/tcl/spellcheck-init.tcl 4 Oct 2003 12:12:01 -0000 1.1 +++ openacs-4/packages/acs-templating/tcl/spellcheck-init.tcl 5 Oct 2003 17:55:55 -0000 1.2 @@ -17,4 +17,78 @@ 0 [exec which ispell] \ ""]] + +# Do we want dialect dictionaries (if available) or not? +# Note that if you change this param it won't take effect +# until the server has been restarted. +set dialects_p [parameter::get_from_package_key \ + -package_key acs-templating \ + -parameter SpellcheckDialectsP \ + -default 0] + +# aspell or ispell? +if { [regexp aspell $bin] } { + # aspell + set dicts [exec $bin dump dicts] + set default_lang [exec $bin config lang] + if { !$dialects_p } { + # If no dialects, the the default_lang locale returned from aspell + # must be shortened to the first two letters, so that it matches + # the one of the names in the pull-down menu. + set default_lang [string range $default_lang 0 1] + } +} elseif { [regexp ispell $bin] } { + # ispell - if someone knows how to get the availagle dictionaries and the + # default language from ispell, please add it here :-) + set dicts "" + set default_lang "" +} else { + set dicts "" + set default_lang "" +} + + +# Build the select options list and filter out unwanted dictionaries. +set wanted_dicts [list {"No, thanks" :nospell:}] + +if { [empty_string_p $dicts] } { + # Just add the default locale (the empty string will work too). + lappend wanted_dicts [list "Yes, please" $default_lang] +} + +db_transaction { + + foreach dict $dicts { + if { [string length $dict] == 2 } { + # We have a lang (e.g., en) + lappend wanted_dicts [list [string totitle [lang::util::nls_language_from_language $dict]] $dict] + set last_dict $dict + } elseif { $dialects_p && [string length $dict] == 5 && [regexp _ $dict] } { + # We have a locale (e.g., en_US) + if { [info exists last_dict] } { + set wanted_dicts [lreplace $wanted_dicts end end] + unset last_dict + } + # Some five-char aspell dicts (locales) are missing in ad_locales so we + # need to catch those cases and use the locale as the pretty name, ugh ... + if { [catch { lappend wanted_dicts [list [string totitle [ad_locale_get_label $dict]] $dict] }] } { + lappend wanted_dicts [list "Locale $dict" $dict] + } + } + } + +} on_error { + # Just add the default locale. + lappend wanted_dicts [list "Yes, please" $default_lang] +} + + +##### +# +# Initialize the cache. +# +##### + nsv_set spellchecker path $bin +nsv_set spellchecker lang_options $wanted_dicts +nsv_set spellchecker default_lang $default_lang Index: openacs-4/packages/acs-templating/tcl/spellcheck-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/spellcheck-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/acs-templating/tcl/spellcheck-procs.tcl 4 Oct 2003 12:12:01 -0000 1.3 +++ openacs-4/packages/acs-templating/tcl/spellcheck-procs.tcl 5 Oct 2003 17:55:55 -0000 1.4 @@ -62,14 +62,15 @@ return [list] } - set spellcheck_p [ad_decode [ns_queryget $element(id).spellcheck_p] 1 1 0] + set spellcheck_p [ad_decode [set language [ns_queryget $element(id).spellcheck]] ":nospell:" 0 1] # 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 {} \ @@ -133,6 +134,7 @@ -text:required {-html:boolean 0} -var_to_spellcheck:required + {-language ""} -error_num_ref:required -formtext_to_display_ref:required {-just_the_errwords_ref ""} @@ -173,11 +175,6 @@ set spellchecker_path [nsv_get spellchecker path] - set language [parameter::get_from_package_key \ - -package_key acs-templating \ - -parameter SpellcheckLang \ - -default {}] - # the --lang switch only works with aspell and if it is not present # aspell's (or ispell's) default language will have to do. if { ![empty_string_p $language] } { @@ -197,7 +194,7 @@ } if { [catch [close $ispell_proc] errmsg] } { - ad_return_error "No Dictionary Found" "Spell-checking is enabled but the spell-check program could not be executed. Check the SpellcheckerPath parameter in acs-templating. Also check the permissions on the spell-check program.

Here is the error message:

$errmsg
" + ad_return_error "No Dictionary Found" "Spell-checking is enabled but the spell-check program could not be executed. Check the permissions on the spell-check program (_server_root_/bin/webspell).

Here is the error message:

$errmsg
" ad_script_abort } @@ -315,20 +312,22 @@ } { upvar $element_ref element - if { [empty_string_p [set spellcheck_p [ns_queryget $element(id).spellcheck_p]]] } { + if { [empty_string_p [set spellcheck [ns_queryget $element(id).spellcheck]]] } { # The user hasn't been able to state whether (s)he wants spellchecking to be performed or not. # That's either because spell-checking is disabled for this element, or we're not dealing with a submit. # Whichever it is, let's see if, and then how, we should render the spellcheck "sub widget". if { [empty_string_p [nsv_get spellchecker path]] } { - # The aspell or ispell bibary was not found during server startup - turn spell-checking off. - set spellcheck_p 0 + # The aspell or ispell binary was not found during server startup - turn spell-checking off. + #set spellcheck ":nospell:" + set spellcheck_p 0 } else { - array set widget_info [string trim [parameter::get_from_package_key -package_key acs-templating \ + array set widget_info [string trim [parameter::get_from_package_key \ + -package_key acs-templating \ -parameter SpellcheckFormWidgets \ -default ""]] @@ -340,39 +339,34 @@ } if { $spellcheck_p } { - # This is not a submit; we are rendering the form element for the first time. - # Since the spellcheck "sub widget" is to be displayed we'll also want to know - # whether it is the "Yes" or the "No" button that should be pressed by default. + # This is not a submit; we are rendering the form element for the first time and + # since the spellcheck "sub widget" is to be displayed we'll also want to know + # which option that should be selected by default. + if { $widget_info(${element(widget)}) } { - set yes_checked "checked" - set no_checked "" + set spellcheck [nsv_get spellchecker default_lang] + set selected_option $spellcheck } else { - set yes_checked "" - set no_checked "checked" + set spellcheck [nsv_get spellchecker default_lang] + set selected_option ":nospell:" } + } else { - # set these to something so the script won't choke. - set yes_checked "n/a" - set no_checked "n/a" + + # set this to something so the script won't choke. + set selected_option "n/a" + set spellcheck ":nospell:" } } else { - # The user has explicitly stated if (s)he wants spellchecking to be performed on the text or not. - # Hence we are in submit mode with spell-checking enabled (radio button true or false). - # Let's check which it is and keep record of the states of our radio buttons in case the error - # page is shown. + # The user has explicitly stated if (s)he wants spellchecking to be performed + # on the text or not. Hence we are in submit mode with spell-checking enabled. + # Let's check which it is and keep record of the states of our select menu in + # case the error page is shown. - if { $spellcheck_p } { - set yes_checked "checked" - set no_checked "" - } else { - set yes_checked "" - set no_checked "checked" - set spellcheck_p 1 - } - + set selected_option $spellcheck } - return [list $spellcheck_p $yes_checked $no_checked] + return [list $spellcheck $selected_option] } 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 -N -r1.24 -r1.25 --- openacs-4/packages/acs-templating/tcl/widget-procs.tcl 30 Sep 2003 19:27:49 -0000 1.24 +++ openacs-4/packages/acs-templating/tcl/widget-procs.tcl 5 Oct 2003 17:55:55 -0000 1.25 @@ -210,14 +210,12 @@ set output [textarea_internal $element(name) attributes $value $mode] set spellcheck_properties [template::util::spellcheck::spellcheck_properties -element_ref element] - set spellcheck_p [lindex $spellcheck_properties 0] + set spellcheck [lindex $spellcheck_properties 0] - if { $spellcheck_p } { - set yes_checked [lindex $spellcheck_properties 1] - set no_checked [lindex $spellcheck_properties 2] - append output "
Spellcheck? - Yes \n - No" + if { ![string equal ":nospell:" $spellcheck] } { + set selected_option [lindex $spellcheck_properties 1] + append output "
Spellcheck: +[menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] $selected_option {}]" } return $output @@ -333,14 +331,12 @@ upvar $element_reference element set spellcheck_properties [template::util::spellcheck::spellcheck_properties -element_ref element] - set spellcheck_p [lindex $spellcheck_properties 0] + set spellcheck [lindex $spellcheck_properties 0] - if { [string equal $element(mode) "edit"] && $spellcheck_p } { - set yes_checked [lindex $spellcheck_properties 1] - set no_checked [lindex $spellcheck_properties 2] - return "[input text element $tag_attributes]
Spellcheck? - Yes \n - No" + if { [string equal $element(mode) "edit"] && ![string equal ":nospell:" $spellcheck] } { + set selected_option [lindex $spellcheck_properties 1] + return "[input text element $tag_attributes]
Spellcheck: +[menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] $selected_option {}]" } else { return [input text element $tag_attributes] }