aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-08-09 23:28:40 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-08-09 23:28:40 -0400
commitacb767f14d6300ebff793f87b1a62ebbb4bde82a (patch)
tree0715813b866c3635ec637d6779a019601c136bfa
parent66232035aa1e0d81d5c8f141b45521998cd7207e (diff)
downloadforums-acb767f14d6300ebff793f87b1a62ebbb4bde82a.tar
forums-acb767f14d6300ebff793f87b1a62ebbb4bde82a.tar.gz
forums-acb767f14d6300ebff793f87b1a62ebbb4bde82a.tar.bz2
forums-acb767f14d6300ebff793f87b1a62ebbb4bde82a.tar.xz
forums-acb767f14d6300ebff793f87b1a62ebbb4bde82a.zip
[feature/template-engine] Dependency inject locator into template.
PHPBB3-9726
-rw-r--r--phpBB/common.php3
-rw-r--r--phpBB/includes/bbcode.php3
-rw-r--r--phpBB/includes/functions_messenger.php3
-rw-r--r--phpBB/includes/template/template.php5
-rw-r--r--tests/template/template_inheritance_test.php3
-rw-r--r--tests/template/template_test_case.php4
6 files changed, 14 insertions, 7 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 67fb5cf6ae..f206dc70fd 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -224,7 +224,8 @@ $config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
-$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user);
+$template_locator = new phpbb_template_locator();
+$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $template_locator);
// Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 85d7459163..482858446c 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -133,7 +133,8 @@ class bbcode
{
$this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']);
- $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user);
+ $template_locator = new phpbb_template_locator();
+ $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $template_locator);
$template->set_template();
$locator = $template->_get_locator();
$locator->set_filenames(array('bbcode.html' => 'bbcode.html'));
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index da7e7cb9e4..507f523866 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -193,7 +193,8 @@ class messenger
// tpl_msg now holds a template object we can use to parse the template file
if (!isset($this->tpl_msg[$template_lang . $template_file]))
{
- $this->tpl_msg[$template_lang . $template_file] = new phpbb_template($phpbb_root_path, $phpEx, $config, $user);
+ $template_locator = new phpbb_template_locator();
+ $this->tpl_msg[$template_lang . $template_file] = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $template_locator);
$tpl = &$this->tpl_msg[$template_lang . $template_file];
$fallback_template_path = false;
diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php
index 80052ba59a..0409b66da6 100644
--- a/phpBB/includes/template/template.php
+++ b/phpBB/includes/template/template.php
@@ -72,14 +72,15 @@ class phpbb_template
*
* @param string $phpbb_root_path phpBB root path
* @param user $user current user
+ * @param phpbb_template_locator $locator template locator
*/
- public function __construct($phpbb_root_path, $phpEx, $config, $user)
+ public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_template_locator $locator)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx;
$this->config = $config;
$this->user = $user;
- $this->locator = new phpbb_template_locator();
+ $this->locator = $locator;
}
/**
diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php
index ed78cc7ee5..d62562ff0d 100644
--- a/tests/template/template_inheritance_test.php
+++ b/tests/template/template_inheritance_test.php
@@ -68,7 +68,8 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t
$this->template_path = dirname(__FILE__) . '/templates';
$this->parent_template_path = dirname(__FILE__) . '/parent_templates';
- $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user);
+ $this->template_locator = new phpbb_template_locator();
+ $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator);
$this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path);
}
}
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index c87b54f973..e475e4012f 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -13,6 +13,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
{
protected $template;
protected $template_path;
+ protected $template_locator;
// Keep the contents of the cache for debugging?
const PRESERVE_CACHE = true;
@@ -41,7 +42,8 @@ class phpbb_template_template_test_case extends phpbb_test_case
$config = new phpbb_config(array_merge($defaults, $new_config));
$this->template_path = dirname(__FILE__) . '/templates';
- $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user);
+ $this->template_locator = new phpbb_template_locator();
+ $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator);
$this->template->set_custom_template($this->template_path, 'tests');
}