Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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: 09.10.2024, 12:56 - Dateigröße: 3.65 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  /**
015   * @author Fabien Potencier <fabien@symfony.com>
016   */
017  class TransNode extends \Twig_Node
018  {
019      public function __construct(\Twig_Node $body, \Twig_Node $domain = null, \Twig_Node_Expression $count = null, \Twig_Node_Expression $vars = null, \Twig_Node_Expression $locale = null, $lineno = 0, $tag = null)
020      {
021          parent::__construct(array('count' => $count, 'body' => $body, 'domain' => $domain, 'vars' => $vars, 'locale' => $locale), array(), $lineno, $tag);
022      }
023   
024      /**
025       * Compiles the node to PHP.
026       *
027       * @param \Twig_Compiler $compiler A Twig_Compiler instance
028       */
029      public function compile(\Twig_Compiler $compiler)
030      {
031          $compiler->addDebugInfo($this);
032   
033          $vars = $this->getNode('vars');
034          $defaults = new \Twig_Node_Expression_Array(array(), -1);
035          if ($vars instanceof \Twig_Node_Expression_Array) {
036              $defaults = $this->getNode('vars');
037              $vars = null;
038          }
039          list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars);
040   
041          $method = null === $this->getNode('count') ? 'trans' : 'transChoice';
042   
043          $compiler
044              ->write('echo $this->env->getExtension(\'translator\')->getTranslator()->'.$method.'(')
045              ->subcompile($msg)
046          ;
047   
048          $compiler->raw(', ');
049   
050          if (null !== $this->getNode('count')) {
051              $compiler
052                  ->subcompile($this->getNode('count'))
053                  ->raw(', ')
054              ;
055          }
056   
057          if (null !== $vars) {
058              $compiler
059                  ->raw('array_merge(')
060                  ->subcompile($defaults)
061                  ->raw(', ')
062                  ->subcompile($this->getNode('vars'))
063                  ->raw(')')
064              ;
065          } else {
066              $compiler->subcompile($defaults);
067          }
068   
069          $compiler->raw(', ');
070   
071          if (null === $this->getNode('domain')) {
072              $compiler->repr('messages');
073          } else {
074              $compiler->subcompile($this->getNode('domain'));
075          }
076   
077          if (null !== $this->getNode('locale')) {
078              $compiler
079                  ->raw(', ')
080                  ->subcompile($this->getNode('locale'))
081              ;
082          }
083          $compiler->raw(");\n");
084      }
085   
086      protected function compileString(\Twig_Node $body, \Twig_Node_Expression_Array $vars, $ignoreStrictCheck = false)
087      {
088          if ($body instanceof \Twig_Node_Expression_Constant) {
089              $msg = $body->getAttribute('value');
090          } elseif ($body instanceof \Twig_Node_Text) {
091              $msg = $body->getAttribute('data');
092          } else {
093              return array($body, $vars);
094          }
095   
096          preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
097   
098          foreach ($matches[1] as $var) {
099              $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine());
100              if (!$vars->hasElement($key)) {
101                  if ('count' === $var && null !== $this->getNode('count')) {
102                      $vars->addElement($this->getNode('count'), $key);
103                  } else {
104                      $varExpr = new \Twig_Node_Expression_Name($var, $body->getLine());
105                      $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck);
106                      $vars->addElement($varExpr, $key);
107                  }
108              }
109          }
110   
111          return array(new \Twig_Node_Expression_Constant(str_replace('%%', '%', trim($msg)), $body->getLine()), $vars);
112      }
113  }
114