aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/pageutils.php
diff options
context:
space:
mode:
authorSatoshi Sahara <sahara.satoshi@gmail.com>2021-05-09 13:26:07 +0900
committerGitHub <noreply@github.com>2021-05-09 13:26:07 +0900
commit700ab9fdf1102a367a591bba2bc4a470ca345d2f (patch)
tree1e118d31fcf905132d7b3dc8aba2e21b4d1c0e5f /inc/pageutils.php
parent871895a75d164d6a6389dbba8ae132577a744de4 (diff)
parent55c2f8c9858c38a70d317809fbfbee6439c10291 (diff)
downloaddokuwiki-700ab9fdf1102a367a591bba2bc4a470ca345d2f.tar.gz
dokuwiki-700ab9fdf1102a367a591bba2bc4a470ca345d2f.zip
Merge branch 'master' into revisionHandle3
Diffstat (limited to 'inc/pageutils.php')
-rw-r--r--inc/pageutils.php17
1 files changed, 9 insertions, 8 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php
index d4a8bb7c4..c281ffc5b 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -226,7 +226,7 @@ function noNSorNS($id) {
* Creates a XHTML valid linkid from a given headline title
*
* @param string $title The headline title
- * @param array|bool $check Existing IDs (title => number)
+ * @param array|bool $check Existing IDs
* @return string the title
*
* @author Andreas Gohr <andi@splitbrain.org>
@@ -241,15 +241,16 @@ function sectionID($title,&$check) {
}
if(is_array($check)){
- // make sure tiles are unique
- if (!array_key_exists ($title,$check)) {
- $check[$title] = 0;
- } else {
- $title .= ++ $check[$title];
+ $suffix=0;
+ $candidateTitle = $title;
+ while(in_array($candidateTitle, $check)){
+ $candidateTitle = $title . ++$suffix;
}
+ $check []= $candidateTitle;
+ return $candidateTitle;
+ } else {
+ return $title;
}
-
- return $title;
}
/**