|
|
|
@ -71,9 +71,12 @@
|
|
|
|
|
/**
|
|
|
|
|
* Returns the user tags given, without any reserved tags.
|
|
|
|
|
* @param string[] $tags
|
|
|
|
|
* @param bool $remove_redundant Removes duplicate and obvious tags.
|
|
|
|
|
* @return \CommunityTag[]
|
|
|
|
|
*/
|
|
|
|
|
public static function from_user_tags(array $tags): array {
|
|
|
|
|
public static function from_user_tags(
|
|
|
|
|
array $tags, bool $remove_redundant = false
|
|
|
|
|
): array {
|
|
|
|
|
$tags_user = array_filter(
|
|
|
|
|
$tags,
|
|
|
|
|
function($tag) {
|
|
|
|
@ -81,7 +84,17 @@
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return CommunityTag::from_tag_array($tags_user);
|
|
|
|
|
$tags_built = CommunityTag::from_tag_array($tags_user);
|
|
|
|
|
|
|
|
|
|
if ($remove_redundant) {
|
|
|
|
|
$tags_built = CommunityTag::dedupe_tags($tags_built);
|
|
|
|
|
$tags_built = array_filter($tags_built, function(\CommunityTag $tag) {
|
|
|
|
|
$text = strtolower($tag->text);
|
|
|
|
|
return !in_array($text, CommunityTag::REDUNDANT_TAGS);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $tags_built;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -111,8 +124,12 @@
|
|
|
|
|
* @var string[] RESERVED_TAGS
|
|
|
|
|
* Array of derived tags unavailable for manual tagging.
|
|
|
|
|
*/
|
|
|
|
|
private const RESERVED_TAGS = ["official"];
|
|
|
|
|
private const RESERVED_TAGS = ["official", "nsfw"];
|
|
|
|
|
|
|
|
|
|
private const REDUNDANT_TAGS = ["session"];
|
|
|
|
|
|
|
|
|
|
public const NSFW_KEYWORDS = ["nsfw", "porn", "erotic", "18+"];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks whether the given manual tag can be accepted.
|
|
|
|
|
*/
|
|
|
|
|