Index: openacs-4/packages/ecommerce/www/admin/tools/form-custom.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/tools/Attic/form-custom.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/www/admin/tools/form-custom.tcl 26 Aug 2001 23:37:59 -0000 1.1 @@ -0,0 +1,65 @@ +# form-custom.tcl,v 3.0 2000/02/06 03:54:42 ron Exp +# +# Takes the data generated from ad_table_sort_form function +# and inserts into the user_custom table +# +# on succes it does an ns_returnredirect to return_url +# +# davis@arsdigita.com 20000105 + +set internals {item item_group return_url item_original delete_the_set} +ad_page_variables {item item_group return_url {item_original {}} {delete_the_set 0}} + +set db [ns_db gethandle] +set user_id [ad_verify_and_get_user_id] +ad_maybe_redirect_for_registration +set item_type {slider_custom} +set value_type {keyval} + +if {$delete_the_set && ![empty_string_p $item]} { + util_dbq {item item_type value_type item_group} + if {[catch {ns_db dml $db "delete user_custom + where user_id = $user_id and item = $DBQitem and item_group = $DBQitem_group + and item_type = $DBQitem_type"} errmsg]} { + ad_return_complaint 1 "
$errmsg\n" + return + } + ns_returnredirect "$return_url" + return +} + + + +if {[empty_string_p $item]} { + ad_return_complaint 1 "
$errmsg\n" + return +} + +ns_returnredirect "$return_url" Index: openacs-4/packages/ecommerce/www/admin/tools/sort-custom.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/tools/Attic/sort-custom.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/www/admin/tools/sort-custom.tcl 26 Aug 2001 23:37:59 -0000 1.1 @@ -0,0 +1,73 @@ +# sort-custom.tcl,v 3.0 2000/02/06 03:54:43 ron Exp +# +# Takes the data generated from ad_table_sort_form function +# and inserts into the user_custom table +# +# on succes it does an ns_returnredirect to return_url&$item_group=$item +# +# davis@arsdigita.com 20000105 + +ad_page_variables {item item_group return_url {delete_the_sort 0} {col -multiple-list} {dir -multiple-list} {item_original {}}} + +set db [ns_db gethandle] +set user_id [ad_verify_and_get_user_id] +ad_maybe_redirect_for_registration +set item_type {table_sort} +set value_type {list} + +if {$delete_the_sort && ![empty_string_p $item]} { + util_dbq {item item_type value_type item_group} + if {[catch {ns_db dml $db "delete user_custom + where user_id = $user_id and item = $DBQitem and item_group = $DBQitem_group + and item_type = $DBQitem_type"} errmsg]} { + ad_return_complaint 1 "
$errmsg\n" + return + } + ns_returnredirect "$return_url" + return +} + + + +if {[empty_string_p $item]} { + ad_return_complaint 1 "
$errmsg\n" + return +} + +ns_returnredirect "$return_url&$item_group=[ns_urlencode $item]" + Index: openacs-4/packages/ecommerce/www/admin/tools/spell.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/tools/spell.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/www/admin/tools/spell.tcl 26 Aug 2001 23:37:59 -0000 1.1 @@ -0,0 +1,287 @@ +# spell.tcl,v 3.0 2000/02/06 03:54:45 ron Exp +# Jan 6, 2000 (OUMI) +# added html_p argument, set to 1 if $var_to_spellcheck contains html tags +# and you don't want to spell check the HTML tags. Also fixed a bug in +# the exporting of $processed_text. + +# spell.tcl + +# Written by Jin Choi (jsc@arsdigita.com), with additions by Eve Andersson +# (eveander@arsdigita.com). Added to the ACS July 5, 1999. + +# See http://photo.net/doc/tools.html for more information and usage +# example. + +# Arguments: merge_p, var_to_spellcheck, target_url, error_0, error_1... +# html_p +# +# To use, call with var_to_spellcheck, target_url, and whatever form +# variable you specified as var_to_spellcheck. You can also specify +# html_p (set to 't') if the variable to spellcheck contains HTML tags +# and you don't want the tags to get spell checked. +# +# merge_p and the error variables are internal arguments. + +# This script runs in two modes. + +# If merge_p is not set or is 0, we display the form variable specified by +# VAR_TO_SPELLCHECK with any misspellings +# as reported by ispell replaced by either a text field (if it ispell +# marked it as a "miss") or by a drop down box (if ispell marked it a +# "near miss"), and target ourself with the text to merge, the number +# of errors, and each error as error_0, error_1, ... error_n. + +# If merge_p is true, we take the results of the above form, merge the +# corrections back into the text, and pass everything on to TARGET_URL. + +# In either case, we re-export any form variable we don't use. + +proc spell_sorted_list_with_unique_elements {the_list} { + + set sorted_list [lsort $the_list] + set new_list [list] + + set old_element "XXinitial_conditionXX" + foreach list_element $sorted_list { + if { $list_element != $old_element } { + lappend new_list $list_element + } + set old_element $list_element + } + + return $new_list +} + + +set form [ns_conn form] +set var_to_spellcheck [ns_set get $form var_to_spellcheck] +set text [ns_set get $form $var_to_spellcheck] +set html_p [ns_set get $form html_p] +set merge_p [ns_set get $form merge_p] +ns_set delkey $form $var_to_spellcheck +ns_set delkey $form merge_p + +if { $merge_p == "" || $merge_p == 0 } { + + # if $html_p then substitute out all HTML tags + set text_to_spell_check $text + if {[string compare $html_p "t"] == 0} { + regsub -all {<[^<]*>} $text_to_spell_check "" text_to_spell_check + } + + set tmpfile [ns_mktemp "/tmp/webspellXXXXXX"] + set f [open $tmpfile w] + puts $f $text_to_spell_check + close $f + + set lines [split $text "\n"] + + set dictionaryfile [ns_normalizepath "[ns_info pageroot]/../packages/ecommerce/www/admin/tools/ispell-words"] + + # The webspell wrapper is necessary because ispell requires + # the HOME environment set, and setting env(HOME) doesn't appear + # to work from AOLserver. + set spelling_program [ns_normalizepath "[ns_info pageroot]/../packages/ecommerce/www/admin/tools/webspell"] + + set ispell_proc [open "|$spelling_program $tmpfile $dictionaryfile" r] + + # read will occasionally error out with "interrupted system call", + # so retry a few times in the hopes that it will go away. + set try 0 + set max_retry 10 + while {[catch {set ispell_text [read -nonewline $ispell_proc]} errmsg] + && $try < $max_retry} { + incr try + ns_log Notice "spell.tcl had a problem: $errmsg" + } + close $ispell_proc + ns_unlink $tmpfile + + if { $try == $max_retry } { + ns_return 200 text/html "[ad_header "Spell Checker Error"] +
+ If the spell checker has any suggestions for the misspelled word, it will present the suggestions in a + drop-down list. If not, it provides a text field for you to enter your own correction. If a drop-down + list does not include the spelling you wish to have, then push \"Back\" and make the change to your + original document. +
+
+ ++
" + } + ns_write " +
+ [ad_footer]" + + } + +} + + +# an "if" instead of an "elseif" because the above clause may set merge_p to 1 +if { $merge_p != "" && $merge_p } { + set target_url [ns_set get $form target_url] + ns_set delkey $form target_url + + if { ![info exists error_free_p] } { + set merge_text [ns_set get $form merge_text] + } else { + set merge_text $processed_text + } + set num_errors [ns_set get $form num_errors] + ns_set delkey $form merge_text + ns_set delkey $form num_errors + ns_set delkey $form var_to_spellcheck + + for {set i 0} {$i < $num_errors} {incr i} { + regsub "\#$i\#" $merge_text [ns_set get $form "error_$i"] merge_text + ns_set delkey $form "error_$i" + } + +# set merge_text [ns_urlencode $merge_text] + +# ns_returnredirect "$target_url?$var_to_spellcheck=$merge_text&[export_url_vars $form]" + + ReturnHeaders + + ns_write "[ad_header "Spell Checker"] +