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.317 -r1.318 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 30 Dec 2008 16:24:12 -0000 1.317 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 19 Jan 2009 08:18:22 -0000 1.318 @@ -1228,20 +1228,21 @@ } - - - Page instproc substitute_markup {source} { + Page instproc substitute_markup {content} { + # + # The provided content and the returned result are strings + # containing HTML (unless we have other rich-text encodings). + # set baseclass [expr {[[my info class] exists RE] ? [my info class] : [self class]}] $baseclass instvar RE markupmap #my log "-- baseclass for RE = $baseclass" if {[my set mime_type] eq "text/enhanced"} { - set source [ad_enhanced_text_to_html $source] + set content [ad_enhanced_text_to_html $content] } - if {![my do_substitutions]} {return [lindex $source 0]} + if {![my do_substitutions]} {return $content} set content "" set l "" - my log "--- lindex '$source' 0" - foreach l0 [split [lindex $source 0] \n] { + foreach l0 [split $content \n] { append l [string map $markupmap(escape) $l0] if {[string first \{\{ $l] > -1 && [string first \}\} $l] == -1} {append l " "; continue} set l [my regsub_eval $RE(anchor) $l {my anchor "\1"} "1"] @@ -1259,6 +1260,10 @@ Page instproc adp_subst {content} { + # + # The provided content and the returned result are strings + # containing HTML. + # #my msg "--adp_subst in [my name] vars=[my info vars]" set __ignorelist [list RE __defaults name_method object_type_key db_slot] foreach __v [my info vars] { @@ -1278,7 +1283,7 @@ set current_user [::xo::cc set untrusted_user_id] set __vars [info vars] - regsub -all [template::adp_variable_regexp] $content {\1@\2;noquote@} content + regsub -all [template::adp_variable_regexp] $content {\1@\2;noquote@} content_noquote #my log "--adp before adp_eval '[template::adp_level]'" # # The adp buffer has limited size. For large pages, it might happen @@ -1293,9 +1298,14 @@ # we have aolserver 4.5, we can increase the bufsize ns_adp_ctl bufsize [expr {$__l + 1024}] } - set template_code [template::adp_compile -string $content] + set template_code [template::adp_compile -string $content_noquote] set my_parse_level [template::adp_level] if {[catch {set template_value [template::adp_eval template_code]} __errMsg]} { + # + # Something went wrong during substitution; prepare a + # user-friendly error message containing a listing of the + # available variables. + # # compute list of possible variables set __varlist [list] set __template_variables__ "
[string map {> > < <} [my set text]]" + foreach {html mime} [[self]::payload content] break + if {[my render_adp]} { + set html [my adp_subst $html] + return [my substitute_markup $content] + } else { + return [list "
[string map {> > < <} [my set text]]" text/html] + } } } @@ -1996,7 +2016,8 @@ #my log "-- text='$text'" if {[lindex $text 0] ne ""} { my do_substitutions 0 - set content [my substitute_markup [my set text]] + foreach {html mime} [my set text] break + set content [my substitute_markup $html] } elseif {[lindex $form 0] ne ""} { set content [[self class] disable_input_fields [lindex $form 0]] } else {