Merge pull request #8585 from annando/legacy-tag

Removed legacy usage of the "tag" field
This commit is contained in:
Hypolite Petovan 2020-05-05 18:10:22 -04:00 committed by GitHub
commit f4083f6031
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View file

@ -1307,9 +1307,10 @@ function photos_content(App $a)
} }
$tags = null; $tags = null;
$tag_text = Tag::getCSVByURIId($link_item['uri-id']);
if (!empty($link_item['id']) && !empty($link_item['tag'])) { if (!empty($link_item['id']) && !empty($tag_text)) {
$arr = explode(',', $link_item['tag']); $arr = explode(',', $tag_text);
// parse tags and add links // parse tags and add links
$tag_arr = []; $tag_arr = [];
foreach ($arr as $tag) { foreach ($arr as $tag) {

View file

@ -97,15 +97,16 @@ function tagrm_content(App $a)
// NOTREACHED // NOTREACHED
} }
$item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]); $item = Item::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
DI::baseUrl()->redirect($_SESSION['photo_return']); DI::baseUrl()->redirect($_SESSION['photo_return']);
} }
$arr = explode(',', $item['tag']); $tag_text = Tag::getCSVByURIId($item['uri-id']);
$arr = explode(',', $tag_text);
if (empty($item['tag'])) { if (empty($arr)) {
DI::baseUrl()->redirect($_SESSION['photo_return']); DI::baseUrl()->redirect($_SESSION['photo_return']);
} }

View file

@ -339,6 +339,23 @@ class Tag
return DBA::selectToArray('tag-view', ['type', 'name', 'url'], $condition); return DBA::selectToArray('tag-view', ['type', 'name', 'url'], $condition);
} }
/**
* Return a string with all tags and mentions
*
* @param integer $uri_id
* @return string tags and mentions
*/
public static function getCSVByURIId(int $uri_id)
{
$tag_list = [];
$tags = self::getByURIId($uri_id);
foreach ($tags as $tag) {
$tag_list[] = self::TAG_CHARACTER[$tag['type']] . '[url=' . $tag['url'] . ']' . $tag['name'] . '[/url]';
}
return implode(',', $tag_list);
}
/** /**
* Sorts an item's tags into mentions, hashtags and other tags. Generate personalized URLs by user and modify the * Sorts an item's tags into mentions, hashtags and other tags. Generate personalized URLs by user and modify the
* provided item's body with them. * provided item's body with them.