Add a list of blacklisted tags
This commit is contained in:
parent
0fa759c604
commit
f930ca794e
49
src/NodaBlacklistedTerms.php
Normal file
49
src/NodaBlacklistedTerms.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Contains a class of blacklists for unwanted terms.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Contains lists of disallowed terms by language.
|
||||
*/
|
||||
final class NodaBlacklistedTerms {
|
||||
/**
|
||||
* A blacklist of disallowed tags. All entries are listed in full lowercase.
|
||||
*/
|
||||
const TAG_BLACKLIST = [
|
||||
'de' => [
|
||||
'sonstige',
|
||||
'sonst.',
|
||||
'sonst',
|
||||
'andere',
|
||||
'weiteres',
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Checks if an tag name is blacklisted.
|
||||
*
|
||||
* @param string $lang Input language.
|
||||
* @param string $name Input name to check.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function tagIsInBlacklist(string $lang, string $name):bool {
|
||||
|
||||
$toCheck = \strtolower($name);
|
||||
|
||||
if (!isset(self::TAG_BLACKLIST[$lang])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (\in_array($toCheck, self::TAG_BLACKLIST[$lang], true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user