Tentative de régler le bordel
This commit is contained in:
@@ -45,13 +45,6 @@ class asset
|
||||
*/
|
||||
public function set_url($url)
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.4.7') < 0 && substr($url, 0, 2) === '//')
|
||||
{
|
||||
// Workaround for PHP 5.4.6 and older bug #62844 - add fake scheme and then remove it
|
||||
$this->components = parse_url('http:' . $url);
|
||||
$this->components['scheme'] = '';
|
||||
return;
|
||||
}
|
||||
$this->components = parse_url($url);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class context
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreive a single scalar value from a single key.
|
||||
* Retrieve a single scalar value from a single key.
|
||||
*
|
||||
* @param string $varname Variable name
|
||||
* @return mixed Variable value, or null if not set
|
||||
@@ -149,7 +149,7 @@ class context
|
||||
{
|
||||
// If the key name is lowercase and the data is an array,
|
||||
// it could be a template loop. So we set the S_NUM_ROWS there
|
||||
// aswell.
|
||||
// as well.
|
||||
if ($sub_block_name === strtolower($sub_block_name) && is_array($sub_block))
|
||||
{
|
||||
$this->set_num_rows($sub_block);
|
||||
|
||||
@@ -136,7 +136,7 @@ interface template
|
||||
public function retrieve_vars(array $vararray);
|
||||
|
||||
/**
|
||||
* Retreive a single scalar value from a single key.
|
||||
* Retrieve a single scalar value from a single key.
|
||||
*
|
||||
* @param string $varname Variable name
|
||||
* @return mixed Variable value, or null if not set
|
||||
|
||||
@@ -18,6 +18,9 @@ class extension extends \Twig_Extension
|
||||
/** @var \phpbb\template\context */
|
||||
protected $context;
|
||||
|
||||
/** @var \phpbb\template\twig\environment */
|
||||
protected $environment;
|
||||
|
||||
/** @var \phpbb\language\language */
|
||||
protected $language;
|
||||
|
||||
@@ -25,12 +28,13 @@ class extension extends \Twig_Extension
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\template\context $context
|
||||
* @param \phpbb\template\twig\environment $environment
|
||||
* @param \phpbb\language\language $language
|
||||
* @return \phpbb\template\twig\extension
|
||||
*/
|
||||
public function __construct(\phpbb\template\context $context, $language)
|
||||
public function __construct(\phpbb\template\context $context, \phpbb\template\twig\environment $environment, $language)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->environment = $environment;
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
@@ -56,9 +60,9 @@ class extension extends \Twig_Extension
|
||||
new \phpbb\template\twig\tokenparser\includeparser,
|
||||
new \phpbb\template\twig\tokenparser\includejs,
|
||||
new \phpbb\template\twig\tokenparser\includecss,
|
||||
new \phpbb\template\twig\tokenparser\event,
|
||||
new \phpbb\template\twig\tokenparser\includephp,
|
||||
new \phpbb\template\twig\tokenparser\php,
|
||||
new \phpbb\template\twig\tokenparser\event($this->environment),
|
||||
new \phpbb\template\twig\tokenparser\includephp($this->environment),
|
||||
new \phpbb\template\twig\tokenparser\php($this->environment),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,6 +89,8 @@ class extension extends \Twig_Extension
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFunction('lang', array($this, 'lang')),
|
||||
new \Twig_SimpleFunction('lang_defined', array($this, 'lang_defined')),
|
||||
new \Twig_SimpleFunction('get_class', 'get_class'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,7 +142,7 @@ class extension extends \Twig_Extension
|
||||
*
|
||||
* @return mixed The sliced variable
|
||||
*/
|
||||
function loop_subset(\Twig_Environment $env, $item, $start, $end = null, $preserveKeys = false)
|
||||
public function loop_subset(\Twig_Environment $env, $item, $start, $end = null, $preserveKeys = false)
|
||||
{
|
||||
// We do almost the same thing as Twig's slice (array_slice), except when $end is positive
|
||||
if ($end >= 1)
|
||||
@@ -165,7 +171,7 @@ class extension extends \Twig_Extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function lang()
|
||||
public function lang()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$key = $args[0];
|
||||
@@ -182,4 +188,14 @@ class extension extends \Twig_Extension
|
||||
|
||||
return call_user_func_array(array($this->language, 'lang'), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a language variable exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function lang_defined($key)
|
||||
{
|
||||
return call_user_func_array([$this->language, 'is_set'], [$key]);
|
||||
}
|
||||
}
|
||||
|
||||
80
phpbb/template/twig/extension/avatar.php
Normal file
80
phpbb/template/twig/extension/avatar.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\template\twig\extension;
|
||||
|
||||
class avatar extends \Twig_Extension
|
||||
{
|
||||
/**
|
||||
* Get the name of this extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'avatar';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of global functions to add to the existing list.
|
||||
*
|
||||
* @return array An array of global functions
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFunction('avatar', array($this, 'get_avatar')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get avatar for placing into templates.
|
||||
*
|
||||
* How to use in a template:
|
||||
* - {{ avatar('mode', row, alt, ignore_config, lazy) }}
|
||||
*
|
||||
* The mode and row (group_row or user_row) are required.
|
||||
* The other fields (alt|ignore_config|lazy) are optional.
|
||||
*
|
||||
* @uses \phpbb_get_group_avatar()
|
||||
* @uses \phpbb_get_user_avatar()
|
||||
*
|
||||
* @return string The avatar HTML for the specified mode
|
||||
*/
|
||||
public function get_avatar()
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
$mode = (string) $args[0];
|
||||
$row = (array) $args[1];
|
||||
$alt = isset($args[2]) ? (string) $args[2] : false;
|
||||
$ignore_config = isset($args[3]) ? (bool) $args[3] : false;
|
||||
$lazy = isset($args[4]) ? (bool) $args[4] : false;
|
||||
|
||||
// To prevent having to redefine alt attribute ('USER_AVATAR'|'GROUP_AVATAR'), we check if an alternative has been provided
|
||||
switch ($mode)
|
||||
{
|
||||
case 'group':
|
||||
return $alt ? phpbb_get_group_avatar($row, $alt, $ignore_config, $lazy) : phpbb_get_group_avatar($row);
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
return $alt ? phpbb_get_user_avatar($row, $alt, $ignore_config, $lazy) : phpbb_get_user_avatar($row);
|
||||
break;
|
||||
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
64
phpbb/template/twig/extension/config.php
Normal file
64
phpbb/template/twig/extension/config.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\template\twig\extension;
|
||||
|
||||
class config extends \Twig_Extension
|
||||
{
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \phpbb\config\config $config Configuration object
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'config';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of global functions to add to the existing list.
|
||||
*
|
||||
* @return array An array of global functions
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFunction('config', array($this, 'get_config')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a configuration value for use in templates.
|
||||
*
|
||||
* @return string The configuration value
|
||||
*/
|
||||
public function get_config()
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
return $this->config->offsetGet($args[0]);
|
||||
}
|
||||
}
|
||||
84
phpbb/template/twig/extension/username.php
Normal file
84
phpbb/template/twig/extension/username.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\template\twig\extension;
|
||||
|
||||
class username extends \Twig_Extension
|
||||
{
|
||||
/**
|
||||
* Get the name of this extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'username';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of global functions to add to the existing list.
|
||||
*
|
||||
* @return array An array of global functions
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFunction('username', array($this, 'get_username')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get username details for placing into templates.
|
||||
*
|
||||
* How to use in a template:
|
||||
* - {{ username('mode', user_id, username, user_colour, guest_username, custom_profile_url) }}
|
||||
* - {{ username('mode', user_row, guest_username, custom_profile_url) }}
|
||||
* It's possible to provide the user identifier, name and colour separately,
|
||||
* or provide the entire user row at once as an array.
|
||||
*
|
||||
* The mode, user_id and username are required (separately or through a user row).
|
||||
* The other fields (user_colour|guest_username|custom_profile_url) are optional.
|
||||
*
|
||||
* @uses \get_username_string()
|
||||
*
|
||||
* @return string A string based on what is wanted depending on $mode
|
||||
*/
|
||||
public function get_username()
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
$mode = $args[0];
|
||||
$user = $args[1];
|
||||
|
||||
// If the entire user row is provided
|
||||
if (is_array($user))
|
||||
{
|
||||
$user_id = isset($user['user_id']) ? $user['user_id'] : '';
|
||||
$username = isset($user['username']) ? $user['username'] : '';
|
||||
$user_colour = isset($user['user_colour']) ? $user['user_colour'] : '';
|
||||
$guest_username = isset($args[2]) ? $args[2] : false;
|
||||
$custom_profile_url = isset($args[3]) ? $args[3] : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Options are provided separately
|
||||
$user_id = $user;
|
||||
$username = $args[2];
|
||||
$user_colour = isset($args[3]) ? $args[3] : '';
|
||||
$guest_username = isset($args[4]) ? $args[4] : false;
|
||||
$custom_profile_url = isset($args[5]) ? $args[5] : false;
|
||||
}
|
||||
|
||||
return get_username_string($mode, $user_id, $username, $user_colour, $guest_username, $custom_profile_url);
|
||||
}
|
||||
}
|
||||
@@ -15,20 +15,10 @@ namespace phpbb\template\twig;
|
||||
|
||||
class lexer extends \Twig_Lexer
|
||||
{
|
||||
public function set_environment(\Twig_Environment $env)
|
||||
public function tokenize(\Twig_Source $source)
|
||||
{
|
||||
$this->env = $env;
|
||||
}
|
||||
|
||||
public function tokenize($code, $filename = null)
|
||||
{
|
||||
// Handle \Twig_Source format input
|
||||
if ($code instanceof \Twig_Source)
|
||||
{
|
||||
$source = $code;
|
||||
$code = $source->getCode();
|
||||
$filename = $source->getName();
|
||||
}
|
||||
$code = $source->getCode();
|
||||
$filename = $source->getName();
|
||||
|
||||
// Our phpBB tags
|
||||
// Commented out tokens are handled separately from the main replace
|
||||
|
||||
@@ -35,7 +35,7 @@ class loader extends \Twig_Loader_Filesystem
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
|
||||
parent::__construct($paths, $this->filesystem->realpath(dirname(__FILE__)));
|
||||
parent::__construct($paths, __DIR__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ class loader extends \Twig_Loader_Filesystem
|
||||
* Override for Twig_Loader_Filesystem::findTemplate to add support
|
||||
* for loading from safe directories.
|
||||
*/
|
||||
protected function findTemplate($name)
|
||||
protected function findTemplate($name, $throw = true)
|
||||
{
|
||||
$name = (string) $name;
|
||||
|
||||
@@ -132,12 +132,12 @@ class loader extends \Twig_Loader_Filesystem
|
||||
|
||||
// First, find the template name. The override above of validateName
|
||||
// causes the validateName process to be skipped for this call
|
||||
$file = parent::findTemplate($name);
|
||||
$file = parent::findTemplate($name, $throw);
|
||||
|
||||
try
|
||||
{
|
||||
// Try validating the name (which may throw an exception)
|
||||
parent::validateName($name);
|
||||
$this->validateName($name);
|
||||
}
|
||||
catch (\Twig_Error_Loader $e)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace phpbb\template\twig\node;
|
||||
|
||||
class definenode extends \Twig_Node
|
||||
{
|
||||
public function __construct($capture, \Twig_NodeInterface $name, \Twig_NodeInterface $value, $lineno, $tag = null)
|
||||
public function __construct($capture, \Twig_Node $name, \Twig_Node $value, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('name' => $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag);
|
||||
}
|
||||
|
||||
@@ -15,15 +15,11 @@ namespace phpbb\template\twig\node;
|
||||
|
||||
abstract class includeasset extends \Twig_Node
|
||||
{
|
||||
/** @var \Twig_Environment */
|
||||
protected $environment;
|
||||
|
||||
public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null)
|
||||
public function __construct(\Twig_Node_Expression $expr, $lineno, $tag = null)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
|
||||
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
@@ -33,20 +29,18 @@ abstract class includeasset extends \Twig_Node
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
$config = $this->environment->get_phpbb_config();
|
||||
|
||||
$compiler
|
||||
->write("\$asset_file = ")
|
||||
->subcompile($this->getNode('expr'))
|
||||
->raw(";\n")
|
||||
->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper(), \$this->getEnvironment()->get_filesystem());\n")
|
||||
->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->env->get_path_helper(), \$this->env->get_filesystem());\n")
|
||||
->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")
|
||||
->indent()
|
||||
->write("\$asset_path = \$asset->get_path();")
|
||||
->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n")
|
||||
->write("\$local_file = \$this->env->get_phpbb_root_path() . \$asset_path;\n")
|
||||
->write("if (!file_exists(\$local_file)) {\n")
|
||||
->indent()
|
||||
->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n")
|
||||
->write("\$local_file = \$this->env->findTemplate(\$asset_path);\n")
|
||||
->write("\$asset->set_path(\$local_file, true);\n")
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
@@ -55,10 +49,10 @@ abstract class includeasset extends \Twig_Node
|
||||
->write("\n")
|
||||
->write("if (\$asset->is_relative()) {\n")
|
||||
->indent()
|
||||
->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
|
||||
->write("\$asset->add_assets_version(\$this->env->get_phpbb_config()['assets_version']);\n")
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
->write("\$this->getEnvironment()->get_assets_bag()->add_{$this->get_setters_name()}(\$asset);")
|
||||
->write("\$this->env->get_assets_bag()->add_{$this->get_setters_name()}(\$asset);")
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,15 +63,15 @@ class includephp extends \Twig_Node
|
||||
// Absolute path specified
|
||||
->write("require(\$location);\n")
|
||||
->outdent()
|
||||
->write("} else if (file_exists(\$this->getEnvironment()->get_phpbb_root_path() . \$location)) {\n")
|
||||
->write("} else if (file_exists(\$this->env->get_phpbb_root_path() . \$location)) {\n")
|
||||
->indent()
|
||||
// PHP file relative to phpbb_root_path
|
||||
->write("require(\$this->getEnvironment()->get_phpbb_root_path() . \$location);\n")
|
||||
->write("require(\$this->env->get_phpbb_root_path() . \$location);\n")
|
||||
->outdent()
|
||||
->write("} else {\n")
|
||||
->indent()
|
||||
// Local path (behaves like INCLUDE)
|
||||
->write("require(\$this->getEnvironment()->getLoader()->getCacheKey(\$location));\n")
|
||||
->write("require(\$this->env->getLoader()->getCacheKey(\$location));\n")
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
;
|
||||
|
||||
@@ -21,7 +21,7 @@ class defineparser extends \Twig_TokenParser
|
||||
*
|
||||
* @param \Twig_Token $token A Twig_Token instance
|
||||
*
|
||||
* @return \Twig_NodeInterface A Twig_NodeInterface instance
|
||||
* @return \Twig_Node A Twig_Node instance
|
||||
* @throws \Twig_Error_Syntax
|
||||
* @throws \phpbb\template\twig\node\definenode
|
||||
*/
|
||||
@@ -41,7 +41,7 @@ class defineparser extends \Twig_TokenParser
|
||||
{
|
||||
// This would happen if someone improperly formed their DEFINE syntax
|
||||
// e.g. <!-- DEFINE $VAR = foo -->
|
||||
throw new \Twig_Error_Syntax('Invalid DEFINE', $token->getLine(), $this->parser->getFilename());
|
||||
throw new \Twig_Error_Syntax('Invalid DEFINE', $token->getLine(), $this->parser->getStream()->getSourceContext()->getPath());
|
||||
}
|
||||
|
||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
@@ -15,12 +15,25 @@ namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
class event extends \Twig_TokenParser
|
||||
{
|
||||
/** @var \phpbb\template\twig\environment */
|
||||
protected $environment;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\template\twig\environment $environment
|
||||
*/
|
||||
public function __construct(\phpbb\template\twig\environment $environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param \Twig_Token $token A Twig_Token instance
|
||||
*
|
||||
* @return \Twig_NodeInterface A Twig_NodeInterface instance
|
||||
* @return \Twig_Node A Twig_Node instance
|
||||
*/
|
||||
public function parse(\Twig_Token $token)
|
||||
{
|
||||
@@ -29,7 +42,7 @@ class event extends \Twig_TokenParser
|
||||
$stream = $this->parser->getStream();
|
||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
return new \phpbb\template\twig\node\event($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag());
|
||||
return new \phpbb\template\twig\node\event($expr, $this->environment, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ class includecss extends \Twig_TokenParser
|
||||
*
|
||||
* @param \Twig_Token $token A Twig_Token instance
|
||||
*
|
||||
* @return \Twig_NodeInterface A Twig_NodeInterface instance
|
||||
* @return \Twig_Node A Twig_Node instance
|
||||
*/
|
||||
public function parse(\Twig_Token $token)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ class includecss extends \Twig_TokenParser
|
||||
$stream = $this->parser->getStream();
|
||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
return new \phpbb\template\twig\node\includecss($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag());
|
||||
return new \phpbb\template\twig\node\includecss($expr, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ class includejs extends \Twig_TokenParser
|
||||
*
|
||||
* @param \Twig_Token $token A Twig_Token instance
|
||||
*
|
||||
* @return \Twig_NodeInterface A Twig_NodeInterface instance
|
||||
* @return \Twig_Node A Twig_Node instance
|
||||
*/
|
||||
public function parse(\Twig_Token $token)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ class includejs extends \Twig_TokenParser
|
||||
$stream = $this->parser->getStream();
|
||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
return new \phpbb\template\twig\node\includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag());
|
||||
return new \phpbb\template\twig\node\includejs($expr, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ class includeparser extends \Twig_TokenParser_Include
|
||||
*
|
||||
* @param \Twig_Token $token A Twig_Token instance
|
||||
*
|
||||
* @return \Twig_NodeInterface A Twig_NodeInterface instance
|
||||
* @return \Twig_Node A Twig_Node instance
|
||||
*/
|
||||
public function parse(\Twig_Token $token)
|
||||
{
|
||||
|
||||
@@ -16,12 +16,25 @@ namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
class includephp extends \Twig_TokenParser
|
||||
{
|
||||
/** @var \phpbb\template\twig\environment */
|
||||
protected $environment;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\template\twig\environment $environment
|
||||
*/
|
||||
public function __construct(\phpbb\template\twig\environment $environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param \Twig_Token $token A Twig_Token instance
|
||||
*
|
||||
* @return \Twig_NodeInterface A Twig_NodeInterface instance
|
||||
* @return \Twig_Node A Twig_Node instance
|
||||
*/
|
||||
public function parse(\Twig_Token $token)
|
||||
{
|
||||
@@ -40,7 +53,7 @@ class includephp extends \Twig_TokenParser
|
||||
|
||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
return new \phpbb\template\twig\node\includephp($expr, $this->parser->getEnvironment(), $token->getLine(), $ignoreMissing, $this->getTag());
|
||||
return new \phpbb\template\twig\node\includephp($expr, $this->environment, $token->getLine(), $ignoreMissing, $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,12 +15,25 @@ namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
class php extends \Twig_TokenParser
|
||||
{
|
||||
/** @var \phpbb\template\twig\environment */
|
||||
protected $environment;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\template\twig\environment $environment
|
||||
*/
|
||||
public function __construct(\phpbb\template\twig\environment $environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @param \Twig_Token $token A Twig_Token instance
|
||||
*
|
||||
* @return \Twig_NodeInterface A Twig_NodeInterface instance
|
||||
* @return \Twig_Node A Twig_Node instance
|
||||
*/
|
||||
public function parse(\Twig_Token $token)
|
||||
{
|
||||
@@ -32,7 +45,7 @@ class php extends \Twig_TokenParser
|
||||
|
||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
return new \phpbb\template\twig\node\php($body, $this->parser->getEnvironment(), $token->getLine(), $this->getTag());
|
||||
return new \phpbb\template\twig\node\php($body, $this->environment, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
public function decideEnd(\Twig_Token $token)
|
||||
|
||||
Reference in New Issue
Block a user