| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Linter; |
| 22 |
|
| 23 |
class HtmlTags { |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
private static $allowedHtmlTags = null; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
public function __construct( $parent ) { |
| 33 |
|
| 34 |
if ( self::$allowedHtmlTags === null ) { |
| 35 |
$tagOptionAll = $parent->msg( 'linter-form-tag-option-all' )->escaped(); |
| 36 |
self::$allowedHtmlTags = $this->createAllowedHTMLTags(); |
| 37 |
|
| 38 |
|
| 39 |
self::$allowedHtmlTags = array_merge( [ $tagOptionAll => 'all' ], self::$allowedHtmlTags ); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
private function createAllowedHTMLTags(): array { |
| 48 |
$allowedHtmlTags = [ |
| 49 |
'a', |
| 50 |
'abbr', |
| 51 |
'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', |
| 52 |
'caption', 'center', 'cite', 'code', |
| 53 |
'data', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', |
| 54 |
'em', |
| 55 |
'font', |
| 56 |
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', |
| 57 |
'i', 'ins', |
| 58 |
'kbd', |
| 59 |
'li', |
| 60 |
'mark', |
| 61 |
'ol', |
| 62 |
'p', 'pre', |
| 63 |
'q', |
| 64 |
'rb', 'rp', 'rt', 'rtc', 'ruby', |
| 65 |
's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup', |
| 66 |
'table', 'td', 'th', 'time', 'tr', 'tt', |
| 67 |
'u', 'ul', |
| 68 |
'var', |
| 69 |
'wbr', |
| 70 |
]; |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
return array_combine( $allowedHtmlTags, $allowedHtmlTags ); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public function getAllowedHTMLTags(): array { |
| 81 |
return self::$allowedHtmlTags; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
public function checkAllowedHTMLTags( string $tag ): bool { |
| 89 |
return in_array( $tag, self::$allowedHtmlTags, true ); |
| 90 |
} |
| 91 |
|
| 92 |
} |