Index: trunk/phase3/includes/Parser.php |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | var $mOutput, $mAutonumber, $mDTopen, $mStripState; |
102 | 102 | var $mIncludeCount, $mArgStack, $mLastSection, $mInPre; |
103 | 103 | var $mInterwikiLinkHolders, $mLinkHolders, $mUniqPrefix; |
104 | | - var $mIncludeSizes; |
| 104 | + var $mIncludeSizes, $mDefaultSort; |
105 | 105 | var $mTemplates, // cache of already loaded templates, avoids |
106 | 106 | // multiple SQL queries for the same string |
107 | 107 | $mTemplatePath; // stores an unsorted hash of all the templates already loaded |
— | — | @@ -167,6 +167,7 @@ |
168 | 168 | $this->setFunctionHook( 'padright', array( 'CoreParserFunctions', 'padright' ), SFH_NO_HASH ); |
169 | 169 | $this->setFunctionHook( 'anchorencode', array( 'CoreParserFunctions', 'anchorencode' ), SFH_NO_HASH ); |
170 | 170 | $this->setFunctionHook( 'special', array( 'CoreParserFunctions', 'special' ) ); |
| 171 | + $this->setFunctionHook( 'defaultsort', array( 'CoreParserFunctions', 'defaultsort' ), SFH_NO_HASH ); |
171 | 172 | |
172 | 173 | if ( $wgAllowDisplayTitle ) { |
173 | 174 | $this->setFunctionHook( 'displaytitle', array( 'CoreParserFunctions', 'displaytitle' ), SFH_NO_HASH ); |
— | — | @@ -231,6 +232,7 @@ |
232 | 233 | 'post-expand' => 0, |
233 | 234 | 'arg' => 0 |
234 | 235 | ); |
| 236 | + $this->mDefaultSort = false; |
235 | 237 | |
236 | 238 | wfRunHooks( 'ParserClearState', array( &$this ) ); |
237 | 239 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1750,11 +1752,7 @@ |
1751 | 1753 | $s = rtrim($s . "\n"); # bug 87 |
1752 | 1754 | |
1753 | 1755 | if ( $wasblank ) { |
1754 | | - if ( $this->mTitle->getNamespace() == NS_CATEGORY ) { |
1755 | | - $sortkey = $this->mTitle->getText(); |
1756 | | - } else { |
1757 | | - $sortkey = $this->mTitle->getPrefixedText(); |
1758 | | - } |
| 1756 | + $sortkey = $this->getDefaultSort(); |
1759 | 1757 | } else { |
1760 | 1758 | $sortkey = $text; |
1761 | 1759 | } |
— | — | @@ -4667,6 +4665,32 @@ |
4668 | 4666 | } |
4669 | 4667 | return $this->mRevisionTimestamp; |
4670 | 4668 | } |
| 4669 | + |
| 4670 | + /** |
| 4671 | + * Mutator for $mDefaultSort |
| 4672 | + * |
| 4673 | + * @param $sort New value |
| 4674 | + */ |
| 4675 | + public function setDefaultSort( $sort ) { |
| 4676 | + $this->mDefaultSort = $sort; |
| 4677 | + } |
| 4678 | + |
| 4679 | + /** |
| 4680 | + * Accessor for $mDefaultSort |
| 4681 | + * Will use the title/prefixed title if none is set |
| 4682 | + * |
| 4683 | + * @return string |
| 4684 | + */ |
| 4685 | + public function getDefaultSort() { |
| 4686 | + if( $this->mDefaultSort !== false ) { |
| 4687 | + return $this->mDefaultSort; |
| 4688 | + } else { |
| 4689 | + return $this->mTitle->getNamespace() == NS_CATEGORY |
| 4690 | + ? $this->mTitle->getText() |
| 4691 | + : $this->mTitle->getPrefixedText(); |
| 4692 | + } |
| 4693 | + } |
| 4694 | + |
4671 | 4695 | } |
4672 | 4696 | |
4673 | 4697 | /** |
Index: trunk/phase3/includes/MagicWord.php |
— | — | @@ -101,6 +101,7 @@ |
102 | 102 | 'contentlanguage', |
103 | 103 | 'pagesinnamespace', |
104 | 104 | 'numberofadmins', |
| 105 | + 'defaultsort', |
105 | 106 | ); |
106 | 107 | |
107 | 108 | static public $mObjects = array(); |
Index: trunk/phase3/includes/CoreParserFunctions.php |
— | — | @@ -180,6 +180,14 @@ |
181 | 181 | return wfMsgForContent( 'nosuchspecialpage' ); |
182 | 182 | } |
183 | 183 | } |
| 184 | + |
| 185 | + public static function defaultsort( $parser, $text ) { |
| 186 | + $text = trim( $text ); |
| 187 | + if( strlen( $text ) > 0 ) |
| 188 | + $parser->setDefaultSort( $text ); |
| 189 | + return ''; |
| 190 | + } |
| 191 | + |
184 | 192 | } |
185 | 193 | |
186 | 194 | ?> |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -423,8 +423,9 @@ |
424 | 424 | * (bug 8401) Fix regression in SORBS lookup for some DNS setups |
425 | 425 | * Use raw file descriptor in posix_isatty() check to avoid warning on |
426 | 426 | Linux systems with at least some versions of PHP |
| 427 | +* (bug 5908) Allow overriding the default category sort key for all items on |
| 428 | + a page using {{DEFAULTSORT}} |
427 | 429 | |
428 | | - |
429 | 430 | == Languages updated == |
430 | 431 | |
431 | 432 | * Basque (eu) |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -332,6 +332,7 @@ |
333 | 333 | 'padleft' => array( 0, 'PADLEFT' ), |
334 | 334 | 'padright' => array( 0, 'PADRIGHT' ), |
335 | 335 | 'special' => array( 0, 'special', ), |
| 336 | + 'defaultsort' => array( 1, 'DEFAULTSORT:' ), |
336 | 337 | ); |
337 | 338 | |
338 | 339 | /** |