* (bug 12644) Template list on edit page now sorted on preview
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 8 May 2008 23:16:36 +0000 (23:16 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 8 May 2008 23:16:36 +0000 (23:16 +0000)
On initial edit, items were sorted by virtue of being pulled from a sorted table, but on preview they were displayed in rough order of use in parsing, which is a bit less legible.

Added Title::compare() static comparator available as a callback for usort(), using it in Linker::formatTemplates().

RELEASE-NOTES
includes/Linker.php
includes/Title.php

index 88b3f2d..8089db7 100644 (file)
@@ -265,6 +265,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 14047) Fix regression in installer which hid DB-specific options.
   Also makes SQLite path configurable in the installer.
 * (bug 13546) Follow image redirects on image page
+* (bug 12644) Template list on edit page now sorted on preview
 
 === API changes in 1.13 ===
 
index 037d12c..a2d48c6 100644 (file)
@@ -1357,6 +1357,7 @@ class Linker {
                        }
                        $outText .= '</div><ul>';
 
+                       usort( $templates, array( 'Title', 'compare' ) );
                        foreach ( $templates as $titleObj ) {
                                $r = $titleObj->getRestrictions( 'edit' );
                                if ( in_array( 'sysop', $r ) ) {
index 70673ac..9dc3b4e 100644 (file)
@@ -2935,6 +2935,17 @@ class Title {
                        && $this->getDBkey() === $title->getDBkey();
        }
 
+       /**
+        * Callback for usort() to do title sorts by (namespace, title)
+        */
+       static function compare( $a, $b ) {
+               if( $a->getNamespace() == $b->getNamespace() ) {
+                       return strcmp( $a->getText(), $b->getText() );
+               } else {
+                       return $a->getNamespace() - $b->getNamespace();
+               }
+       }
+
        /**
         * Return a string representation of this title
         *