2013-06-09 22:09:00 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package phpBB3
|
|
|
|
* @copyright (c) 2013 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
if (!defined('IN_PHPBB'))
|
|
|
|
{
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
class phpbb_template_twig_lexer extends Twig_Lexer
|
|
|
|
{
|
|
|
|
protected function lexExpression()
|
|
|
|
{
|
2013-06-09 23:32:39 -05:00
|
|
|
parent::lexExpression();
|
|
|
|
|
|
|
|
// Last element parsed
|
|
|
|
$last_element = end($this->tokens);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check for old fashioned INCLUDE statements without enclosed quotes
|
|
|
|
*/
|
|
|
|
if ($last_element->getValue() === 'INCLUDE')
|
|
|
|
{
|
|
|
|
if (preg_match('#^\s*([a-zA-Z0-9_]+\.[a-zA-Z0-9]+)#', substr($this->code, $this->cursor), $match))
|
|
|
|
{
|
|
|
|
$this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[1]));
|
|
|
|
$this->moveCursor($match[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-09 22:09:00 -05:00
|
|
|
/**
|
|
|
|
* This is some compatibility code to continue supporting expressions such as:
|
|
|
|
* <!-- IF .blah -->
|
|
|
|
*/
|
2013-06-09 23:32:39 -05:00
|
|
|
if ($last_element->getValue() === 'IF')
|
2013-06-09 22:09:00 -05:00
|
|
|
{
|
2013-06-09 23:32:39 -05:00
|
|
|
if (preg_match('#^\s*\.([a-zA-Z0-9\.]+)#', substr($this->code, $this->cursor), $match))
|
|
|
|
{
|
|
|
|
$this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[1]));
|
|
|
|
$this->moveCursor($match[0]);
|
|
|
|
}
|
2013-06-09 22:09:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|