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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Renderer.php
01 <?php
02
03 /*
04 * @package s9e\TextFormatter
05 * @copyright Copyright (c) 2010-2016 The s9e Authors
06 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
07 */
08 namespace s9e\TextFormatter;
09 use DOMDocument;
10 use InvalidArgumentException;
11 abstract class Renderer
12 {
13 public $metaElementsRegexp = '(<[eis]>[^<]*</[eis]>)';
14 protected $params = array();
15 protected function loadXML($xml)
16 {
17 $this->checkUnsupported($xml);
18 $flags = (\LIBXML_VERSION >= 20700) ? \LIBXML_COMPACT | \LIBXML_PARSEHUGE : 0;
19 $dom = new DOMDocument;
20 $dom->loadXML($xml, $flags);
21 return $dom;
22 }
23 public function render($xml)
24 {
25 if (\substr($xml, 0, 3) === '<t>')
26 return $this->renderPlainText($xml);
27 else
28 return $this->renderRichText(\preg_replace($this->metaElementsRegexp, '', $xml));
29 }
30 protected function renderPlainText($xml)
31 {
32 $html = \substr($xml, 3, -4);
33 $html = \str_replace('<br/>', '<br>', $html);
34 $html = $this->decodeSMP($html);
35 return $html;
36 }
37 abstract protected function renderRichText($xml);
38 public function getParameter($paramName)
39 {
40 return (isset($this->params[$paramName])) ? $this->params[$paramName] : '';
41 }
42 public function getParameters()
43 {
44 return $this->params;
45 }
46 public function setParameter($paramName, $paramValue)
47 {
48 $this->params[$paramName] = (string) $paramValue;
49 }
50 public function setParameters(array $params)
51 {
52 foreach ($params as $paramName => $paramValue)
53 $this->setParameter($paramName, $paramValue);
54 }
55 protected function checkUnsupported($xml)
56 {
57 if (\strpos($xml, '<!') !== \false)
58 throw new InvalidArgumentException('DTDs, CDATA nodes and comments are not allowed');
59 if (\strpos($xml, '<?') !== \false)
60 throw new InvalidArgumentException('Processing instructions are not allowed');
61 }
62 protected function decodeSMP($str)
63 {
64 if (\strpos($str, '&#') === \false)
65 return $str;
66 return \preg_replace_callback('(&#(?:x[0-9A-Fa-f]+|[0-9]+);)', __CLASS__ . '::decodeEntity', $str);
67 }
68 protected static function decodeEntity(array $m)
69 {
70 return \htmlspecialchars(\html_entity_decode($m[0], \ENT_QUOTES, 'UTF-8'), \ENT_COMPAT);
71 }
72 }