mirror of
https://github.com/friendica/friendica
synced 2025-04-26 16:30:12 +00:00
File and category aren't using "term" anymore
This commit is contained in:
parent
233d6eea2b
commit
875d6b36e9
10 changed files with 276 additions and 59 deletions
|
@ -124,22 +124,14 @@ class Tag
|
|||
}
|
||||
|
||||
if (empty($cid)) {
|
||||
$fields = ['name' => substr($name, 0, 96), 'url' => ''];
|
||||
|
||||
if (($type != self::HASHTAG) && !empty($url) && ($url != $name)) {
|
||||
$fields['url'] = strtolower($url);
|
||||
}
|
||||
|
||||
$tag = DBA::selectFirst('tag', ['id'], $fields);
|
||||
if (!DBA::isResult($tag)) {
|
||||
DBA::insert('tag', $fields, true);
|
||||
$tagid = DBA::lastInsertId();
|
||||
$url = strtolower($url);
|
||||
} else {
|
||||
$tagid = $tag['id'];
|
||||
$url = '';
|
||||
}
|
||||
|
||||
$tagid = self::getID($name, $url);
|
||||
if (empty($tagid)) {
|
||||
Logger::error('No tag id created', $fields);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +152,32 @@ class Tag
|
|||
Logger::info('Stored tag/mention', ['uri-id' => $uriid, 'tag-id' => $tagid, 'contact-id' => $cid, 'name' => $name, 'type' => $type, 'callstack' => System::callstack(8)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a tag id for a given tag name and url
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $url
|
||||
* @return void
|
||||
*/
|
||||
public static function getID(string $name, string $url = '')
|
||||
{
|
||||
$fields = ['name' => substr($name, 0, 96), 'url' => $url];
|
||||
|
||||
$tag = DBA::selectFirst('tag', ['id'], $fields);
|
||||
if (DBA::isResult($tag)) {
|
||||
return $tag['id'];
|
||||
}
|
||||
|
||||
DBA::insert('tag', $fields, true);
|
||||
$tid = DBA::lastInsertId();
|
||||
if (!empty($tid)) {
|
||||
return $tid;
|
||||
}
|
||||
|
||||
Logger::error('No tag id created', $fields);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store tag/mention elements
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue