aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/LinkDB.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php
index 8ca0fab3..5e38e848 100644
--- a/application/LinkDB.php
+++ b/application/LinkDB.php
@@ -464,6 +464,39 @@ You use the community supported version of the original Shaarli project, by Seba
464 } 464 }
465 465
466 /** 466 /**
467 * Rename or delete a tag across all links.
468 *
469 * @param string $from Tag to rename
470 * @param string $to New tag. If none is provided, the from tag will be deleted
471 *
472 * @return array|bool List of altered links or false on error
473 */
474 public function renameTag($from, $to)
475 {
476 if (empty($from)) {
477 return false;
478 }
479 $delete = empty($to);
480 // True for case-sensitive tag search.
481 $linksToAlter = $this->filterSearch(['searchtags' => $from], true);
482 foreach($linksToAlter as $key => &$value)
483 {
484 $tags = preg_split('/\s+/', trim($value['tags']));
485 if (($pos = array_search($from, $tags)) !== false) {
486 if ($delete) {
487 unset($tags[$pos]); // Remove tag.
488 } else {
489 $tags[$pos] = trim($to);
490 }
491 $value['tags'] = trim(implode(' ', array_unique($tags)));
492 $this[$value['id']] = $value;
493 }
494 }
495
496 return $linksToAlter;
497 }
498
499 /**
467 * Returns the list of days containing articles (oldest first) 500 * Returns the list of days containing articles (oldest first)
468 * Output: An array containing days (in format YYYYMMDD). 501 * Output: An array containing days (in format YYYYMMDD).
469 */ 502 */