Hi Joel,
you are right. But still these messages are returned not using the master template of the OpenACS installation and have a total different look&feel.
I was rather thinking of something like this:
# /wrapper-procs.tcl
ad_library {
}
namespace eval wrapper {}
ad_proc -public wrapper::ad_return_error { msg content } {
Wrapper for error messages
} {
wrap $msg $content
}
ad_proc -public wrapper::ad_return_complaint { msg content } {
Wrapper for complaints
} {
wrap $msg $content
}
ad_proc -public wrapper::wrap_content { content } {
Wrapper for any content
} {
wrap "" $content
}
ad_proc -public wrap { msg content } {
Wraps the error message inside a template page if existent and if a placeholdertag is given.
} {
set message "<h1>$msg</h1><p>$content</p>"
set templatePath [ad_parameter -package_id [wrapper_instance_id] Template wrapper]
if { ![empty_string_p $templatePath] } {
set template [ad_parse_template $templatePath]
set placeholder [ad_parameter TemplatePlaceHolderTag]
set placeholder [ad_parameter -package_id [wrapper_instance_id] TemplatePlaceHolderTag wrapper]
if { ![empty_string_p $placeholder ] } {
set header ""
set footer ""
if {[catch { regexp "^(.*)<$placeholder\[ \n\t\]*/>(.*)$" $template match header footer } err] == 1} {
append $content "<hr><b>Wrapper</b>: Regular expression failed.<hr>"
ad_return_error $msg $content
} else {
set result ""
append result $header $message $footer
doc_return 200 text/html $result
}
} else {
append $content "<hr><b>Wrapper ([wrapper_instance_id])</b>: No PlaceHolder parameter set for the template<hr>"
ad_return_error $msg $content
}
} else {
append $content "<hr><b>Wrapper ([wrapper_instance_id])</b>: Template path error<hr>"
ad_return_error $msg $content
}
}
ad_proc -private wrapper_instance_id {} {
@return The instance of a running wrapper.
} {
return [util_memoize [list db_string acs_kernel_id_get {
select package_id from apm_packages
where package_key = 'wrapper'
} -default 0]]
}
Now what it does is really simple. I created a package called wrapper (a singleton and auto mounted on /wrapper) which has two parameters Template and TemplatePlaceHolderTag (like the Gatekeeper-Package I sent you).
Once installed the wrapper simply wraps ad_return_complaint and ad_return_error inside the master template.
What do you think?
Greetings,
Nima