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 -N -r1.40 -r1.41 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 26 Nov 2007 09:14:43 -0000 1.40 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 30 Nov 2007 12:32:21 -0000 1.41 @@ -168,6 +168,7 @@ if {[string match {\[*\]} $value]} { set value [subst $value] } + #my msg "my [lindex $l 0] $value" my [lindex $l 0] $value } errMsg]} { error "Error during setting attribute '[lindex $l 0]' to value '[lindex $l 1]': $errMsg" @@ -210,7 +211,7 @@ # Since only the configuration might set values, checking value for "" seems safe here. # if {[my value] eq "" && [my exists default] && [my default] ne ""} { - #my msg "reset value to [my default]" + #my msg "+++ reset value to [my default]" my value [my default] } @@ -709,11 +710,12 @@ foreach o $options { foreach {label rep} $o break set atts [list value $rep] - #my msg "lsearch {[my value]} $value ==> [lsearch [my value] $value]" + #my msg "lsearch {[my value]} $rep ==> [lsearch [my value] $rep]" if {[lsearch [my value] $rep] > -1} { lappend atts selected on } ::html::option $atts {::html::t $label} + ::html::t \n }} } @@ -852,6 +854,7 @@ # "yesterday", "next week", .... use _ for blanks FormField::date instproc initialize {} { + #my msg "DATE has value [my value]" my set widget_type date my set format [string map [list _ " "] [my format]] my array set format_map { @@ -871,6 +874,7 @@ ::xowiki::FormField::$class create [self]::$class \ -name [my name].$class -id [my id].$class -locale [my locale] } + #my set_compound_value } FormField::date instproc components {} { @@ -905,6 +909,7 @@ } else { set value_part "" } + #my msg "ticks=$ticks [self]::$class value $value_part" [self]::$class value $value_part } } @@ -986,8 +991,82 @@ next } + ########################################################### # + # ::xowiki::FormField::event + # + ########################################################### + + Class FormField::event -superclass FormField -parameter { + {components ""} + } + + FormField::event instproc initialize {} { + #my msg "EVENT has value [my value]" + my set widget_type event + my set structure { + {start date,format=DD_MONTH_YYYY_HH24_MI,default=now,label=Vortragsbeginn} + {end date,format=HH24_MI,default=now,label=Vortragsende} + {location text,label=Ort} + {summary richtext} + } + foreach entry [my set structure] { + foreach {name spec} $entry break + # + # create for each component a form field + # + my lappend components \ + [::xowiki::FormField create [self]::$name \ + -name [my name].$name -id [my id].$name -locale [my locale] -spec $spec] + } + #foreach c [my components] {my msg "c=$c v='[$c value]'"} + } + + FormField::event instproc set_compound_value {} { + #my msg "original value '[my value]'" + set value [my value] + # set the value parts for each components + array set {} $value + foreach c [my components] { + # Set only those parts, for which attribute values pairs are given. + # Components might have own default values... + if {[info exists ([$c name])]} { + $c value $([$c name]) + } + } + } + + FormField::event instproc get_compound_value {} { + # Set the internal representation based on the components values. + set value [list] + foreach c [my components] { + lappend value [$c name] [$c value] + } + #my msg "compound value=$value" + return $value + } + + FormField::event instproc pretty_value {v} { + return pretty=[my value] + } + + FormField::event instproc render_content {} { + #my msg "" + my set_compound_value + my set style "margin: 0px; padding: 0px;" + html::fieldset [my get_attributes id style] { + foreach c [my components] { + $c render + } + } + } + + + + + ########################################################### + # # a few test cases # ########################################################### Index: openacs-4/packages/xowiki/tcl/includelet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/includelet-procs.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 21 Nov 2007 09:13:27 -0000 1.4 +++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 30 Nov 2007 12:32:21 -0000 1.5 @@ -407,10 +407,9 @@ if(d.selection){t=d.selection.createRange().text} else if(d.getSelection){t=d.getSelection()} else if(w.getSelection){t=w.getSelection()} - void(w.open('$url?m=create-new&title='+escape(d.title)+ - '&detail_link='+escape(d.location.href)+'&text='+escape(t), - '_blank','scrollbars=yes,width=500,height=575,status=yes, - resizable=yes,scrollbars=yes')) + void(open('$url?m=create-new&title='+escape(d.title)+ + '&detail_link='+escape(d.location.href)+'&text='+escape(t),'_blank', + 'scrollbars=yes,width=700,height=575,status=yes,resizable=yes,scrollbars=yes')) }] regsub -all {[\n ]+} $href " " href return "$label" 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 -N -r1.193 -r1.194 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 26 Nov 2007 09:14:43 -0000 1.193 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 30 Nov 2007 12:32:21 -0000 1.194 @@ -958,24 +958,31 @@ # # Some utility functions, called on different kind of pages # + Page instproc form_field_index {nodes} { + set marker ::__computed_form_field_names($nodes) + if {[info exists $marker]} return + foreach n $nodes { + if {![$n istype ::xowiki::FormField]} continue + set ::_form_field_names([$n name]) $n + my form_field_index [$n info children] + } + set $marker 1 + } + Page instproc lookup_form_field { -name form_fields } { - set found 0 - foreach f $form_fields { - if {[$f name] eq $name} {set found 1; break} + set key ::_form_field_names($name) + #my msg "form_fields=$form_fields, search for $name" + my form_field_index $form_fields + + #my msg "FOUND($name)=[info exists $key]" + if {[info exists $key]} { + return [set $key] } - if {!$found && [regexp {^([^.]+)[.](.*)$} $name _ container component]} { - # components of a field - set f [my lookup_form_field -name $container $form_fields]::$component - set found 1 - } - if {!$found} { - error "No form field with name $name found" - } - return $f + error "No form field with name $name found" } Page instproc show_fields {form_fields} { 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 -N -r1.116 -r1.117 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 26 Nov 2007 09:14:43 -0000 1.116 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 30 Nov 2007 12:32:21 -0000 1.117 @@ -523,8 +523,7 @@ # user form content fields set f [my lookup_form_field -name $att $form_fields] set value [$f value [::xo::cc form_parameter $att]] - # my msg "value of $att is $value" - if {![string match *.* $att]} {set __ia($att) $value} + if {![string match *.* $att]} {set __ia($att) $value} } } if {[string match *.* $att]} {