Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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 |
Bundle.php
001 <?php
002
003 /**
004 * @package s9e\TextFormatter
005 * @copyright Copyright (c) 2010-2022 The s9e authors
006 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
007 */
008 namespace s9e\TextFormatter;
009
010 abstract class Bundle
011 {
012 /**
013 * Return a cached instance of the parser
014 *
015 * @return Parser
016 */
017 public static function getCachedParser()
018 {
019 if (!isset(static::$parser))
020 {
021 static::$parser = static::getParser();
022 }
023
024 return static::$parser;
025 }
026
027 /**
028 * Return a cached instance of the renderer
029 *
030 * @return Renderer
031 */
032 public static function getCachedRenderer()
033 {
034 if (!isset(static::$renderer))
035 {
036 static::$renderer = static::getRenderer();
037 }
038
039 return static::$renderer;
040 }
041
042 /**
043 * Return a new instance of s9e\TextFormatter\Parser
044 *
045 * @return Parser
046 */
047 abstract public static function getParser();
048
049 /**
050 * Return a new instance of s9e\TextFormatter\Renderer
051 *
052 * @return Renderer
053 */
054 abstract public static function getRenderer();
055
056 /**
057 * Return the source of the JavaScript parser if available
058 *
059 * @return string
060 */
061 public static function getJS()
062 {
063 return '';
064 }
065
066 /**
067 * Parse given text using a singleton instance of the bundled Parser
068 *
069 * @param string $text Original text
070 * @return string Intermediate representation
071 */
072 public static function parse($text)
073 {
074 if (isset(static::$beforeParse))
075 {
076 $text = call_user_func(static::$beforeParse, $text);
077 }
078
079 $xml = static::getCachedParser()->parse($text);
080
081 if (isset(static::$afterParse))
082 {
083 $xml = call_user_func(static::$afterParse, $xml);
084 }
085
086 return $xml;
087 }
088
089 /**
090 * Render an intermediate representation using a singleton instance of the bundled Renderer
091 *
092 * @param string $xml Intermediate representation
093 * @param array $params Stylesheet parameters
094 * @return string Rendered result
095 */
096 public static function render($xml, array $params = [])
097 {
098 $renderer = static::getCachedRenderer();
099
100 if (!empty($params))
101 {
102 $renderer->setParameters($params);
103 }
104
105 if (isset(static::$beforeRender))
106 {
107 $xml = call_user_func(static::$beforeRender, $xml);
108 }
109
110 $output = $renderer->render($xml);
111
112 if (isset(static::$afterRender))
113 {
114 $output = call_user_func(static::$afterRender, $output);
115 }
116
117 return $output;
118 }
119
120 /**
121 * Reset the cached parser and renderer
122 *
123 * @return void
124 */
125 public static function reset()
126 {
127 static::$parser = null;
128 static::$renderer = null;
129 }
130
131 /**
132 * Transform an intermediate representation back to its original form
133 *
134 * @param string $xml Intermediate representation
135 * @return string Original text
136 */
137 public static function unparse($xml)
138 {
139 if (isset(static::$beforeUnparse))
140 {
141 $xml = call_user_func(static::$beforeUnparse, $xml);
142 }
143
144 $text = Unparser::unparse($xml);
145
146 if (isset(static::$afterUnparse))
147 {
148 $text = call_user_func(static::$afterUnparse, $text);
149 }
150
151 return $text;
152 }
153 }