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

AutoEscape.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.55 KiB


 01  <?php
 02   
 03  /*
 04   * This file is part of Twig.
 05   *
 06   * (c) 2009 Fabien Potencier
 07   *
 08   * For the full copyright and license information, please view the LICENSE
 09   * file that was distributed with this source code.
 10   */
 11   
 12  /**
 13   * Marks a section of a template to be escaped or not.
 14   *
 15   * <pre>
 16   * {% autoescape true %}
 17   *   Everything will be automatically escaped in this block
 18   * {% endautoescape %}
 19   *
 20   * {% autoescape false %}
 21   *   Everything will be outputed as is in this block
 22   * {% endautoescape %}
 23   *
 24   * {% autoescape true js %}
 25   *   Everything will be automatically escaped in this block
 26   *   using the js escaping strategy
 27   * {% endautoescape %}
 28   * </pre>
 29   */
 30  class Twig_TokenParser_AutoEscape extends Twig_TokenParser
 31  {
 32      /**
 33       * Parses a token and returns a node.
 34       *
 35       * @param Twig_Token $token A Twig_Token instance
 36       *
 37       * @return Twig_NodeInterface A Twig_NodeInterface instance
 38       */
 39      public function parse(Twig_Token $token)
 40      {
 41          $lineno = $token->getLine();
 42          $stream = $this->parser->getStream();
 43   
 44          if ($stream->test(Twig_Token::BLOCK_END_TYPE)) {
 45              $value = 'html';
 46          } else {
 47              $expr = $this->parser->getExpressionParser()->parseExpression();
 48              if (!$expr instanceof Twig_Node_Expression_Constant) {
 49                  throw new Twig_Error_Syntax('An escaping strategy must be a string or a Boolean.', $stream->getCurrent()->getLine(), $stream->getFilename());
 50              }
 51              $value = $expr->getAttribute('value');
 52   
 53              $compat = true === $value || false === $value;
 54   
 55              if (true === $value) {
 56                  $value = 'html';
 57              }
 58   
 59              if ($compat && $stream->test(Twig_Token::NAME_TYPE)) {
 60                  if (false === $value) {
 61                      throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getFilename());
 62                  }
 63   
 64                  $value = $stream->next()->getValue();
 65              }
 66          }
 67   
 68          $stream->expect(Twig_Token::BLOCK_END_TYPE);
 69          $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
 70          $stream->expect(Twig_Token::BLOCK_END_TYPE);
 71   
 72          return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag());
 73      }
 74   
 75      public function decideBlockEnd(Twig_Token $token)
 76      {
 77          return $token->test('endautoescape');
 78      }
 79   
 80      /**
 81       * Gets the tag name associated with this token parser.
 82       *
 83       * @return string The tag name
 84       */
 85      public function getTag()
 86      {
 87          return 'autoescape';
 88      }
 89  }
 90