adp_parse_ad_conn_file (private)
adp_parse_ad_conn_file
Defined in packages/acs-templating/tcl/acs-integration-procs.tcl
Handle a request for an adp and/or Tcl file in the template system based on the current setting of [ad_conn file]. This proc is registered via rp_register_extension_handler
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set ::template::parse_level "" #ns_log debug "adp_parse_ad_conn_file => file '[file rootname [ad_conn file]]'" # # 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. # set absolute_file [ad_conn file] set relative_name [string range $absolute_file [string length $::acs::rootdir] end] set themed_template $::acs::rootdir/[template::themed_template [file rootname $relative_name]] set parsed_template [template::adp_parse $themed_template {}] if {$parsed_template ne ""} { # # acs-lang translator mode # if { [lang::util::translator_mode_p] } { 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] } {} # Attempt to move all message keys outside of <select>...</select> statements regsub -all -nocase -- {(<option\s[^>]*>[^<]*)(\x02\(\x01[^\x01]*\x01\)\x02)([^<]*</option[^>]*>)} $parsed_template {\2\1\3} parsed_template while { [regsub -all -nocase -- {(<select[^>]*>[^<]*)(\x02\(\x01[^\x01]*\x01\)\x02)} $parsed_template {\2\1} parsed_template] } {} set start 0 while { [regexp -nocase -indices -start $start {(<select[^\x02]*)(\x02\(\x01[^\x01]*\x01\)\x02)} $parsed_template indices select_idx message_idx] } { set select [string range $parsed_template [lindex $select_idx 0] [lindex $select_idx 1]] if { [string first "</select" [string tolower $select]] != -1 } { set start [lindex $indices 1] } else { set before [string range $parsed_template 0 [lindex $indices 0]-1] set message [string range $parsed_template [lindex $message_idx 0] [lindex $message_idx 1]] set after [string range $parsed_template [lindex $indices 1]+1 end] set parsed_template "${before}${message}${select}${after}" } } # TODO: We could also move message keys out of <head>...</head> while { [regexp -indices {\x02\(\x01([^\x01]*)\x01\)\x02} $parsed_template indices key] } { set before [string range $parsed_template 0 [lindex $indices 0]-1] set after [string range $parsed_template [lindex $indices 1]+1 end] set key [string range $parsed_template [lindex $key 0] [lindex $key 1]] lassign [split $key "."] package_key message_key set locale [ad_conn locale] set edit_url [export_vars -base "${apm_package_url}admin/edit-localized-message" { { locale {$locale} } package_key message_key { return_url [ad_return_url] } }] if { [lang::message::message_exists_p $locale $key] } { set edit_link [subst {<a class="acs-lang-localized" href="[ns_quotehtml $edit_url]" title="$key"><adp:icon name="check" title="Message Key '$key': available in current locale $locale"></a>}] } else { if { [lang::message::message_exists_p "en_US" $key] } { # Translation missing in this locale set edit_link [subst {<a class="acs-lang-us_only" href="[ns_quotehtml $edit_url]" title="$key"><adp:icon name="warn" title="Message Key $key: missing in $locale"></a>}] } 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 {<a class="acs-lang-missing" href="[ns_quotehtml $new_url]" title="$key"><adp:icon name="warn" title="Message Key '$key': undefined"></a>}] } } set parsed_template "${before}[::template::adp_parse_tags ${edit_link}]${after}" } } set mime_type [template::get_mime_type] set header_preamble [template::get_mime_header_preamble $mime_type] doc_return 200 $mime_type "$header_preamble$parsed_template" } else { db_release_unused_handles }XQL Not present: Generic, PostgreSQL, Oracle