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.88 -r1.89 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 9 Sep 2008 08:44:04 -0000 1.88 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 9 Sep 2008 12:46:45 -0000 1.89 @@ -737,7 +737,7 @@ if {[my wiki]} { [my object] set unresolved_references 0 [my object] set __unresolved_references [list] - ::html::t -disableOutputEscaping [[my object] substitute_markup [list [my value] text/html]] + ::html::t -disableOutputEscaping [[my object] substitute_markup [list [my value] text/html]] } else { ::html::t -disableOutputEscaping [my value] } 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.271 -r1.272 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 8 Sep 2008 11:27:12 -0000 1.271 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 9 Sep 2008 12:46:45 -0000 1.272 @@ -1213,7 +1213,7 @@ my set __unresolved_references [list] #my log "--W setting unresolved_references to 0 [info exists unresolved_references]" set content [my get_content] - #my log "--W after content [info exists unresolved_references] [my exists unresolved_references] ?? [info vars]" + #my msg "we have the content, update=$update_references, unresolved=$unresolved_references" if {$update_references || $unresolved_references > 0} { my update_references $item_id [lsort -unique $references] } @@ -1547,13 +1547,18 @@ } PageInstance instproc get_form {} { + # get the (HTML) form of the ::xowiki::PageTemplates/::xowiki::Form set form [my get_from_template form] if {[llength $form] == 2 && [lindex $form 1] eq "text/html"} {set form [lindex $form 0]} return $form } - PageInstance instproc get_form_id {} { - return [my page_template] + PageInstance instproc get_template_object {} { + set id [my page_template] + if {![my isobject ::$id]} { + ::xo::db::CrClass get_instance_from_db -item_id $id + } + return ::$id } PageInstance instproc get_form_constraints {{-trylocal false}} { @@ -1578,37 +1583,33 @@ @return either the property value or a default value } { #my msg "get $var from template" - set form_id [my get_form_id] - # add here a "my require_cr_object $id" ??? - if {![my isobject ::$form_id]} { - # The page does not exist, we fetch it - ::xo::db::CrClass get_instance_from_db -item_id $form_id - } + set form_obj [my get_template_object] # The resulting page should be either a Form (PageTemplate) or # a FormPage (PageInstance) # - # my msg "parent of self [my name] is [$form_id name] type [::$form_id info class]" + # my msg "parent of self [my name] is [$form_obj name] type [$form_obj info class]" # # If it is as well a PageInstance, we find the information in the # properties of this page. # - if {[::$form_id istype ::xowiki::PageInstance]} { - #my msg "returning parent property [::$form_id property $var]" - return [::$form_id property $var] + if {[$form_obj istype ::xowiki::PageInstance]} { + #my msg "returning parent property [$form_obj property $var]" + return [$form_obj property $var] } # # .... otherwise, it should be an instance variable .... # - if {[::$form_id exists $var]} { - #my msg "returning parent instvar [::$form_id set $var]" - return [::$form_id set $var] + if {[$form_obj exists $var]} { + #my msg "returning parent instvar [$form_obj set $var]" + return [$form_obj set $var] } # # .... or, we try to resolve it against a local property. # - # This case is needed in the workflow case, where e.g. anon_instances - # is tried to be catched from the first form, which might not contain - # it, if e.g. the first form is a plain wiki page. + # This case is currently needed in the workflow case, where + # e.g. anon_instances is tried to be catched from the first form, + # which might not contain it, if e.g. the first form is a plain + # wiki page. # if {[my istype ::xowiki::FormPage] && [my exists_property $var]} { #my msg "returning local property [my property $var]" @@ -1617,7 +1618,7 @@ # # if everything fails, return the default. # - #my msg "returning the default, parent is of type [::$form_id info class]" + #my msg "returning the default, parent is of type [$form_obj info class]" return $default } 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.165 -r1.166 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 8 Sep 2008 11:27:13 -0000 1.165 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 9 Sep 2008 12:45:18 -0000 1.166 @@ -88,9 +88,9 @@ namespace eval ::xowiki { Page instproc view {{content ""}} { - # The method view is used primarily for the toplevel call, when + # The method "view" is used primarily for the toplevel call, when # the xowiki page is viewed. It is not intended for e.g. embedded - # wiki pages (see include). + # wiki pages (see include), since it contains full framing, etc. my instvar package_id item_id $package_id instvar folder_id ;# this is the root folder ::xowiki::Page set recursion_count 0 @@ -102,12 +102,14 @@ $template_file before_render [self] } + # the content may be passed by other methods (e.g. edit) to + # make use of the same templating machinery below. if {$content eq ""} { set content [my render] + #my log "--after render" } - #my log "--after render" - set footer [my htmlFooter -content $content] + set footer [my htmlFooter -content $content] set top_includelets "" set vp [string trim [$package_id get_parameter "top_includelet" ""]] if {$vp ne ""} { @@ -1115,6 +1117,12 @@ -use_given_publish_date [expr {[lsearch $field_names _publish_date] > -1}] \ [::xo::cc form_parameter __object_name ""] $category_ids + # The data might have references. We render do the rendering here + # instead on every view (which would be safer, but slower). This is + # roughly the counterpart to edit_data and save_data in ad_forms. + set content [my render -update_references] + #my msg "after save refs=[expr {[my exists references]?[my set references] : {NONE}}]" + set redirect_method [my form_parameter __form_redirect_method "view"] if {$redirect_method eq "__none"} { return @@ -1213,7 +1221,6 @@ if {[my exists __field_in_form($att)]} continue set f [my lookup_form_field -name $att $form_fields] #my msg "insert auto_field $att" - #if {[$f name] eq "form"} {my msg [$f serialize]} $f render_item } } $fcn