1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 12:03:21 +01:00

53 lines
1.2 KiB
PHP
Raw Normal View History

<?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()
{
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]);
}
}
/**
* This is some compatibility code to continue supporting expressions such as:
* <!-- IF .blah -->
*/
if ($last_element->getValue() === 'IF')
{
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]);
}
}
}
}