From c6568d42d53cab0d8fef498f00a3b9f30d7403ad Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 12 Mar 2014 18:20:33 +0000 Subject: Refactor updateTuple() The existing function was difficult to follow. It worked when adding a new tuple, but not in the most sensible manner. --- inc/indexer.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'inc') diff --git a/inc/indexer.php b/inc/indexer.php index a167db47f..5ca2f0bb1 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -1218,19 +1218,18 @@ class Doku_Indexer { * @author Tom N Harris */ protected function updateTuple($line, $id, $count) { - $newLine = $line; - if ($newLine !== ''){ - $newLine = preg_replace('/(^|:)'.preg_quote($id,'/').'\*\d*/', '', $newLine); + if ($line != ''){ + $line = preg_replace('/(^|:)'.preg_quote($id,'/').'\*\d*/', '', $line); } - $newLine = trim($newLine, ':'); + $line = trim($line, ':'); if ($count) { - if (strlen($newLine) > 0) { - return "$id*$count:".$newLine; + if ($line) { + return "$id*$count:".$line; } else { - return "$id*$count".$newLine; + return "$id*$count"; } } - return $newLine; + return $line; } /** -- cgit v1.2.3