mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-16 20:05:14 +02:00
The old tag handling is removed
This commit is contained in:
parent
92cf4879e5
commit
b0cb6536dd
14 changed files with 40 additions and 543 deletions
|
@ -25,7 +25,6 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\Term;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function tagrm_post(App $a)
|
||||
|
@ -58,35 +57,24 @@ function tagrm_post(App $a)
|
|||
* @param $tags array
|
||||
* @throws Exception
|
||||
*/
|
||||
function update_tags($item_id, $tags){
|
||||
if (empty($item_id) || empty($tags)){
|
||||
function update_tags($item_id, $tags)
|
||||
{
|
||||
if (empty($item_id) || empty($tags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$item = Item::selectFirst(['tag', 'uri-id'], ['id' => $item_id, 'uid' => local_user()]);
|
||||
$item = Item::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]);
|
||||
if (!DBA::isResult($item)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$old_tags = explode(',', $item['tag']);
|
||||
|
||||
foreach ($tags as $new_tag) {
|
||||
if (preg_match_all('/([#@!])\[url\=([^\[\]]*)\]([^\[\]]*)\[\/url\]/ism', $new_tag, $results, PREG_SET_ORDER)) {
|
||||
foreach ($results as $tag) {
|
||||
Tag::removeByHash($item['uri-id'], $tag[1], $tag[3], $tag[2]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($old_tags as $index => $old_tag) {
|
||||
if (strcmp($old_tag, $new_tag) == 0) {
|
||||
unset($old_tags[$index]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tag_str = implode(',', $old_tags);
|
||||
Term::insertFromTagFieldByItemId($item_id, $tag_str);
|
||||
}
|
||||
|
||||
function tagrm_content(App $a)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue