// parse tags and add links
$tag_arr = [];
foreach ($arr as $tag) {
- array_push($tag_arr, ['name' => BBCode::convert($tag), 'removeurl' => '/tagrm/'.$link_item['id'] . '/' . bin2hex($tag)]);
+ array_push($tag_arr, ['name' => BBCode::convert($tag),
+ 'removeurl' => '/tagrm/'.$link_item['id'] . '/' . bin2hex($tag)]);
}
$tags = ['title' => L10n::t('Tags: '), 'tags' => $tag_arr];
if ($cmd === 'edit') {
$tags += ['removeanyurl' => 'tagrm/' . $link_item['id']];
- $tags += ['removetitle' => L10n::t('[Remove any tag]')];
+ $tags += ['removetitle' => L10n::t('[Select tags to remove]')];
}
}
$item_id = defaults($_POST,'item', 0);
update_tags($item_id, $tags);
- info(L10n::t('Tag(s) removed') . EOL );
-
$a->internalRedirect($_SESSION['photo_return']);
// NOTREACHED
*/
function update_tags($item_id, $tags){
if (empty($item_id) || empty($tags)){
- $a->internalRedirect($_SESSION['photo_return']);
+ return;
}
$item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
- $a->internalRedirect($_SESSION['photo_return']);
+ return;
}
$old_tags = explode(',', $item['tag']);
}
$tag_str = implode(',',$old_tags);
- if(!empty($tag_str)) {
- Item::update(['tag' => $tag_str], ['id' => $item_id]);
- }
- else {
- Term::deleteByItemId($item_id);
- }
+ Term::insertFromTagFieldByItemId($item_id, $tag_str);
info(L10n::t('Tag(s) removed') . EOL );
}