/** Map of action to the expiry time of the existing protection */
var $mExistingExpiry = array();
- function __construct( Article $article ) {
+ function __construct( Page $article ) {
global $wgUser;
// Set instance variables.
$this->mArticle = $article;
* @param $err String: error message or null if there's no error
*/
function show( $err = null ) {
- global $wgOut, $wgUser;
+ global $wgOut;
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->wrapWikiMsg( "<div id=\"mw-protect-cascadeon\">\n$1\n" . $titles . "</div>", array( 'protect-cascadeon', count($cascadeSources) ) );
}
- $sk = $wgUser->getSkin();
- $titleLink = $sk->link( $this->mTitle );
+ $titleLink = Linker::link( $this->mTitle );
$wgOut->setPageTitle( wfMsg( 'protect-title', $this->mTitle->getPrefixedText() ) );
$wgOut->setSubtitle( wfMsg( 'protect-backlink', $titleLink ) );
$msg = wfMessage( 'restriction-' . $action );
$out .= "<tr><td>".
Xml::openElement( 'fieldset' ) .
- Xml::element( 'legend', null, $msg->exists() ? $action : $msg->text() ) .
+ Xml::element( 'legend', null, $msg->exists() ? $msg->text() : $action ) .
Xml::openElement( 'table', array( 'id' => "mw-protect-table-$action" ) ) .
"<tr><td>" . $this->buildSelector( $action, $selected ) . "</td></tr><tr><td>";
$expiryFormOptions = '';
if ( $this->mExistingExpiry[$action] && $this->mExistingExpiry[$action] != 'infinity' ) {
- $timestamp = $wgLang->timeanddate( $this->mExistingExpiry[$action] );
- $d = $wgLang->date( $this->mExistingExpiry[$action] );
- $t = $wgLang->time( $this->mExistingExpiry[$action] );
+ $timestamp = $wgLang->timeanddate( $this->mExistingExpiry[$action], true );
+ $d = $wgLang->date( $this->mExistingExpiry[$action], true );
+ $t = $wgLang->time( $this->mExistingExpiry[$action], true );
$expiryFormOptions .=
Xml::option(
wfMsg( 'protect-existing-expiry', $timestamp, $d, $t ),
if ( $wgUser->isAllowed( 'editinterface' ) ) {
$title = Title::makeTitle( NS_MEDIAWIKI, 'Protect-dropdown' );
- $link = $wgUser->getSkin()->link(
+ $link = Linker::link(
$title,
wfMsgHtml( 'protect-edit-reasonlist' ),
array(),
return wfMsg( 'protect-default' );
} else {
$msg = wfMessage( "protect-level-{$permission}" );
- if( !$msg->exists() ) {
+ if( $msg->exists() ) {
return $msg->text();
}
return wfMsg( 'protect-fallback', $permission );
}
function buildCleanupScript() {
- global $wgRestrictionLevels, $wgGroupPermissions;
- $script = 'var wgCascadeableLevels=';
- $CascadeableLevels = array();
+ global $wgRestrictionLevels, $wgGroupPermissions, $wgOut;
+
+ $cascadeableLevels = array();
foreach( $wgRestrictionLevels as $key ) {
- if ( (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect']) || $key == 'protect' ) {
- $CascadeableLevels[] = "'" . Xml::escapeJsString( $key ) . "'";
+ if ( ( isset( $wgGroupPermissions[$key]['protect'] ) && $wgGroupPermissions[$key]['protect'] )
+ || $key == 'protect'
+ ) {
+ $cascadeableLevels[] = $key;
}
}
- $script .= "[" . implode(',',$CascadeableLevels) . "];\n";
- $options = (object)array(
+ $options = array(
'tableId' => 'mwProtectSet',
- 'labelText' => wfMsg( 'protect-unchain-permissions' ),
- 'numTypes' => count($this->mApplicableTypes),
- 'existingMatch' => 1 == count( array_unique( $this->mExistingExpiry ) ),
+ 'labelText' => wfMessage( 'protect-unchain-permissions' )->plain(),
+ 'numTypes' => count( $this->mApplicableTypes ),
+ 'existingMatch' => count( array_unique( $this->mExistingExpiry ) ) === 1,
);
- $encOptions = Xml::encodeJsVar( $options );
- $script .= "ProtectionForm.init($encOptions)";
- return Html::inlineScript( "if ( window.mediaWiki ) { $script }" );
+ $wgOut->addJsConfigVars( 'wgCascadeableLevels', $cascadeableLevels );
+ $script = Xml::encodeJsCall( 'ProtectionForm.init', array( $options ) );
+ return Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) );
}
/**
function showLogExtract( &$out ) {
# Show relevant lines from the protection log:
$out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'protect' ) ) );
- LogEventsList::showLogExtract( $out, 'protect', $this->mTitle->getPrefixedText() );
+ LogEventsList::showLogExtract( $out, 'protect', $this->mTitle );
# Let extensions add other relevant log extracts
wfRunHooks( 'ProtectionForm::showLogExtract', array($this->mArticle,$out) );
}