Index: openacs-4/packages/xowiki/tcl/form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/form-field-procs.tcl,v diff -u -r1.55 -r1.56 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 12 Mar 2008 12:04:13 -0000 1.55 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 25 Mar 2008 12:01:17 -0000 1.56 @@ -33,7 +33,9 @@ {display_field true} {hide_value false} {inline false} + {disabled} CSSclass + form-widget-CSSclass {type text} {label} {name} @@ -47,7 +49,9 @@ default object slot + answer } + FormField set abstract 1 FormField instproc init {} { if {![my exists label]} {my label [string totitle [my name]]} if {![my exists id]} {my id [my name]} @@ -193,12 +197,12 @@ FormField instproc config_from_spec {spec} { my instvar type - if {[my info class] eq [self class]} { - # Check, wether the actual class of the formfield differs from the - # generic FromField class. If yes, the object was already - # reclassed to a concrete form field type. Since config_from_spec - # can be called multiple times, we want to do the reclassing only - # once. + if {[[my info class] exists abstract]} { + # had earlier here: [my info class] eq [self class] + # Check, wether the actual class is a concrete class (mapped to + # concrete field type) or an abstact class. Since + # config_from_spec can be called multiple times, we want to do + # the reclassing only once. my class [self class]::$type ::xotcl::Class::Parameter searchDefaults [self]; # TODO: will be different in xotcl 1.6.* } @@ -271,14 +275,16 @@ FormField instproc render_form_widget {} { # This method provides the form-widget wrapper - ::html::div -class form-widget { my render_input } + set class form-widget + if {[my exists form-widget-CSSclass]} {append class " [my form-widget-CSSclass]"} + ::html::div -class $class { my render_input } } FormField instproc render_input {} { # This is the most general widget content renderer. # If no special renderer is defined, we fall back to this one, # which is in most cases a simple input fied of type string. - ::html::input [my get_attributes type size maxlength id name value] {} + ::html::input [my get_attributes type size maxlength id name value disabled {CSSclass class}] {} } FormField instproc render_item {} { @@ -363,7 +369,9 @@ my set value [::xo::localize [_ xowiki.Form-submit_button]] } FormField::submit_button instproc render_input {} { - ::html::input [my get_attributes name type {CSSclass class} value] {} + # don't disable submit buttons + if {[my type] eq "submit"} {my unset -nocomplain disabled} + ::html::input [my get_attributes name type {CSSclass class} value disabled] {} my render_localizer } @@ -398,7 +406,7 @@ } FormField::inform instproc render_input {} { ::html::t [my value] - ::html::input [my get_attributes type id name value] {} + ::html::input [my get_attributes type id name value disabled {CSSclass class}] {} } FormField::inform instproc render_help_text {} { } @@ -508,7 +516,7 @@ } FormField::textarea instproc render_input {} { - ::html::textarea [my get_attributes id name cols rows style {CSSclass class}] { + ::html::textarea [my get_attributes id name cols rows style {CSSclass class} disabled] { ::html::t [my value] } } @@ -679,7 +687,8 @@ set value [my value] foreach o [my options] { foreach {label rep} $o break - set atts [list id [my id]:$rep name [my name] type radio value $rep] + set atts [my get_attributes disabled {CSSclass class}] + lappend atts id [my id]:$rep name [my name] type radio value $rep if {$value eq $rep} {lappend atts checked checked} ::html::input $atts {} html::t "$label " @@ -701,7 +710,7 @@ my set widget_type text(select) } FormField::select instproc render_input {} { - set atts [my get_attributes id name] + set atts [my get_attributes id name disabled] if {[my multiple]} {lappend atts multiple [my multiple]} set options [my options] if {![my required]} { @@ -710,7 +719,8 @@ ::html::select $atts { foreach o $options { foreach {label rep} $o break - set atts [list value $rep] + set atts [my get_attributes disabled] + lappend atts value $rep #my msg "lsearch {[my value]} $rep ==> [lsearch [my value] $rep]" if {[lsearch [my value] $rep] > -1} { lappend atts selected on Index: openacs-4/packages/xowiki/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v diff -u -r1.113 -r1.114 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 14 Mar 2008 20:04:56 -0000 1.113 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 25 Mar 2008 12:01:17 -0000 1.114 @@ -271,7 +271,7 @@ return [my error_msg "Method '$method' is not defined for this object"] } else { #my msg "--invoke [my set object] id=$page method=$method" - return [my call $page $method] + return [my call $page $method ""] } } else { # the requested page was not found, provide an error message and @@ -420,14 +420,14 @@ return $page } - Package instproc call {object method} { + Package instproc call {object method options} { my instvar policy id set allowed [$policy enforce_permissions \ -package_id $id -user_id [::xo::cc user_id] \ $object $method] if {$allowed} { #my msg "--p calling $object ([$object info class]) '$method'" - $object $method + eval $object $method $options } else { my log "not allowed to call $object $method" } Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.216 -r1.217 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 19 Mar 2008 13:07:41 -0000 1.216 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 25 Mar 2008 12:01:17 -0000 1.217 @@ -1380,13 +1380,21 @@ return [my include [list form-menu -form_item_id [my item_id]]] } - Form proc disable_input_fields {form} { - dom parse -simple -html $form doc - $doc documentElement root + Form proc dom_disable_input_fields {{-with_submit 0} root} { set fields [$root selectNodes "//button | //input | //optgroup | //option | //select | //textarea "] foreach field $fields { + if {$with_submit == 0 && [$field getAttribute type] eq "submit"} continue + # Disabled fields are not transmitted from the form; + # some applications expect it to be transmitted, so don't disable it... + if {[$field getAttribute type] eq "hidden"} continue $field setAttribute disabled "disabled" } + } + + Form proc disable_input_fields {{-with_submit 0} form} { + dom parse -simple -html $form doc + $doc documentElement root + my disable_input_fields_dom $root return [$root asHTML] } @@ -1480,7 +1488,13 @@ } } + FormPage instproc form_attributes {} { + my log "DEPRECATRED, use 'field_names_from_form' instead " + return [my field_names_from_form] + } + + FormPage instproc field_names_from_form {} { # # this method returns the form attributes (including _*) # @@ -1497,7 +1511,7 @@ #if {[string match _* $var]} continue if {[lsearch $allvars $var] == -1} {lappend field_names $var} } - set form_vars 0 + set from_HTML_form 0 } else { foreach {match 1 att} [regexp -all -inline [template::adp_variable_regexp] $form] { #if {[string match _* $att]} continue @@ -1518,9 +1532,9 @@ lappend field_names $att } } - set form_vars 1 + set from_HTML_form 1 } - return [list $form_vars $field_names] + return [list $from_HTML_form $field_names] } @@ -1534,7 +1548,7 @@ } else { ::xowiki::Form requireFormCSS set form [lindex [my get_from_template form] 0] - foreach {form_vars field_names} [my form_attributes] break + foreach {form_vars field_names} [my field_names_from_form] break my array unset __field_in_form if {$form_vars} {foreach v $field_names {my set __field_in_form($v) 1}} set form_fields [my create_form_fields $field_names] Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v diff -u -r1.133 -r1.134 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 12 Mar 2008 12:04:13 -0000 1.133 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 25 Mar 2008 12:01:17 -0000 1.134 @@ -461,7 +461,7 @@ FormPage instproc set_form_value {att value} { #my msg "set_form_value $att $value" my instvar root item_id - set fields [$root selectNodes "//*\[@name='$att'\]"] + set fields [$root selectNodes "//form//*\[@name='$att'\]"] #my msg "found field = $fields xp=//*\[@name='$att'\]" foreach field $fields { # TODO missing: textarea @@ -471,7 +471,7 @@ switch $type { checkbox { #my msg "CHECKBOX value='$value', [$field hasAttribute checked], [expr {$value == false}]" - if {[catch {set f [expr $value ? 1 : 0]}]} {set f 1} + if {[catch {set f [expr {$value ? 1 : 0}]}]} {set f 1} if {$value eq "" || $f == 0} { if {[$field hasAttribute checked]} { $field removeAttribute checked @@ -724,7 +724,7 @@ FormPage instproc field_names {} { my instvar package_id - foreach {form_vars needed_attributes} [my form_attributes] break + foreach {form_vars needed_attributes} [my field_names_from_form] break #my msg "form_vars=$form_vars needed_attributes=$needed_attributes" my array unset __field_in_form if {$form_vars} {foreach v $needed_attributes {my set __field_in_form($v) 1}} @@ -866,6 +866,7 @@ FormPage instproc edit { {-validation_errors ""} + {-disable_input_fields 0} } { my instvar page_template doc root package_id @@ -909,7 +910,6 @@ $f config_from_spec hidden } #my show_fields $form_fields - if {[my form_parameter __form_action ""] eq "save-form-data"} { #my msg "we have to validate" # @@ -1052,11 +1052,19 @@ set url [export_vars -base [$package_id pretty_link [my name]] {{m "edit"} return_url}] $form setAttribute action $url method POST set oldCSSClass [expr {[$form hasAttribute class] ? [$form getAttribute class] : ""}] - $form setAttribute class [string trim "$oldCSSClass margin-form"] + if {[lsearch -exact $oldCSSClass margin-form] == -1} { + $form setAttribute class [string trim "$oldCSSClass margin-form"] + } } my set_form_data $form_fields + if {$disable_input_fields} { + # (a) disable explicit input fields + foreach f $form_fields {$f disabled disabled} + # (b) disable input in HTML-specified fields + Form dom_disable_input_fields $root + } + my post_process_edit_fields $root $form_fields set html [$root asHTML] - set html [my regsub_eval \ {(^|[^\\])\x003([a-zA-Z0-9_:]+)\x003} $html \ {my form_field_as_html "\\\1" "\2" $form_fields}] @@ -1065,8 +1073,12 @@ my view $html } + FormPage instproc post_process_edit_fields {dom_root form_field} { + # Part of the input fields comes from HTML, part comes via $form_fields + # We offer here the possibility to iterate over the fields before they + # are presented; can be overloaded + } - File instproc download {} { my instvar text mime_type package_id item_id revision_id $package_id set mime_type $mime_type