50 lines
1.0 KiB
PHP
50 lines
1.0 KiB
PHP
|
<?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;
|
||
|
|
||
|
}
|
||
|
}
|