37 $this->debugInfo = array();
75 $this->lastLine = null;
77 $this->sourceOffset = 0;
79 $this->sourceLine = 1;
83 $this->filename = $node->getAttribute(
'filename');
109 public function raw($string)
111 $this->source .= $string;
123 $strings = func_get_args();
124 foreach ($strings as $string) {
126 $this->source .= $string;
139 $this->source .= str_repeat(
' ', $this->indentation * 4);
153 $this->source .= sprintf(
'"%s"', addcslashes($value,
"\0\t\"\$\\"));
167 if (is_int($value) || is_float($value)) {
168 if (
false !== $locale = setlocale(LC_NUMERIC, 0)) {
169 setlocale(LC_NUMERIC,
'C');
174 if (
false !== $locale) {
175 setlocale(LC_NUMERIC, $locale);
177 }
elseif (null === $value) {
179 }
elseif (is_bool($value)) {
180 $this->
raw($value ?
'true' :
'false');
181 }
elseif (is_array($value)) {
182 $this->
raw(
'array(');
184 foreach ($value as $key => $value) {
210 $this->
write(
"// line {$node->getLine()}\n");
215 if (((
int) ini_get(
'mbstring.func_overload')) & 2) {
217 $this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset),
"\n");
219 $this->sourceLine += substr_count($this->source,
"\n", $this->sourceOffset);
221 $this->sourceOffset = strlen($this->source);
224 $this->lastLine = $node->
getLine();
244 $this->indentation += $step;
259 if ($this->indentation < $step) {
260 throw new LogicException(
'Unable to call outdent() as the indentation would become negative');
263 $this->indentation -= $step;
compile(Twig_NodeInterface $node, $indentation=0)
Compiles a node.
Interface implemented by compiler classes.
Compiles a node to PHP code.
outdent($step=1)
Outdents the generated code.
indent($step=1)
Indents the generated code.
addDebugInfo(Twig_NodeInterface $node)
Adds debugging information.
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))
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
string($value)
Adds a quoted string to the compiled code.
getEnvironment()
Returns the environment instance related to this compiler.
Represents a module node.
__construct(Twig_Environment $env)
Constructor.
subcompile(Twig_NodeInterface $node, $raw=true)
repr($value)
Returns a PHP representation of a given value.
Represents a node in the AST.
raw($string)
Adds a raw string to the compiled code.
Stores the Twig configuration.
getSource()
Gets the current PHP code after compilation.
write()
Writes a string to the compiled code by adding indentation.
addIndentation()
Appends an indentation to the current PHP code after compilation.