- if (isset($_POST['deletetag']) && !empty($_POST['fromtag'])) {
- $delete = true;
- } else if (isset($_POST['renametag']) && !empty($_POST['fromtag']) && !empty($_POST['totag'])) {
- $delete = false;
- } else {
- $PAGE->renderPage('changetag');
- exit;
- }
-
- $count = 0;
- $needle = trim($_POST['fromtag']);
- // True for case-sensitive tag search.
- $linksToAlter = $LINKSDB->filterSearch(array('searchtags' => $needle), true);
- foreach($linksToAlter as $key => $value)
- {
- $tags = explode(' ',trim($value['tags']));
- if (($pos = array_search($needle,$tags)) !== false) {
- if ($delete) {
- unset($tags[$pos]); // Remove tag.
- } else {
- $tags[$pos] = trim($_POST['totag']);
- }
- $value['tags'] = trim(implode(' ', array_unique($tags)));
- $LINKSDB[$key]=$value;
- $history->updateLink($LINKSDB[$key]);
- ++$count;
- }
- }