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

Escaper.php

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


001  <?php
002   
003  /*
004   * This file is part of Twig.
005   *
006   * (c) 2009 Fabien Potencier
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011  class Twig_Extension_Escaper extends Twig_Extension
012  {
013      protected $defaultStrategy;
014   
015      /**
016       * Constructor.
017       *
018       * @param string|false|callable $defaultStrategy An escaping strategy
019       *
020       * @see setDefaultStrategy()
021       */
022      public function __construct($defaultStrategy = 'html')
023      {
024          $this->setDefaultStrategy($defaultStrategy);
025      }
026   
027      public function getTokenParsers()
028      {
029          return array(new Twig_TokenParser_AutoEscape());
030      }
031   
032      public function getNodeVisitors()
033      {
034          return array(new Twig_NodeVisitor_Escaper());
035      }
036   
037      public function getFilters()
038      {
039          return array(
040              new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
041          );
042      }
043   
044      /**
045       * Sets the default strategy to use when not defined by the user.
046       *
047       * The strategy can be a valid PHP callback that takes the template
048       * "filename" as an argument and returns the strategy to use.
049       *
050       * @param string|false|callable $defaultStrategy An escaping strategy
051       */
052      public function setDefaultStrategy($defaultStrategy)
053      {
054          // for BC
055          if (true === $defaultStrategy) {
056              @trigger_error('Using "true" as the default strategy is deprecated since version 1.21. Use "html" instead.', E_USER_DEPRECATED);
057   
058              $defaultStrategy = 'html';
059          }
060   
061          if ('filename' === $defaultStrategy) {
062              $defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
063          }
064   
065          $this->defaultStrategy = $defaultStrategy;
066      }
067   
068      /**
069       * Gets the default strategy to use when not defined by the user.
070       *
071       * @param string $filename The template "filename"
072       *
073       * @return string|false The default strategy to use for the template
074       */
075      public function getDefaultStrategy($filename)
076      {
077          // disable string callables to avoid calling a function named html or js,
078          // or any other upcoming escaping strategy
079          if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) {
080              return call_user_func($this->defaultStrategy, $filename);
081          }
082   
083          return $this->defaultStrategy;
084      }
085   
086      public function getName()
087      {
088          return 'escaper';
089      }
090  }
091   
092  /**
093   * Marks a variable as being safe.
094   *
095   * @param string $string A PHP variable
096   *
097   * @return string
098   */
099  function twig_raw_filter($string)
100  {
101      return $string;
102  }
103