use Friendica\Database\DBA;
use Friendica\Model\Item;
+use Friendica\Model\Post;
use Friendica\Model\Tag;
/**
{
$file_text = '';
- $tags = DBA::selectToArray('post-category', ['type', 'name'], ['uri-id' => $uri_id, 'uid' => $uid]);
+ $tags = DBA::selectToArray('category-view', ['type', 'name'], ['uri-id' => $uri_id, 'uid' => $uid]);
foreach ($tags as $tag) {
if ($tag['type'] == self::CATEGORY) {
- $file_text .= '<' . $tag['term'] . '>';
+ $file_text .= '<' . $tag['name'] . '>';
} else {
- $file_text .= '[' . $tag['term'] . ']';
+ $file_text .= '[' . $tag['name'] . ']';
}
}
*/
public static function storeTextByURIId(int $uri_id, int $uid, string $files)
{
- $message = Item::selectFirst(['deleted'], ['uri-id' => $uri_id, 'uid' => $uid]);
- if (!DBA::isResult($message)) {
- return;
- }
-
- // Clean up all tags
- DBA::delete('post-category', ['uri-id' => $uri_id, 'uid' => $uid]);
+ $message = Post::selectFirst(['deleted'], ['uri-id' => $uri_id, 'uid' => $uid]);
+ if (DBA::isResult($message)) {
+ // Clean up all tags
+ DBA::delete('post-category', ['uri-id' => $uri_id, 'uid' => $uid]);
- if ($message['deleted']) {
- return;
+ if ($message['deleted']) {
+ return;
+ }
}
if (preg_match_all("/\[(.*?)\]/ism", $files, $result)) {
continue;
}
- DBA::insert('post-category', [
+ DBA::replace('post-category', [
'uri-id' => $uri_id,
'uid' => $uid,
'type' => self::FILE,
continue;
}
- DBA::insert('post-category', [
+ DBA::replace('post-category', [
'uri-id' => $uri_id,
'uid' => $uid,
'type' => self::CATEGORY,