Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

TransNode.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 3.99 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of the Symfony package.
 005   *
 006   * (c) Fabien Potencier <fabien@symfony.com>
 007   *
 008   * For the full copyright and license information, please view the LICENSE
 009   * file that was distributed with this source code.
 010   */
 011   
 012  namespace Symfony\Bridge\Twig\Node;
 013   
 014  use Twig\Compiler;
 015  use Twig\Node\Expression\AbstractExpression;
 016  use Twig\Node\Expression\ArrayExpression;
 017  use Twig\Node\Expression\ConstantExpression;
 018  use Twig\Node\Expression\NameExpression;
 019  use Twig\Node\Node;
 020  use Twig\Node\TextNode;
 021   
 022  // BC/FC with namespaced Twig
 023  class_exists('Twig\Node\Expression\ArrayExpression');
 024   
 025  /**
 026   * @author Fabien Potencier <fabien@symfony.com>
 027   */
 028  class TransNode extends Node
 029  {
 030      public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, $lineno = 0, $tag = null)
 031      {
 032          $nodes = ['body' => $body];
 033          if (null !== $domain) {
 034              $nodes['domain'] = $domain;
 035          }
 036          if (null !== $count) {
 037              $nodes['count'] = $count;
 038          }
 039          if (null !== $vars) {
 040              $nodes['vars'] = $vars;
 041          }
 042          if (null !== $locale) {
 043              $nodes['locale'] = $locale;
 044          }
 045   
 046          parent::__construct($nodes, [], $lineno, $tag);
 047      }
 048   
 049      public function compile(Compiler $compiler)
 050      {
 051          $compiler->addDebugInfo($this);
 052   
 053          $defaults = new ArrayExpression([], -1);
 054          if ($this->hasNode('vars') && ($vars = $this->getNode('vars')) instanceof ArrayExpression) {
 055              $defaults = $this->getNode('vars');
 056              $vars = null;
 057          }
 058          list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars);
 059   
 060          $method = !$this->hasNode('count') ? 'trans' : 'transChoice';
 061   
 062          $compiler
 063              ->write('echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->getTranslator()->'.$method.'(')
 064              ->subcompile($msg)
 065          ;
 066   
 067          $compiler->raw(', ');
 068   
 069          if ($this->hasNode('count')) {
 070              $compiler
 071                  ->subcompile($this->getNode('count'))
 072                  ->raw(', ')
 073              ;
 074          }
 075   
 076          if (null !== $vars) {
 077              $compiler
 078                  ->raw('array_merge(')
 079                  ->subcompile($defaults)
 080                  ->raw(', ')
 081                  ->subcompile($this->getNode('vars'))
 082                  ->raw(')')
 083              ;
 084          } else {
 085              $compiler->subcompile($defaults);
 086          }
 087   
 088          $compiler->raw(', ');
 089   
 090          if (!$this->hasNode('domain')) {
 091              $compiler->repr('messages');
 092          } else {
 093              $compiler->subcompile($this->getNode('domain'));
 094          }
 095   
 096          if ($this->hasNode('locale')) {
 097              $compiler
 098                  ->raw(', ')
 099                  ->subcompile($this->getNode('locale'))
 100              ;
 101          }
 102          $compiler->raw(");\n");
 103      }
 104   
 105      protected function compileString(Node $body, ArrayExpression $vars, $ignoreStrictCheck = false)
 106      {
 107          if ($body instanceof ConstantExpression) {
 108              $msg = $body->getAttribute('value');
 109          } elseif ($body instanceof TextNode) {
 110              $msg = $body->getAttribute('data');
 111          } else {
 112              return [$body, $vars];
 113          }
 114   
 115          preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
 116   
 117          foreach ($matches[1] as $var) {
 118              $key = new ConstantExpression('%'.$var.'%', $body->getTemplateLine());
 119              if (!$vars->hasElement($key)) {
 120                  if ('count' === $var && $this->hasNode('count')) {
 121                      $vars->addElement($this->getNode('count'), $key);
 122                  } else {
 123                      $varExpr = new NameExpression($var, $body->getTemplateLine());
 124                      $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck);
 125                      $vars->addElement($varExpr, $key);
 126                  }
 127              }
 128          }
 129   
 130          return [new ConstantExpression(str_replace('%%', '%', trim($msg)), $body->getTemplateLine()), $vars];
 131      }
 132  }
 133