| Index: trunk/phase3/RELEASE-NOTES-1.19 |
| — | — | @@ -57,6 +57,8 @@ |
| 58 | 58 | * (bug 30774) mediawiki.html: Add support for numbers and booleans in the |
| 59 | 59 | attribute values and element contents. |
| 60 | 60 | * Conversion script between Tifinagh and Latin for the Tachelhit language |
| | 61 | +* (bug 16755) Add options 'noreplace' and 'noerror' to {{DEFAULTSORT:...}} |
| | 62 | + to stop it from replace an already existing default sort, and suppress error. |
| 61 | 63 | |
| 62 | 64 | === Bug fixes in 1.19 === |
| 63 | 65 | * $wgUploadNavigationUrl should be used for file redlinks if |
| Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
| — | — | @@ -677,23 +677,33 @@ |
| 678 | 678 | |
| 679 | 679 | /** |
| 680 | 680 | * @param $parser Parser |
| 681 | | - * @param $text |
| | 681 | + * @param $text String The sortkey to use |
| | 682 | + * @param $arg String Either "noreplace" or "noerror" |
| | 683 | + * both suppress errors, and noreplace does nothing if |
| | 684 | + * a default sortkey already exists. |
| 682 | 685 | * @return string |
| 683 | 686 | */ |
| 684 | | -public static function defaultsort( $parser, $text ) { |
| | 687 | +public static function defaultsort( $parser, $text, $arg = '' ) { |
| 685 | 688 | $text = trim( $text ); |
| | 689 | +$arg = trim( strtolower( $arg ) ); |
| 686 | 690 | if( strlen( $text ) == 0 ) |
| 687 | 691 | return ''; |
| 688 | 692 | $old = $parser->getCustomDefaultSort(); |
| 689 | | -$parser->setDefaultSort( $text ); |
| 690 | | -if( $old === false || $old == $text ) |
| | 693 | +if ( $old === false || $arg !== 'noreplace' ) { |
| | 694 | +$parser->setDefaultSort( $text ); |
| | 695 | +} |
| | 696 | + |
| | 697 | +if( $old === false || $old == $text || $arg === 'noreplace' |
| | 698 | +|| $arg === 'noerror' ) |
| | 699 | +{ |
| 691 | 700 | return ''; |
| 692 | | -else |
| | 701 | +} else { |
| 693 | 702 | return( '<span>' . |
| 694 | 703 | wfMsgForContent( 'duplicate-defaultsort', |
| 695 | 704 | htmlspecialchars( $old ), |
| 696 | 705 | htmlspecialchars( $text ) ) . |
| 697 | 706 | '</span>' ); |
| | 707 | +} |
| 698 | 708 | } |
| 699 | 709 | |
| 700 | 710 | // Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}} |