mirror of
https://github.com/friendica/friendica
synced 2025-04-26 18:30:11 +00:00
More preparations for term to tag transition
This commit is contained in:
parent
5df5e9521b
commit
7f5f68a904
11 changed files with 33 additions and 21 deletions
|
@ -25,6 +25,7 @@ use Friendica\Core\Renderer;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\Term;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +47,7 @@ class TagCloud
|
|||
* @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);
|
||||
|
@ -85,7 +86,7 @@ class TagCloud
|
|||
* @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)) : '';
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Content\Widget;
|
|||
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\Term;
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,7 +61,7 @@ class Item
|
|||
|
||||
// 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',
|
||||
|
@ -77,7 +77,7 @@ class Item
|
|||
];
|
||||
|
||||
// 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',
|
||||
|
@ -1674,6 +1674,11 @@ class Item
|
|||
// 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;
|
||||
|
@ -3558,7 +3563,7 @@ class Item
|
|||
return $ev;
|
||||
}
|
||||
|
||||
$tags = Term::populateTagsFromItem($item);
|
||||
$tags = Tag::populateTagsFromItem($item);
|
||||
|
||||
$item['tags'] = $tags['tags'];
|
||||
$item['hashtags'] = $tags['hashtags'];
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\Term;
|
||||
|
||||
class UserItem
|
||||
|
@ -207,7 +208,7 @@ 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)) {
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\BaseModule;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\Term;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +45,7 @@ class Hashtag extends BaseModule
|
|||
|
||||
$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']];
|
||||
|
|
|
@ -31,6 +31,7 @@ use Friendica\DI;
|
|||
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;
|
||||
|
@ -148,7 +149,7 @@ class Status extends BaseProfile
|
|||
|
||||
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)) {
|
||||
|
|
|
@ -33,6 +33,7 @@ use Friendica\Database\DBA;
|
|||
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;
|
||||
|
@ -153,7 +154,7 @@ class Index extends BaseSearch
|
|||
$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],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue