42 $token = $this->parser->getCurrentToken();
43 while ($this->
isBinary($token) && $this->binaryOperators[$token->getValue()][
'precedence'] >= $precedence) {
44 $op = $this->binaryOperators[$token->getValue()];
45 $this->parser->getStream()->next();
47 if (isset($op[
'callable'])) {
48 $expr = call_user_func($op[
'callable'], $this->parser, $expr);
50 $expr1 = $this->
parseExpression(self::OPERATOR_LEFT === $op[
'associativity'] ? $op[
'precedence'] + 1 : $op[
'precedence']);
52 $expr =
new $class($expr, $expr1, $token->getLine());
55 $token = $this->parser->getCurrentToken();
58 if (0 === $precedence) {
67 $token = $this->parser->getCurrentToken();
70 $operator = $this->unaryOperators[$token->getValue()];
71 $this->parser->getStream()->next();
73 $class = $operator[
'class'];
77 $this->parser->getStream()->next();
90 $this->parser->getStream()->next();
94 $this->parser->getStream()->next();
100 $this->parser->getStream()->next();
123 $token = $this->parser->getCurrentToken();
124 switch ($token->getType()) {
126 $this->parser->getStream()->next();
127 switch ($token->getValue()) {
146 if (
'(' === $this->parser->getCurrentToken()->getValue()) {
155 $this->parser->getStream()->next();
170 throw new Twig_Error_Syntax(sprintf(
'Unexpected token "%s" of value "%s"',
Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine(), $this->parser->getFilename());
179 $stream = $this->parser->getStream();
183 $nextCanBeString =
true;
186 $token = $stream->next();
188 $nextCanBeString =
false;
193 $nextCanBeString =
true;
199 $expr = array_shift($nodes);
200 foreach ($nodes as $node) {
209 $stream = $this->parser->getStream();
234 $stream = $this->parser->getStream();
257 $token = $stream->next();
262 $current = $stream->getCurrent();
264 throw new Twig_Error_Syntax(sprintf(
'A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s"',
Twig_Token::typeToEnglish($current->getType(), $current->getLine()), $current->getValue()), $current->getLine(), $this->parser->getFilename());
270 $node->addElement($value, $key);
280 $token = $this->parser->getCurrentToken();
282 if (
'.' == $token->getValue() ||
'[' == $token->getValue()) {
284 }
elseif (
'|' == $token->getValue()) {
302 if (!count($this->parser->getBlockStack())) {
303 throw new Twig_Error_Syntax(
'Calling "parent" outside a block is forbidden', $line, $this->parser->getFilename());
306 if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
307 throw new Twig_Error_Syntax(
'Calling "parent" on a template that does not extend nor "use" another template is forbidden', $line, $this->parser->getFilename());
315 if (count($args) < 2) {
316 throw new Twig_Error_Syntax(
'The "attribute" function takes at least two arguments (the variable and the attributes)', $line, $this->parser->getFilename());
321 if (null !== $alias = $this->parser->getImportedSymbol(
'function', $name)) {
324 $arguments->addElement($n);
328 $node->setAttribute(
'safe',
true);
336 return new $class($name, $args, $line);
342 $stream = $this->parser->getStream();
343 $token = $stream->next();
344 $lineno = $token->getLine();
347 if ($token->getValue() ==
'.') {
348 $token = $stream->next();
361 $arguments->addElement($n);
365 throw new Twig_Error_Syntax(
'Expected name or number', $lineno, $this->parser->getFilename());
368 if ($node instanceof
Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol(
'template', $node->getAttribute(
'name'))) {
370 throw new Twig_Error_Syntax(sprintf(
'Dynamic macro names are not supported (called on "%s")', $node->getAttribute(
'name')), $token->getLine(), $this->parser->getFilename());
403 $arguments =
new Twig_Node(array($arg, $length));
419 $this->parser->getStream()->next();
438 $node =
new $class($node, $name, $arguments, $token->getLine(), $tag);
444 $this->parser->getStream()->next();
459 $stream = $this->parser->getStream();
476 $token = $stream->next();
478 throw new Twig_Error_Syntax(sprintf(
'A parameter name must be a string, "%s" given', get_class($value)), $token->getLine(), $this->parser->getFilename());
480 $name = $value->getAttribute(
'name');
486 throw new Twig_Error_Syntax(sprintf(
'A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $this->parser->getFilename());
494 if (null === $name) {
495 $name = $value->getAttribute(
'name');
498 $args[$name] = $value;
500 if (null === $name) {
503 $args[$name] = $value;
516 $token = $this->parser->getStream()->expect(
Twig_Token::NAME_TYPE, null,
'Only variables can be assigned to');
517 if (in_array($token->getValue(), array(
'true',
'false',
'none'))) {
518 throw new Twig_Error_Syntax(sprintf(
'You cannot assign a value to "%s"', $token->getValue()), $token->getLine(), $this->parser->getFilename());
525 $this->parser->getStream()->next();
539 $this->parser->getStream()->next();
547 $env = $this->parser->getEnvironment();
549 if (
false === $function = $env->getFunction($name)) {
550 $message = sprintf(
'The function "%s" does not exist', $name);
551 if ($alternatives = $env->computeAlternatives($name, array_keys($env->getFunctions()))) {
552 $message = sprintf(
'%s. Did you mean "%s"', $message, implode(
'", "', $alternatives));
559 return $function->getNodeClass();
567 $env = $this->parser->getEnvironment();
569 if (
false === $filter = $env->getFilter($name)) {
570 $message = sprintf(
'The filter "%s" does not exist', $name);
571 if ($alternatives = $env->computeAlternatives($name, array_keys($env->getFilters()))) {
572 $message = sprintf(
'%s. Did you mean "%s"', $message, implode(
'", "', $alternatives));
579 return $filter->getNodeClass();
592 foreach ($node as $n) {
Represents a template function as a node.
isBinary(Twig_Token $token)
if($rub=fetch_assoc($rub_query)) if(check_if_module_active('url_rewriting')) $class
getFunctionNodeClass($name, $line)
parseSubscriptExpression($node)
getFilterNodeClass($name, $line)
getFunctionNode($name, $line)
parsePostfixExpression($node)
Represents a node in the AST.
Represents a template function.
__construct(Twig_Parser $parser, array $unaryOperators, array $binaryOperators)
parseExpression($precedence=0)
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Default parser implementation.
const INTERPOLATION_END_TYPE
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
static typeToEnglish($type, $line=-1)
Returns the english representation of a given type.
setAttribute($name, $value)
Sets an attribute.
parseFilterExpression($node)
parseAssignmentExpression()
parseMultitargetExpression()
addElement(Twig_Node_Expression $value, Twig_Node_Expression $key=null)
parseConditionalExpression($expr)
Represents a parent node.
Represents a template filter as a node.
Represents a node in the AST.
const INTERPOLATION_START_TYPE
checkConstantExpression(Twig_NodeInterface $node)
getValue()
Gets the token value.
test($type, $values=null)
Tests the current token for a type and/or a value.
Represents a block call node.
Represents a template filter.
parseFilterExpressionRaw($node, $tag=null)
isUnary(Twig_Token $token)
parseArguments($namedArguments=false, $definition=false)
Parses arguments.