Used PHPStorm's code formatting feature, with manual checks and updates.
Change-Id: I0496eba007056bc9c4b09163387f11d6cea2a55d
$this->setHeaders();
global $wgUseDatabaseMessages;
- if( !$wgUseDatabaseMessages ) {
+ if ( !$wgUseDatabaseMessages ) {
$out->addWikiMsg( 'allmessagesnotsupportedDB' );
return;
} else {
$request = $this->getRequest();
$this->filter = $request->getVal( 'filter', 'all' );
- if( $this->filter === 'all' ) {
+ if ( $this->filter === 'all' ) {
$this->custom = null; // So won't match in either case
} else {
- $this->custom = ($this->filter == 'unmodified');
+ $this->custom = ( $this->filter == 'unmodified' );
}
$prefix = $this->getLanguage()->ucfirst( $request->getVal( 'prefix', '' ) );
$prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal( 'prefix', null ) ) : null;
- if( $prefix !== null ) {
+ if ( $prefix !== null ) {
$this->displayPrefix = $prefix->getDBkey();
$this->prefix = '/^' . preg_quote( $this->displayPrefix ) . '/i';
} else {
// The suffix that may be needed for message names if we're in a
// different language (eg [[MediaWiki:Foo/fr]]: $suffix = '/fr'
- if( $this->foreign ) {
+ if ( $this->foreign ) {
$this->suffix = '/' . $this->langcode;
} else {
$this->suffix = '';
Xml::openElement( 'table', array( 'class' => 'mw-allmessages-table' ) ) . "\n" .
'<tr>
<td class="mw-label">' .
- Xml::label( $this->msg( 'allmessages-prefix' )->text(), 'mw-allmessages-form-prefix' ) .
- "</td>\n
- <td class=\"mw-input\">" .
- Xml::input( 'prefix', 20, str_replace( '_', ' ', $this->displayPrefix ), array( 'id' => 'mw-allmessages-form-prefix' ) ) .
- "</td>\n
+ Xml::label( $this->msg( 'allmessages-prefix' )->text(), 'mw-allmessages-form-prefix' ) .
+ "</td>\n
+ <td class=\"mw-input\">" .
+ Xml::input( 'prefix', 20, str_replace( '_', ' ', $this->displayPrefix ), array( 'id' => 'mw-allmessages-form-prefix' ) ) .
+ "</td>\n
</tr>
<tr>\n
- <td class='mw-label'>" .
- $this->msg( 'allmessages-filter' )->escaped() .
- "</td>\n
+ <td class='mw-label'>" .
+ $this->msg( 'allmessages-filter' )->escaped() .
+ "</td>\n
<td class='mw-input'>" .
- Xml::radioLabel( $this->msg( 'allmessages-filter-unmodified' )->text(),
- 'filter',
- 'unmodified',
- 'mw-allmessages-form-filter-unmodified',
- ( $this->filter == 'unmodified' )
- ) .
- Xml::radioLabel( $this->msg( 'allmessages-filter-all' )->text(),
- 'filter',
- 'all',
- 'mw-allmessages-form-filter-all',
- ( $this->filter == 'all' )
- ) .
- Xml::radioLabel( $this->msg( 'allmessages-filter-modified' )->text(),
- 'filter',
- 'modified',
- 'mw-allmessages-form-filter-modified',
- ( $this->filter == 'modified' )
- ) .
- "</td>\n
+ Xml::radioLabel( $this->msg( 'allmessages-filter-unmodified' )->text(),
+ 'filter',
+ 'unmodified',
+ 'mw-allmessages-form-filter-unmodified',
+ ( $this->filter == 'unmodified' )
+ ) .
+ Xml::radioLabel( $this->msg( 'allmessages-filter-all' )->text(),
+ 'filter',
+ 'all',
+ 'mw-allmessages-form-filter-all',
+ ( $this->filter == 'all' )
+ ) .
+ Xml::radioLabel( $this->msg( 'allmessages-filter-modified' )->text(),
+ 'filter',
+ 'modified',
+ 'mw-allmessages-form-filter-modified',
+ ( $this->filter == 'modified' )
+ ) .
+ "</td>\n
</tr>
<tr>\n
<td class=\"mw-label\">" . $langSelect[0] . "</td>\n
'<tr>
<td class="mw-label">' .
- Xml::label( $this->msg( 'table_pager_limit_label' )->text(), 'mw-table_pager_limit_label' ) .
- '</td>
- <td class="mw-input">' .
- $this->getLimitSelect() .
- '</td>
+ Xml::label( $this->msg( 'table_pager_limit_label' )->text(), 'mw-table_pager_limit_label' ) .
+ '</td>
+ <td class="mw-input">' .
+ $this->getLimitSelect() .
+ '</td>
<tr>
<td></td>
<td>' .
- Xml::submitButton( $this->msg( 'allmessages-filter-submit' )->text() ) .
- "</td>\n
+ Xml::submitButton( $this->msg( 'allmessages-filter-submit' )->text() ) .
+ "</td>\n
</tr>" .
Xml::closeElement( 'table' ) .
function getAllMessages( $descending ) {
wfProfileIn( __METHOD__ );
$messageNames = Language::getLocalisationCache()->getSubitemList( 'en', 'messages' );
- if( $descending ) {
+ if ( $descending ) {
rsort( $messageNames );
} else {
asort( $messageNames );
foreach ( $res as $s ) {
$exists = false;
- if( $foreign ) {
+ if ( $foreign ) {
$title = explode( '/', $s->page_title );
- if( count( $title ) === 2 && $langcode == $title[1]
- && isset( $xNames[$title[0]] ) ) {
+ if ( count( $title ) === 2 && $langcode == $title[1]
+ && isset( $xNames[$title[0]] )
+ ) {
$exists = $title[0];
}
- } elseif( isset( $xNames[$s->page_title] ) ) {
+ } elseif ( isset( $xNames[$s->page_title] ) ) {
$exists = $s->page_title;
}
- if( $exists && $s->page_namespace == NS_MEDIAWIKI ) {
+ if ( $exists && $s->page_namespace == NS_MEDIAWIKI ) {
$pageFlags[$exists] = true;
- } elseif( $exists && $s->page_namespace == NS_MEDIAWIKI_TALK ) {
+ } elseif ( $exists && $s->page_namespace == NS_MEDIAWIKI_TALK ) {
$talkFlags[$exists] = true;
}
}
$statuses = self::getCustomisedStatuses( $messageNames, $this->langcode, $this->foreign );
$count = 0;
- foreach( $messageNames as $key ) {
+ foreach ( $messageNames as $key ) {
$customised = isset( $statuses['pages'][$key] );
- if( $customised !== $this->custom &&
+ if ( $customised !== $this->custom &&
( $descending && ( $key < $offset || !$offset ) || !$descending && $key > $offset ) &&
( ( $this->prefix && preg_match( $this->prefix, $key ) ) || $this->prefix === false )
) {
$actual = wfMessage( $key )->inLanguage( $this->langcode )->plain();
$default = wfMessage( $key )->inLanguage( $this->langcode )->useDatabase( false )->plain();
$result->result[] = array(
- 'am_title' => $key,
- 'am_actual' => $actual,
- 'am_default' => $default,
+ 'am_title' => $key,
+ 'am_actual' => $actual,
+ 'am_default' => $default,
'am_customised' => $customised,
'am_talk_exists' => isset( $statuses['talks'][$key] )
);
$count++;
}
- if( $count == $limit ) {
+
+ if ( $count == $limit ) {
break;
}
}
return Xml::openElement( 'table', array( 'class' => 'mw-datatable TablePager', 'id' => 'mw-allmessagestable' ) ) . "\n" .
"<thead><tr>
<th rowspan=\"2\">" .
- $this->msg( 'allmessagesname' )->escaped() . "
+ $this->msg( 'allmessagesname' )->escaped() . "
</th>
<th>" .
- $this->msg( 'allmessagesdefault' )->escaped() .
- "</th>
+ $this->msg( 'allmessagesdefault' )->escaped() .
+ "</th>
</tr>\n
<tr>
<th>" .
- $this->msg( 'allmessagescurrent' )->escaped() .
- "</th>
+ $this->msg( 'allmessagescurrent' )->escaped() .
+ "</th>
</tr></thead><tbody>\n";
}
function formatValue( $field, $value ) {
- switch( $field ) {
+ switch ( $field ) {
case 'am_title' :
$title = Title::makeTitle( NS_MEDIAWIKI, $value . $this->suffix );
$talk = Title::makeTitle( NS_MEDIAWIKI_TALK, $value . $this->suffix );
- if( $this->mCurrentRow->am_customised ) {
+ if ( $this->mCurrentRow->am_customised ) {
$title = Linker::linkKnown( $title, $this->getLanguage()->lcfirst( $value ) );
} else {
$title = Linker::link(
$s = parent::formatRow( $row );
// But if there's a customised message, add that too.
- if( $row->am_customised ) {
+ if ( $row->am_customised ) {
$s .= Xml::openElement( 'tr', $this->getRowAttrs( $row, true ) );
$formatted = strval( $this->formatValue( 'am_actual', $row->am_actual ) );
if ( $formatted == '' ) {
function getRowAttrs( $row, $isSecond = false ) {
$arr = array();
- if( $row->am_customised ) {
+ if ( $row->am_customised ) {
$arr['class'] = 'allmessages-customised';
}
- if( !$isSecond ) {
+ if ( !$isSecond ) {
$arr['id'] = Sanitizer::escapeId( 'msg_' . $this->getLanguage()->lcfirst( $row->am_title ) );
}
return $arr;
}
function getCellAttrs( $field, $value ) {
- if( $this->mCurrentRow->am_customised && $field == 'am_title' ) {
+ if ( $this->mCurrentRow->am_customised && $field == 'am_title' ) {
return array( 'rowspan' => '2', 'class' => $field );
- } elseif( $field == 'am_title' ) {
+ } elseif ( $field == 'am_title' ) {
return array( 'class' => $field );
} else {
return array( 'lang' => $this->langcode, 'dir' => $this->lang->getDir(), 'class' => $field );
$out->setPageTitle(
( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) ) ?
- $this->msg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
- $this->msg( 'allarticles' )
+ $this->msg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) :
+ $this->msg( 'allarticles' )
);
$out->addModuleStyles( 'mediawiki.special' );
- if( $par !== null ) {
+ if ( $par !== null ) {
$this->showChunk( $namespace, $par, $to, $hideredirects );
- } elseif( $from !== null && $to === null ) {
+ } elseif ( $from !== null && $to === null ) {
$this->showChunk( $namespace, $from, $to, $hideredirects );
} else {
$this->showToplevel( $namespace, $from, $to, $hideredirects );
$from = ( $from && $from->isLocal() ) ? $from->getDBkey() : null;
$to = ( $to && $to->isLocal() ) ? $to->getDBkey() : null;
- if( isset( $from ) )
+ if ( isset( $from ) ) {
$where[] = 'page_title >= ' . $dbr->addQuotes( $from );
- if( isset( $to ) )
+ }
+
+ if ( isset( $to ) ) {
$where[] = 'page_title <= ' . $dbr->addQuotes( $to );
+ }
global $wgMemc;
$key = wfMemcKey( 'allpages', 'ns', $namespace, sha1( $from ), sha1( $to ) );
$maxPerSubpage = intval( $count / $this->maxLineCount );
$maxPerSubpage = max( $maxPerSubpage, $this->maxPerPage );
- if( !is_array( $lines ) ) {
+ if ( !is_array( $lines ) ) {
$options = array( 'LIMIT' => 1 );
$options['ORDER BY'] = 'page_title ASC';
$firstTitle = $dbr->selectField( 'page', 'page_title', $where, __METHOD__, $options );
$lines = array( $firstTitle );
# If we are going to show n rows, we need n+1 queries to find the relevant titles.
$done = false;
- while( !$done ) {
+ while ( !$done ) {
// Fetch the last title of this chunk and the first of the next
$chunk = ( $lastTitle === false )
? array()
);
$s = $dbr->fetchObject( $res );
- if( $s ) {
+ if ( $s ) {
array_push( $lines, $s->page_title );
} else {
// Final chunk, but ended prematurely. Go back and find the end.
array_push( $lines, $endTitle );
$done = true;
}
+
$s = $res->fetchObject();
- if( $s ) {
+ if ( $s ) {
array_push( $lines, $s->page_title );
$lastTitle = $s->page_title;
} else {
// If there are only two or less sections, don't even display them.
// Instead, display the first section directly.
- if( count( $lines ) <= 2 ) {
- if( !empty( $lines ) ) {
+ if ( count( $lines ) <= 2 ) {
+ if ( !empty( $lines ) ) {
$this->showChunk( $namespace, $from, $to, $hideredirects );
} else {
$output->addHTML( $this->namespaceForm( $namespace, $from, $to, $hideredirects ) );
# At this point, $lines should contain an even number of elements.
$out .= Xml::openElement( 'table', array( 'class' => 'allpageslist' ) );
- while( count ( $lines ) > 0 ) {
+ while ( count( $lines ) > 0 ) {
$inpoint = array_shift( $lines );
$outpoint = array_shift( $lines );
$out .= $this->showline( $inpoint, $outpoint, $namespace, $hideredirects );
$nsForm = $this->namespaceForm( $namespace, $from, $to, $hideredirects );
# Is there more?
- if( $this->including() ) {
+ if ( $this->including() ) {
$out2 = '';
} else {
- if( isset( $from ) || isset( $to ) ) {
- $out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ).
- '<tr>
+ if ( isset( $from ) || isset( $to ) ) {
+ $out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ) .
+ '<tr>
<td>' .
- $nsForm .
- '</td>
+ $nsForm .
+ '</td>
<td class="mw-allpages-nav">' .
- Linker::link( $this->getTitle(), $this->msg( 'allpages' )->escaped(),
- array(), array(), 'known' ) .
- "</td>
+ Linker::link( $this->getTitle(), $this->msg( 'allpages' )->escaped(),
+ array(), array(), 'known' ) .
+ "</td>
</tr>" .
Xml::closeElement( 'table' );
} else {
$conds['page_is_redirect'] = 0;
}
- if( $toKey !== "" ) {
+ if ( $toKey !== "" ) {
$conds[] = 'page_title <= ' . $dbr->addQuotes( $toKey );
}
$conds,
__METHOD__,
array(
- 'ORDER BY' => 'page_title',
- 'LIMIT' => $this->maxPerPage + 1,
+ 'ORDER BY' => 'page_title',
+ 'LIMIT' => $this->maxPerPage + 1,
'USE INDEX' => 'name_title',
)
);
- if( $res->numRows() > 0 ) {
+ if ( $res->numRows() > 0 ) {
$out = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-chunk' ) );
- while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
+ while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::newFromRow( $s );
- if( $t ) {
+ if ( $t ) {
$link = ( $s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
Linker::link( $t ) .
- ($s->page_is_redirect ? '</div>' : '' );
+ ( $s->page_is_redirect ? '</div>' : '' );
} else {
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
- if( $n % 3 == 0 ) {
+
+ if ( $n % 3 == 0 ) {
$out .= '<tr>';
}
+
$out .= "<td style=\"width:33%\">$link</td>";
$n++;
- if( $n % 3 == 0 ) {
+ if ( $n % 3 == 0 ) {
$out .= "</tr>\n";
}
}
- if( ($n % 3) != 0 ) {
+
+ if ( ( $n % 3 ) != 0 ) {
$out .= "</tr>\n";
}
$out .= Xml::closeElement( 'table' );
if ( $this->including() ) {
$out2 = '';
} else {
- if( $from == '' ) {
+ if ( $from == '' ) {
// First chunk; no previous link.
$prevTitle = null;
} else {
);
# Get first title of previous complete chunk
- if( $dbr->numrows( $res_prev ) >= $this->maxPerPage ) {
+ if ( $dbr->numrows( $res_prev ) >= $this->maxPerPage ) {
$pt = $dbr->fetchObject( $res_prev );
$prevTitle = Title::makeTitle( $namespace, $pt->page_title );
} else {
# The previous chunk is not complete, need to link to the very first title
# available in the database
$options = array( 'LIMIT' => 1 );
- if ( ! $dbr->implicitOrderby() ) {
+ if ( !$dbr->implicitOrderby() ) {
$options['ORDER BY'] = 'page_title';
}
$reallyFirstPage_title = $dbr->selectField( 'page', 'page_title',
array( 'page_namespace' => $namespace ), __METHOD__, $options );
# Show the previous link if it s not the current requested chunk
- if( $from != $reallyFirstPage_title ) {
+ if ( $from != $reallyFirstPage_title ) {
$prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title );
} else {
$prevTitle = null;
$self = $this->getTitle();
$nsForm = $this->namespaceForm( $namespace, $from, $to, $hideredirects );
- $out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ).
- '<tr>
+ $out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ) .
+ '<tr>
<td>' .
- $nsForm .
- '</td>
+ $nsForm .
+ '</td>
<td class="mw-allpages-nav">' .
- Linker::link( $self, $this->msg( 'allpages' )->escaped() );
+ Linker::link( $self, $this->msg( 'allpages' )->escaped() );
# Do we put a previous link ?
- if( isset( $prevTitle ) && $pt = $prevTitle->getText() ) {
+ if ( isset( $prevTitle ) && $pt = $prevTitle->getText() ) {
$query = array( 'from' => $prevTitle->getText() );
- if( $namespace )
+ if ( $namespace ) {
$query['namespace'] = $namespace;
+ }
- if( $hideredirects )
+ if ( $hideredirects ) {
$query['hideredirects'] = $hideredirects;
+ }
$prevLink = Linker::linkKnown(
$self,
$out2 = $this->getLanguage()->pipeList( array( $out2, $prevLink ) );
}
- if( $n == $this->maxPerPage && $s = $res->fetchObject() ) {
+ if ( $n == $this->maxPerPage && $s = $res->fetchObject() ) {
# $s is the first link of the next chunk
$t = Title::makeTitle( $namespace, $s->page_title );
$query = array( 'from' => $t->getText() );
- if( $namespace )
+ if ( $namespace ) {
$query['namespace'] = $namespace;
+ }
- if( $hideredirects )
+ if ( $hideredirects ) {
$query['hideredirects'] = $hideredirects;
+ }
$nextLink = Linker::linkKnown(
$self,
$output->addHTML( $out2 . $out );
$links = array();
- if ( isset( $prevLink ) ) $links[] = $prevLink;
- if ( isset( $nextLink ) ) $links[] = $nextLink;
+ if ( isset( $prevLink ) ) {
+ $links[] = $prevLink;
+ }
+
+ if ( isset( $nextLink ) ) {
+ $links[] = $nextLink;
+ }
if ( count( $links ) ) {
$output->addHTML(
Html::element( 'hr' ) .
- Html::rawElement( 'div', array( 'class' => 'mw-allpages-nav' ),
- $this->getLanguage()->pipeList( $links )
- ) );
+ Html::rawElement( 'div', array( 'class' => 'mw-allpages-nav' ),
+ $this->getLanguage()->pipeList( $links )
+ )
+ );
}
}
* @return array( int namespace, string dbkey, string pagename ) or NULL on error
*/
protected function getNamespaceKeyAndText( $ns, $text ) {
- if ( $text == '' )
- return array( $ns, '', '' ); # shortcut for common case
+ if ( $text == '' ) {
+ # shortcut for common case
+ return array( $ns, '', '' );
+ }
$t = Title::makeTitleSafe( $ns, $text );
if ( $t && $t->isLocal() ) {
function getQueryInfo() {
return array(
'tables' => array( 'page', 'revision' ),
- 'fields' => array( 'namespace' => 'page_namespace',
- 'title' => 'page_title',
- 'value' => 'rev_timestamp' ),
- 'conds' => array( 'page_namespace' => MWNamespace::getContentNamespaces(),
- 'page_is_redirect' => 0,
- 'page_latest=rev_id' )
+ 'fields' => array(
+ 'namespace' => 'page_namespace',
+ 'title' => 'page_title',
+ 'value' => 'rev_timestamp'
+ ),
+ 'conds' => array(
+ 'page_namespace' => MWNamespace::getContentNamespaces(),
+ 'page_is_redirect' => 0,
+ 'page_latest=rev_id'
+ )
);
}
public function __construct() {
parent::__construct( 'Blankpage' );
}
+
public function execute( $par ) {
$this->setHeaders();
$this->getOutput()->addWikiMsg( 'intentionallyblankpage' );
$s = HTMLForm::formatErrors( $this->preErrors );
if ( $s ) {
$form->addHeaderText( Html::rawElement(
- 'div',
- array( 'class' => 'error' ),
- $s
- ) );
+ 'div',
+ array( 'class' => 'error' ),
+ $s
+ ) );
}
}
}
if ( $block instanceof Block && !$block->mAuto # The block exists and isn't an autoblock
&& ( $this->type != Block::TYPE_RANGE # The block isn't a rangeblock
|| $block->getTarget() == $this->target ) # or if it is, the range is what we're about to block
- )
- {
+ ) {
$fields['HardBlock']['default'] = $block->isHardblock();
$fields['CreateAccount']['default'] = $block->prevents( 'createaccount' );
$fields['AutoBlock']['default'] = $block->isAutoblocking();
$i = 0;
$target = null;
- while( true ) {
- switch( $i++ ) {
+ while ( true ) {
+ switch ( $i++ ) {
case 0:
# The HTMLForm will check wpTarget first and only if it doesn't get
# a value use the default, which will be generated from the options
# but $data['target'] gets overriden by (non-normalized) request variable
# from previous request.
if ( $target === $performer->getName() &&
- ( $data['PreviousTarget'] !== $target || !$data['Confirm'] ) )
- {
+ ( $data['PreviousTarget'] !== $target || !$data['Confirm'] )
+ ) {
return array( 'ipb-blockingself' );
}
} elseif ( $type == Block::TYPE_RANGE ) {
}
if ( ( strlen( $data['Expiry'] ) == 0 ) || ( strlen( $data['Expiry'] ) > 50 )
- || !self::parseExpiryInput( $data['Expiry'] ) )
- {
+ || !self::parseExpiryInput( $data['Expiry'] )
+ ) {
return array( 'ipb_expiry_invalid' );
}
$reblockNotAllowed = ( array_key_exists( 'Reblock', $data ) && !$data['Reblock'] );
# Show form unless the user is already aware of this...
- if( $blockNotConfirmed || $reblockNotAllowed ) {
+ if ( $blockNotConfirmed || $reblockNotAllowed ) {
return array( array( 'ipb_already_blocked', $block->getTarget() ) );
- # Otherwise, try to update the block...
+ # Otherwise, try to update the block...
} else {
# This returns direct blocks before autoblocks/rangeblocks, since we should
# be sure the user is blocked by now it should work for our purposes
# User is trying to unblock themselves
if ( $performer->isAllowed( 'unblockself' ) ) {
return true;
- # User blocked themselves and is now trying to reverse it
+ # User blocked themselves and is now trying to reverse it
} elseif ( $performer->blockedBy() === $performer->getName() ) {
return true;
} else {
$action = $request->getText( 'action' );
- if( $action == 'unblock' || $action == 'submit' && $request->wasPosted() ) {
+ if ( $action == 'unblock' || $action == 'submit' && $request->wasPosted() ) {
# B/C @since 1.18: Unblock interface is now at Special:Unblock
$title = SpecialPage::getTitleFor( 'Unblock', $this->target );
$out->redirect( $title->getFullUrl() );
if ( $this->target !== '' ) {
list( $target, $type ) = Block::parseTarget( $this->target );
- switch( $type ) {
+ switch ( $type ) {
case Block::TYPE_ID:
case Block::TYPE_AUTO:
$conds['ipb_id'] = $target;
}
# Apply filters
- if( in_array( 'userblocks', $this->options ) ) {
+ if ( in_array( 'userblocks', $this->options ) ) {
$conds['ipb_user'] = 0;
}
- if( in_array( 'tempblocks', $this->options ) ) {
+ if ( in_array( 'tempblocks', $this->options ) ) {
$conds['ipb_expiry'] = 'infinity';
}
- if( in_array( 'addressblocks', $this->options ) ) {
+ if ( in_array( 'addressblocks', $this->options ) ) {
$conds[] = "ipb_user != 0 OR ipb_range_end > ipb_range_start";
}
- if( in_array( 'rangeblocks', $this->options ) ) {
+ if ( in_array( 'rangeblocks', $this->options ) ) {
$conds[] = "ipb_range_end = ipb_range_start";
}
# Show additional header for the local block only when other blocks exists.
# Not necessary in a standard installation without such extensions enabled
- if( count( $otherBlockLink ) ) {
+ if ( count( $otherBlockLink ) ) {
$out->addHTML(
Html::element( 'h2', array(), $this->msg( 'ipblocklist-localblock' )->text() ) . "\n"
);
if ( $pager->getNumRows() ) {
$out->addHTML(
$pager->getNavigationBar() .
- $pager->getBody().
- $pager->getNavigationBar()
+ $pager->getBody() .
+ $pager->getNavigationBar()
);
} elseif ( $this->target ) {
$out->addWikiMsg( 'ipblocklist-empty' );
}
- if( count( $otherBlockLink ) ) {
+ if ( count( $otherBlockLink ) ) {
$out->addHTML(
Html::rawElement(
'h2',
) . "\n"
);
$list = '';
- foreach( $otherBlockLink as $link ) {
+ foreach ( $otherBlockLink as $link ) {
$list .= Html::rawElement( 'li', array(), $link ) . "\n";
}
$out->addHTML( Html::rawElement( 'ul', array( 'class' => 'mw-ipblocklist-otherblocks' ), $list ) . "\n" );
'ipb_params' => 'blocklist-params',
'ipb_reason' => 'blocklist-reason',
);
- foreach( $headers as $key => $val ) {
+ foreach ( $headers as $key => $val ) {
$headers[$key] = $this->msg( $val )->text();
}
}
$formatted = '';
- switch( $name ) {
+ switch ( $name ) {
case 'ipb_timestamp':
$formatted = $this->getLanguage()->userTimeAndDate( $value, $this->getUser() );
break;
case 'ipb_target':
- if( $row->ipb_auto ) {
+ if ( $row->ipb_auto ) {
$formatted = $this->msg( 'autoblockid', $row->ipb_id )->parse();
} else {
list( $target, $type ) = Block::parseTarget( $row->ipb_address );
- switch( $type ) {
+ switch ( $type ) {
case Block::TYPE_USER:
case Block::TYPE_IP:
$formatted = Linker::userLink( $target->getId(), $target );
break;
case 'ipb_expiry':
- $formatted = $this->getLanguage()->formatExpiry( $value, /* User preference timezone */ true );
- if( $this->getUser()->isAllowed( 'block' ) ) {
- if( $row->ipb_auto ) {
+ $formatted = $this->getLanguage()->formatExpiry( $value, /* User preference timezone */true );
+ if ( $this->getUser()->isAllowed( 'block' ) ) {
+ if ( $row->ipb_auto ) {
$links[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Unblock' ),
$msg['unblocklink'],
}
$ua = UserArray::newFromIDs( $userids );
- foreach( $ua as $user ) {
+ foreach ( $ua as $user ) {
$name = str_replace( ' ', '_', $user->getName() );
$lb->add( NS_USER, $name );
$lb->add( NS_USER_TALK, $name );
$this->outputHeader();
$ip = $this->getRequest()->getIP();
- if( !$wgBlockOpenProxies || $this->getRequest()->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
+ if ( !$wgBlockOpenProxies || $this->getRequest()->getText( 'ip' ) != md5( $ip . $wgProxyKey ) ) {
$this->getOutput()->addWikiMsg( 'proxyblocker-disabled' );
return;
}
$this->outputHeader();
$this->isbn = self::cleanIsbn( $isbn ? $isbn : $this->getRequest()->getText( 'isbn' ) );
$this->getOutput()->addHTML( $this->makeForm() );
- if( strlen( $this->isbn ) > 0 ) {
- if( !self::isValidISBN( $this->isbn ) ) {
+ if ( strlen( $this->isbn ) > 0 ) {
+ if ( !self::isValidISBN( $this->isbn ) ) {
$this->getOutput()->wrapWikiMsg( "<div class=\"error\">\n$1\n</div>", 'booksources-invalid-isbn' );
}
$this->showList();
public static function isValidISBN( $isbn ) {
$isbn = self::cleanIsbn( $isbn );
$sum = 0;
- if( strlen( $isbn ) == 13 ) {
- for( $i = 0; $i < 12; $i++ ) {
- if( $i % 2 == 0 ) {
+ if ( strlen( $isbn ) == 13 ) {
+ for ( $i = 0; $i < 12; $i++ ) {
+ if ( $i % 2 == 0 ) {
$sum += $isbn[$i];
} else {
$sum += 3 * $isbn[$i];
}
}
- $check = (10 - ($sum % 10)) % 10;
+ $check = ( 10 - ( $sum % 10 ) ) % 10;
if ( $check == $isbn[12] ) {
return true;
}
- } elseif( strlen( $isbn ) == 10 ) {
- for( $i = 0; $i < 9; $i++ ) {
- $sum += $isbn[$i] * ($i + 1);
+ } elseif ( strlen( $isbn ) == 10 ) {
+ for ( $i = 0; $i < 9; $i++ ) {
+ $sum += $isbn[$i] * ( $i + 1 );
}
$check = $sum % 11;
- if( $check == 10 ) {
+ if ( $check == 10 ) {
$check = "X";
}
- if( $check == $isbn[9] ) {
+ if ( $check == $isbn[9] ) {
return true;
}
}
# Check for a local page such as Project:Book_sources and use that if available
$page = $this->msg( 'booksources' )->inContentLanguage()->text();
$title = Title::makeTitleSafe( NS_PROJECT, $page ); # Show list in content language
- if( is_object( $title ) && $title->exists() ) {
+ if ( is_object( $title ) && $title->exists() ) {
$rev = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
$content = $rev->getContent();
$this->getOutput()->addWikiMsg( 'booksources-text' );
$this->getOutput()->addHTML( '<ul>' );
$items = $wgContLang->getBookstoreList();
- foreach( $items as $label => $url )
+ foreach ( $items as $label => $url )
$this->getOutput()->addHTML( $this->makeListItem( $label, $url ) );
$this->getOutput()->addHTML( '</ul>' );
return true;
* @return array
*/
function getOrderFields() {
- return array ( 'rd_namespace', 'rd_title', 'rd_from' );
+ return array( 'rd_namespace', 'rd_title', 'rd_from' );
}
/**
$out = $from . $this->msg( 'word-separator' )->escaped();
- if( $this->getUser()->isAllowed( 'delete' ) ) {
+ if ( $this->getUser()->isAllowed( 'delete' ) ) {
$links[] = Linker::linkKnown(
$fromObj,
$this->msg( 'brokenredirects-delete' )->escaped(),
$this->getOutput()->addHTML(
Html::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) .
- $this->msg( 'categoriespagetext', $cap->getNumRows() )->parseAsBlock() .
- $cap->getStartForm( $from ) .
- $cap->getNavigationBar() .
- '<ul>' . $cap->getBody() . '</ul>' .
- $cap->getNavigationBar() .
- Html::closeElement( 'div' )
+ $this->msg( 'categoriespagetext', $cap->getNumRows() )->parseAsBlock() .
+ $cap->getStartForm( $from ) .
+ $cap->getNavigationBar() .
+ '<ul>' . $cap->getBody() . '</ul>' .
+ $cap->getNavigationBar() .
+ Html::closeElement( 'div' )
);
}
function __construct( IContextSource $context, $from ) {
parent::__construct( $context );
$from = str_replace( ' ', '_', $from );
- if( $from !== '' ) {
+ if ( $from !== '' ) {
$from = Title::capitalize( $from, NS_CATEGORY );
$this->setOffset( $from );
$this->setIncludeOffset( true );
unset( $this->mDefaultQuery['from'] );
return $this->mDefaultQuery;
}
+
# protected function getOrderTypeMessages() {
# return array( 'abc' => 'special-categories-sort-abc',
# 'count' => 'special-categories-sort-count' );
public function getStartForm( $from ) {
global $wgScript;
- return Xml::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
- Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
- Xml::fieldset( $this->msg( 'categories' )->text(),
- Xml::inputLabel( $this->msg( 'categoriesfrom' )->text(),
+ return Xml::tags(
+ 'form',
+ array( 'method' => 'get', 'action' => $wgScript ),
+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
+ Xml::fieldset(
+ $this->msg( 'categories' )->text(),
+ Xml::inputLabel(
+ $this->msg( 'categoriesfrom' )->text(),
'from', 'from', 20, $from ) .
- ' ' .
- Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) ) );
+ ' ' .
+ Xml::submitButton( $this->msg( 'allpagessubmit' )->text()
+ )
+ )
+ );
}
}
$this->mNewEmail = $request->getVal( 'wpNewEmail' );
if ( $request->wasPosted()
- && $user->matchEditToken( $request->getVal( 'token' ) ) )
- {
+ && $user->matchEditToken( $request->getVal( 'token' ) )
+ ) {
$info = $this->attemptChange( $user, $this->mPassword, $this->mNewEmail );
if ( $info === true ) {
$this->doReturnTo();
$this->getOutput()->addHTML(
Xml::fieldset( $this->msg( 'changeemail-header' )->text() ) .
- Xml::openElement( 'form',
- array(
- 'method' => 'post',
- 'action' => $this->getTitle()->getLocalUrl(),
- 'id' => 'mw-changeemail-form' ) ) . "\n" .
- Html::hidden( 'token', $user->getEditToken() ) . "\n" .
- Html::hidden( 'returnto', $this->getRequest()->getVal( 'returnto' ) ) . "\n" .
- $this->msg( 'changeemail-text' )->parseAsBlock() . "\n" .
- Xml::openElement( 'table', array( 'id' => 'mw-changeemail-table' ) ) . "\n"
+ Xml::openElement( 'form',
+ array(
+ 'method' => 'post',
+ 'action' => $this->getTitle()->getLocalUrl(),
+ 'id' => 'mw-changeemail-form' ) ) . "\n" .
+ Html::hidden( 'token', $user->getEditToken() ) . "\n" .
+ Html::hidden( 'returnto', $this->getRequest()->getVal( 'returnto' ) ) . "\n" .
+ $this->msg( 'changeemail-text' )->parseAsBlock() . "\n" .
+ Xml::openElement( 'table', array( 'id' => 'mw-changeemail-table' ) ) . "\n"
);
$items = array(
array( 'wpName', 'username', 'text', $user->getName() ),
$this->getOutput()->addHTML(
$this->pretty( $items ) .
- "\n" .
- "<tr>\n" .
+ "\n" .
+ "<tr>\n" .
"<td></td>\n" .
'<td class="mw-input">' .
- Xml::submitButton( $this->msg( 'changeemail-submit' )->text() ) .
- Xml::submitButton( $this->msg( 'changeemail-cancel' )->text(), array( 'name' => 'wpCancel' ) ) .
+ Xml::submitButton( $this->msg( 'changeemail-submit' )->text() ) .
+ Xml::submitButton( $this->msg( 'changeemail-cancel' )->text(), array( 'name' => 'wpCancel' ) ) .
"</td>\n" .
- "</tr>\n" .
- Xml::closeElement( 'table' ) .
- Xml::closeElement( 'form' ) .
- Xml::closeElement( 'fieldset' ) . "\n"
+ "</tr>\n" .
+ Xml::closeElement( 'table' ) .
+ Xml::closeElement( 'form' ) .
+ Xml::closeElement( 'fieldset' ) . "\n"
);
}
$out = '';
foreach ( $fields as $list ) {
list( $name, $label, $type, $value ) = $list;
- if( $type == 'text' ) {
+ if ( $type == 'text' ) {
$field = htmlspecialchars( $value );
} else {
$attribs = array( 'id' => $name );
if ( !$status->isGood() ) {
$this->getOutput()->addHTML(
'<p class="error">' .
- $this->getOutput()->parseInline( $status->getWikiText( 'mailerror' ) ) .
- '</p>' );
+ $this->getOutput()->parseInline( $status->getWikiText( 'mailerror' ) ) .
+ '</p>' );
return false;
}
$this->mDomain = $request->getVal( 'wpDomain' );
$user = $this->getUser();
- if( !$request->wasPosted() && !$user->isLoggedIn() ) {
+ if ( !$request->wasPosted() && !$user->isLoggedIn() ) {
$this->error( $this->msg( 'resetpass-no-info' )->text() );
return;
}
- if( $request->wasPosted() && $request->getBool( 'wpCancel' ) ) {
+ if ( $request->wasPosted() && $request->getBool( 'wpCancel' ) ) {
$this->doReturnTo();
return;
}
$this->checkReadOnly();
- if( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'token' ) ) ) {
+ if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'token' ) ) ) {
try {
$this->mDomain = $wgAuth->getDomain();
- if( !$wgAuth->allowPasswordChange() ) {
+ if ( !$wgAuth->allowPasswordChange() ) {
$this->error( $this->msg( 'resetpass_forbidden' )->text() );
return;
}
$this->attemptReset( $this->mNewpass, $this->mRetype );
- if( $user->isLoggedIn() ) {
+ if ( $user->isLoggedIn() ) {
$this->doReturnTo();
} else {
LoginForm::setLoginToken();
$token = LoginForm::getLoginToken();
$data = array(
- 'action' => 'submitlogin',
- 'wpName' => $this->mUserName,
- 'wpDomain' => $this->mDomain,
+ 'action' => 'submitlogin',
+ 'wpName' => $this->mUserName,
+ 'wpDomain' => $this->mDomain,
'wpLoginToken' => $token,
- 'wpPassword' => $request->getVal( 'wpNewPassword' ),
+ 'wpPassword' => $request->getVal( 'wpNewPassword' ),
) + $request->getValues( 'wpRemember', 'returnto', 'returntoquery' );
$login = new LoginForm( new FauxRequest( $data, true ) );
$login->setContext( $this->getContext() );
$login->execute( null );
}
return;
- } catch( PasswordError $e ) {
+ } catch ( PasswordError $e ) {
$this->error( $e->getMessage() );
}
}
$rememberMe = '<tr>' .
'<td></td>' .
'<td class="mw-input">' .
- Xml::checkLabel(
- $this->msg( 'remembermypassword' )->numParams( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )->text(),
- 'wpRemember', 'wpRemember',
- $this->getRequest()->getCheck( 'wpRemember' ) ) .
+ Xml::checkLabel(
+ $this->msg( 'remembermypassword' )->numParams( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )->text(),
+ 'wpRemember', 'wpRemember',
+ $this->getRequest()->getCheck( 'wpRemember' ) ) .
'</td>' .
- '</tr>';
+ '</tr>';
$submitMsg = 'resetpass_submit';
$oldpassMsg = 'resetpass-temp-password';
} else {
$extraFields = array();
wfRunHooks( 'ChangePasswordForm', array( &$extraFields ) );
$prettyFields = array(
- array( 'wpName', 'username', 'text', $this->mUserName ),
- array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass ),
- array( 'wpNewPassword', 'newpassword', 'password', null ),
- array( 'wpRetype', 'retypenew', 'password', null ),
- );
+ array( 'wpName', 'username', 'text', $this->mUserName ),
+ array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass ),
+ array( 'wpNewPassword', 'newpassword', 'password', null ),
+ array( 'wpRetype', 'retypenew', 'password', null ),
+ );
$prettyFields = array_merge( $prettyFields, $extraFields );
$hiddenFields = array(
'token' => $user->getEditToken(),
'wpDomain' => $this->mDomain,
) + $this->getRequest()->getValues( 'returnto', 'returntoquery' );
$hiddenFieldsStr = '';
- foreach( $hiddenFields as $fieldname => $fieldvalue ) {
+ foreach ( $hiddenFields as $fieldname => $fieldvalue ) {
$hiddenFieldsStr .= Html::hidden( $fieldname, $fieldvalue ) . "\n";
}
$this->getOutput()->addHTML(
Xml::fieldset( $this->msg( 'resetpass_header' )->text() ) .
- Xml::openElement( 'form',
- array(
- 'method' => 'post',
- 'action' => $this->getTitle()->getLocalUrl(),
- 'id' => 'mw-resetpass-form' ) ) . "\n" .
- $hiddenFieldsStr .
- $this->msg( 'resetpass_text' )->parseAsBlock() . "\n" .
- Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) ) . "\n" .
- $this->pretty( $prettyFields ) . "\n" .
- $rememberMe .
- "<tr>\n" .
+ Xml::openElement( 'form',
+ array(
+ 'method' => 'post',
+ 'action' => $this->getTitle()->getLocalUrl(),
+ 'id' => 'mw-resetpass-form' ) ) . "\n" .
+ $hiddenFieldsStr .
+ $this->msg( 'resetpass_text' )->parseAsBlock() . "\n" .
+ Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) ) . "\n" .
+ $this->pretty( $prettyFields ) . "\n" .
+ $rememberMe .
+ "<tr>\n" .
"<td></td>\n" .
'<td class="mw-input">' .
- Xml::submitButton( $this->msg( $submitMsg )->text() ) .
- Xml::submitButton( $this->msg( 'resetpass-submit-cancel' )->text(), array( 'name' => 'wpCancel' ) ) .
+ Xml::submitButton( $this->msg( $submitMsg )->text() ) .
+ Xml::submitButton( $this->msg( 'resetpass-submit-cancel' )->text(), array( 'name' => 'wpCancel' ) ) .
"</td>\n" .
- "</tr>\n" .
- Xml::closeElement( 'table' ) .
- Xml::closeElement( 'form' ) .
- Xml::closeElement( 'fieldset' ) . "\n"
+ "</tr>\n" .
+ Xml::closeElement( 'table' ) .
+ Xml::closeElement( 'form' ) .
+ Xml::closeElement( 'fieldset' ) . "\n"
);
}
$out = '';
foreach ( $fields as $list ) {
list( $name, $label, $type, $value ) = $list;
- if( $type == 'text' ) {
+ if ( $type == 'text' ) {
$field = htmlspecialchars( $value );
} else {
$attribs = array( 'id' => $name );
}
$out .= "<tr>\n";
$out .= "\t<td class='mw-label'>";
- if ( $type != 'text' )
+
+ if ( $type != 'text' ) {
$out .= Xml::label( $this->msg( $label )->text(), $name );
- else
+ } else {
$out .= $this->msg( $label )->escaped();
+ }
+
$out .= "</td>\n";
$out .= "\t<td class='mw-input'>";
$out .= $field;
$user = User::newFromName( $this->mUserName );
}
- if( !$user || $user->isAnon() ) {
+ if ( !$user || $user->isAnon() ) {
throw new PasswordError( $this->msg( 'nosuchusershort', $this->mUserName )->text() );
}
- if( $newpass !== $retype ) {
+ if ( $newpass !== $retype ) {
wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'badretype' ) );
throw new PasswordError( $this->msg( 'badretype' )->text() );
}
throw new PasswordError( $this->msg( 'login-throttled' )->text() );
}
- if( !$user->checkTemporaryPassword( $this->mOldpass ) && !$user->checkPassword( $this->mOldpass ) ) {
+ if ( !$user->checkTemporaryPassword( $this->mOldpass ) && !$user->checkPassword( $this->mOldpass ) ) {
wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) );
throw new PasswordError( $this->msg( 'resetpass-wrong-oldpass' )->text() );
}
$user->setPassword( $this->mNewpass );
wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) );
$this->mNewpass = $this->mOldpass = $this->mRetype = '';
- } catch( PasswordError $e ) {
+ } catch ( PasswordError $e ) {
wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) );
throw new PasswordError( $e->getMessage() );
}
$rev1 = self::revOrTitle( $data['Revision1'], $data['Page1'] );
$rev2 = self::revOrTitle( $data['Revision2'], $data['Page2'] );
- if( $rev1 && $rev2 ) {
+ if ( $rev1 && $rev2 ) {
$revision = Revision::newFromId( $rev1 );
if ( $revision ) { // NOTE: $rev1 was already checked, should exist.
}
public static function revOrTitle( $revision, $title ) {
- if( $revision ) {
+ if ( $revision ) {
return $revision;
- } elseif( $title ) {
+ } elseif ( $title ) {
$title = Title::newFromText( $title );
- if( $title instanceof Title ) {
+ if ( $title instanceof Title ) {
return $title->getLatestRevID();
}
}