Index: openacs-4/packages/acs-templating/tcl/acs-integration-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/acs-integration-procs.tcl,v diff -u -r1.27 -r1.28 --- openacs-4/packages/acs-templating/tcl/acs-integration-procs.tcl 24 Aug 2018 13:36:43 -0000 1.27 +++ openacs-4/packages/acs-templating/tcl/acs-integration-procs.tcl 3 Sep 2024 15:37:35 -0000 1.28 @@ -33,8 +33,21 @@ } if { $string_p } { - return [template::adp_parse \ - [template::util::url_to_file $template [ad_conn file]] {}] + # + # We have to pass the application variables to ad_parse. As it + # looks, we have to omit the variables in use for + # "template::ad_parse" internally. This is not pretty, but it + # should help to get the base mechanism working. There is + # probably a more pretty solution for this. + # + set application_vars {} + foreach var [uplevel [list info vars]] { + if {[string match __adp* $var] || [string match __args* $var]} { + continue + } + lappend application_vars $var [uplevel [list set $var]] + } + return [template::adp_parse [template::util::url_to_file $template [ad_conn file]] $application_vars] } } @@ -46,7 +59,7 @@ @param params The parameters to pass to the template. Note that pass-by-reference params must be in the page namespace, they cannot be in a local procedure, or any other namespace. - @param template The template file name. + @param template The template filename. Example: @@ -75,7 +88,7 @@ @param status The HTTP status to return, by default HTTP 500 (Error) @param params The parameters to pass to the template. - @param template The template file name. + @param template The template filename. Example: @@ -86,19 +99,25 @@ } -ad_proc adp_parse_ad_conn_file {} { +ad_proc -private adp_parse_ad_conn_file {} { Handle a request for an adp and/or Tcl file in the template system - based on the current setting of [ad_conn file]. This file is + based on the current setting of [ad_conn file]. This proc is registered via rp_register_extension_handler @see rp_register_extension_handler } { set ::template::parse_level "" #ns_log debug "adp_parse_ad_conn_file => file '[file rootname [ad_conn file]]'" - template::reset_request_vars # + # The proper place to reset the variables is after the request, + # not on the begin of a special kind of request (i.e. via "ns_ictl + # trace freeconn") + # + #template::reset_request_vars + + # # [ad_conn file] is always an absolute name, remove the # acs::rootdir, compute the template and add the acs::rootdir # again. @@ -118,12 +137,12 @@ set apm_package_url [apm_package_url_from_key "acs-lang"] # Attempt to move all message keys outside of tags - while { [regsub -all {(<[^>]*)(\x02\(\x01[^\x01]*\x01\)\x02)([^>]*>)} $parsed_template {\2\1\3} parsed_template] } {} + while { [regsub -all -- {(<[^>]*)(\x02\(\x01[^\x01]*\x01\)\x02)([^>]*>)} $parsed_template {\2\1\3} parsed_template] } {} # Attempt to move all message keys outside of statements - regsub -all -nocase {(]*>[^<]*)(\x02\(\x01[^\x01]*\x01\)\x02)([^<]*]*>)} $parsed_template {\2\1\3} parsed_template + regsub -all -nocase -- {(]*>[^<]*)(\x02\(\x01[^\x01]*\x01\)\x02)([^<]*]*>)} $parsed_template {\2\1\3} parsed_template - while { [regsub -all -nocase {(]*>[^<]*)(\x02\(\x01[^\x01]*\x01\)\x02)} $parsed_template {\2\1} parsed_template] } {} + while { [regsub -all -nocase -- {(]*>[^<]*)(\x02\(\x01[^\x01]*\x01\)\x02)} $parsed_template {\2\1} parsed_template] } {} set start 0 while { [regexp -nocase -indices -start $start {(o}] + if { [lang::message::message_exists_p $locale $key] } { + set edit_link [subst {}] } else { if { [lang::message::message_exists_p "en_US" $key] } { # Translation missing in this locale - set edit_link [subst {*}] + set edit_link [subst {}] } else { # Message key missing entirely set new_url [export_vars -base "${apm_package_url}admin/localized-message-new" { { locale en_US } package_key message_key { return_url [ad_return_url] } }] - set edit_link [subst {@}] + set edit_link [subst {}] } } - set parsed_template "${before}${edit_link}${after}" + set parsed_template "${before}[::template::adp_parse_tags ${edit_link}]${after}" } }