summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Template.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-03-01 02:33:29 +0100
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-03-01 02:33:29 +0100
commit78be753e3be38903b0eeb81e36a7c51704bc6cf3 (patch)
tree295e7a99a07ed742872570d1ecf72f4312978109 /Bugzilla/Template.pm
parent5080ecd2f4c2711b228127e1c12647906d37f3bd (diff)
downloadbugzilla-78be753e3be38903b0eeb81e36a7c51704bc6cf3.tar.gz
bugzilla-78be753e3be38903b0eeb81e36a7c51704bc6cf3.tar.xz
Bug 508823: Make it so that you don't ever have to reset template_inner (like
Bugzilla->template_inner("")). r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/Template.pm')
-rw-r--r--Bugzilla/Template.pm23
1 files changed, 20 insertions, 3 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 44282e4bc..79382ece2 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -84,9 +84,9 @@ sub _load_constants {
# settings of the user and of the available languages
# If no Accept-Language is present it uses the defined default
# Templates may also be found in the extensions/ tree
-sub getTemplateIncludePath {
+sub _include_path {
+ my $lang = shift || '';
my $cache = Bugzilla->request_cache;
- my $lang = $cache->{'language'} || '';
$cache->{"template_include_path_$lang"} ||=
template_include_path({ language => $lang });
return $cache->{"template_include_path_$lang"};
@@ -428,6 +428,17 @@ $Template::Stash::SCALAR_OPS->{ truncate } =
###############################################################################
+sub process {
+ my $self = shift;
+ # All of this current_langs stuff allows template_inner to correctly
+ # determine what-language Template object it should instantiate.
+ my $current_langs = Bugzilla->request_cache->{template_current_lang} ||= [];
+ unshift(@$current_langs, $self->context->{bz_language});
+ my $retval = $self->SUPER::process(@_);
+ shift @$current_langs;
+ return $retval;
+}
+
# Construct the Template object
# Note that all of the failure cases here can't use templateable errors,
@@ -442,7 +453,8 @@ sub create {
my $config = {
# Colon-separated list of directories containing templates.
- INCLUDE_PATH => $opts{'include_path'} || getTemplateIncludePath(),
+ INCLUDE_PATH => $opts{'include_path'}
+ || _include_path($opts{'language'}),
# Remove white-space before template directives (PRE_CHOMP) and at the
# beginning and end of templates and template blocks (TRIM) for better
@@ -787,6 +799,11 @@ sub create {
Bugzilla::Hook::process('template_before_create', { config => $config });
my $template = $class->new($config)
|| die("Template creation failed: " . $class->error());
+
+ # Pass on our current language to any template hooks or inner templates
+ # called by this Template object.
+ $template->context->{bz_language} = $opts{language} || '';
+
return $template;
}