Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Include.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 2.83 KiB


001  <?php
002   
003  /*
004   * This file is part of Twig.
005   *
006   * (c) 2009 Fabien Potencier
007   * (c) 2009 Armin Ronacher
008   *
009   * For the full copyright and license information, please view the LICENSE
010   * file that was distributed with this source code.
011   */
012   
013  /**
014   * Represents an include node.
015   *
016   * @author Fabien Potencier <fabien@symfony.com>
017   */
018  class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
019  {
020      public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
021      {
022          parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (Boolean) $only, 'ignore_missing' => (Boolean) $ignoreMissing), $lineno, $tag);
023      }
024   
025      /**
026       * Compiles the node to PHP.
027       *
028       * @param Twig_Compiler A Twig_Compiler instance
029       */
030      public function compile(Twig_Compiler $compiler)
031      {
032          $compiler->addDebugInfo($this);
033   
034          if ($this->getAttribute('ignore_missing')) {
035              $compiler
036                  ->write("try {\n")
037                  ->indent()
038              ;
039          }
040   
041          $this->addGetTemplate($compiler);
042   
043          $compiler->raw('->display(');
044   
045          $this->addTemplateArguments($compiler);
046   
047          $compiler->raw(");\n");
048   
049          if ($this->getAttribute('ignore_missing')) {
050              $compiler
051                  ->outdent()
052                  ->write("} catch (Twig_Error_Loader \$e) {\n")
053                  ->indent()
054                  ->write("// ignore missing template\n")
055                  ->outdent()
056                  ->write("}\n\n")
057              ;
058          }
059      }
060   
061      protected function addGetTemplate(Twig_Compiler $compiler)
062      {
063          if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) {
064              $compiler
065                  ->write("\$this->env->loadTemplate(")
066                  ->subcompile($this->getNode('expr'))
067                  ->raw(")")
068              ;
069          } else {
070              $compiler
071                  ->write("\$template = \$this->env->resolveTemplate(")
072                  ->subcompile($this->getNode('expr'))
073                  ->raw(");\n")
074                  ->write('$template')
075              ;
076          }
077      }
078   
079      protected function addTemplateArguments(Twig_Compiler $compiler)
080      {
081          if (false === $this->getAttribute('only')) {
082              if (null === $this->getNode('variables')) {
083                  $compiler->raw('$context');
084              } else {
085                  $compiler
086                      ->raw('array_merge($context, ')
087                      ->subcompile($this->getNode('variables'))
088                      ->raw(')')
089                  ;
090              }
091          } else {
092              if (null === $this->getNode('variables')) {
093                  $compiler->raw('array()');
094              } else {
095                  $compiler->subcompile($this->getNode('variables'));
096              }
097          }
098      }
099  }
100