aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-06-18 10:37:25 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-06-18 10:37:25 -0500
commit93d94d5cbe5bd8a713fbfca46d8e44fde169cd19 (patch)
treef7734937f6238587678187997ebcfe43e375d247 /phpBB/includes
parentc5db8be580679427a906a9c44d696cd8d9bfc76e (diff)
downloadforums-93d94d5cbe5bd8a713fbfca46d8e44fde169cd19.tar
forums-93d94d5cbe5bd8a713fbfca46d8e44fde169cd19.tar.gz
forums-93d94d5cbe5bd8a713fbfca46d8e44fde169cd19.tar.bz2
forums-93d94d5cbe5bd8a713fbfca46d8e44fde169cd19.tar.xz
forums-93d94d5cbe5bd8a713fbfca46d8e44fde169cd19.zip
[feature/twig] Setup the style chain/loader properly
PHPBB3-11598
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/template/twig/twig.php44
1 files changed, 26 insertions, 18 deletions
diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php
index 3db873c9ba..a28905ca4e 100644
--- a/phpBB/includes/template/twig/twig.php
+++ b/phpBB/includes/template/twig/twig.php
@@ -111,29 +111,13 @@ class phpbb_template_twig implements phpbb_template
$this->cachepath = $phpbb_root_path . 'cache/twig/';
- // Setup loader with __main__ paths
- $loader = new Twig_Loader_Filesystem(array(
- $phpbb_root_path . 'styles/prosilver/template/',
- ), $this->locator);
-
- // Add core namespace
- $loader->addPath($this->phpbb_root_path . 'styles/prosilver/template/', 'core');
+ // Initiate the loader, __main__ namespace paths will be setup later in set_style_names()
+ $loader = new Twig_Loader_Filesystem('');
// Add admin namespace
// @todo use phpbb_admin path
$loader->addPath($this->phpbb_root_path . 'adm/style/', 'admin');
- // Add all namespaces for all extensions
- if ($this->extension_manager instanceof phpbb_extension_manager)
- {
- foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path)
- {
- // @todo proper style chain
- $loader->addPath($ext_path . 'styles/prosilver/', $ext_namespace);
- $loader->addPath($ext_path . 'styles/all/', $ext_namespace);
- }
- }
-
$this->twig = new Twig_Environment($loader, array(
'cache' => $this->cachepath,
'debug' => true, // @todo
@@ -179,8 +163,32 @@ class phpbb_template_twig implements phpbb_template
{
$this->style_names = $style_names;
+ // Set as __main__ namespace
$this->twig->getLoader()->setPaths($style_paths);
+ // Core style namespace from phpbb_style::set_style()
+ if ($style_names === array($this->user->style['style_path']) || $style_names[0] == $this->user->style['style_path'])
+ {
+ $this->twig->getLoader()->setPaths($style_paths, 'core');
+
+ // Add all namespaces for all extensions
+ if ($this->extension_manager instanceof phpbb_extension_manager)
+ {
+ $style_names[] = 'all';
+
+ foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path)
+ {
+ foreach ($style_names as $style_name)
+ {
+ if (is_dir($ext_path . 'styles/' . $style_name))
+ {
+ $this->twig->getLoader()->addPath($ext_path . 'styles/' . $style_name, $ext_namespace);
+ }
+ }
+ }
+ }
+ }
+
return $this;
}