From df46a576e952881df963dcc03daede58dfb98927 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 7 Aug 2011 19:26:28 -0400 Subject: [PATCH] [feature/template-engine] Use template engine class in bbcode class. PHPBB3-9726 --- phpBB/includes/bbcode.php | 23 ++++++----------------- phpBB/includes/template/template.php | 13 +++++++++++++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index a360bcd5d1..c29875dcbf 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -128,28 +128,17 @@ class bbcode */ function bbcode_cache_init() { - global $phpbb_root_path, $template, $user; + global $phpbb_root_path, $phpEx, $template, $config, $user; if (empty($this->template_filename)) { $this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']); - $this->template_filename = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template/bbcode.html'; - if (!@file_exists($this->template_filename)) - { - if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id']) - { - $this->template_filename = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template/bbcode.html'; - if (!@file_exists($this->template_filename)) - { - trigger_error('The file ' . $this->template_filename . ' is missing.', E_USER_ERROR); - } - } - else - { - trigger_error('The file ' . $this->template_filename . ' is missing.', E_USER_ERROR); - } - } + $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user); + $template->set_template(); + $locator = $template->_get_locator(); + $locator->set_filenames(array('bbcode.html' => 'bbcode.html')); + $this->template_filename = $locator->get_source_file_for_handle('bbcode.html'); } $bbcode_ids = $rowset = $sql = array(); diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 5ac9a32724..71fecc7d26 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -493,4 +493,17 @@ class phpbb_template } include($file); } + + /** + * Retrieves the template locator object. + * + * This function is public for the benefit of bbcode implementation. + * It should not be considered part of template class's public API. + * + * @return phpbb_template_locator Template locator for this template + */ + public function _get_locator() + { + return $this->locator; + } }