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.542.2.92 -r1.542.2.93 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 5 Nov 2020 13:53:36 -0000 1.542.2.92 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 7 Nov 2020 11:51:56 -0000 1.542.2.93 @@ -1396,12 +1396,14 @@ ::xo::db::CrClass get_instance_from_db -item_id ${:page_template} } set page_template_name [${:page_template} name] - if {$page_template_name eq "en:folder.form"} {return 1} - if {$include_folder_links && $page_template_name eq "en:link.form"} { + if {$page_template_name eq "en:folder.form"} { + return 1 + } elseif {$include_folder_links && $page_template_name eq "en:link.form"} { set link_type [:get_property_from_link_page link_type] return [expr {$link_type eq "folder_link"}] + } else { + return 0 } - return 0 } # @@ -3264,9 +3266,8 @@ error "No form field with name $name found" } - Page instproc show_fields {form_fields} { + Page instproc show_fields {form_fields {msg ""}} { # this method is for debugging only - set msg "" foreach f $form_fields { append msg "[$f name] [namespace tail [$f info class]], " } :msg $msg :log "form_fields: $msg" @@ -3730,6 +3731,20 @@ return "" } + PageInstance instproc field_names_from_form_constraints {} { + set form_constraints [:get_form_constraints] + set result {} + foreach name_and_spec $form_constraints { + regexp {^([^:]+):} $name_and_spec _ name + if {[string range $name 0 0] eq "@"} { + # return no aggregated (pseudo) form field names + continue + } + lappend result $name + } + return $result + } + PageInstance instproc get_short_spec {name} { #set form_constraints [:get_from_template form_constraints] set form_constraints [:get_form_constraints] 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.368.2.78 -r1.368.2.79 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 7 Oct 2020 10:09:42 -0000 1.368.2.78 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 7 Nov 2020 11:51:56 -0000 1.368.2.79 @@ -582,7 +582,7 @@ by "compare_revision_id". We can choose here between the more fancy "::util::html_diff" and a plain text diff. The latter is used, when the query variable "plain_text_diff" is provided, or - when the fnacy diff raises an exception. + when the fancy diff raises an exception. } { @@ -1289,7 +1289,7 @@ #if {$formgiven && ![string match _* $att]} continue if {[info exists :__field_in_form($att)]} continue set f [:lookup_form_field -name $att $form_fields] - #:log "insert auto_field $att $f" + #:log "insert auto_field $att $f ([$f info class])" $f render_item } } $fcn @@ -2834,12 +2834,30 @@ } FormPage instproc field_names {{-form ""}} { + # + # Ge the field-names mentioned in form (the provided form has + # always highest precedence). + # lassign [:field_names_from_form -form $form] form_vars needed_attributes - #:msg "form=$form, form_vars=$form_vars needed_attributes=$needed_attributes" + # + # In case, we have no form, get the field-names from the form + # constraints. + # + if {[llength $needed_attributes] == 0} { + set needed_attributes [:field_names_from_form_constraints] + } + #:log "form=$form, form_vars=$form_vars needed_attributes=$needed_attributes" + array unset :__field_in_form array unset :__field_needed - if {$form_vars} {foreach v $needed_attributes {set :__field_in_form($v) 1}} - foreach v $needed_attributes {set :__field_needed($v) 1} + if {$form_vars} { + foreach v $needed_attributes { + set :__field_in_form($v) 1 + } + } + foreach v $needed_attributes { + set :__field_needed($v) 1 + } # # Remove the fields already included in auto_fields form the needed_attributes. @@ -2851,20 +2869,23 @@ foreach f $auto_fields { set p [lsearch -exact $reduced_attributes $f] if {$p > -1} { - #if {$form_vars} { - #set auto_field_in_form($f) 1 - #} set reduced_attributes [lreplace $reduced_attributes $p $p] } } #:msg reduced_attributes(after)=$reduced_attributes #:msg fields_from_form=[array names :__field_in_form] - set field_names [list _name] - if {[::${:package_id} show_page_order]} { lappend field_names _page_order } + set field_names _name + if {[::${:package_id} show_page_order]} { + lappend field_names _page_order + } lappend field_names _title _creator _assignee - foreach fn $reduced_attributes { lappend field_names $fn } - foreach fn [list _text _description _nls_language] { lappend field_names $fn } + foreach fn $reduced_attributes { + lappend field_names $fn + } + foreach fn [list _text _description _nls_language] { + lappend field_names $fn + } #:msg final-field_names=$field_names return $field_names } @@ -2873,7 +2894,9 @@ array set dont_modify {item_id 1 revision_id 1 object_id 1 object_title 1 page_id 1 name 1} set field_names [list] foreach field_name [[:info class] array names db_slot] { - if {[info exists dont_modify($field_name)]} continue + if {[info exists dont_modify($field_name)]} { + continue + } lappend field_names _$field_name } #:msg field_names=$field_names