52 return sprintf(
'__internal_%s', hash(
'sha1', uniqid(mt_rand(),
true),
false));
57 return $this->stream->getFilename();
70 $vars = get_object_vars($this);
71 unset($vars[
'stack'], $vars[
'env'], $vars[
'handlers'], $vars[
'visitors'], $vars[
'expressionParser']);
72 $this->stack[] = $vars;
75 if (null === $this->handlers) {
76 $this->handlers = $this->env->getTokenParsers();
77 $this->handlers->setParser($this);
81 if (null === $this->visitors) {
82 $this->visitors = $this->env->getNodeVisitors();
85 if (null === $this->expressionParser) {
86 $this->expressionParser =
new Twig_ExpressionParser($this, $this->env->getUnaryOperators(), $this->env->getBinaryOperators());
91 $this->blocks = array();
92 $this->macros = array();
93 $this->traits = array();
94 $this->blockStack = array();
95 $this->importedSymbols = array(array());
96 $this->embeddedTemplates = array();
99 $body = $this->
subparse($test, $dropNeedle);
101 if (null !== $this->parent) {
122 $node = $traverser->traverse($node);
125 foreach (array_pop($this->stack) as $key => $val) {
132 public function subparse($test, $dropNeedle =
false)
136 while (!$this->stream->isEOF()) {
139 $token = $this->stream->next();
140 $rv[] =
new Twig_Node_Text($token->getValue(), $token->getLine());
144 $token = $this->stream->next();
145 $expr = $this->expressionParser->parseExpression();
151 $this->stream->next();
158 if (null !== $test && call_user_func($test, $token)) {
160 $this->stream->next();
163 if (1 === count($rv)) {
167 return new Twig_Node($rv, array(), $lineno);
170 $subparser = $this->handlers->getTokenParser($token->getValue());
171 if (null === $subparser) {
172 if (null !== $test) {
173 $error = sprintf(
'Unexpected tag name "%s"', $token->getValue());
175 $error .= sprintf(
' (expecting closing tag for the "%s" tag defined near line %s)', $test[0]->getTag(), $lineno);
181 $message = sprintf(
'Unknown tag name "%s"', $token->getValue());
182 if ($alternatives = $this->env->computeAlternatives($token->getValue(), array_keys($this->env->getTags()))) {
183 $message = sprintf(
'%s. Did you mean "%s"', $message, implode(
'", "', $alternatives));
189 $this->stream->next();
191 $node = $subparser->parse($token);
192 if (null !== $node) {
202 if (1 === count($rv)) {
206 return new Twig_Node($rv, array(), $lineno);
211 $this->handlers[$name] =
$class;
216 $this->visitors[] = $visitor;
226 return $this->blockStack[count($this->blockStack) - 1];
231 array_pop($this->blockStack);
236 $this->blockStack[] = $name;
241 return isset($this->blocks[$name]);
246 return $this->blocks[$name];
251 $this->blocks[$name] =
new Twig_Node_Body(array($value), array(), $value->getLine());
256 return isset($this->macros[$name]);
261 if (null === $this->reservedMacroNames) {
262 $this->reservedMacroNames = array();
263 $r =
new ReflectionClass($this->env->getBaseTemplateClass());
264 foreach ($r->getMethods() as $method) {
265 $this->reservedMacroNames[] = $method->getName();
269 if (in_array($name, $this->reservedMacroNames)) {
273 $this->macros[$name] = $node;
278 $this->traits[] = $trait;
283 return count($this->traits) > 0;
290 $this->embeddedTemplates[] = $template;
295 $this->importedSymbols[0][$type][$alias] = array(
'name' => $name,
'node' => $node);
300 foreach ($this->importedSymbols as $functions) {
301 if (isset($functions[$type][$alias])) {
302 return $functions[$type][$alias];
309 return 1 === count($this->importedSymbols);
314 array_unshift($this->importedSymbols, array());
319 array_shift($this->importedSymbols);
359 return $this->stream->getCurrent();
366 ($node instanceof
Twig_Node_Text && !ctype_space($node->getAttribute(
'data')))
370 if (
false !== strpos((
string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
371 throw new Twig_Error_Syntax(
'A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed.', $node->
getLine(), $this->
getFilename());
386 foreach ($node as $k => $n) {
388 $node->removeNode($k);
Twig_NodeTraverser is a node traverser.
subparse($test, $dropNeedle=false)
if($rub=fetch_assoc($rub_query)) if(check_if_module_active('url_rewriting')) $class
getTemplateLine()
Gets the template line where the error occurred.
getImportedSymbol($type, $alias)
setTemplateLine($lineno)
Sets the template line where the error occurred.
embedTemplate(Twig_Node_Module $template)
if(!select_db($_SESSION['session_install_choixbase'], $GLOBALS['database_object'], true)) $error
filterBodyNodes(Twig_NodeInterface $node)
getTemplateFile()
Gets the filename where the error occurred.
parse(Twig_TokenStream $stream, $test=null, $dropNeedle=false)
Converts a token stream to a node tree.
Represents a node in the AST.
getStream()
Gets the token stream.
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Represents a block call node.
Default parser implementation.
getExpressionParser()
Gets the expression parser.
Interface implemented by token parsers.
__construct(Twig_Environment $env)
Constructor.
getCurrentToken()
Gets the current token.
setMacro($name, Twig_Node_Macro $node)
Abstract class for all nodes that represents an expression.
addNodeVisitor(Twig_NodeVisitorInterface $visitor)
Represents a module node.
Represents a token stream.
addHandler($name, $class)
Twig_NodeVisitorInterface is the interface the all node visitor classes must implement.
Represents a node in the AST.
addImportedSymbol($type, $alias, $name=null, Twig_Node_Expression $node=null)
Represents a displayable node in the AST.
Stores the Twig configuration.
Interface implemented by parser classes.
setTemplateFile($filename)
Sets the filename where the error occurred.
Represents a node that outputs an expression.