aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/template/twig/node
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/template/twig/node')
-rw-r--r--phpBB/phpbb/template/twig/node/event.php6
-rw-r--r--phpBB/phpbb/template/twig/node/includeasset.php32
-rw-r--r--phpBB/phpbb/template/twig/node/includecss.php16
-rw-r--r--phpBB/phpbb/template/twig/node/includejs.php18
4 files changed, 18 insertions, 54 deletions
diff --git a/phpBB/phpbb/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php
index b765bde98d..11fdb75247 100644
--- a/phpBB/phpbb/template/twig/node/event.php
+++ b/phpBB/phpbb/template/twig/node/event.php
@@ -46,7 +46,7 @@ class event extends \Twig_Node
{
$ext_namespace = str_replace('/', '_', $ext_namespace);
- if (defined('DEBUG'))
+ if ($this->environment->isDebug())
{
// If debug mode is enabled, lets check for new/removed EVENT
// templates on page load rather than at compile. This is
@@ -58,7 +58,7 @@ class event extends \Twig_Node
;
}
- if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
+ if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
{
$compiler
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")
@@ -70,7 +70,7 @@ class event extends \Twig_Node
;
}
- if (defined('DEBUG'))
+ if ($this->environment->isDebug())
{
$compiler
->outdent()
diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php
index 15195a226b..12034b7820 100644
--- a/phpBB/phpbb/template/twig/node/includeasset.php
+++ b/phpBB/phpbb/template/twig/node/includeasset.php
@@ -39,7 +39,7 @@ abstract class includeasset extends \Twig_Node
->write("\$asset_file = ")
->subcompile($this->getNode('expr'))
->raw(";\n")
- ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper());\n")
+ ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper(), \$this->getEnvironment()->get_filesystem());\n")
->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")
->indent()
->write("\$asset_path = \$asset->get_path();")
@@ -49,33 +49,23 @@ abstract class includeasset extends \Twig_Node
->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n")
->write("\$asset->set_path(\$local_file, true);\n")
->outdent()
- ->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
- ->write("\$asset_file = \$asset->get_url();\n")
->write("}\n")
->outdent()
->write("}\n")
- ->write("\$context['definition']->append('{$this->get_definition_name()}', '")
- ;
-
- $this->append_asset($compiler);
-
- $compiler
- ->raw("\n');\n")
+ ->write("\n")
+ ->write("if (\$asset->is_relative()) {\n")
+ ->indent()
+ ->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
+ ->outdent()
+ ->write("}\n")
+ ->write("\$this->getEnvironment()->get_assets_bag()->add_{$this->get_setters_name()}(\$asset);")
;
}
/**
- * Get the definition name
- *
- * @return string (e.g. 'SCRIPTS')
- */
- abstract public function get_definition_name();
-
- /**
- * Append the output code for the asset
+ * Get the name of the assets bag setter
*
- * @param \Twig_Compiler A Twig_Compiler instance
- * @return null
+ * @return string (e.g. 'script')
*/
- abstract protected function append_asset(\Twig_Compiler $compiler);
+ abstract public function get_setters_name();
}
diff --git a/phpBB/phpbb/template/twig/node/includecss.php b/phpBB/phpbb/template/twig/node/includecss.php
index 2dac154036..2e97d4972d 100644
--- a/phpBB/phpbb/template/twig/node/includecss.php
+++ b/phpBB/phpbb/template/twig/node/includecss.php
@@ -18,20 +18,8 @@ class includecss extends \phpbb\template\twig\node\includeasset
/**
* {@inheritdoc}
*/
- public function get_definition_name()
+ public function get_setters_name()
{
- return 'STYLESHEETS';
- }
-
- /**
- * {@inheritdoc}
- */
- public function append_asset(\Twig_Compiler $compiler)
- {
- $compiler
- ->raw("<link href=\"' . ")
- ->raw("\$asset_file . '\"")
- ->raw(' rel="stylesheet" type="text/css" media="screen" />')
- ;
+ return 'stylesheet';
}
}
diff --git a/phpBB/phpbb/template/twig/node/includejs.php b/phpBB/phpbb/template/twig/node/includejs.php
index 0f67f9ff60..505b49757b 100644
--- a/phpBB/phpbb/template/twig/node/includejs.php
+++ b/phpBB/phpbb/template/twig/node/includejs.php
@@ -18,22 +18,8 @@ class includejs extends \phpbb\template\twig\node\includeasset
/**
* {@inheritdoc}
*/
- public function get_definition_name()
+ public function get_setters_name()
{
- return 'SCRIPTS';
- }
-
- /**
- * {@inheritdoc}
- */
- protected function append_asset(\Twig_Compiler $compiler)
- {
- $config = $this->environment->get_phpbb_config();
-
- $compiler
- ->raw("<script type=\"text/javascript\" src=\"' . ")
- ->raw("\$asset_file")
- ->raw(". '\"></script>\n")
- ;
+ return 'script';
}
}