summaryrefslogtreecommitdiff
path: root/inc/parser
diff options
context:
space:
mode:
authorChris Smith <chris.eureka@jalakai.co.uk>2009-04-19 18:08:06 +0200
committerChris Smith <chris.eureka@jalakai.co.uk>2009-04-19 18:08:06 +0200
commit7cc4b757599955448f7e34845a802e2a03240be0 (patch)
tree4a2de8486d486f7ccc9fad899663b524c7526b0e /inc/parser
parent3c147a01a69ef160ca27492a49ae58daf2d15c20 (diff)
downloadrpg-7cc4b757599955448f7e34845a802e2a03240be0.tar.gz
rpg-7cc4b757599955448f7e34845a802e2a03240be0.tar.bz2
FS#1648 - sort acronyms into descending order by string length
darcs-hash:20090419160806-f07c6-a2d1bd681e2dd369422bd3839d2837833288cee5.gz
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/parser.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index db49ff0c3..491206b81 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -611,6 +611,7 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
var $pattern = '';
function Doku_Parser_Mode_acronym($acronyms) {
+ usort($acronyms,array($this,'_compare'));
$this->acronyms = $acronyms;
}
@@ -633,6 +634,21 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
function getSort() {
return 240;
}
+
+ /**
+ * sort callback to order by string length descending
+ */
+ function _compare($a,$b) {
+ $a_len = strlen($a);
+ $b_len = strlen($b);
+ if ($a_len > $b_len) {
+ return -1;
+ } else if ($a_len < $b_len) {
+ return 1;
+ }
+
+ return 0;
+ }
}
//-------------------------------------------------------------------