Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/90551
Change subject: Use restriction-level-* messages in Linker::formatTemplates
......................................................................
Use restriction-level-* messages in Linker::formatTemplates
The current implementation of Linker::formatTemplates only checks for
"sysop" and "autoconfirmed", and completely ignores any other protection
levels. That needs fixing.
Rather than introducing additional messages "template-protected-*" to
match template-protected and template-semiprotected, let's just use the
existing restriction-level-foo messages and wrap them in parentheses.
The old messages are kept for backwards compatability, but could
probably be considered deprecated.
Bug: 43462
Change-Id: I0c507f4ecc1921f599acbda834fa55e96388fa7b
---
M includes/Linker.php
1 file changed, 23 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/51/90551/1
diff --git a/includes/Linker.php b/includes/Linker.php
index 5bb9230..23ece75 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -1960,6 +1960,7 @@
* @return String: HTML output
*/
public static function formatTemplates( $templates, $preview = false,
$section = false, $more = null ) {
+ global $wgLang;
wfProfileIn( __METHOD__ );
$outText = '';
@@ -1987,13 +1988,28 @@
usort( $templates, 'Title::compare' );
foreach ( $templates as $titleObj ) {
- $r = $titleObj->getRestrictions( 'edit' );
- if ( in_array( 'sysop', $r ) ) {
- $protected = wfMessage(
'template-protected' )->parse();
- } elseif ( in_array( 'autoconfirmed', $r ) ) {
- $protected = wfMessage(
'template-semiprotected' )->parse();
- } else {
- $protected = '';
+ $protected = '';
+ $restrictions = $titleObj->getRestrictions(
'edit' );
+ if ( $restrictions ) {
+ // Check backwards-compatible messages
+ $msg = null;
+ if ( $restrictions === array( 'sysop' )
) {
+ $msg = wfMessage(
'template-protected' );
+ } elseif ( $restrictions === array(
'autoconfirmed' ) ) {
+ $msg = wfMessage(
'template-semiprotected' );
+ }
+ if ( $msg && !$msg->isDisabled() ) {
+ $protected = $msg->parse();
+ } else {
+ // Construct the message from
restriction-level-*
+ // e.g.
restriction-level-sysop, restriction-level-autoconfirmed
+ $msgs = array();
+ foreach ( $restrictions as $r )
{
+ $msgs[] = wfMessage(
"restriction-level-$r" )->parse();
+ }
+ $protected = wfMessage(
'parentheses' )
+ ->rawParams(
$wgLang->commaList( $msgs ) )->escaped();
+ }
}
if ( $titleObj->quickUserCan( 'edit' ) ) {
$editLink = self::link(
--
To view, visit https://gerrit.wikimedia.org/r/90551
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c507f4ecc1921f599acbda834fa55e96388fa7b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits