23 parent::__construct(array(
'parent' => $parent,
'body' => $body,
'blocks' => $blocks,
'macros' => $macros,
'traits' => $traits), array(
'filename' =>
$filename,
'index' => null,
'embedded_templates' => $embeddedTemplates), 1);
40 foreach ($this->
getAttribute(
'embedded_templates') as $template) {
48 $compiler->
write(
'<?php');
80 if (null === $this->
getNode(
'parent')) {
85 ->
write(
"protected function doGetParent(array \$context)\n",
"{\n")
94 ->
raw(
"\$this->env->resolveTemplate(")
95 ->subcompile($this->
getNode(
'parent'))
111 if (null !== $this->
getNode(
'parent')) {
113 $compiler->
write(
"\$this->parent");
115 $compiler->
write(
"\$this->getParent(\$context)");
117 $compiler->
raw(
"->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
126 ->write(
"/* ".str_replace(
'*/',
'* /', $this->
getAttribute(
'filename')).
" */\n")
128 ->raw(sprintf(
" extends %s\n", $compiler->
getEnvironment()->getBaseTemplateClass()))
137 ->
write(
"public function __construct(Twig_Environment \$env)\n",
"{\n")
139 ->write(
"parent::__construct(\$env);\n\n")
143 if (null === $this->
getNode(
'parent')) {
144 $compiler->
write(
"\$this->parent = false;\n\n");
147 ->
write(
"\$this->parent = \$this->env->loadTemplate(")
148 ->subcompile($this->
getNode(
'parent'))
156 foreach ($this->
getNode(
'traits') as
$i => $trait) {
161 ->write(sprintf(
"if (!\$_trait_%s->isTraitable()) {\n",
$i))
163 ->write(
"throw new Twig_Error_Runtime('Template \"'.")
164 ->subcompile($trait->getNode(
'template'))
165 ->raw(
".'\" cannot be used as a trait.');\n")
168 ->write(sprintf(
"\$_trait_%s_blocks = \$_trait_%s->getBlocks();\n\n",
$i,
$i))
171 foreach ($trait->getNode(
'targets') as $key => $value) {
173 ->
write(sprintf(
"\$_trait_%s_blocks[",
$i))
175 ->raw(sprintf(
"] = \$_trait_%s_blocks[",
$i))
177 ->raw(sprintf(
"]; unset(\$_trait_%s_blocks[",
$i))
184 if ($countTraits > 1) {
186 ->
write(
"\$this->traits = array_merge(\n")
190 for (
$i = 0;
$i < $countTraits;
$i++) {
192 ->
write(sprintf(
"\$_trait_%s_blocks".(
$i == $countTraits - 1 ?
'' :
',').
"\n",
$i))
202 ->
write(
"\$this->traits = \$_trait_0_blocks;\n\n")
207 ->
write(
"\$this->blocks = array_merge(\n")
209 ->write(
"\$this->traits,\n")
214 ->
write(
"\$this->blocks = array(\n")
223 foreach ($this->
getNode(
'blocks') as $name => $node) {
225 ->
write(sprintf(
"'%s' => array(\$this, 'block_%s'),\n", $name, $name))
247 ->
write(
"protected function doDisplay(array \$context, array \$blocks = array())\n",
"{\n")
276 ->
write(
"public function getTemplateName()\n",
"{\n")
307 foreach (
$nodes as $node) {
312 if ($node instanceof
Twig_Node_Text && ctype_space($node->getAttribute(
'data'))) {
330 ->
write(
"public function isTraitable()\n",
"{\n")
332 ->write(sprintf(
"return %s;\n", $traitable ?
'true' :
'false'))
341 ->
write(
"public function getDebugInfo()\n",
"{\n")
343 ->write(sprintf(
"return %s;\n", str_replace(
"\n",
'', var_export(array_reverse($compiler->
getDebugInfo(),
true),
true))))
353 ->
write(sprintf(
"%s = \$this->env->loadTemplate(", $var))
359 ->
write(sprintf(
"%s = ", $var))
362 ->write(sprintf(
"if (!%s", $var))
363 ->raw(
" instanceof Twig_Template) {\n")
365 ->write(sprintf(
"%s = \$this->env->loadTemplate(%s);\n", $var, $var))
compileDisplayFooter(Twig_Compiler $compiler)
compileClassHeader(Twig_Compiler $compiler)
compileDisplayBody(Twig_Compiler $compiler)
Compiles a node to PHP code.
compileDisplayHeader(Twig_Compiler $compiler)
outdent($step=1)
Outdents the generated code.
compileTemplate(Twig_Compiler $compiler)
indent($step=1)
Indents the generated code.
Represents a node in the AST.
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
Represents a block call node.
getAttribute($name)
Gets an attribute.
addDebugInfo(Twig_NodeInterface $node)
Adds debugging information.
compileLoadTemplate(Twig_Compiler $compiler, $node, $var)
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))
Abstract class for all nodes that represents an expression.
compileGetParent(Twig_Compiler $compiler)
setAttribute($name, $value)
Sets an attribute.
getEnvironment()
Returns the environment instance related to this compiler.
compileClassFooter(Twig_Compiler $compiler)
compileIsTraitable(Twig_Compiler $compiler)
Represents a module node.
compileMacros(Twig_Compiler $compiler)
subcompile(Twig_NodeInterface $node, $raw=true)
Represents a node in the AST.
compileDebugInfo(Twig_Compiler $compiler)
__construct(Twig_NodeInterface $body, Twig_Node_Expression $parent=null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $embeddedTemplates, $filename)
raw($string)
Adds a raw string to the compiled code.
write()
Writes a string to the compiled code by adding indentation.
compileGetTemplateName(Twig_Compiler $compiler)
compileConstructor(Twig_Compiler $compiler)
getNode($name)
Gets a node by name.