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 "
  • I was unable to delete the defaults. The database said
    $errmsg
    \n" + return + } + ns_returnredirect "$return_url" + return +} + + + +if {[empty_string_p $item]} { + ad_return_complaint 1 "
  • You did not specify a name for this default set." + return +} + +set form [ns_getform] +for {set i 0} { $i < [ns_set size $form]} {incr i} { + if {[lsearch $internals [ns_set key $form $i]] < 0} { + lappend data [list [ns_set key $form $i] [ns_set value $form $i]] + } +} + + +if {[empty_string_p $data]} { + ad_return_complaint 1 "
  • You did not specify any default data." + return +} + +util_dbq {item item_original item_type value_type item_group} +with_transaction $db { + ns_db dml $db "delete user_custom + where user_id = $user_id and item = $DBQitem_original and item_group = $DBQitem_group + and item_type = $DBQitem_type" + + ns_ora clob_dml $db "insert into user_custom (user_id, item, item_group, item_type, value_type, value) + values ($user_id, $DBQitem, $DBQitem_group, $DBQitem_type, 'list', empty_clob()) + returning value into :1" $data +} { + ad_return_complaint 1 "
  • I was unable to insert your defaults. The database said
    $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 "
  • I was unable to delete the sort. The database said
    $errmsg
    \n" + return + } + ns_returnredirect "$return_url" + return +} + + + +if {[empty_string_p $item]} { + ad_return_complaint 1 "
  • You did not specify a name for this sort" + return +} + + +set col_clean {} +set direction(asc) {} +set direction(desc) {*} + +# Strip the blank columns... +set i 0 +foreach c $col { + if {![empty_string_p $c]} { + lappend col_clean "$c$direction([lindex $dir $i])" + } + incr i +} + +if {[empty_string_p $col_clean]} { + ad_return_complaint 1 "
  • You did not specify any columns to sort by" + return +} + +set col_clean [join $col_clean ","] + +util_dbq {item item_original item_type value_type item_group} +with_transaction $db { + ns_db dml $db "delete user_custom + where user_id = $user_id and item = $DBQitem_original and item_group = $DBQitem_group + and item_type = $DBQitem_type" + + ns_ora clob_dml $db "insert into user_custom (user_id, item, item_group, item_type, value_type, value) + values ($user_id, $DBQitem, $DBQitem_group, $DBQitem_type, 'list', empty_clob()) + returning value into :1" $col_clean +} { + ad_return_complaint 1 "
  • I was unable to insert your table customizations. The database said
    $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"] +

    Spell Checker Error

    +
    +The spell checker was unable to process your document. Please hit \"Reload\" to try again If this message occurs again, please contact [ad_system_owner]. +[ad_footer]" + return + } + + set ispell_lines [split $ispell_text "\n"] + # Remove the version line. + if { [llength $ispell_lines] > 0 } { + set ispell_lines [lreplace $ispell_lines 0 0] + } + + set error_num 0 + set errors [list] + + set processed_text "" + + set line [lindex $lines 0] + + foreach ispell_line $ispell_lines { + switch -glob -- $ispell_line { + "#*" { + regexp "^\# (\[^ \]+) (\[0-9\]+)" $ispell_line dummy word pos + regsub $word $line "\#$error_num\#" line + lappend errors [list miss $error_num $word] + incr error_num + } + "&*" { + regexp {^& ([^ ]+) ([0-9]+) ([0-9]+): (.*)$} $ispell_line dummy word n_options pos options + regsub $word $line "\#$error_num\#" line + lappend errors [list nearmiss $error_num $word $options] + incr error_num + } + "" { + append processed_text "$line\n" + if { [llength $lines] > 0 } { + set lines [lreplace $lines 0 0] + set line [lindex $lines 0] + } + } + } + } + + + if { $error_num == 0 } { + # then there were no errors, so we just want to skip the user to the next screen + set merge_p 1 + set error_free_p 1 + } else { + + set formtext $processed_text + foreach err $errors { + set errtype [lindex $err 0] + set errnum [lindex $err 1] + set errword [lindex $err 2] + set wordlen [string length $errword] + + if { $errtype == "miss" } { + regsub "\#$errnum\#" $formtext "" formtext + } elseif { $errtype == "nearmiss" } { + set erroptions [lindex $err 3] + regsub -all ", " $erroptions "," erroptions + set options [split $erroptions ","] + set select_text "\n" + regsub "\#$errnum\#" $formtext $select_text formtext + } + + } + + # regsub -all {"} $processed_text {\"} processed_text + # a regsub isn't enough for exporting $processed_text in + # a hidden variable. + set processed_text [philg_quote_double_quotes $processed_text] + + ReturnHeaders + ns_write "[ad_header "Spell Checker"] +

    Spell Checker

    +
    + The spell checker has found one or more words in your document which could not be found in our dictionary. +

    + 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. +

    +
    + Please make changes below: +
    +

    +

    + + + + [export_entire_form] + [export_form_vars var_to_spellcheck merge_text] + " + + regsub -all "\r\n" $formtext "
    " formtext_to_display + ns_write " + $formtext_to_display +

    +

    + + +
    +
    + If you like, you can add any words that the spell checker caught to the spelling dictionary. This will + prevent the spell checker from catching them in the future. +

    +

    +

    + [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"] +

    Spell Checker

    +
    + " + + if { [info exists error_free_p] } { + ns_write "Your document contains 0 spelling errors. " + } else { + ns_write "Here is the final document with any spelling corrections included. " + } + + ns_write "Please confirm that you are satisfied + with it. If not, push your browser's \"Back\" button to go back and make changes. +
    + [export_entire_form] + +
    + +
    +
    +
    $merge_text
    +

    + [ad_footer] + " + return +} Index: openacs-4/packages/ecommerce/www/admin/tools/spelling-dictionary-add-to.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/tools/spelling-dictionary-add-to.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/www/admin/tools/spelling-dictionary-add-to.tcl 26 Aug 2001 23:37:59 -0000 1.1 @@ -0,0 +1,28 @@ +# spelling-dictionary-add-to.tcl,v 3.0 2000/02/06 03:54:46 ron Exp +set_the_usual_form_variables +#errword + +set db [ns_db gethandle] + +if [catch {ns_db dml $db "insert into ispell_words (ispell_word) values ('$QQerrword')"}] { + ad_return_error "Unable to add word" "We were unable to add $errword to the dictionary. It is probably because somebody else tried to add the same word at the same time to the dictionary (words in the dictionary must be unique)." + return +} + +# Now that Oracle has handled the transaction control of adding words to the dictionary, bash the +# ispell-words file. Jin has promised me (eveander) that ispell-words won't become corrupted because, +# since one chunk is only to be added to the file at a time, it is impossible for the chunks to +# become interspersed. + +set ispell_file [open "[ns_info pageroot]/tools/ispell-words" a] + +# ispell-words will be of the form: one word per line, with a newline at the end (since -nonewline is not specified) +puts $ispell_file "$errword" + +ReturnHeaders +ns_write "[ad_header "$errword added"] +

    $errword has been added to the spelling dictionary

    +
    +Please push \"Back\" to continue with the spell checker. +[ad_footer] +" Index: openacs-4/packages/ecommerce/www/admin/tools/table-custom.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/tools/Attic/table-custom.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/www/admin/tools/table-custom.tcl 26 Aug 2001 23:37:59 -0000 1.1 @@ -0,0 +1,65 @@ +# table-custom.tcl,v 3.0 2000/02/06 03:54:47 ron Exp +# Takes the data generated from ad_table_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_view 0} {col -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_view} +set value_type {list} + +if {$delete_the_view && ![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 "
  • I was unable to delete the view. The database said
    $errmsg
    \n" + return + } + ns_returnredirect "$return_url" + return +} + + +if {[empty_string_p $item]} { + ad_return_complaint 1 "
  • You did not specify a name for this table view" + return +} + +set col_clean [list] + +# Strip the blank columns... +foreach c $col { + if {![empty_string_p $c]} { + lappend col_clean $c + } +} + +if {[empty_string_p $col_clean]} { + ad_return_complaint 1 "
  • You did not specify any columns to display" + return +} + +util_dbq {item item_original item_type value_type item_group} +with_transaction $db { + ns_db dml $db "delete user_custom + where user_id = $user_id and item = $DBQitem_original and item_group = $DBQitem_group + and item_type = $DBQitem_type" + + ns_ora clob_dml $db "insert into user_custom (user_id, item, item_group, item_type, value_type, value) + values ($user_id, $DBQitem, $DBQitem_group, $DBQitem_type, 'list', empty_clob()) + returning value into :1" $col_clean +} { + ad_return_complaint 1 "
  • I was unable to insert your table customizations. The database said
    $errmsg
    \n" + return +} + +ns_returnredirect "$return_url&$item_group=[ns_urlencode $item]" + Index: openacs-4/packages/ecommerce/www/admin/tools/webspell =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/tools/webspell,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/www/admin/tools/webspell 26 Aug 2001 23:37:59 -0000 1.1 @@ -0,0 +1,9 @@ +#!/bin/sh + +# Wrapper for ispell that sets the HOME environment variable. +# Can't seem to do this from AOLserver Tcl. +# Takes two arguments: file to spellcheck, dictionary file. + +HOME=/home/nsadmin +export HOME +exec /usr/bin/ispell -a -p $2 < $1