$r = null;
//is it a person tag?
- if (Term::isType($tag, Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION)) {
+ if (Tag::isType($tag, Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION)) {
$tag_type = substr($tag, 0, 1);
//is it already replaced?
if (strpos($tag, '[url=')) {
return $tags ?: [];
}
+
+ /**
+ * Check if the provided tag is of one of the provided term types.
+ *
+ * @param string $tag
+ * @param int ...$types
+ * @return bool
+ */
+ public static function isType($tag, ...$types)
+ {
+ $tag_chars = [];
+ foreach ($types as $type) {
+ if (array_key_exists($type, self::TAG_CHARACTER)) {
+ $tag_chars[] = self::TAG_CHARACTER[$type];
+ }
+ }
+
+ return Strings::startsWith($tag, $tag_chars);
+ }
}
namespace Friendica\Model;
-use Friendica\Core\Cache\Duration;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\DI;
}
foreach ($tags as $link => $tag) {
- if (self::isType($tag, self::HASHTAG)) {
+ if (Tag::isType($tag, self::HASHTAG)) {
// try to ignore #039 or #1 or anything like that
if (ctype_digit(substr(trim($tag), 1))) {
continue;
$type = self::HASHTAG;
$term = substr($tag, 1);
$link = '';
- } elseif (self::isType($tag, self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION)) {
- if (self::isType($tag, self::MENTION, self::EXCLUSIVE_MENTION)) {
+ } elseif (Tag::isType($tag, self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION)) {
+ if (Tag::isType($tag, self::MENTION, self::EXCLUSIVE_MENTION)) {
$type = self::MENTION;
} else {
$type = self::IMPLICIT_MENTION;
]);
// Search for mentions
- if (self::isType($tag, self::MENTION, self::EXCLUSIVE_MENTION)
+ if (Tag::isType($tag, self::MENTION, self::EXCLUSIVE_MENTION)
&& (
strpos($link, $profile_base_friendica) !== false
|| strpos($link, $profile_base_diaspora) !== false
// Clean up all tags
DBA::delete('term', ['otype' => self::OBJECT_TYPE_POST, 'oid' => $item_id, 'type' => $type]);
}
-
- /**
- * Check if the provided tag is of one of the provided term types.
- *
- * @param string $tag
- * @param int ...$types
- * @return bool
- */
- public static function isType($tag, ...$types)
- {
- $tag_chars = [];
- foreach ($types as $type) {
- if (array_key_exists($type, self::TAG_CHARACTER)) {
- $tag_chars[] = self::TAG_CHARACTER[$type];
- }
- }
-
- return Strings::startsWith($tag, $tag_chars);
- }
}