use Friendica\Model\Mail;
use Friendica\Model\Notify;
use Friendica\Model\Photo;
+use Friendica\Model\Tag;
use Friendica\Model\Term;
use Friendica\Model\User;
use Friendica\Model\UserItem;
$condition = ["`oid` > ?
AND (`uid` = 0 OR (`uid` = ? AND NOT `global`))
AND `otype` = ? AND `type` = ? AND `term` = ?",
- $since_id, local_user(), Term::OBJECT_TYPE_POST, Term::HASHTAG, $searchTerm];
+ $since_id, local_user(), Term::OBJECT_TYPE_POST, Tag::HASHTAG, $searchTerm];
if ($max_id > 0) {
$condition[0] .= ' AND `oid` <= ?';
$condition[] = $max_id;
*/
use Friendica\App;
-use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
foreach ($tags as $tag) {
$tag_type = substr($tag, 0, 1);
- if ($tag_type == Term::TAG_CHARACTER[Term::HASHTAG]) {
+ if ($tag_type == Tag::TAG_CHARACTER[Tag::HASHTAG]) {
continue;
}
$tagged[] = $tag;
}
// When the forum is private or the forum is addressed with a "!" make the post private
- if (is_array($success['contact']) && (!empty($success['contact']['prv']) || ($tag_type == Term::TAG_CHARACTER[Term::EXCLUSIVE_MENTION]))) {
+ if (is_array($success['contact']) && (!empty($success['contact']['prv']) || ($tag_type == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]))) {
$private_forum = $success['contact']['prv'];
- $only_to_forum = ($tag_type == Term::TAG_CHARACTER[Term::EXCLUSIVE_MENTION]);
+ $only_to_forum = ($tag_type == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]);
$private_id = $success['contact']['id'];
$forum_contact = $success['contact'];
} elseif (is_array($success['contact']) && !empty($success['contact']['forum']) &&
$r = null;
//is it a person tag?
- if (Term::isType($tag, Term::MENTION, Term::IMPLICIT_MENTION, Term::EXCLUSIVE_MENTION)) {
+ if (Term::isType($tag, Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION)) {
$tag_type = substr($tag, 0, 1);
//is it already replaced?
if (strpos($tag, '[url=')) {
if (DI::config()->get('system', 'disable_implicit_mentions')) {
// Add a tag if the parent contact is from ActivityPub or OStatus (This will notify them)
if (in_array($thread_parent_contact['network'], [Protocol::OSTATUS, Protocol::ACTIVITYPUB])) {
- $contact = Term::TAG_CHARACTER[Term::MENTION] . '[url=' . $thread_parent_contact['url'] . ']' . $thread_parent_contact['nick'] . '[/url]';
+ $contact = Tag::TAG_CHARACTER[Tag::MENTION] . '[url=' . $thread_parent_contact['url'] . ']' . $thread_parent_contact['nick'] . '[/url]';
if (!stripos(implode($tags), '[url=' . $thread_parent_contact['url'] . ']')) {
$tags[] = $contact;
}
$thread_parent_contact['url'] => $thread_parent_contact['nick']
];
- $parent_terms = Term::tagArrayFromItemId($thread_parent_id, [Term::MENTION, Term::IMPLICIT_MENTION]);
+ $parent_terms = Term::tagArrayFromItemId($thread_parent_id, [Tag::MENTION, Tag::IMPLICIT_MENTION]);
foreach ($parent_terms as $parent_term) {
$implicit_mentions[$parent_term['url']] = $parent_term['term'];
foreach ($implicit_mentions as $url => $label) {
if ($url != \Friendica\Model\Profile::getMyURL() && !stripos(implode($tags), '[url=' . $url . ']')) {
- $tags[] = Term::TAG_CHARACTER[Term::IMPLICIT_MENTION] . '[url=' . $url . ']' . $label . '[/url]';
+ $tags[] = Tag::TAG_CHARACTER[Tag::IMPLICIT_MENTION] . '[url=' . $url . ']' . $label . '[/url]';
}
}
}
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Profile;
+use Friendica\Model\Tag;
use Friendica\Model\Term;
use Friendica\Module\Security\Login;
use Friendica\Util\DateTimeFormat;
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
WHERE `item`.`uid` = 0 AND `item`.$ordering < ? AND `item`.$ordering > ? AND `item`.`gravity` = ?
AND NOT `author`.`hidden` AND NOT `author`.`blocked`" . $sql_tag_nets,
- local_user(), Term::OBJECT_TYPE_POST, Term::HASHTAG,
+ local_user(), Term::OBJECT_TYPE_POST, Tag::HASHTAG,
$top_limit, $bottom_limit, GRAVITY_PARENT);
$data = DBA::toArray($items);
q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
intval($item['id']),
$term_objtype,
- Term::HASHTAG,
+ Tag::HASHTAG,
DBA::escape($term),
'',
intval($owner_uid)
q("INSERT INTO term (`oid`, `otype`, `type`, `term`, `url`, `uid`) VALUE (%d, %d, %d, '%s', '%s', %d)",
intval($original_item['id']),
$term_objtype,
- Term::HASHTAG,
+ Tag::HASHTAG,
DBA::escape($term),
'',
intval($owner_uid)
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
+use Friendica\Model\Tag;
use Friendica\Model\Term;
/**
* @return string HTML formatted output.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = Term::HASHTAG)
+ public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = Tag::HASHTAG)
{
$o = '';
$r = self::tagadelic($uid, $count, $owner_id, $flags, $type);
* @return array Alphabetical sorted array of used tags of an user.
* @throws \Exception
*/
- private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = Term::HASHTAG)
+ private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = Tag::HASHTAG)
{
$sql_options = Item::getPermissionsSQLByUserId($uid);
$limit = $count ? sprintf('LIMIT %d', intval($count)) : '';
use Friendica\Core\Renderer;
use Friendica\DI;
+use Friendica\Model\Tag;
use Friendica\Model\Term;
/**
// Field list that is used to display the items
const DISPLAY_FIELDLIST = [
- 'uid', 'id', 'parent', 'uri', 'thr-parent', 'parent-uri', 'guid', 'network', 'gravity',
+ 'uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid', 'network', 'gravity',
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'attach', 'language',
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
];
// Field list that is used to deliver items via the protocols
- const DELIVER_FIELDLIST = ['uid', 'id', 'parent', 'uri', 'thr-parent', 'parent-uri', 'guid',
+ const DELIVER_FIELDLIST = ['uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid',
'parent-guid', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
'private', 'title', 'body', 'location', 'coord', 'app',
'attach', 'tag', 'deleted', 'extid', 'post-type',
// Check for hashtags in the body and repair or add hashtag links
self::setHashtags($item);
+ // Store tags from the body if this hadn't been handled previously in the protocol classes
+ if (!Tag::existsForPost($item['uri-id'])) {
+ Tag::storeFromBody($item['uri-id'], $item['body']);
+ }
+
$item['thr-parent'] = $item['parent-uri'];
$notify_type = Delivery::POST;
return $ev;
}
- $tags = Term::populateTagsFromItem($item);
+ $tags = Tag::populateTagsFromItem($item);
$item['tags'] = $tags['tags'];
$item['hashtags'] = $tags['hashtags'];
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings;
+use Friendica\Model\Tag;
use Friendica\Model\Term;
class UserItem
}
// Or the contact is a mentioned forum
- $tags = DBA::select('term', ['url'], ['otype' => Term::OBJECT_TYPE_POST, 'oid' => $item['id'], 'type' => Term::MENTION, 'uid' => $uid]);
+ $tags = DBA::select('term', ['url'], ['otype' => Term::OBJECT_TYPE_POST, 'oid' => $item['id'], 'type' => Tag::MENTION, 'uid' => $uid]);
while ($tag = DBA::fetch($tags)) {
$condition = ['nurl' => Strings::normaliseLink($tag['url']), 'uid' => $uid, 'notify_new_posts' => true, 'contact-type' => Contact::TYPE_COMMUNITY];
if (DBA::exists('contact', $condition)) {
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Util\Strings;
+use Friendica\Model\Tag;
use Friendica\Model\Term;
/**
$taglist = DBA::p("SELECT DISTINCT(`term`) FROM `term` WHERE `term` LIKE ? AND `type` = ? ORDER BY `term`",
$t . '%',
- intval(Term::HASHTAG)
+ intval(Tag::HASHTAG)
);
while ($tag = DBA::fetch($taglist)) {
$result[] = ['text' => $tag['term']];
use Friendica\Model\Item;
use Friendica\Model\Profile as ProfileModel;
use Friendica\Model\User;
+use Friendica\Model\Tag;
use Friendica\Model\Term;
use Friendica\Module\BaseProfile;
use Friendica\Module\Security\Login;
if (!empty($hashtags)) {
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
- DBA::escape(Strings::protectSprintf($hashtags)), intval(Term::OBJECT_TYPE_POST), intval(Term::HASHTAG), intval($a->profile['uid']));
+ DBA::escape(Strings::protectSprintf($hashtags)), intval(Term::OBJECT_TYPE_POST), intval(Tag::HASHTAG), intval($a->profile['uid']));
}
if (!empty($datequery)) {
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
+use Friendica\Model\Tag;
use Friendica\Model\Term;
use Friendica\Module\BaseSearch;
use Friendica\Network\HTTPException;
$condition = [
"(`uid` = 0 OR (`uid` = ? AND NOT `global`))
AND `otype` = ? AND `type` = ? AND `term` = ?",
- local_user(), Term::OBJECT_TYPE_POST, Term::HASHTAG, $search
+ local_user(), Term::OBJECT_TYPE_POST, Tag::HASHTAG, $search
];
$params = [
'order' => ['received' => true],