aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-06-24 22:37:58 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-06-24 22:37:58 -0500
commit3ca99f8122c149a66f59dbf3c9884c095db7ad3c (patch)
tree9c7d28a32673b39fb1af9dc4af1ee845f44d0fa8 /phpBB
parent814d57d201d654ce0510ede5b43cfad6b06d372e (diff)
downloadforums-3ca99f8122c149a66f59dbf3c9884c095db7ad3c.tar
forums-3ca99f8122c149a66f59dbf3c9884c095db7ad3c.tar.gz
forums-3ca99f8122c149a66f59dbf3c9884c095db7ad3c.tar.bz2
forums-3ca99f8122c149a66f59dbf3c9884c095db7ad3c.tar.xz
forums-3ca99f8122c149a66f59dbf3c9884c095db7ad3c.zip
[feature/twig] Append assets_version to includejs tag
Some fixes for main template parser PHPBB3-11598
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/template/twig/environment.php26
-rw-r--r--phpBB/includes/template/twig/node/event.php1
-rw-r--r--phpBB/includes/template/twig/node/includejs.php11
-rw-r--r--phpBB/includes/template/twig/tokenparser/includejs.php2
-rw-r--r--phpBB/includes/template/twig/twig.php21
5 files changed, 49 insertions, 12 deletions
diff --git a/phpBB/includes/template/twig/environment.php b/phpBB/includes/template/twig/environment.php
index 4c7f0002ba..616321e15a 100644
--- a/phpBB/includes/template/twig/environment.php
+++ b/phpBB/includes/template/twig/environment.php
@@ -20,6 +20,9 @@ class phpbb_template_twig_environment extends Twig_Environment
/** @var array */
protected $phpbbExtensions;
+ /** @var phpbb_config */
+ protected $phpbbConfig;
+
/** @var array **/
protected $namespaceLookUpOrder = array('__main__');
@@ -63,6 +66,29 @@ class phpbb_template_twig_environment extends Twig_Environment
}
/**
+ * Get phpBB config
+ *
+ * @return phpbb_config
+ */
+ public function get_phpbb_config()
+ {
+ return $this->phpbbConfig;
+ }
+
+ /**
+ * Set phpBB config
+ *
+ * @param phpbb_config $config
+ * @return Twig_Environment
+ */
+ public function set_phpbb_config($config)
+ {
+ $this->phpbbConfig = $config;
+
+ return $this;
+ }
+
+ /**
* Get the namespace look up order
*
* @return array
diff --git a/phpBB/includes/template/twig/node/event.php b/phpBB/includes/template/twig/node/event.php
index 12e6ef1329..358c68dae5 100644
--- a/phpBB/includes/template/twig/node/event.php
+++ b/phpBB/includes/template/twig/node/event.php
@@ -9,6 +9,7 @@
class phpbb_template_twig_node_event extends Twig_Node
{
+ /** @var Twig_Environment */
protected $environment;
public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $lineno, $tag = null)
diff --git a/phpBB/includes/template/twig/node/includejs.php b/phpBB/includes/template/twig/node/includejs.php
index 881636a326..f4c26affa4 100644
--- a/phpBB/includes/template/twig/node/includejs.php
+++ b/phpBB/includes/template/twig/node/includejs.php
@@ -9,8 +9,13 @@
class phpbb_template_twig_node_includejs extends Twig_Node
{
- public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
+ /** @var Twig_Environment */
+ protected $environment;
+
+ public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $lineno, $tag = null)
{
+ $this->environment = $environment;
+
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
}
@@ -23,10 +28,12 @@ class phpbb_template_twig_node_includejs extends Twig_Node
{
$compiler->addDebugInfo($this);
+ $config = $this->environment->get_phpbb_config();
+
$compiler
->write("\$context['SCRIPTS'] .= '<script type=\"text/javascript\" src=\"' . ")
->subcompile($this->getNode('expr'))
- ->raw(" . '\">';\n\n")
+ ->raw(" . '?assets_version=" . $config['assets_version'] . "\"></script>';\n\n")
;
}
}
diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/includes/template/twig/tokenparser/includejs.php
index efa8692f4b..0b46f315d2 100644
--- a/phpBB/includes/template/twig/tokenparser/includejs.php
+++ b/phpBB/includes/template/twig/tokenparser/includejs.php
@@ -23,7 +23,7 @@ class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser
$stream = $this->parser->getStream();
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- return new phpbb_template_twig_node_includejs($expr, $token->getLine(), $this->getTag());
+ return new phpbb_template_twig_node_includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag());
}
/**
diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php
index e2c9afbc78..af8ab615e6 100644
--- a/phpBB/includes/template/twig/twig.php
+++ b/phpBB/includes/template/twig/twig.php
@@ -127,6 +127,9 @@ class phpbb_template_twig implements phpbb_template
$this->twig->set_phpbb_extensions($this->extension_manager->all_enabled());
}
+ // Set config
+ $this->twig->set_phpbb_config($this->config);
+
// Clear previous cache files (while WIP)
// @todo remove
$this->clear_cache();
@@ -187,7 +190,7 @@ class phpbb_template_twig implements phpbb_template
// Add admin namespace
// @todo use phpbb_admin path
- $loader->addPath($this->phpbb_root_path . 'adm/style/', 'admin');
+ $this->twig->getLoader()->addPath($this->phpbb_root_path . 'adm/style/', 'admin');
// Add all namespaces for all extensions
if ($this->extension_manager instanceof phpbb_extension_manager)
@@ -439,16 +442,16 @@ class phpbb_template_twig implements phpbb_template
$vars['L_' . strtoupper($key)] = $value;
$vars['LA_' . strtoupper($key)] = addslashes($value);
}
-
- $vars = array_merge(
- $vars,
- $this->context->get_rootref(),
- array(
- '_phpbb_blocks' => $this->context->get_tpldata(),
- )
- );
}
+ $vars = array_merge(
+ $vars,
+ $this->context->get_rootref(),
+ array(
+ '_phpbb_blocks' => $this->context->get_tpldata(),
+ )
+ );
+
// Must do this so that <!-- IF .blah --> works correctly
// (only for the base loops, the rest are properly handled by the begin node)
foreach ($this->context->get_tpldata() as $block_name => $block_values)