@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | /** |
| 211 | 211 | * shorthand for self::attributeIn('__BBTAG__', $array) |
| 212 | 212 | * |
| 213 | - * @param array $array |
|
| 214 | - * @param mixed $default |
|
| 213 | + * @param string[] $array |
|
| 214 | + * @param string $default |
|
| 215 | 215 | * |
| 216 | 216 | * @return mixed |
| 217 | 217 | */ |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | * @param string $name the desired attributes name |
| 256 | 256 | * @param array $whitelist an array with whitelisted key -> value pairs |
| 257 | - * @param mixed $default [optional] a default value in case the attribute isn't set, defaults to false |
|
| 257 | + * @param string $default [optional] a default value in case the attribute isn't set, defaults to false |
|
| 258 | 258 | * |
| 259 | 259 | * @return mixed boolean if no $default is set, otherwise the whitelist value to the given key in case it exists or $default |
| 260 | 260 | */ |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | /** |
| 268 | 268 | * Checks if the current tag is whitelisted |
| 269 | 269 | * |
| 270 | - * @param array $whitelist an array with whitelisted tag names |
|
| 271 | - * @param mixed $default [optional] a default value in case the tag isn't whitelisted |
|
| 270 | + * @param string[] $whitelist an array with whitelisted tag names |
|
| 271 | + * @param string $default [optional] a default value in case the tag isn't whitelisted |
|
| 272 | 272 | * |
| 273 | 273 | * @return mixed boolean if no $default is set, otherwise the whitelisted tag or $default |
| 274 | 274 | */ |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\BBCode\Output; |
| 14 | 14 | |
| 15 | -use chillerlan\Settings\SettingsContainerInterface; |
|
| 16 | 15 | use Psr\Log\LoggerInterface; |
| 17 | 16 | use Psr\SimpleCache\CacheInterface; |
| 17 | +use chillerlan\Settings\SettingsContainerInterface; |
|
| 18 | 18 | |
| 19 | 19 | abstract class BBCodeModuleAbstract implements BBCodeModuleInterface{ |
| 20 | 20 | |
@@ -24,6 +24,7 @@ |
||
| 24 | 24 | * @param \chillerlan\Settings\SettingsContainerInterface $options |
| 25 | 25 | * @param \Psr\SimpleCache\CacheInterface $cache |
| 26 | 26 | * @param \Psr\Log\LoggerInterface $logger |
| 27 | + * @return void |
|
| 27 | 28 | */ |
| 28 | 29 | public function __construct(SettingsContainerInterface $options, CacheInterface $cache, LoggerInterface $logger); |
| 29 | 30 | |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\BBCode\Output; |
| 14 | 14 | |
| 15 | -use chillerlan\Settings\SettingsContainerInterface; |
|
| 16 | 15 | use Psr\Log\LoggerInterface; |
| 17 | 16 | use Psr\SimpleCache\CacheInterface; |
| 17 | +use chillerlan\Settings\SettingsContainerInterface; |
|
| 18 | 18 | |
| 19 | 19 | interface BBCodeModuleInterface{ |
| 20 | 20 | |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\BBCode\Output; |
| 14 | 14 | |
| 15 | -use chillerlan\Settings\SettingsContainerInterface; |
|
| 16 | 15 | use Psr\Log\LoggerInterface; |
| 17 | 16 | use Psr\SimpleCache\CacheInterface; |
| 17 | +use chillerlan\Settings\SettingsContainerInterface; |
|
| 18 | 18 | |
| 19 | 19 | abstract class BBCodeOutputAbstract implements BBCodeOutputInterface{ |
| 20 | 20 | |
@@ -24,6 +24,7 @@ |
||
| 24 | 24 | * @param \chillerlan\Settings\SettingsContainerInterface $options |
| 25 | 25 | * @param \Psr\SimpleCache\CacheInterface $cache |
| 26 | 26 | * @param \Psr\Log\LoggerInterface $logger |
| 27 | + * @return void |
|
| 27 | 28 | */ |
| 28 | 29 | public function __construct(SettingsContainerInterface $options, CacheInterface $cache, LoggerInterface $logger); |
| 29 | 30 | |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\BBCode\Output; |
| 14 | 14 | |
| 15 | -use chillerlan\Settings\SettingsContainerInterface; |
|
| 16 | 15 | use Psr\Log\LoggerInterface; |
| 17 | 16 | use Psr\SimpleCache\CacheInterface; |
| 17 | +use chillerlan\Settings\SettingsContainerInterface; |
|
| 18 | 18 | |
| 19 | 19 | interface BBCodeOutputInterface{ |
| 20 | 20 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if($this->options->sanitizeInput || $this->options->sanitizeOutput){ |
| 144 | - $this->sanitizerInterface = new $this->options->sanitizerInterface($this->options); |
|
| 144 | + $this->sanitizerInterface = new $this->options->sanitizerInterface($this->options); |
|
| 145 | 145 | |
| 146 | 146 | if(!$this->sanitizerInterface instanceof SanitizerInterface){ |
| 147 | 147 | throw new BBcodeException('invalid SanitizerInterface'); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | return ''; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if($callback_count < $this->limit && !in_array($tag, $this->noparse , true)){ |
|
| 256 | + if($callback_count < $this->limit && !in_array($tag, $this->noparse, true)){ |
|
| 257 | 257 | $content = preg_replace_callback('#\[(\w+)((?:\s|=)[^]]*)?]((?:[^[]|\[(?!/?\1((?:\s|=)[^]]*)?])|(?R))*)\[/\1]#', __METHOD__, $content); |
| 258 | 258 | $e = preg_last_error(); |
| 259 | 259 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | if($e !== PREG_NO_ERROR){ |
| 269 | 269 | $this->logger->debug('preg_error', ['errno' => $e, '$content' => $content]); |
| 270 | 270 | |
| 271 | - $content = $match ?? '';//$content ?? $bbcode ?? |
|
| 271 | + $content = $match ?? ''; //$content ?? $bbcode ?? |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
@@ -30,10 +30,10 @@ |
||
| 30 | 30 | |
| 31 | 31 | $str = [ |
| 32 | 32 | 'b' => '**', // bold |
| 33 | - 'c' => '`', // inline code |
|
| 33 | + 'c' => '`', // inline code |
|
| 34 | 34 | 'del' => '~~', // strikethrough |
| 35 | - 'em' => '_', // italic |
|
| 36 | - 'i' => '_', // italic |
|
| 35 | + 'em' => '_', // italic |
|
| 36 | + 'i' => '_', // italic |
|
| 37 | 37 | 's' => '~~', // strikethrough |
| 38 | 38 | 'strong' => '**', // bold |
| 39 | 39 | ][$this->tag]; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | protected function url():string{ // @todo linktext |
| 52 | 52 | |
| 53 | - $url = filter_var($this->bbtag() ?? $this->content, FILTER_VALIDATE_URL);// @todo |
|
| 53 | + $url = filter_var($this->bbtag() ?? $this->content, FILTER_VALIDATE_URL); // @todo |
|
| 54 | 54 | |
| 55 | 55 | if($url){ |
| 56 | 56 | return '[url]('.$url.')'; |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | $id = $this->randomID(); |
| 32 | 32 | |
| 33 | 33 | return '<div class="'.$this->tag.'-container">'. |
| 34 | - '<div data-id="'.$id.'" class="'.$this->tag.'-header expander"><span>'.$this->tag.': '.$this->getAttribute('desc').'</span></div>'. // @todo: desc in tag attribute |
|
| 35 | - '<div id="'.$id.'" class="'.$this->tag.'-body" style="display:none;">'.$this->content.'</div>'. |
|
| 36 | - '</div>'; |
|
| 34 | + '<div data-id="'.$id.'" class="'.$this->tag.'-header expander"><span>'.$this->tag.': '.$this->getAttribute('desc').'</span></div>'. // @todo: desc in tag attribute |
|
| 35 | + '<div id="'.$id.'" class="'.$this->tag.'-body" style="display:none;">'.$this->content.'</div>'. |
|
| 36 | + '</div>'; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | // @todo |
| 52 | 52 | return '<div class="quote-container">'. |
| 53 | - '<div data-id="'.$id.'" class="quote-header expander">quote '.($this->getAttribute('source', null) ?? '').(!empty($url) ? ' <small>[<a href="'.$url.'">link</a>]<small>' : '').'</div>'. |
|
| 54 | - '<blockquote id="'.$id.'" class="quote-body" style="display:block;">'.$this->content.'</blockquote>'. // @todo: collapse (js: collapse child elements etc.) |
|
| 55 | - '</div>'; |
|
| 53 | + '<div data-id="'.$id.'" class="quote-header expander">quote '.($this->getAttribute('source', null) ?? '').(!empty($url) ? ' <small>[<a href="'.$url.'">link</a>]<small>' : '').'</div>'. |
|
| 54 | + '<blockquote id="'.$id.'" class="quote-body" style="display:block;">'.$this->content.'</blockquote>'. // @todo: collapse (js: collapse child elements etc.) |
|
| 55 | + '</div>'; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $id = $this->randomID(); |
| 32 | 32 | |
| 33 | 33 | return '<div class="'.$this->tag.'-container">'. |
| 34 | - '<div data-id="'.$id.'" class="'.$this->tag.'-header expander"><span>'.$this->tag.': '.$this->getAttribute('desc').'</span></div>'. // @todo: desc in tag attribute |
|
| 34 | + '<div data-id="'.$id.'" class="'.$this->tag.'-header expander"><span>'.$this->tag.': '.$this->getAttribute('desc').'</span></div>'.// @todo: desc in tag attribute |
|
| 35 | 35 | '<div id="'.$id.'" class="'.$this->tag.'-body" style="display:none;">'.$this->content.'</div>'. |
| 36 | 36 | '</div>'; |
| 37 | 37 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | // @todo |
| 52 | 52 | return '<div class="quote-container">'. |
| 53 | 53 | '<div data-id="'.$id.'" class="quote-header expander">quote '.($this->getAttribute('source', null) ?? '').(!empty($url) ? ' <small>[<a href="'.$url.'">link</a>]<small>' : '').'</div>'. |
| 54 | - '<blockquote id="'.$id.'" class="quote-body" style="display:block;">'.$this->content.'</blockquote>'. // @todo: collapse (js: collapse child elements etc.) |
|
| 54 | + '<blockquote id="'.$id.'" class="quote-body" style="display:block;">'.$this->content.'</blockquote>'.// @todo: collapse (js: collapse child elements etc.) |
|
| 55 | 55 | '</div>'; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -169,11 +169,11 @@ |
||
| 169 | 169 | $list_tag = (count($this->attributes) === 0 || $this->attributeIn('type', $ul) ? 'ul' : 'ol'); |
| 170 | 170 | |
| 171 | 171 | return '<'.$list_tag.' class="bb-list '.$this->attributeKeyIn('type', $types, 'disc').'" ' |
| 172 | - .(is_numeric($start) && $this->attributeIn('type', $ol) ? ' start="'.ceil($start).'"' : '') |
|
| 173 | - .($this->getAttribute('reversed') && $this->attributeIn('type', $ol) ? ' reversed="true"' : '') |
|
| 174 | - .'>' |
|
| 175 | - .'<li>'.implode(array_slice(explode('[*]', $this->content), true), '</li><li>').'</li>' // nasty |
|
| 176 | - .'</'.$list_tag.'>'; |
|
| 172 | + .(is_numeric($start) && $this->attributeIn('type', $ol) ? ' start="'.ceil($start).'"' : '') |
|
| 173 | + .($this->getAttribute('reversed') && $this->attributeIn('type', $ol) ? ' reversed="true"' : '') |
|
| 174 | + .'>' |
|
| 175 | + .'<li>'.implode(array_slice(explode('[*]', $this->content), true), '</li><li>').'</li>' // nasty |
|
| 176 | + .'</'.$list_tag.'>'; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @var array |
| 19 | 19 | */ |
| 20 | 20 | protected $tags = [ |
| 21 | - 'noparse', 'nobb', 'color', 'font', 'size','br', 'hr', 'clear','img', 'url', 'c', 'list', |
|
| 21 | + 'noparse', 'nobb', 'color', 'font', 'size', 'br', 'hr', 'clear', 'img', 'url', 'c', 'list', |
|
| 22 | 22 | 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', |
| 23 | 23 | 'strong', 'sub', 'sup', 'del', 'small', 'em', 's', 'b', 'u', 'i', 'tt', |
| 24 | 24 | ]; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @return string |
| 117 | 117 | */ |
| 118 | 118 | protected function img():string{ |
| 119 | - $url = filter_var($this->content, FILTER_VALIDATE_URL);// @todo |
|
| 119 | + $url = filter_var($this->content, FILTER_VALIDATE_URL); // @todo |
|
| 120 | 120 | |
| 121 | 121 | if(!$url){ |
| 122 | 122 | return ''; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | return ''; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $url = filter_var($this->bbtag() ?? $this->content, FILTER_VALIDATE_URL);// @todo |
|
| 137 | + $url = filter_var($this->bbtag() ?? $this->content, FILTER_VALIDATE_URL); // @todo |
|
| 138 | 138 | $host = parse_url($url, PHP_URL_HOST); |
| 139 | 139 | $target = (!empty($host) && (isset($_SERVER['SERVER_NAME']) && $host === $_SERVER['SERVER_NAME'])) || empty($host) ? 'self' : 'blank'; |
| 140 | 140 | |
@@ -64,7 +64,8 @@ discard block |
||
| 64 | 64 | /** |
| 65 | 65 | * @return string |
| 66 | 66 | */ |
| 67 | - protected function c(){ // @todo |
|
| 67 | + protected function c(){ |
|
| 68 | +// @todo |
|
| 68 | 69 | $this->clearPseudoClosingTags(); |
| 69 | 70 | return '<code class="bb-inline-code" style="display: inline">'.$this->content.'</code>'; |
| 70 | 71 | } |
@@ -80,14 +81,16 @@ discard block |
||
| 80 | 81 | /** |
| 81 | 82 | * @return string |
| 82 | 83 | */ |
| 83 | - protected function font(){ // @todo: restrict fonts via classname |
|
| 84 | + protected function font(){ |
|
| 85 | +// @todo: restrict fonts via classname |
|
| 84 | 86 | return '<span class="bb-text font comic-sans">'.$this->content.'</span>'; |
| 85 | 87 | } |
| 86 | 88 | |
| 87 | 89 | /** |
| 88 | 90 | * @return string |
| 89 | 91 | */ |
| 90 | - protected function size(){ // @todo: restrict sizes via css |
|
| 92 | + protected function size(){ |
|
| 93 | +// @todo: restrict sizes via css |
|
| 91 | 94 | return '<span class="bb-text size extra-tiny">'.$this->content.'</span>'; |
| 92 | 95 | } |
| 93 | 96 | |