public function process_tags($form)
{
if ($_POST['action'] == 'delete') {
$tag_names = array();
foreach ($form->selected_items->value as $id) {
// We only collect the names so we can display them - deletion could also happen directly using the id
$tag = Tags::get_by_id($id);
$tag_names[] = $tag->term_display;
Tags::vocabulary()->delete_term($tag);
}
Session::notice(_n(_t('Tag %s has been deleted.', array(implode('', $tag_names))), _t('%d tags have been deleted.', array(count($tag_names))), count($tag_names)));
} elseif ($_POST['action'] == 'rename') {
if (!isset($_POST['rename_text']) || empty($_POST['rename_text'])) {
Session::error(_t('Error: New name not specified.'));
} else {
$tag_names = array();
foreach ($form->selected_items->value as $id) {
$tag = Tags::get_by_id($id);
$tag_names[] = $tag->term_display;
}
Tags::vocabulary()->merge($_POST['rename_text'], $tag_names);
Session::notice(sprintf(_n('Tag %1$s has been renamed to %2$s.', 'Tags %1$s have been renamed to %2$s.', count($tag_names)), implode($tag_names, ', '), $_POST['rename_text']));
}
}
Utils::redirect(URL::get('display_tags'));
}