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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Escaper.php
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 public function __construct($defaultStrategy = 'html')
016 {
017 $this->setDefaultStrategy($defaultStrategy);
018 }
019
020 /**
021 * Returns the token parser instances to add to the existing list.
022 *
023 * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
024 */
025 public function getTokenParsers()
026 {
027 return array(new Twig_TokenParser_AutoEscape());
028 }
029
030 /**
031 * Returns the node visitor instances to add to the existing list.
032 *
033 * @return array An array of Twig_NodeVisitorInterface instances
034 */
035 public function getNodeVisitors()
036 {
037 return array(new Twig_NodeVisitor_Escaper());
038 }
039
040 /**
041 * Returns a list of filters to add to the existing list.
042 *
043 * @return array An array of filters
044 */
045 public function getFilters()
046 {
047 return array(
048 new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
049 );
050 }
051
052 /**
053 * Sets the default strategy to use when not defined by the user.
054 *
055 * The strategy can be a valid PHP callback that takes the template
056 * "filename" as an argument and returns the strategy to use.
057 *
058 * @param mixed $defaultStrategy An escaping strategy
059 */
060 public function setDefaultStrategy($defaultStrategy)
061 {
062 // for BC
063 if (true === $defaultStrategy) {
064 $defaultStrategy = 'html';
065 }
066
067 $this->defaultStrategy = $defaultStrategy;
068 }
069
070 /**
071 * Gets the default strategy to use when not defined by the user.
072 *
073 * @param string $filename The template "filename"
074 *
075 * @return string The default strategy to use for the template
076 */
077 public function getDefaultStrategy($filename)
078 {
079 // disable string callables to avoid calling a function named html or js,
080 // or any other upcoming escaping strategy
081 if (!is_string($this->defaultStrategy) && is_callable($this->defaultStrategy)) {
082 return call_user_func($this->defaultStrategy, $filename);
083 }
084
085 return $this->defaultStrategy;
086 }
087
088 /**
089 * Returns the name of the extension.
090 *
091 * @return string The extension name
092 */
093 public function getName()
094 {
095 return 'escaper';
096 }
097 }
098
099 /**
100 * Marks a variable as being safe.
101 *
102 * @param string $string A PHP variable
103 */
104 function twig_raw_filter($string)
105 {
106 return $string;
107 }
108