to in both cases prevent the "A sortkey already was specified earlier in the page, yadda yadda" message and in the second case, also do not replace the sortkey
if one was already specified.
* (bug 30774) mediawiki.html: Add support for numbers and booleans in the
attribute values and element contents.
* Conversion script between Tifinagh and Latin for the Tachelhit language
* (bug 30774) mediawiki.html: Add support for numbers and booleans in the
attribute values and element contents.
* Conversion script between Tifinagh and Latin for the Tachelhit language
+* (bug 16755) Add options 'noreplace' and 'noerror' to {{DEFAULTSORT:...}}
+ to stop it from replace an already existing default sort, and suppress error.
=== Bug fixes in 1.19 ===
* $wgUploadNavigationUrl should be used for file redlinks if
=== Bug fixes in 1.19 ===
* $wgUploadNavigationUrl should be used for file redlinks if
/**
* @param $parser Parser
/**
* @param $parser Parser
+ * @param $text String The sortkey to use
+ * @param $arg String Either "noreplace" or "noerror"
+ * both suppress errors, and noreplace does nothing if
+ * a default sortkey already exists.
- public static function defaultsort( $parser, $text ) {
+ public static function defaultsort( $parser, $text, $arg = '' ) {
+ $arg = trim( strtolower( $arg ) );
if( strlen( $text ) == 0 )
return '';
$old = $parser->getCustomDefaultSort();
if( strlen( $text ) == 0 )
return '';
$old = $parser->getCustomDefaultSort();
- $parser->setDefaultSort( $text );
- if( $old === false || $old == $text )
+ if ( $old === false || $arg !== 'noreplace' ) {
+ $parser->setDefaultSort( $text );
+ }
+
+ if( $old === false || $old == $text || $arg === 'noreplace'
+ || $arg === 'noerror' )
+ {
return( '<span class="error">' .
wfMsgForContent( 'duplicate-defaultsort',
htmlspecialchars( $old ),
htmlspecialchars( $text ) ) .
'</span>' );
return( '<span class="error">' .
wfMsgForContent( 'duplicate-defaultsort',
htmlspecialchars( $old ),
htmlspecialchars( $text ) ) .
'</span>' );
}
// Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}}
}
// Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}}