$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;
*/
private function getFrameworkListHtml() {
$list = '<ul>';
- foreach( self::$frameworks as $framework => $initFn ) {
+ foreach ( self::$frameworks as $framework => $initFn ) {
$list .= Html::rawElement(
'li',
array(),
*/
private function wrapSummaryHtml( $html, $state ) {
$validStates = array( 'noframework', 'unknownframework', 'frameworkfound' );
- if( !in_array( $state, $validStates ) ) {
+ if ( !in_array( $state, $validStates ) ) {
throw new MWException( __METHOD__
. ' given an invalid state. Must be one of "'
. join( '", "', $validStates ) . '".'
$namespace = $request->getIntorNull( 'namespace', null );
$protocols_list = array();
- foreach( $wgUrlProtocols as $prot ) {
+ foreach ( $wgUrlProtocols as $prot ) {
if ( $prot !== '//' ) {
$protocols_list[] = $prot;
}
Html::closeElement( 'form' ) . "\n";
$out->addHTML( $s );
- if( $target != '' ) {
+ if ( $target != '' ) {
$this->setParams( array(
'query' => $target2,
'namespace' => $namespace,
'protocol' => $protocol ) );
parent::execute( $par );
- if( $this->mMungedQuery === false )
+ if ( $this->mMungedQuery === false ) {
$out->addWikiMsg( 'linksearch-error' );
+ }
}
}
global $wgMiserMode;
$params = array();
$params['target'] = $this->mProt . $this->mQuery;
- if( isset( $this->mNs ) && !$wgMiserMode ) {
+ if ( isset( $this->mNs ) && !$wgMiserMode ) {
$params['namespace'] = $this->mNs;
}
return $params;
// index-based-only lookup would be done
list( $this->mMungedQuery, $clause ) = self::mungeQuery(
$this->mQuery, $this->mProt );
- if( $this->mMungedQuery === false )
+ if ( $this->mMungedQuery === false ) {
// Invalid query; return no results
return array( 'tables' => 'page', 'fields' => 'page_id', 'conds' => '0=1' );
+ }
$stripped = LinkFilter::keepOneWildcard( $this->mMungedQuery );
$like = $dbr->buildLike( $stripped );
*/
function doQuery( $offset = false, $limit = false ) {
list( $this->mMungedQuery, ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt );
- if( $this->mMungedQuery === false ) {
+ if ( $this->mMungedQuery === false ) {
$this->getOutput()->addWikiMsg( 'linksearch-error' );
} else {
// For debugging
'img_user_text' => $this->msg( 'listfiles_user' )->text(),
'img_description' => $this->msg( 'listfiles_description' )->text(),
);
- if( !$wgMiserMode ) {
+ if ( !$wgMiserMode ) {
$this->mFieldNames['count'] = $this->msg( 'listfiles_count' )->text();
}
}
$options = $join_conds = array();
# Depends on $wgMiserMode
- if( isset( $this->mFieldNames['count'] ) ) {
+ if ( isset( $this->mFieldNames['count'] ) ) {
$tables[] = 'oldimage';
# Need to rewrite this one
unset( $field );
$dbr = wfGetDB( DB_SLAVE );
- if( $dbr->implicitGroupby() ) {
+ if ( $dbr->implicitGroupby() ) {
$options = array( 'GROUP BY' => 'img_name' );
} else {
$columnlist = preg_grep( '/^img/', array_keys( $this->getFieldNames() ) );
$join_conds = array( 'oldimage' => array( 'LEFT JOIN', 'oi_name = img_name' ) );
}
return array(
- 'tables' => $tables,
- 'fields' => $fields,
- 'conds' => $this->mQueryConds,
- 'options' => $options,
+ 'tables' => $tables,
+ 'fields' => $fields,
+ 'conds' => $this->mQueryConds,
+ 'options' => $options,
'join_conds' => $join_conds
);
}
return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) );
case 'img_name':
static $imgfile = null;
- if ( $imgfile === null ) $imgfile = $this->msg( 'imgfile' )->text();
+ if ( $imgfile === null ) {
+ $imgfile = $this->msg( 'imgfile' )->text();
+ }
// Weird files can maybe exist? Bug 22227
$filePage = Title::makeTitleSafe( NS_FILE, $value );
- if( $filePage ) {
+ if ( $filePage ) {
$link = Linker::linkKnown( $filePage, htmlspecialchars( $filePage->getText() ) );
$download = Xml::element( 'a',
array( 'href' => wfLocalFile( $filePage )->getURL() ),
if ( !$wgMiserMode ) {
$inputForm['listfiles_search_for'] = Html::input( 'ilsearch', $this->mSearch, 'text',
array(
- 'size' => '40',
+ 'size' => '40',
'maxlength' => '255',
- 'id' => 'mw-ilsearch',
+ 'id' => 'mw-ilsearch',
) );
}
$inputForm['username'] = Html::input( 'user', $this->mUserName, 'text', array(
- 'size' => '40',
+ 'size' => '40',
'maxlength' => '255',
- 'id' => 'mw-listfiles-user',
+ 'id' => 'mw-listfiles-user',
) );
return Html::openElement( 'form',
array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) ) .
$msg->text() :
MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
- if( $group == '*' ) {
+ if ( $group == '*' ) {
// Do not make a link for the generic * group
$grouppage = htmlspecialchars( $groupnameLocalized );
} else {
*/
private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
$r = array();
- foreach( $permissions as $permission => $granted ) {
+ foreach ( $permissions as $permission => $granted ) {
//show as granted only if it isn't revoked to prevent duplicate display of permissions
- if( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
+ if ( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
$description = $this->msg( 'listgrouprights-right-display',
User::getRightDescription( $permission ),
'<span class="mw-listgrouprights-right-name">' . $permission . '</span>'
$r[] = $description;
}
}
- foreach( $revoke as $permission => $revoked ) {
- if( $revoked ) {
+ foreach ( $revoke as $permission => $revoked ) {
+ if ( $revoked ) {
$description = $this->msg( 'listgrouprights-right-revoked',
User::getRightDescription( $permission ),
'<span class="mw-listgrouprights-right-name">' . $permission . '</span>'
}
sort( $r );
$lang = $this->getLanguage();
- if( $add === true ) {
+ if ( $add === true ) {
$r[] = $this->msg( 'listgrouprights-addgroup-all' )->escaped();
- } elseif( is_array( $add ) && count( $add ) ) {
+ } elseif ( is_array( $add ) && count( $add ) ) {
$add = array_values( array_unique( $add ) );
$r[] = $this->msg( 'listgrouprights-addgroup',
$lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $add ) ),
count( $add )
)->parse();
}
- if( $remove === true ) {
+ if ( $remove === true ) {
$r[] = $this->msg( 'listgrouprights-removegroup-all' )->escaped();
- } elseif( is_array( $remove ) && count( $remove ) ) {
+ } elseif ( is_array( $remove ) && count( $remove ) ) {
$remove = array_values( array_unique( $remove ) );
$r[] = $this->msg( 'listgrouprights-removegroup',
$lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ),
count( $remove )
)->parse();
}
- if( $addSelf === true ) {
+ if ( $addSelf === true ) {
$r[] = $this->msg( 'listgrouprights-addgroup-self-all' )->escaped();
- } elseif( is_array( $addSelf ) && count( $addSelf ) ) {
+ } elseif ( is_array( $addSelf ) && count( $addSelf ) ) {
$addSelf = array_values( array_unique( $addSelf ) );
$r[] = $this->msg( 'listgrouprights-addgroup-self',
$lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ),
count( $addSelf )
)->parse();
}
- if( $removeSelf === true ) {
+ if ( $removeSelf === true ) {
$r[] = $this->msg( 'listgrouprights-removegroup-self-all' )->parse();
- } elseif( is_array( $removeSelf ) && count( $removeSelf ) ) {
+ } elseif ( is_array( $removeSelf ) && count( $removeSelf ) ) {
$removeSelf = array_values( array_unique( $removeSelf ) );
$r[] = $this->msg( 'listgrouprights-removegroup-self',
$lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ),
count( $removeSelf )
)->parse();
}
- if( empty( $r ) ) {
+ if ( empty( $r ) ) {
return '';
} else {
return '<ul><li>' . implode( "</li>\n<li>", $r ) . '</li></ul>';
# Find out where the redirect leads
$target = $this->getRedirectTarget( $result );
- if( $target ) {
+ if ( $target ) {
# Make a link to the destination page
$lang = $this->getLanguage();
$arr = $lang->getArrow() . $lang->getDirMark();
$this->requestedUser = '';
if ( $un != '' ) {
$username = Title::makeTitleSafe( NS_USER, $un );
- if( ! is_null( $username ) ) {
+ if ( ! is_null( $username ) ) {
$this->requestedUser = $username->getText();
}
}
$dbr = wfGetDB( DB_SLAVE );
$conds = array();
// Don't show hidden names
- if( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+ if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
$conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0';
}
$options = array();
- if( $this->requestedGroup != '' ) {
+ if ( $this->requestedGroup != '' ) {
$conds['ug_group'] = $this->requestedGroup;
} else {
//$options['USE INDEX'] = $this->creationSort ? 'PRIMARY' : 'user_name';
}
- if( $this->requestedUser != '' ) {
+ if ( $this->requestedUser != '' ) {
# Sorted either by account creation or name
- if( $this->creationSort ) {
+ if ( $this->creationSort ) {
$conds[] = 'user_id >= ' . intval( User::idFromName( $this->requestedUser ) );
} else {
$conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser );
}
}
- if( $this->editsOnly ) {
+ if ( $this->editsOnly ) {
$conds[] = 'user_editcount > 0';
}
$groups = '';
$groups_list = self::getGroups( $row->user_id );
- if( !$this->including && count( $groups_list ) > 0 ) {
+ if ( !$this->including && count( $groups_list ) > 0 ) {
$list = array();
- foreach( $groups_list as $group )
+ foreach ( $groups_list as $group ) {
$list[] = self::buildGroupLink( $group, $userName );
+ }
$groups = $lang->commaList( $list );
}
$item = $lang->specialList( $ulinks, $groups );
- if( $row->ipb_deleted ) {
+ if ( $row->ipb_deleted ) {
$item = "<span class=\"deleted\">$item</span>";
}
$created = '';
# Some rows may be NULL
- if( !$this->including && $row->creation ) {
+ if ( !$this->including && $row->creation ) {
$user = $this->getUser();
$d = $lang->userDate( $row->creation, $user );
$t = $lang->userTime( $row->creation, $user );
$out .= Xml::label( $this->msg( 'group' )->text(), 'group' ) . ' ' .
Xml::openElement( 'select', array( 'name' => 'group', 'id' => 'group' ) ) .
Xml::option( $this->msg( 'group-all' )->text(), '' );
- foreach( $this->getAllGroups() as $group => $groupText )
+ foreach ( $this->getAllGroups() as $group => $groupText ) {
$out .= Xml::option( $groupText, $group, $group == $this->requestedGroup );
+ }
$out .= Xml::closeElement( 'select' ) . '<br />';
$out .= Xml::checkLabel( $this->msg( 'listusers-editsonly' )->text(), 'editsOnly', 'editsOnly', $this->editsOnly );
$out .= ' ';
*/
function getAllGroups() {
$result = array();
- foreach( User::getAllGroups() as $group ) {
+ foreach ( User::getAllGroups() as $group ) {
$result[$group] = User::getGroupName( $group );
}
asort( $result );
*/
function getDefaultQuery() {
$query = parent::getDefaultQuery();
- if( $this->requestedGroup != '' ) {
+ if ( $this->requestedGroup != '' ) {
$query['group'] = $this->requestedGroup;
}
- if( $this->requestedUser != '' ) {
+ if ( $this->requestedUser != '' ) {
$query['username'] = $this->requestedUser;
}
wfRunHooks( 'SpecialListusersDefaultQuery', array( $this, &$query ) );
$s = $up->getPageHeader();
}
- if( $usersbody ) {
+ if ( $usersbody ) {
$s .= $up->getNavigationBar();
$s .= Html::rawElement( 'ul', array(), $usersbody );
$s .= $up->getNavigationBar();
# Some log types are only for a 'User:' title but we might have been given
# only the username instead of the full title 'User:username'. This part try
# to lookup for a user by that name and eventually fix user input. See bug 1697.
- if( in_array( $opts->getValue( 'type' ), $this->typeOnUser ) ) {
+ if ( in_array( $opts->getValue( 'type' ), $this->typeOnUser ) ) {
# ok we have a type of log which expect a user title.
$target = Title::newFromText( $opts->getValue( 'page' ) );
- if( $target && $target->getNamespace() === NS_MAIN ) {
+ if ( $target && $target->getNamespace() === NS_MAIN ) {
# User forgot to add 'User:', we are adding it for him
$opts->setValue( 'page',
Title::makeTitleSafe( NS_USER, $opts->getValue( 'page' ) )
function getOrderFields() {
// For some crazy reason ordering by a constant
// causes a filesort in MySQL 5
- if( count( MWNamespace::getContentNamespaces() ) > 1 ) {
+ if ( count( MWNamespace::getContentNamespaces() ) > 1 ) {
return array( 'page_namespace', 'page_title' );
} else {
return array( 'page_title' );
$this->mTargetID = intval( $request->getVal( 'targetID' ) );
$this->mDestID = intval( $request->getVal( 'destID' ) );
$this->mTimestamp = $request->getVal( 'mergepoint' );
- if( !preg_match( '/[0-9]{14}/', $this->mTimestamp ) ) {
+ if ( !preg_match( '/[0-9]{14}/', $this->mTimestamp ) ) {
$this->mTimestamp = '';
}
$this->mComment = $request->getText( 'wpComment' );
$this->mMerge = $request->wasPosted() && $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) );
// target page
- if( $this->mSubmitted ) {
+ if ( $this->mSubmitted ) {
$this->mTargetObj = Title::newFromURL( $this->mTarget );
$this->mDestObj = Title::newFromURL( $this->mDest );
} else {
*/
function preCacheMessages() {
// Precache various messages
- if( !isset( $this->message ) ) {
+ if ( !isset( $this->message ) ) {
$this->message['last'] = $this->msg( 'last' )->escaped();
}
}
$this->setHeaders();
$this->outputHeader();
- if( $this->mTargetID && $this->mDestID && $this->mAction == 'submit' && $this->mMerge ) {
+ if ( $this->mTargetID && $this->mDestID && $this->mAction == 'submit' && $this->mMerge ) {
$this->merge();
return;
}
$errors = array();
if ( !$this->mTargetObj instanceof Title ) {
$errors[] = $this->msg( 'mergehistory-invalid-source' )->parseAsBlock();
- } elseif( !$this->mTargetObj->exists() ) {
+ } elseif ( !$this->mTargetObj->exists() ) {
$errors[] = $this->msg( 'mergehistory-no-source', array( 'parse' ),
wfEscapeWikiText( $this->mTargetObj->getPrefixedText() )
)->parseAsBlock();
if ( !$this->mDestObj instanceof Title ) {
$errors[] = $this->msg( 'mergehistory-invalid-destination' )->parseAsBlock();
- } elseif( !$this->mDestObj->exists() ) {
+ } elseif ( !$this->mDestObj->exists() ) {
$errors[] = $this->msg( 'mergehistory-no-destination', array( 'parse' ),
wfEscapeWikiText( $this->mDestObj->getPrefixedText() )
)->parseAsBlock();
);
$out->addHTML( $top );
- if( $haveRevisions ) {
+ if ( $haveRevisions ) {
# Format the user-visible controls (comment field, submission button)
# in a nice little table
$table =
$this->msg( 'mergehistory-list' )->escaped() . "</h2>\n"
);
- if( $haveRevisions ) {
+ if ( $haveRevisions ) {
$out->addHTML( $revisions->getNavigationBar() );
$out->addHTML( '<ul>' );
$out->addHTML( $revisions->getBody() );
array(),
array( 'oldid' => $rev->getId() )
);
- if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
+ if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
$pageLink = '<span class="history-deleted">' . $pageLink . '</span>';
}
# Last link
- if( !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
+ if ( !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
$last = $this->message['last'];
- } elseif( isset( $this->prevId[$row->rev_id] ) ) {
+ } elseif ( isset( $this->prevId[$row->rev_id] ) ) {
$last = Linker::linkKnown(
$rev->getTitle(),
$this->message['last'],
$userLink = Linker::revUserTools( $rev );
$size = $row->rev_len;
- if( !is_null( $size ) ) {
+ if ( !is_null( $size ) ) {
$stxt = Linker::formatRevisionSize( $size );
}
$comment = Linker::revComment( $rev );
# keep it consistent...
$targetTitle = Title::newFromID( $this->mTargetID );
$destTitle = Title::newFromID( $this->mDestID );
- if( is_null( $targetTitle ) || is_null( $destTitle ) ) {
+ if ( is_null( $targetTitle ) || is_null( $destTitle ) ) {
return false; // validate these
}
- if( $targetTitle->getArticleID() == $destTitle->getArticleID() ) {
+ if ( $targetTitle->getArticleID() == $destTitle->getArticleID() ) {
return false;
}
# Verify that this timestamp is valid
__METHOD__
);
# Destination page must exist with revisions
- if( !$maxtimestamp ) {
+ if ( !$maxtimestamp ) {
$this->getOutput()->addWikiMsg( 'mergehistory-fail' );
return false;
}
__METHOD__
);
# $this->mTimestamp must be older than $maxtimestamp
- if( $this->mTimestamp >= $maxtimestamp ) {
+ if ( $this->mTimestamp >= $maxtimestamp ) {
$this->getOutput()->addWikiMsg( 'mergehistory-fail' );
return false;
}
# Update the revisions
- if( $this->mTimestamp ) {
+ if ( $this->mTimestamp ) {
$timewhere = "rev_timestamp <= {$this->mTimestamp}";
$timestampLimit = wfTimestamp( TS_MW, $this->mTimestamp );
} else {
__METHOD__,
array( 'FOR UPDATE' )
);
- if( !$haveRevisions ) {
- if( $this->mComment ) {
+ if ( !$haveRevisions ) {
+ if ( $this->mComment ) {
$comment = $this->msg(
'mergehistory-comment',
$targetTitle->getPrefixedText(),
if ( $redirectContent ) {
$redirectPage = WikiPage::factory( $targetTitle );
$redirectRevision = new Revision( array(
- 'title' => $targetTitle,
- 'page' => $this->mTargetID,
+ 'title' => $targetTitle,
+ 'page' => $this->mTargetID,
'comment' => $comment,
'content' => $redirectContent ) );
$redirectRevision->insertOn( $dbw );
$dbw->delete( 'pagelinks', array( 'pl_from' => $this->mDestID ), __METHOD__ );
$dbw->insert( 'pagelinks',
array(
- 'pl_from' => $this->mDestID,
+ 'pl_from' => $this->mDestID,
'pl_namespace' => $destTitle->getNamespace(),
- 'pl_title' => $destTitle->getDBkey() ),
+ 'pl_title' => $destTitle->getDBkey() ),
__METHOD__
);
} else {
}
$destTitle->invalidateCache(); // update histories
# Check if this did anything
- if( !$count ) {
+ if ( !$count ) {
$this->getOutput()->addWikiMsg( 'mergehistory-fail' );
return false;
}
$batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
$rev_id = isset( $rev_id ) ? $rev_id : $row->rev_id;
- if( $rev_id > $row->rev_id ) {
+ if ( $rev_id > $row->rev_id ) {
$this->mForm->prevId[$rev_id] = $row->rev_id;
- } elseif( $rev_id < $row->rev_id ) {
+ } elseif ( $rev_id < $row->rev_id ) {
$this->mForm->prevId[$row->rev_id] = $rev_id;
}
return array(
'tables' => array( 'revision', 'page', 'user' ),
'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
- 'conds' => $conds,
+ 'conds' => $conds,
'join_conds' => array(
'page' => Revision::pageJoinCond(),
'user' => Revision::userJoinCond() )
$oldTitleText = $request->getVal( 'wpOldTitle', $target );
$this->oldTitle = Title::newFromText( $oldTitleText );
- if( is_null( $this->oldTitle ) ) {
+ if ( is_null( $this->oldTitle ) ) {
throw new ErrorPageError( 'notargettitle', 'notargettext' );
}
- if( !$this->oldTitle->exists() ) {
+ if ( !$this->oldTitle->exists() ) {
throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
}
# link, check for validity. We can then show some diagnostic
# information and save a click.
$newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
- if( is_array( $newerr ) ) {
+ if ( is_array( $newerr ) ) {
$err = $newerr;
}
}
}
} else {
$errStr = array();
- foreach( $err as $errMsg ) {
- if( $errMsg[0] == 'hookaborted' ) {
+ foreach ( $err as $errMsg ) {
+ if ( $errMsg[0] == 'hookaborted' ) {
$errStr[] = $errMsg[1];
} else {
$errMsgName = array_shift( $errMsg );
</tr>"
);
- if( $considerTalk ) {
+ if ( $considerTalk ) {
$out->addHTML( "
<tr>
<td></td>
);
}
- if( $canMoveSubpage ) {
+ if ( $canMoveSubpage ) {
$out->addHTML( "
<tr>
<td></td>
$watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' )
|| $user->isWatched( $this->oldTitle ) );
# Don't allow watching if user is not logged in
- if( $user->isLoggedIn() ) {
+ if ( $user->isLoggedIn() ) {
$out->addHTML( "
<tr>
<td></td>
<td class='mw-input'>" .
Xml::checkLabel( $this->msg( 'move-watch' )->text(), 'wpWatch', 'watch', $watchChecked ) .
"</td>
- </tr>");
+ </tr>" );
}
$out->addHTML( "
# Now we move extra pages we've been asked to move: subpages and talk
# pages. First, if the old page or the new page is a talk page, we
# can't move any talk pages: cancel that.
- if( $ot->isTalkPage() || $nt->isTalkPage() ) {
+ if ( $ot->isTalkPage() || $nt->isTalkPage() ) {
$this->moveTalk = false;
}
// @todo FIXME: Use Title::moveSubpages() here
$dbr = wfGetDB( DB_MASTER );
- if( $this->moveSubpages && (
+ if ( $this->moveSubpages && (
MWNamespace::hasSubpages( $nt->getNamespace() ) || (
$this->moveTalk &&
MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
. ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
);
$conds['page_namespace'] = array();
- if( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
+ if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
$conds['page_namespace'][] = $ot->getNamespace();
}
- if( $this->moveTalk && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) ) {
+ if ( $this->moveTalk && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) ) {
$conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
}
- } elseif( $this->moveTalk ) {
+ } elseif ( $this->moveTalk ) {
$conds = array(
'page_namespace' => $ot->getTalkPage()->getNamespace(),
'page_title' => $ot->getDBkey()
}
$extraPages = array();
- if( !is_null( $conds ) ) {
+ if ( !is_null( $conds ) ) {
$extraPages = TitleArray::newFromResult(
$dbr->select( 'page',
array( 'page_id', 'page_namespace', 'page_title' ),
$extraOutput = array();
$count = 1;
- foreach( $extraPages as $oldSubpage ) {
- if( $ot->equals( $oldSubpage ) ) {
+ foreach ( $extraPages as $oldSubpage ) {
+ if ( $ot->equals( $oldSubpage ) ) {
# Already did this one.
continue;
}
StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
$oldSubpage->getDBkey()
);
- if( $oldSubpage->isTalkPage() ) {
+ if ( $oldSubpage->isTalkPage() ) {
$newNs = $nt->getTalkPage()->getNamespace();
} else {
$newNs = $nt->getSubjectPage()->getNamespace();
# Bug 14385: we need makeTitleSafe because the new page names may
# be longer than 255 characters.
$newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
- if( !$newSubpage ) {
+ if ( !$newSubpage ) {
$oldLink = Linker::linkKnown( $oldSubpage );
$extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink
)->params( Title::makeName( $newNs, $newPageName ) )->escaped();
$extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
} else {
$success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
- if( $success === true ) {
+ if ( $success === true ) {
if ( $this->fixRedirects ) {
DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage );
}
$newLink = Linker::linkKnown( $newSubpage );
$extraOutput[] = $this->msg( 'movepage-page-moved' )->rawParams( $oldLink, $newLink )->escaped();
++$count;
- if( $count >= $wgMaximumMovedPages ) {
+ if ( $count >= $wgMaximumMovedPages ) {
$extraOutput[] = $this->msg( 'movepage-max-pages' )->numParams( $wgMaximumMovedPages )->escaped();
break;
}
}
- if( $extraOutput !== array() ) {
+ if ( $extraOutput !== array() ) {
$out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
}
# Deal with watches (we don't watch subpages)
- if( $this->watch && $user->isLoggedIn() ) {
+ if ( $this->watch && $user->isLoggedIn() ) {
$user->addWatch( $ot );
$user->addWatch( $nt );
} else {
# Re-clear the file redirect cache, which may have been polluted by
# parsing in messages above. See CR r56745.
# @todo FIXME: Needs a more robust solution inside FileRepo.
- if( $ot->getNamespace() == NS_FILE ) {
+ if ( $ot->getNamespace() == NS_FILE ) {
RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $ot );
}
}
}
function showSubpages( $title ) {
- if( !MWNamespace::hasSubpages( $title->getNamespace() ) )
+ if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
return;
+ }
$subpages = $title->getSubpages();
$count = $subpages instanceof TitleArray ? $subpages->count() : 0;
$out->addWikiMsg( 'movesubpagetext', $this->getLanguage()->formatNum( $count ) );
$out->addHTML( "<ul>\n" );
- foreach( $subpages as $subpage ) {
+ foreach ( $subpages as $subpage ) {
$link = Linker::link( $subpage );
$out->addHTML( "<li>$link</li>\n" );
}
$conds = $jconds = array();
$tables = array( 'image' );
- if( !$this->showbots ) {
+ if ( !$this->showbots ) {
$groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
- if( count( $groupsWithBotPermission ) ) {
+ if ( count( $groupsWithBotPermission ) ) {
$tables[] = 'user_groups';
$conds[] = 'ug_group IS NULL';
$jconds['user_groups'] = array(
}
}
- if( !$wgMiserMode && $this->like !== null ) {
+ if ( !$wgMiserMode && $this->like !== null ) {
$dbr = wfGetDB( DB_SLAVE );
$likeObj = Title::newFromURL( $this->like );
- if( $likeObj instanceof Title ) {
+ if ( $likeObj instanceof Title ) {
$like = $dbr->buildLike( $dbr->anyString(), strtolower( $likeObj->getDBkey() ), $dbr->anyString() );
$conds[] = "LOWER(img_name) $like";
}
),
);
- if( $wgMiserMode ) {
+ if ( $wgMiserMode ) {
unset( $fields['like'] );
}
$this->customFilters = array();
wfRunHooks( 'SpecialNewPagesFilters', array( $this, &$this->customFilters ) );
- foreach( $this->customFilters as $key => $params ) {
+ foreach ( $this->customFilters as $key => $params ) {
$opts->add( $key, $params['default'] );
}
// Set values
$opts->fetchValuesFromRequest( $this->getRequest() );
- if ( $par ) $this->parseParams( $par );
+ if ( $par ) {
+ $this->parseParams( $par );
+ }
// Validate
$opts->validateIntBounds( 'limit', 0, 5000 );
- if( !$wgEnableNewpagesUserFilter ) {
+ if ( !$wgEnableNewpagesUserFilter ) {
$opts->setValue( 'username', '' );
}
}
}
if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
$ns = $this->getLanguage()->getNsIndex( $m[1] );
- if( $ns !== false ) {
+ if ( $ns !== false ) {
$this->opts->setValue( 'namespace', $ns );
}
}
$this->showNavigation = !$this->including(); // Maybe changed in setup
$this->setup( $par );
- if( !$this->including() ) {
+ if ( !$this->including() ) {
// Settings
$this->form();
$feedType = $this->opts->getValue( 'feed' );
- if( $feedType ) {
+ if ( $feedType ) {
$this->feed( $feedType );
return;
}
$pager->mLimit = $this->opts->getValue( 'limit' );
$pager->mOffset = $this->opts->getValue( 'offset' );
- if( $pager->getNumRows() ) {
+ if ( $pager->getNumRows() ) {
$navigation = '';
if ( $this->showNavigation ) {
$navigation = $pager->getNavigationBar();
'selected' => $namespace,
'all' => 'all',
), array(
- 'name' => 'namespace',
- 'id' => 'namespace',
+ 'name' => 'namespace',
+ 'id' => 'namespace',
'class' => 'namespaceselector',
)
) . ' ' .
$query = array( 'redirect' => 'no' );
- if( $this->patrollable( $result ) ) {
+ if ( $this->patrollable( $result ) ) {
$query['rcid'] = $result->rc_id;
}
}
# Tags, if any.
- if( isset( $result->ts_tags ) ) {
+ if ( isset( $result->ts_tags ) ) {
list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( $result->ts_tags, 'newpages' );
$classes = array_merge( $classes, $newClasses );
} else {
return;
}
- if( !isset( $wgFeedClasses[$type] ) ) {
+ if ( !isset( $wgFeedClasses[$type] ) ) {
$this->getOutput()->addWikiMsg( 'feed-invalid' );
return;
}
$pager->mLimit = min( $limit, $wgFeedLimit );
$feed->outHeader();
- if( $pager->getNumRows() > 0 ) {
+ if ( $pager->getNumRows() > 0 ) {
foreach ( $pager->mResult as $row ) {
$feed->outItem( $this->feedItem( $row ) );
}
protected function feedItem( $row ) {
$title = Title::makeTitle( intval( $row->rc_namespace ), $row->rc_title );
- if( $title ) {
+ if ( $title ) {
$date = $row->rc_timestamp;
$comments = $title->getTalkPage()->getFullURL();
protected function feedItemDesc( $row ) {
$revision = Revision::newFromId( $row->rev_id );
- if( $revision ) {
+ if ( $revision ) {
//XXX: include content model/type in feed item?
return '<p>' . htmlspecialchars( $revision->getUserText() ) .
$this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
$username = $this->opts->getValue( 'username' );
$user = Title::makeTitleSafe( NS_USER, $username );
- if( $namespace !== false ) {
+ if ( $namespace !== false ) {
if ( $this->opts->getValue( 'invert' ) ) {
$conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace );
} else {
}
# $wgEnableNewpagesUserFilter - temp WMF hack
- if( $wgEnableNewpagesUserFilter && $user ) {
+ if ( $wgEnableNewpagesUserFilter && $user ) {
$conds['rc_user_text'] = $user->getText();
$rcIndexes = 'rc_user_text';
# If anons cannot make new pages, don't "exclude logged in users"!
- } elseif( User::groupHasPermission( '*', 'createpage' ) && $this->opts->getValue( 'hideliu' ) ) {
+ } elseif ( User::groupHasPermission( '*', 'createpage' ) && $this->opts->getValue( 'hideliu' ) ) {
$conds['rc_user'] = 0;
}
# If this user cannot see patrolled edits or they are off, don't do dumb queries!
- if( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
+ if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
$conds['rc_patrolled'] = 0;
}
- if( $this->opts->getValue( 'hidebots' ) ) {
+ if ( $this->opts->getValue( 'hidebots' ) ) {
$conds['rc_bot'] = 0;
}
$tables = array( 'recentchanges', 'page' );
$fields = array(
'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text',
- 'rc_comment', 'rc_timestamp', 'rc_patrolled','rc_id', 'rc_deleted',
+ 'rc_comment', 'rc_timestamp', 'rc_patrolled', 'rc_id', 'rc_deleted',
'length' => 'page_len', 'rev_id' => 'page_latest', 'rc_this_oldid',
'page_namespace', 'page_title'
);
array( &$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds ) );
$info = array(
- 'tables' => $tables,
- 'fields' => $fields,
- 'conds' => $conds,
- 'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ),
+ 'tables' => $tables,
+ 'fields' => $fields,
+ 'conds' => $conds,
+ 'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ),
'join_conds' => $join_conds
);
'type' => 'text',
'label-message' => 'passwordreset-username',
);
- if( $this->getUser()->isLoggedIn() ) {
+ if ( $this->getUser()->isLoggedIn() ) {
$a['Username']['default'] = $this->getUser()->getName();
}
}
);
}
- if( $this->getUser()->isAllowed( 'passwordreset' ) ) {
+ if ( $this->getUser()->isAllowed( 'passwordreset' ) ) {
$a['Capture'] = array(
'type' => 'check',
'label-message' => 'passwordreset-capture',
}
}
- if( isset( $data['Capture'] ) && !$this->getUser()->isAllowed( 'passwordreset' ) ) {
+ if ( isset( $data['Capture'] ) && !$this->getUser()->isAllowed( 'passwordreset' ) ) {
// The user knows they don't have the passwordreset permission, but they tried to spoof the form. That's naughty
throw new PermissionsError( 'passwordreset' );
}
);
if ( $res ) {
$users = array();
- foreach( $res as $row ) {
+ foreach ( $res as $row ) {
$users[] = User::newFromRow( $row );
}
} else {
return array( $error );
}
- if( count( $users ) == 0 ) {
- if( $method == 'email' ) {
+ if ( count( $users ) == 0 ) {
+ if ( $method == 'email' ) {
// Don't reveal whether or not an email address is in use
return true;
} else {
$this->result = $firstUser->sendMail( $title->escaped(), $this->email->text() );
- if( isset( $data['Capture'] ) && $data['Capture'] ) {
+ if ( isset( $data['Capture'] ) && $data['Capture'] ) {
// Save the user, will be used if an error occurs when sending the email
$this->firstUser = $firstUser;
} else {
if ( $this->result->isGood() ) {
return true;
- } elseif( isset( $data['Capture'] ) && $data['Capture'] ) {
+ } elseif ( isset( $data['Capture'] ) && $data['Capture'] ) {
// The email didn't send, but maybe they knew that and that's why they captured it
return true;
} else {
}
public function onSuccess() {
- if( $this->getUser()->isAllowed( 'passwordreset' ) && $this->email != null ) {
+ if ( $this->getUser()->isAllowed( 'passwordreset' ) && $this->email != null ) {
// @todo: Logging
- if( $this->result->isGood() ) {
+ if ( $this->result->isGood() ) {
$this->getOutput()->addWikiMsg( 'passwordreset-emailsent-capture' );
} else {
$this->getOutput()->addWikiMsg( 'passwordreset-emailerror-capture',
global $wgContLang;
$title = Title::makeTitleSafe( $result->namespace, $result->title );
- if( !$title ) {
+ if ( !$title ) {
return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
}
);
$showme = '';
- if( isset( $par ) ) {
+ if ( isset( $par ) ) {
$showme = $par;
- } elseif( $prefix != '' ) {
+ } elseif ( $prefix != '' ) {
$showme = $prefix;
- } elseif( $from != '' && $ns === null ) {
+ } elseif ( $from != '' && $ns === null ) {
// For back-compat with Special:Allpages
// Don't do this if namespace is passed, so paging works when doing NS views.
$showme = $from;
Html::namespaceSelector( array(
'selected' => $namespace,
), array(
- 'name' => 'namespace',
- 'id' => 'namespace',
+ 'name' => 'namespace',
+ 'id' => 'namespace',
'class' => 'namespaceselector',
) ) .
Xml::checkLabel(
$conds,
__METHOD__,
array(
- 'ORDER BY' => 'page_title',
- 'LIMIT' => $this->maxPerPage + 1,
+ 'ORDER BY' => 'page_title',
+ 'LIMIT' => $this->maxPerPage + 1,
'USE INDEX' => 'name_title',
)
);
### @todo FIXME: Side link to previous
$n = 0;
- if( $res->numRows() > 0 ) {
+ if ( $res->numRows() > 0 ) {
$out = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-list-table' ) );
- while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
+ while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title );
- if( $t ) {
+ if ( $t ) {
$link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
Linker::linkKnown(
$t,
} else {
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
- if( $n % 3 == 0 ) {
+ if ( $n % 3 == 0 ) {
$out .= '<tr>';
}
$out .= "<td>$link</td>";
$n++;
- if( $n % 3 == 0 ) {
+ if ( $n % 3 == 0 ) {
$out .= '</tr>';
}
}
- if( ($n % 3) != 0 ) {
+ if ( ($n % 3) != 0 ) {
$out .= '</tr>';
}
$out .= Xml::closeElement( 'table' );
'</td>
<td id="mw-prefixindex-nav-form" class="mw-prefixindex-nav">';
- if( isset( $res ) && $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
+ if ( isset( $res ) && $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$query = array(
'from' => $s->page_title,
'prefix' => $prefix,
'hideredirects' => $hideredirects,
);
- if( $namespace || $prefix == '' ) {
+ if ( $namespace || $prefix == '' ) {
// Keep the namespace even if it's 0 for empty prefixes.
// This tells us we're not just a holdover from old links.
$query['namespace'] = $namespace;
$this->outputHeader();
// Purge expired entries on one in every 10 queries
- if( !mt_rand( 0, 10 ) ) {
+ if ( !mt_rand( 0, 10 ) ) {
Title::purgeExpiredRestrictions();
}
$this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level, $sizetype, $size, $indefOnly, $cascadeOnly ) );
- if( $pager->getNumRows() ) {
+ if ( $pager->getNumRows() ) {
$this->getOutput()->addHTML(
$pager->getNavigationBar() .
'<ul>' . $pager->getBody() . '</ul>' .
static $infinity = null;
- if( is_null( $infinity ) ) {
+ if ( is_null( $infinity ) ) {
$infinity = wfGetDB( DB_SLAVE )->getInfinity();
}
$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- if( !$title ) {
+ if ( !$title ) {
wfProfileOut( __METHOD__ );
return Html::rawElement( 'li', array(),
Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
$description_items[] = $protType;
- if( $row->pr_cascade ) {
+ if ( $row->pr_cascade ) {
$description_items[] = $this->msg( 'protect-summary-cascade' )->text();
}
$lang = $this->getLanguage();
$expiry = $lang->formatExpiry( $row->pr_expiry, TS_MW );
- if( $expiry != $infinity ) {
+ if ( $expiry != $infinity ) {
$user = $this->getUser();
$description_items[] = $this->msg(
'protect-expiring-local',
)->escaped();
}
- if( !is_null( $size = $row->page_len ) ) {
+ if ( !is_null( $size = $row->page_len ) ) {
$stxt = $lang->getDirMark() . ' ' . Linker::formatRevisionSize( $size );
}
# Show a link to the change protection form for allowed users otherwise a link to the protection log
- if( $this->getUser()->isAllowed( 'protect' ) ) {
+ if ( $this->getUser()->isAllowed( 'protect' ) ) {
$changeProtection = Linker::linkKnown(
$title,
$this->msg( 'protect_change' )->escaped(),
$options = array();
// First pass to load the log names
- foreach( Title::getFilteredRestrictionTypes( true ) as $type ) {
+ foreach ( Title::getFilteredRestrictionTypes( true ) as $type ) {
$text = $this->msg( "restriction-$type" )->text();
$m[$text] = $type;
}
// Third pass generates sorted XHTML content
- foreach( $m as $text => $type ) {
+ foreach ( $m as $text => $type ) {
$selected = ($type == $pr_type );
$options[] = Xml::option( $text, $type, $selected ) . "\n";
}
$options = array();
// First pass to load the log names
- foreach( $wgRestrictionLevels as $type ) {
+ foreach ( $wgRestrictionLevels as $type ) {
// Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
- if( $type != '' && $type != '*' ) {
+ if ( $type != '' && $type != '*' ) {
$text = $this->msg( "restriction-level-$type" )->text();
$m[$text] = $type;
}
}
// Third pass generates sorted XHTML content
- foreach( $m as $text => $type ) {
- $selected = ($type == $pr_level );
+ foreach ( $m as $text => $type ) {
+ $selected = ( $type == $pr_level );
$options[] = Xml::option( $text, $type, $selected );
}
$conds[] = 'page_id=pr_page';
$conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type );
- if( $this->sizetype == 'min' ) {
+ if ( $this->sizetype == 'min' ) {
$conds[] = 'page_len>=' . $this->size;
- } elseif( $this->sizetype == 'max' ) {
+ } elseif ( $this->sizetype == 'max' ) {
$conds[] = 'page_len<=' . $this->size;
}
- if( $this->indefonly ) {
+ if ( $this->indefonly ) {
$conds[] = "pr_expiry = {$this->mDb->addQuotes( $this->mDb->getInfinity() )} OR pr_expiry IS NULL";
}
- if( $this->cascadeonly ) {
+ if ( $this->cascadeonly ) {
$conds[] = 'pr_cascade = 1';
}
- if( $this->level )
+ if ( $this->level ) {
$conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level );
- if( !is_null( $this->namespace ) )
+ }
+ if ( !is_null( $this->namespace ) ) {
$conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace );
+ }
return array(
'tables' => array( 'page_restrictions', 'page' ),
'fields' => array( 'pr_id', 'page_namespace', 'page_title', 'page_len',
static $infinity = null;
- if( is_null( $infinity ) ) {
+ if ( is_null( $infinity ) ) {
$infinity = wfGetDB( DB_SLAVE )->getInfinity();
}
$title = Title::makeTitleSafe( $row->pt_namespace, $row->pt_title );
- if( !$title ) {
+ if ( !$title ) {
wfProfileOut( __METHOD__ );
return Html::rawElement( 'li', array(),
Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
$lang = $this->getLanguage();
$expiry = strlen( $row->pt_expiry ) ? $lang->formatExpiry( $row->pt_expiry, TS_MW ) : $infinity;
- if( $expiry != $infinity ) {
+ if ( $expiry != $infinity ) {
$user = $this->getUser();
$description_items[] = $this->msg(
'protect-expiring-local',
$options = array();
// First pass to load the log names
- foreach( $wgRestrictionLevels as $type ) {
+ foreach ( $wgRestrictionLevels as $type ) {
if ( $type != '' && $type != '*' ) {
$text = $this->msg( "restriction-level-$type" )->text();
$m[$text] = $type;
}
}
// Is there only one level (aside from "all")?
- if( count( $m ) <= 2 ) {
+ if ( count( $m ) <= 2 ) {
return '';
}
// Third pass generates sorted XHTML content
- foreach( $m as $text => $type ) {
+ foreach ( $m as $text => $type ) {
$selected = ($type == $pr_level );
$options[] = Xml::option( $text, $type, $selected );
}
function getQueryInfo() {
$conds = $this->mConds;
$conds[] = 'pt_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() );
- if( $this->level )
+ if ( $this->level ) {
$conds['pt_create_perm'] = $this->level;
- if( !is_null( $this->namespace ) )
+ }
+ if ( !is_null( $this->namespace ) ) {
$conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace );
+ }
return array(
'tables' => 'protected_titles',
'fields' => array( 'pt_namespace', 'pt_title', 'pt_create_perm',
}
public function setNamespace( $ns ) {
- if( !$ns || $ns < NS_MAIN ) {
+ if ( !$ns || $ns < NS_MAIN ) {
$ns = NS_MAIN;
}
$this->namespaces = array( $ns );
$title = $this->getRandomTitle();
- if( is_null( $title ) ) {
+ if ( is_null( $title ) ) {
$this->setHeaders();
$this->getOutput()->addWikiMsg( strtolower( $this->getName() ) . '-nopages',
$this->getNsList(), count( $this->namespaces ) );
private function getNsList() {
global $wgContLang;
$nsNames = array();
- foreach( $this->namespaces as $n ) {
- if( $n === NS_MAIN ) {
+ foreach ( $this->namespaces as $n ) {
+ if ( $n === NS_MAIN ) {
$nsNames[] = $this->msg( 'blanknamespace' )->plain();
} else {
$nsNames[] = $wgContLang->getNsText( $n );
* any more bias than what the page_random scheme
* causes anyway. Trust me, I'm a mathematician. :)
*/
- if( !$row ) {
+ if ( !$row ) {
$row = $this->selectRandomPageFromDB( "0" );
}
- if( $row ) {
+ if ( $row ) {
return Title::makeTitleSafe( $row->page_namespace, $row->page_title );
} else {
return null;
public function setup( $parameters ) {
$opts = $this->getDefaultOptions();
- foreach( $this->getCustomFilters() as $key => $params ) {
+ foreach ( $this->getCustomFilters() as $key => $params ) {
$opts->add( $key, $params['default'] );
}
$opts->fetchValuesFromRequest( $this->getRequest() );
// Give precedence to subpage syntax
- if( $parameters !== null ) {
+ if ( $parameters !== null ) {
$this->parseParameters( $parameters, $opts );
}
$this->getOutput()->setSquidMaxage( 10 );
# Check if the client has a cached version
$lastmod = $this->checkLastModified( $feedFormat );
- if( $lastmod === false ) {
+ if ( $lastmod === false ) {
return;
}
// Fetch results, prepare a batch link existence check query
$conds = $this->buildMainQueryConds( $opts );
$rows = $this->doMainQuery( $conds, $opts );
- if( $rows === false ) {
- if( !$this->including() ) {
+ if ( $rows === false ) {
+ if ( !$this->including() ) {
$this->doHeader( $opts );
}
return;
}
- if( !$feedFormat ) {
+ if ( !$feedFormat ) {
$batch = new LinkBatch;
- foreach( $rows as $row ) {
+ foreach ( $rows as $row ) {
$batch->add( NS_USER, $row->rc_user_text );
$batch->add( NS_USER_TALK, $row->rc_user_text );
$batch->add( $row->rc_namespace, $row->rc_title );
}
$batch->execute();
}
- if( $feedFormat ) {
+ if ( $feedFormat ) {
list( $changesFeed, $formatter ) = $this->getFeedObject( $feedFormat );
/** @var ChangesFeed $changesFeed */
$changesFeed->execute( $formatter, $rows, $lastmod, $opts );
*/
public function parseParameters( $par, FormOptions $opts ) {
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
- foreach( $bits as $bit ) {
- if( 'hidebots' === $bit ) {
+ foreach ( $bits as $bit ) {
+ if ( 'hidebots' === $bit ) {
$opts['hidebots'] = true;
}
- if( 'bots' === $bit ) {
+ if ( 'bots' === $bit ) {
$opts['hidebots'] = false;
}
- if( 'hideminor' === $bit ) {
+ if ( 'hideminor' === $bit ) {
$opts['hideminor'] = true;
}
- if( 'minor' === $bit ) {
+ if ( 'minor' === $bit ) {
$opts['hideminor'] = false;
}
- if( 'hideliu' === $bit ) {
+ if ( 'hideliu' === $bit ) {
$opts['hideliu'] = true;
}
- if( 'hidepatrolled' === $bit ) {
+ if ( 'hidepatrolled' === $bit ) {
$opts['hidepatrolled'] = true;
}
- if( 'hideanons' === $bit ) {
+ if ( 'hideanons' === $bit ) {
$opts['hideanons'] = true;
}
- if( 'hidemyself' === $bit ) {
+ if ( 'hidemyself' === $bit ) {
$opts['hidemyself'] = true;
}
- if( is_numeric( $bit ) ) {
+ if ( is_numeric( $bit ) ) {
$opts['limit'] = $bit;
}
$m = array();
- if( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
+ if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
$opts['limit'] = $m[1];
}
- if( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
+ if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
$opts['days'] = $m[1];
}
- if( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
+ if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
$opts['namespace'] = $m[1];
}
}
public function checkLastModified( $feedFormat ) {
$dbr = wfGetDB( DB_SLAVE );
$lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
- if( $feedFormat || !$this->getUser()->useRCPatrol() ) {
- if( $lastmod && $this->getOutput()->checkLastModified( $lastmod ) ) {
+ if ( $feedFormat || !$this->getUser()->useRCPatrol() ) {
+ if ( $lastmod && $this->getOutput()->checkLastModified( $lastmod ) ) {
# Client cache fresh and headers sent, nothing more to do.
return false;
}
# It makes no sense to hide both anons and logged-in users
# Where this occurs, force anons to be shown
$forcebot = false;
- if( $opts['hideanons'] && $opts['hideliu'] ) {
+ if ( $opts['hideanons'] && $opts['hideliu'] ) {
# Check if the user wants to show bots only
- if( $opts['hidebots'] ) {
+ if ( $opts['hidebots'] ) {
$opts['hideanons'] = false;
} else {
$forcebot = true;
$cutoff = $dbr->timestamp( $cutoff_unixtime );
$fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
- if( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
+ if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
$cutoff = $dbr->timestamp( $opts['from'] );
} else {
$opts->reset( 'from' );
$hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
$hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
- if( $opts['hideminor'] ) {
+ if ( $opts['hideminor'] ) {
$conds['rc_minor'] = 0;
}
- if( $opts['hidebots'] ) {
+ if ( $opts['hidebots'] ) {
$conds['rc_bot'] = 0;
}
- if( $hidePatrol ) {
+ if ( $hidePatrol ) {
$conds['rc_patrolled'] = 0;
}
- if( $forcebot ) {
+ if ( $forcebot ) {
$conds['rc_bot'] = 1;
}
- if( $hideLoggedInUsers ) {
+ if ( $hideLoggedInUsers ) {
$conds[] = 'rc_user = 0';
}
- if( $hideAnonymousUsers ) {
+ if ( $hideAnonymousUsers ) {
$conds[] = 'rc_user != 0';
}
- if( $opts['hidemyself'] ) {
- if( $this->getUser()->getId() ) {
+ if ( $opts['hidemyself'] ) {
+ if ( $this->getUser()->getId() ) {
$conds[] = 'rc_user != ' . $dbr->addQuotes( $this->getUser()->getId() );
} else {
$conds[] = 'rc_user_text != ' . $dbr->addQuotes( $this->getUser()->getName() );
}
# Namespace filtering
- if( $opts['namespace'] !== '' ) {
+ if ( $opts['namespace'] !== '' ) {
$selectedNS = $dbr->addQuotes( $opts['namespace'] );
$operator = $opts['invert'] ? '!=' : '=';
$boolean = $opts['invert'] ? 'AND' : 'OR';
# namespace association (bug 2429)
- if( !$opts['associated'] ) {
+ if ( !$opts['associated'] ) {
$condition = "rc_namespace $operator $selectedNS";
} else {
# Also add the associated namespace
// (b) We want pages in more than one namespace (inverted/associated)
// (c) There is a tag to filter on (use tag index instead)
// (d) UNION + sort/limit is not an option for the DBMS
- if( $namespace === ''
+ if ( $namespace === ''
|| ( $invert || $associated )
|| $opts['tagfilter'] != ''
|| !$dbr->unionSupportsOrderAndLimit() )
$limit = $opts['limit'];
- if( !$this->including() ) {
+ if ( !$this->including() ) {
// Output options box
$this->doHeader( $opts );
}
$this->getOutput()->setFeedAppendQuery( false );
}
- if( $wgAllowCategorizedRecentChanges ) {
+ if ( $wgAllowCategorizedRecentChanges ) {
$this->filterByCategories( $rows, $opts );
}
$list = ChangesList::newFromContext( $this->getContext() );
$s = $list->beginRecentChangesList();
- foreach( $rows as $obj ) {
- if( $limit == 0 ) {
+ foreach ( $rows as $obj ) {
+ if ( $limit == 0 ) {
break;
}
$rc = RecentChange::newFromRow( $obj );
$rc->counter = $counter++;
# Check if the page has been updated since the last visit
- if( $wgShowUpdatedMarker && !empty( $obj->wl_notificationtimestamp ) ) {
+ if ( $wgShowUpdatedMarker && !empty( $obj->wl_notificationtimestamp ) ) {
$rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
} else {
$rc->notificationtimestamp = false; // Default
}
# Check the number of users watching the page
$rc->numberofWatchingusers = 0; // Default
- if( $showWatcherCount && $obj->rc_namespace >= 0 ) {
- if( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
+ if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
+ if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
$watcherCache[$obj->rc_namespace][$obj->rc_title] =
$dbr->selectField(
'watchlist',
$submit = ' ' . Xml::submitbutton( $this->msg( 'allpagessubmit' )->text() );
$out = Xml::openElement( 'table', array( 'class' => 'mw-recentchanges-table' ) );
- foreach( $extraOpts as $name => $optionRow ) {
+ foreach ( $extraOpts as $name => $optionRow ) {
# Add submit button to the last row only
++$count;
$addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
$out .= Xml::openElement( 'tr' );
- if( is_array( $optionRow ) ) {
+ if ( is_array( $optionRow ) ) {
$out .= Xml::tags( 'td', array( 'class' => 'mw-label mw-' . $name . '-label' ), $optionRow[0] );
$out .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $optionRow[1] . $addSubmit );
} else {
$out .= Xml::closeElement( 'table' );
$unconsumed = $opts->getUnconsumedValues();
- foreach( $unconsumed as $key => $value ) {
+ foreach ( $unconsumed as $key => $value ) {
$out .= Html::hidden( $key, $value );
}
$extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
global $wgAllowCategorizedRecentChanges;
- if( $wgAllowCategorizedRecentChanges ) {
+ if ( $wgAllowCategorizedRecentChanges ) {
$extraOpts['category'] = $this->categoryFilterForm( $opts );
}
function filterByCategories( &$rows, FormOptions $opts ) {
$categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
- if( !count( $categories ) ) {
+ if ( !count( $categories ) ) {
return;
}
# Filter categories
$cats = array();
- foreach( $categories as $cat ) {
+ foreach ( $categories as $cat ) {
$cat = trim( $cat );
- if( $cat == '' ) {
+ if ( $cat == '' ) {
continue;
}
$cats[] = $cat;
$articles = array();
$a2r = array();
$rowsarr = array();
- foreach( $rows as $k => $r ) {
+ foreach ( $rows as $k => $r ) {
$nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
$id = $nt->getArticleID();
- if( $id == 0 ) {
+ if ( $id == 0 ) {
continue; # Page might have been deleted...
}
- if( !in_array( $id, $articles ) ) {
+ if ( !in_array( $id, $articles ) ) {
$articles[] = $id;
}
- if( !isset( $a2r[$id] ) ) {
+ if ( !isset( $a2r[$id] ) ) {
$a2r[$id] = array();
}
$a2r[$id][] = $k;
}
# Shortcut?
- if( !count( $articles ) || !count( $cats ) ) {
+ if ( !count( $articles ) || !count( $cats ) ) {
return;
}
# Filter
$newrows = array();
- foreach( $match as $id ) {
- foreach( $a2r[$id] as $rev ) {
+ foreach ( $match as $id ) {
+ foreach ( $a2r[$id] as $rev ) {
$k = $rev;
$newrows[$k] = $rowsarr[$k];
}
$note = '';
$msg = $this->msg( 'rclegend' );
- if( !$msg->isDisabled() ) {
+ if ( !$msg->isDisabled() ) {
$note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
}
$lang = $this->getLanguage();
$user = $this->getUser();
- if( $options['from'] ) {
+ if ( $options['from'] ) {
$note .= $this->msg( 'rcnotefrom' )->numParams( $options['limit'] )->params(
$lang->userTimeAndDate( $options['from'], $user ),
$lang->userDate( $options['from'], $user ),
// limit links
$cl = array();
- foreach( $wgRCLinkLimits as $value ) {
+ foreach ( $wgRCLinkLimits as $value ) {
$cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
array( 'limit' => $value ), $nondefaults, $value == $options['limit'] );
}
// day links, reset 'from' to none
$dl = array();
- foreach( $wgRCLinkDays as $value ) {
+ foreach ( $wgRCLinkDays as $value ) {
$dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] );
}
// show/hide links
$showhide = array( $this->msg( 'show' )->text(), $this->msg( 'hide' )->text() );
$filters = array(
- 'hideminor' => 'rcshowhideminor',
- 'hidebots' => 'rcshowhidebots',
- 'hideanons' => 'rcshowhideanons',
- 'hideliu' => 'rcshowhideliu',
+ 'hideminor' => 'rcshowhideminor',
+ 'hidebots' => 'rcshowhidebots',
+ 'hideanons' => 'rcshowhideanons',
+ 'hideliu' => 'rcshowhideliu',
'hidepatrolled' => 'rcshowhidepatr',
- 'hidemyself' => 'rcshowhidemine'
+ 'hidemyself' => 'rcshowhidemine'
);
foreach ( $this->getCustomFilters() as $key => $params ) {
$filters[$key] = $params['msg'];
}
$outputPage = $this->getOutput();
$title = Title::newFromURL( $target );
- if( !$title || $title->getInterwiki() != '' ) {
+ if ( !$title || $title->getInterwiki() != '' ) {
$outputPage->wrapWikiMsg( "<div class=\"errorbox\">\n$1\n</div><br style=\"clear: both\" />", 'allpagesbadtitle' );
return false;
}
// left join with watchlist table to highlight watched rows
$uid = $this->getUser()->getId();
- if( $uid ) {
+ if ( $uid ) {
$tables[] = 'watchlist';
$select[] = 'wl_user';
$join_conds['watchlist'] = array( 'LEFT JOIN', array(
return false;
}
- if( $ns == NS_CATEGORY && !$showlinkedto ) {
+ if ( $ns == NS_CATEGORY && !$showlinkedto ) {
// special handling for categories
// XXX: should try to make this less kludgy
$link_tables = array( 'categorylinks' );
// for now, always join on these tables; really should be configurable as in whatlinkshere
$link_tables = array( 'pagelinks', 'templatelinks' );
// imagelinks only contains links to pages in NS_FILE
- if( $ns == NS_FILE || !$showlinkedto ) {
+ if ( $ns == NS_FILE || !$showlinkedto ) {
$link_tables[] = 'imagelinks';
}
}
- if( $id == 0 && !$showlinkedto ) {
+ if ( $id == 0 && !$showlinkedto ) {
return false; // nonexistent pages can't link to any pages
}
$subsql = array(); // SELECT statements to combine with UNION
- foreach( $link_tables as $link_table ) {
+ foreach ( $link_tables as $link_table ) {
$pfx = $prefix[$link_table];
// imagelinks and categorylinks tables have no xx_namespace field, and have xx_to instead of xx_title
- if( $link_table == 'imagelinks' ) {
+ if ( $link_table == 'imagelinks' ) {
$link_ns = NS_FILE;
- } elseif( $link_table == 'categorylinks' ) {
+ } elseif ( $link_table == 'categorylinks' ) {
$link_ns = NS_CATEGORY;
} else {
$link_ns = 0;
}
- if( $showlinkedto ) {
+ if ( $showlinkedto ) {
// find changes to pages linking to this page
- if( $link_ns ) {
- if( $ns != $link_ns ) {
+ if ( $link_ns ) {
+ if ( $ns != $link_ns ) {
continue;
} // should never happen, but check anyway
$subconds = array( "{$pfx}_to" => $dbkey );
} else {
// find changes to pages linked from this page
$subconds = array( "{$pfx}_from" => $id );
- if( $link_table == 'imagelinks' || $link_table == 'categorylinks' ) {
+ if ( $link_table == 'imagelinks' || $link_table == 'categorylinks' ) {
$subconds["rc_namespace"] = $link_ns;
$subjoin = "rc_title = {$pfx}_to";
} else {
}
}
- if( $dbr->unionSupportsOrderAndLimit() ) {
+ if ( $dbr->unionSupportsOrderAndLimit() ) {
$order = array( 'ORDER BY' => 'rc_timestamp DESC' );
} else {
$order = array();
$join_conds + array( $link_table => array( 'INNER JOIN', $subjoin ) )
);
- if( $dbr->unionSupportsOrderAndLimit() )
+ if ( $dbr->unionSupportsOrderAndLimit() ) {
$query = $dbr->limitResult( $query, $limit );
+ }
$subsql[] = $query;
}
- if( count( $subsql ) == 0 ) {
+ if ( count( $subsql ) == 0 ) {
return false; // should never happen
}
- if( count( $subsql ) == 1 && $dbr->unionSupportsOrderAndLimit() ) {
+ if ( count( $subsql ) == 1 && $dbr->unionSupportsOrderAndLimit() ) {
$sql = $subsql[0];
} else {
// need to resort and relimit after union
$res = $dbr->query( $sql, __METHOD__ );
- if( $res->numRows() == 0 ) {
+ if ( $res->numRows() == 0 ) {
$this->mResultEmpty = true;
}
function setTopText( FormOptions $opts ) {
$target = $this->getTargetTitle();
- if( $target ) {
+ if ( $target ) {
$this->getOutput()->addBacklinkSubtitle( $target );
}
}
function setBottomText( FormOptions $opts ) {
- if( isset( $this->mResultEmpty ) && $this->mResultEmpty ) {
+ if ( isset( $this->mResultEmpty ) && $this->mResultEmpty ) {
$this->getOutput()->addWikiMsg( 'recentchangeslinked-noresult' );
}
}
'list-class' => 'RevDel_ArchiveList',
'permission' => 'deleterevision',
),
- 'oldimage'=> array(
+ 'oldimage' => array(
'check-label' => 'revdelete-hide-image',
'deletion-bits' => File::DELETED_FILE,
'success' => 'revdelete-success',
}
# No targets?
- if( !isset( self::$allowedTypes[$this->typeName] ) || count( $this->ids ) == 0 ) {
+ if ( !isset( self::$allowedTypes[$this->typeName] ) || count( $this->ids ) == 0 ) {
throw new ErrorPageError( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
}
$this->typeInfo = self::$allowedTypes[$this->typeName];
# If we have revisions, get the title from the first one
# since they should all be from the same page. This allows
# for more flexibility with page moves...
- if( $this->typeName == 'revision' ) {
+ if ( $this->typeName == 'revision' ) {
$rev = Revision::newFromId( $this->ids[0] );
$this->targetObj = $rev ? $rev->getTitle() : $this->targetObj;
}
$this->otherReason = $request->getVal( 'wpReason' );
# We need a target page!
- if( is_null( $this->targetObj ) ) {
+ if ( is_null( $this->targetObj ) ) {
$output->addWikiMsg( 'undelete-header' );
return;
}
array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ),
array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER )
);
- if( $user->isAllowed( 'suppressrevision' ) ) {
+ if ( $user->isAllowed( 'suppressrevision' ) ) {
$this->checks[] = array( 'revdelete-hide-restricted',
'wpHideRestricted', Revision::DELETED_RESTRICTED );
}
# Either submit or create our form
- if( $this->mIsAllowed && $this->submitClicked ) {
+ if ( $this->mIsAllowed && $this->submitClicked ) {
$this->submit( $request );
} else {
$this->showForm();
LogEventsList::showLogExtract( $output, 'delete',
$this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) );
# Show relevant lines from the suppression log
- if( $user->isAllowed( 'suppressionlog' ) ) {
+ if ( $user->isAllowed( 'suppressionlog' ) ) {
$suppressLogPage = new LogPage( 'suppress' );
$output->addHTML( "<h2>" . $suppressLogPage->getName()->escaped() . "</h2>\n" );
LogEventsList::showLogExtract( $output, 'suppress',
*/
protected function showConvenienceLinks() {
# Give a link to the logs/hist for this page
- if( $this->targetObj ) {
+ if ( $this->targetObj ) {
$links = array();
$links[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Log' ),
array( 'action' => 'history' )
);
# Link to deleted edits
- if( $this->getUser()->isAllowed( 'undelete' ) ) {
+ if ( $this->getUser()->isAllowed( 'undelete' ) ) {
$undelete = SpecialPage::getTitleFor( 'Undelete' );
$links[] = Linker::linkKnown(
$undelete,
return;
}
$user = $this->getUser();
- if( !$oimage->userCan( File::DELETED_FILE, $user ) ) {
- if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
+ if ( !$oimage->userCan( File::DELETED_FILE, $user ) ) {
+ if ( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
throw new PermissionsError( 'suppressrevision' );
} else {
throw new PermissionsError( 'deletedtext' );
for ( $list->reset(); $list->current(); $list->next() ) {
$item = $list->current();
if ( !$item->canView() ) {
- if( !$this->submitClicked ) {
+ if ( !$this->submitClicked ) {
throw new PermissionsError( 'suppressrevision' );
}
$UserAllowed = false;
$this->getOutput()->addHTML( $item->getHTML() );
}
- if( !$numRevisions ) {
+ if ( !$numRevisions ) {
throw new ErrorPageError( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
}
$this->addUsageText();
// Normal sysops can always see what they did, but can't always change it
- if( !$UserAllowed ) return;
+ if ( !$UserAllowed ) {
+ return;
+ }
// Show form if the user can submit
- if( $this->mIsAllowed ) {
+ if ( $this->mIsAllowed ) {
$out = Xml::openElement( 'form', array( 'method' => 'post',
'action' => $this->getTitle()->getLocalURL( array( 'action' => 'submit' ) ),
'id' => 'mw-revdel-form-revisions' ) ) .
} else {
$out = '';
}
- if( $this->mIsAllowed ) {
+ if ( $this->mIsAllowed ) {
$out .= Xml::closeElement( 'form' ) . "\n";
// Show link to edit the dropdown reasons
- if( $this->getUser()->isAllowed( 'editinterface' ) ) {
+ if ( $this->getUser()->isAllowed( 'editinterface' ) ) {
$title = Title::makeTitle( NS_MEDIAWIKI, 'Revdelete-reason-dropdown' );
$link = Linker::link(
$title,
*/
protected function addUsageText() {
$this->getOutput()->addWikiMsg( 'revdelete-text' );
- if( $this->getUser()->isAllowed( 'suppressrevision' ) ) {
+ if ( $this->getUser()->isAllowed( 'suppressrevision' ) ) {
$this->getOutput()->addWikiMsg( 'revdelete-suppress-text' );
}
- if( $this->mIsAllowed ) {
+ if ( $this->mIsAllowed ) {
$this->getOutput()->addWikiMsg( 'revdelete-confirm' );
}
}
$html = '<table>';
// If there is just one item, use checkboxes
$list = $this->getList();
- if( $list->length() == 1 ) {
+ if ( $list->length() == 1 ) {
$list->reset();
$bitfield = $list->current()->getBits(); // existing field
- if( $this->submitClicked ) {
+ if ( $this->submitClicked ) {
$bitfield = $this->extractBitfield( $this->extractBitParams(), $bitfield );
}
- foreach( $this->checks as $item ) {
+ foreach ( $this->checks as $item ) {
list( $message, $name, $field ) = $item;
$innerHTML = Xml::checkLabel( $this->msg( $message )->text(), $name, $name, $bitfield & $field );
- if( $field == Revision::DELETED_RESTRICTED )
+ if ( $field == Revision::DELETED_RESTRICTED ) {
$innerHTML = "<b>$innerHTML</b>";
+ }
$line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
$html .= "<tr>$line</tr>\n";
}
$html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
$html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
$html .= "<th></th></tr>\n";
- foreach( $this->checks as $item ) {
+ foreach ( $this->checks as $item ) {
list( $message, $name, $field ) = $item;
// If there are several items, use third state by default...
- if( $this->submitClicked ) {
+ if ( $this->submitClicked ) {
$selected = $this->getRequest()->getInt( $name, 0 /* unchecked */ );
} else {
$selected = -1; // use existing field
$line .= '<td class="mw-revdel-checkbox">' . Xml::radio( $name, 0, $selected == 0 ) . '</td>';
$line .= '<td class="mw-revdel-checkbox">' . Xml::radio( $name, 1, $selected == 1 ) . '</td>';
$label = $this->msg( $message )->escaped();
- if( $field == Revision::DELETED_RESTRICTED ) {
+ if ( $field == Revision::DELETED_RESTRICTED ) {
$label = "<b>$label</b>";
}
$line .= "<td>$label</td>";
protected function submit() {
# Check edit token on submission
$token = $this->getRequest()->getVal( 'wpEditToken' );
- if( $this->submitClicked && !$this->getUser()->matchEditToken( $token ) ) {
+ if ( $this->submitClicked && !$this->getUser()->matchEditToken( $token ) ) {
$this->getOutput()->addWikiMsg( 'sessionfailure' );
return false;
}
$bitParams = $this->extractBitParams();
$listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' ); // from dropdown
$comment = $listReason;
- if( $comment != 'other' && $this->otherReason != '' ) {
+ if ( $comment != 'other' && $this->otherReason != '' ) {
// Entry from drop down menu + additional comment
$comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->otherReason;
- } elseif( $comment == 'other' ) {
+ } elseif ( $comment == 'other' ) {
$comment = $this->otherReason;
}
# Can the user set this field?
- if( $bitParams[Revision::DELETED_RESTRICTED] == 1 && !$this->getUser()->isAllowed( 'suppressrevision' ) ) {
+ if ( $bitParams[Revision::DELETED_RESTRICTED] == 1 && !$this->getUser()->isAllowed( 'suppressrevision' ) ) {
throw new PermissionsError( 'suppressrevision' );
}
# If the save went through, go to success message...
*/
protected function extractBitParams() {
$bitfield = array();
- foreach( $this->checks as $item ) {
+ foreach ( $this->checks as $item ) {
list( /* message */, $name, $field ) = $item;
$val = $this->getRequest()->getInt( $name, 0 /* unchecked */ );
- if( $val < -1 || $val > 1 ) {
+ if ( $val < -1 || $val > 1 ) {
$val = -1; // -1 for existing value
}
$bitfield[$field] = $val;
}
- if( !isset( $bitfield[Revision::DELETED_RESTRICTED] ) ) {
+ if ( !isset( $bitfield[Revision::DELETED_RESTRICTED] ) ) {
$bitfield[Revision::DELETED_RESTRICTED] = 0;
}
return $bitfield;
public static function extractBitfield( $bitPars, $oldfield ) {
// Build the actual new rev_deleted bitfield
$newBits = 0;
- foreach( $bitPars as $const => $val ) {
- if( $val == 1 ) {
+ foreach ( $bitPars as $const => $val ) {
+ if ( $val == 1 ) {
$newBits |= $const; // $const is the *_deleted const
- } elseif( $val == -1 ) {
+ } elseif ( $val == -1 ) {
$newBits |= ($oldfield & $const); // use existing
}
}
if ( $profile === null ) {
// BC with old request format
$profile = 'advanced';
- foreach( $profiles as $key => $data ) {
+ foreach ( $profiles as $key => $data ) {
if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
$profile = $key;
}
# Try to go to page as entered.
$t = Title::newFromText( $term );
# If the string cannot be used to create a title
- if( is_null( $t ) ) {
+ if ( is_null( $t ) ) {
$this->showResults( $term );
return;
}
return;
}
- if( !is_null( $t ) ) {
+ if ( !is_null( $t ) ) {
$this->getOutput()->redirect( $t->getFullURL() );
return;
}
# No match, generate an edit URL
$t = Title::newFromText( $term );
- if( !is_null( $t ) ) {
+ if ( !is_null( $t ) ) {
global $wgGoToEdit;
wfRunHooks( 'SpecialSearchNogomatch', array( &$t ) );
wfDebugLog( 'nogomatch', $t->getText(), false );
# If the feature is enabled, go straight to the edit page
- if( $wgGoToEdit ) {
+ if ( $wgGoToEdit ) {
$this->getOutput()->redirect( $t->getFullURL( array( 'action' => 'edit' ) ) );
return;
}
$rewritten = $search->replacePrefixes( $term );
$titleMatches = $search->searchTitle( $rewritten );
- if( !( $titleMatches instanceof SearchResultTooMany ) ) {
+ if ( !( $titleMatches instanceof SearchResultTooMany ) ) {
$textMatches = $search->searchText( $rewritten );
}
$textStatus = null;
- if( $textMatches instanceof Status ) {
+ if ( $textMatches instanceof Status ) {
$textStatus = $textMatches;
$textMatches = null;
}
// did you mean... suggestions
- if( $textMatches && !$textStatus && $textMatches->hasSuggestion() ) {
+ if ( $textMatches && !$textStatus && $textMatches->hasSuggestion() ) {
$st = SpecialPage::getTitleFor( 'Search' );
# mirror Go/Search behavior of original request ..
$didYouMeanParams = array( 'search' => $textMatches->getSuggestionQuery() );
- if( $this->fulltext != null ) {
+ if ( $this->fulltext != null ) {
$didYouMeanParams['fulltext'] = $this->fulltext;
}
$suggestionSnippet = $textMatches->getSuggestionSnippet();
- if( $suggestionSnippet == '' ) {
+ if ( $suggestionSnippet == '' ) {
$suggestionSnippet = null;
}
);
// Sometimes the search engine knows there are too many hits
- if( $titleMatches instanceof SearchResultTooMany ) {
+ if ( $titleMatches instanceof SearchResultTooMany ) {
$out->wrapWikiMsg( "==$1==\n", 'toomanymatches' );
wfProfileOut( __METHOD__ );
return;
}
$filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
- if( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
+ if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
$out->addHTML( $this->formHeader( $term, 0, 0 ) );
$out->addHtml( $this->getProfileForm( $this->profile, $term ) );
$out->addHTML( '</form>' );
// get total number of results if backend can calculate it
$totalRes = 0;
- if( $titleMatches && !is_null( $titleMatches->getTotalHits() ) )
+ if ( $titleMatches && !is_null( $titleMatches->getTotalHits() ) ) {
$totalRes += $titleMatches->getTotalHits();
- if( $textMatches && !is_null( $textMatches->getTotalHits() ) )
+ }
+ if ( $textMatches && !is_null( $textMatches->getTotalHits() ) ) {
$totalRes += $textMatches->getTotalHits();
+ }
// show number of results and current offset
$out->addHTML( $this->formHeader( $term, $num, $totalRes ) );
$out->addHtml( "<div class='searchresults'>" );
// prev/next links
- if( $num || $this->offset ) {
+ if ( $num || $this->offset ) {
// Show the create link ahead
$this->showCreateLink( $t );
$prevnext = $this->getLanguage()->viewPrevNext( $this->getTitle(), $this->offset, $this->limit,
}
$out->parserOptions()->setEditSection( false );
- if( $titleMatches ) {
- if( $numTitleMatches > 0 ) {
+ if ( $titleMatches ) {
+ if ( $numTitleMatches > 0 ) {
$out->wrapWikiMsg( "==$1==\n", 'titlematches' );
$out->addHTML( $this->showMatches( $titleMatches ) );
}
$titleMatches->free();
}
- if( $textMatches && !$textStatus ) {
+ if ( $textMatches && !$textStatus ) {
// output appropriate heading
- if( $numTextMatches > 0 && $numTitleMatches > 0 ) {
+ if ( $numTextMatches > 0 && $numTitleMatches > 0 ) {
// if no title matches the heading is redundant
$out->wrapWikiMsg( "==$1==\n", 'textmatches' );
- } elseif( $totalRes == 0 ) {
+ } elseif ( $totalRes == 0 ) {
# Don't show the 'no text matches' if we received title matches
# $out->wrapWikiMsg( "==$1==\n", 'notextmatches' );
}
// show interwiki results if any
- if( $textMatches->hasInterwikiResults() ) {
+ if ( $textMatches->hasInterwikiResults() ) {
$out->addHTML( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ) );
}
// show results
- if( $numTextMatches > 0 ) {
+ if ( $numTextMatches > 0 ) {
$out->addHTML( $this->showMatches( $textMatches ) );
}
$textMatches->free();
}
- if( $num === 0 ) {
+ if ( $num === 0 ) {
if ( $textStatus ) {
$out->addHTML( '<div class="error">' .
htmlspecialchars( $textStatus->getWikiText( 'search-error' ) ) . '</div>' );
}
$out->addHtml( "</div>" );
- if( $num || $this->offset ) {
+ if ( $num || $this->offset ) {
$out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
}
wfRunHooks( 'SpecialSearchResultsAppend', array( $this, $out, $term ) );
// show direct page/create link if applicable
// Check DBkey !== '' in case of fragment link only.
- if( is_null( $t ) || $t->getDBkey() === '' ) {
+ if ( is_null( $t ) || $t->getDBkey() === '' ) {
// invalid title
// preserve the paragraph for margins etc...
$this->getOutput()->addHtml( '<p></p>' );
return;
}
- if( $t->isKnown() ) {
+ if ( $t->isKnown() ) {
$messageName = 'searchmenu-exists';
- } elseif( $t->userCan( 'create', $this->getUser() ) ) {
+ } elseif ( $t->userCan( 'create', $this->getUser() ) ) {
$messageName = 'searchmenu-new';
} else {
$messageName = 'searchmenu-new-nocreate';
wfRunHooks( 'SpecialSearchCreateLink', array( $t, &$params ) );
// Extensions using the hook might still return an empty $messageName
- if( $messageName ) {
+ if ( $messageName ) {
$this->getOutput()->wrapWikiMsg( "<p class=\"mw-search-createlink\">\n$1</p>", $params );
} else {
// preserve the paragraph for margins etc...
*/
protected function setupPage( $term ) {
# Should advanced UI be used?
- $this->searchAdvanced = ($this->profile === 'advanced');
+ $this->searchAdvanced = ( $this->profile === 'advanced' );
$out = $this->getOutput();
- if( strval( $term ) !== '' ) {
+ if ( strval( $term ) !== '' ) {
$out->setPageTitle( $this->msg( 'searchresults' ) );
$out->setHTMLTitle( $this->msg( 'pagetitle' )->rawParams(
$this->msg( 'searchresults-title' )->rawParams( $term )->text()
*/
protected function powerSearch( &$request ) {
$arr = array();
- foreach( SearchEngine::searchableNamespaces() as $ns => $name ) {
- if( $request->getCheck( 'ns' . $ns ) ) {
+ foreach ( SearchEngine::searchableNamespaces() as $ns => $name ) {
+ if ( $request->getCheck( 'ns' . $ns ) ) {
$arr[] = $ns;
}
}
protected function powerSearchOptions() {
$opt = array();
$opt['redirs'] = $this->searchRedirects ? 1 : 0;
- if( $this->profile !== 'advanced' ) {
+ if ( $this->profile !== 'advanced' ) {
$opt['profile'] = $this->profile;
} else {
- foreach( $this->namespaces as $n ) {
+ foreach ( $this->namespaces as $n ) {
$opt['ns' . $n] = 1;
}
}
$out = "";
$infoLine = $matches->getInfo();
- if( !is_null( $infoLine ) ) {
+ if ( !is_null( $infoLine ) ) {
$out .= "\n<!-- {$infoLine} -->\n";
}
$out .= "<ul class='mw-search-results'>\n";
$result = $matches->next();
- while( $result ) {
+ while ( $result ) {
$out .= $this->showHit( $result, $terms );
$result = $matches->next();
}
protected function showHit( $result, $terms ) {
wfProfileIn( __METHOD__ );
- if( $result->isBrokenTitle() ) {
+ if ( $result->isBrokenTitle() ) {
wfProfileOut( __METHOD__ );
return "<!-- Broken link in search result -->\n";
}
$titleSnippet = $result->getTitleSnippet( $terms );
- if( $titleSnippet == '' )
+ if ( $titleSnippet == '' ) {
$titleSnippet = null;
+ }
$link_t = clone $t;
//If page content is not readable, just return the title.
//This is not quite safe, but better than showing excerpts from non-readable pages
//Note that hiding the entry entirely would screw up paging.
- if( !$t->userCan( 'read', $this->getUser() ) ) {
+ if ( !$t->userCan( 'read', $this->getUser() ) ) {
wfProfileOut( __METHOD__ );
return "<li>{$link}</li>\n";
}
// If the page doesn't *exist*... our search index is out of date.
// The least confusing at this point is to drop the result.
// You may get less results, but... oh well. :P
- if( $result->isMissingRevision() ) {
+ if ( $result->isMissingRevision() ) {
wfProfileOut( __METHOD__ );
return "<!-- missing page " . htmlspecialchars( $t->getPrefixedText() ) . "-->\n";
}
$sectionText = $result->getSectionSnippet( $terms );
$redirect = '';
- if( !is_null( $redirectTitle ) ) {
- if( $redirectText == '' )
+ if ( !is_null( $redirectTitle ) ) {
+ if ( $redirectText == '' ) {
$redirectText = null;
+ }
$redirect = "<span class='searchalttitle'>" .
$this->msg( 'search-redirect' )->rawParams(
$section = '';
- if( !is_null( $sectionTitle ) ) {
- if( $sectionText == '' )
+ if ( !is_null( $sectionTitle ) ) {
+ if ( $sectionText == '' ) {
$sectionText = null;
+ }
$section = "<span class='searchalttitle'>" .
$this->msg( 'search-section' )->rawParams(
$lang = $this->getLanguage();
// format score
- if( is_null( $result->getScore() ) ) {
+ if ( is_null( $result->getScore() ) ) {
// Search engine doesn't report scoring info
$score = '';
} else {
$size = $this->msg( 'search-result-size', $lang->formatSize( $byteSize ) )
->numParams( $wordCount )->escaped();
- if( $t->getNamespace() == NS_CATEGORY ) {
+ if ( $t->getNamespace() == NS_CATEGORY ) {
$cat = Category::newFromTitle( $t );
$size = $this->msg( 'search-result-category-size' )
->numParams( $cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount() )
// link to related articles if supported
$related = '';
- if( $result->hasRelated() ) {
+ if ( $result->hasRelated() ) {
$st = SpecialPage::getTitleFor( 'Search' );
$stParams = array_merge(
$this->powerSearchOptions(),
}
// Include a thumbnail for media files...
- if( $t->getNamespace() == NS_FILE ) {
+ if ( $t->getNamespace() == NS_FILE ) {
$img = wfFindFile( $t );
- if( $img ) {
+ if ( $img ) {
$thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
- if( $thumb ) {
+ if ( $thumb ) {
$desc = $this->msg( 'parentheses' )->rawParams( $img->getShortDesc() )->escaped();
wfProfileOut( __METHOD__ );
// Float doesn't seem to interact well with the bullets.
// work out custom project captions
$customCaptions = array();
$customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() ); // format per line <iwprefix>:<caption>
- foreach( $customLines as $line ) {
+ foreach ( $customLines as $line ) {
$parts = explode( ":", $line, 2 );
- if( count( $parts ) == 2 ) { // validate line
+ if ( count( $parts ) == 2 ) { // validate line
$customCaptions[$parts[0]] = $parts[1];
}
}
$prev = null;
$result = $matches->next();
- while( $result ) {
+ while ( $result ) {
$out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions );
$prev = $result->getInterwikiPrefix();
$result = $matches->next();
*
* @return string
*/
- protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions) {
+ protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions ) {
wfProfileIn( __METHOD__ );
- if( $result->isBrokenTitle() ) {
+ if ( $result->isBrokenTitle() ) {
wfProfileOut( __METHOD__ );
return "<!-- Broken link in search result -->\n";
}
$titleSnippet = $result->getTitleSnippet( $terms );
- if( $titleSnippet == '' )
+ if ( $titleSnippet == '' ) {
$titleSnippet = null;
+ }
$link = Linker::linkKnown(
$t,
$redirectTitle = $result->getRedirectTitle();
$redirectText = $result->getRedirectSnippet( $terms );
$redirect = '';
- if( !is_null( $redirectTitle ) ) {
- if( $redirectText == '' )
+ if ( !is_null( $redirectTitle ) ) {
+ if ( $redirectText == '' ) {
$redirectText = null;
+ }
$redirect = "<span class='searchalttitle'>" .
$this->msg( 'search-redirect' )->rawParams(
$out = "";
// display project name
- if( is_null( $lastInterwiki ) || $lastInterwiki != $t->getInterwiki() ) {
- if( array_key_exists( $t->getInterwiki(), $customCaptions ) ) {
+ if ( is_null( $lastInterwiki ) || $lastInterwiki != $t->getInterwiki() ) {
+ if ( array_key_exists( $t->getInterwiki(), $customCaptions ) ) {
// captions from 'search-interwiki-custom'
$caption = $customCaptions[$t->getInterwiki()];
} else {
protected function powerSearchBox( $term, $opts ) {
// Groups namespaces into rows according to subject
$rows = array();
- foreach( SearchEngine::searchableNamespaces() as $namespace => $name ) {
+ foreach ( SearchEngine::searchableNamespaces() as $namespace => $name ) {
$subject = MWNamespace::getSubject( $namespace );
- if( !array_key_exists( $subject, $rows ) ) {
+ if ( !array_key_exists( $subject, $rows ) ) {
$rows[$subject] = "";
}
$name = str_replace( '_', ' ', $name );
- if( $name == '' ) {
+ if ( $name == '' ) {
$name = $this->msg( 'blanknamespace' )->text();
}
$rows[$subject] .=
// Lays out namespaces in multiple floating two-column tables so they'll
// be arranged nicely while still accommodating different screen widths
$namespaceTables = '';
- for( $i = 0; $i < $numRows; $i += 4 ) {
+ for ( $i = 0; $i < $numRows; $i += 4 ) {
$namespaceTables .= Xml::openElement(
'table',
array( 'cellpadding' => 0, 'cellspacing' => 0 )
);
- for( $j = $i; $j < $i + 4 && $j < $numRows; $j++ ) {
+ for ( $j = $i; $j < $i + 4 && $j < $numRows; $j++ ) {
$namespaceTables .= Xml::tags( 'tr', null, $rows[$j] );
}
$namespaceTables .= Xml::closeElement( 'table' );
$showSections = array( 'namespaceTables' => $namespaceTables );
// Show redirects check only if backend supports it
- if( $this->getSearchEngine()->supports( 'list-redirects' ) ) {
+ if ( $this->getSearchEngine()->supports( 'list-redirects' ) ) {
$showSections['redirects'] =
Xml::checkLabel( $this->msg( 'powersearch-redir' )->text(), 'redirs', 'redirs', $this->searchRedirects );
}
$hidden = '';
unset( $opts['redirs'] );
- foreach( $opts as $key => $value ) {
+ foreach ( $opts as $key => $value ) {
$hidden .= Html::hidden( $key, $value );
}
// Return final output
wfRunHooks( 'SpecialSearchProfiles', array( &$profiles ) );
- foreach( $profiles as &$data ) {
- if ( !is_array( $data['namespaces'] ) ) continue;
+ foreach ( $profiles as &$data ) {
+ if ( !is_array( $data['namespaces'] ) ) {
+ continue;
+ }
sort( $data['namespaces'] );
}
$out = Xml::openElement( 'div', array( 'class' => 'mw-search-formheader' ) );
$bareterm = $term;
- if( $this->startsWithImage( $term ) ) {
+ if ( $this->startsWithImage( $term ) ) {
// Deletes prefixes
$bareterm = substr( $term, strpos( $term, ':' ) + 1 );
}
*/
protected function makeSearchLink( $term, $namespaces, $label, $tooltip, $params = array() ) {
$opt = $params;
- foreach( $namespaces as $n ) {
+ foreach ( $namespaces as $n ) {
$opt['ns' . $n] = 1;
}
$opt['redirs'] = $this->searchRedirects;
global $wgContLang;
$p = explode( ':', $term );
- if( count( $p ) > 1 ) {
+ if ( count( $p ) > 1 ) {
return $wgContLang->getNsIndex( $p[0] ) == NS_FILE;
}
return false;
$allkeyword = $this->msg( 'searchall' )->inContentLanguage()->text();
$p = explode( ':', $term );
- if( count( $p ) > 1 ) {
+ if ( count( $p ) > 1 ) {
return $p[0] == $allkeyword;
}
return false;
$pages = SpecialPageFactory::getUsablePages( $this->getUser() );
- if( !count( $pages ) ) {
+ if ( !count( $pages ) ) {
# Yeah, that was pointless. Thanks for coming.
return false;
}
foreach ( $pages as $page ) {
if ( $page->isListed() ) {
$group = $page->getFinalGroupName();
- if( !isset( $groups[$group] ) ) {
+ if ( !isset( $groups[$group] ) ) {
$groups[$group] = array();
}
$groups[$group][$page->getDescription()] = array(
/** Sort */
if ( $wgSortSpecialPages ) {
- foreach( $groups as $group => $sortedPages ) {
+ foreach ( $groups as $group => $sortedPages ) {
ksort( $groups[$group] );
}
}
/** Always move "other" to end */
- if( array_key_exists( 'other', $groups ) ) {
+ if ( array_key_exists( 'other', $groups ) ) {
$other = $groups['other'];
unset( $groups['other'] );
$groups['other'] = $other;
Html::openElement( 'td', array( 'style' => 'width:30%;vertical-align:top' ) ) . "\n" .
Html::openElement( 'ul' ) . "\n"
);
- foreach( $sortedPages as $desc => $specialpage ) {
+ foreach ( $sortedPages as $desc => $specialpage ) {
list( $title, $restricted, $cached ) = $specialpage;
$pageClasses = array();
$includesCachedPages = true;
$pageClasses[] = 'mw-specialpagecached';
}
- if( $restricted ) {
+ if ( $restricted ) {
$includesRestrictedPages = true;
$pageClasses[] = 'mw-specialpagerestricted';
}
# Split up the larger groups
$count++;
- if( $total > 3 && $count == $middle ) {
+ if ( $total > 3 && $count == $middle ) {
$out->addHTML(
Html::closeElement( 'ul' ) . Html::closeElement( 'td' ) .
Html::element( 'td', array( 'style' => 'width:10%' ), '' ) .
# Staticic - views
$viewsStats = '';
- if( !$wgDisableCounters ) {
+ if ( !$wgDisableCounters ) {
$viewsStats = $this->getViewsStats();
}
# Set active user count
- if( !$wgMiserMode ) {
+ if ( !$wgMiserMode ) {
$key = wfMemcKey( 'sitestats', 'activeusers-updated' );
// Re-calculate the count if the last tally is old...
- if( !$wgMemc->get( $key ) ) {
+ if ( !$wgMemc->get( $key ) ) {
$dbw = wfGetDB( DB_MASTER );
SiteStatsUpdate::cacheUpdate( $dbw );
$wgMemc->set( $key, '1', 24 * 3600 ); // don't update for 1 day
$text .= $viewsStats;
# Statistic - popular pages
- if( !$wgDisableCounters && !$wgMiserMode ) {
+ if ( !$wgDisableCounters && !$wgMiserMode ) {
$text .= $this->getMostViewedPages();
}
# Statistic - other
$extraStats = array();
- if( wfRunHooks( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
+ if ( wfRunHooks( 'SpecialStatsAddExtra', array( &$extraStats ) ) ) {
$text .= $this->getOtherStats( $extraStats );
}
* @return string table row in HTML format
*/
private function formatRow( $text, $number, $trExtraParams = array(), $descMsg = '', $descMsgParam = '' ) {
- if( $descMsg ) {
+ if ( $descMsg ) {
$msg = $this->msg( $descMsg, $descMsgParam );
if ( $msg->exists() ) {
$descriptionText = $this->msg( 'parentheses' )->rawParams( $msg->parse() )->escaped();
- $text .= "<br />" . Xml::element( 'small', array( 'class' => 'mw-statistic-desc'),
+ $text .= "<br />" . Xml::element( 'small', array( 'class' => 'mw-statistic-desc' ),
" $descriptionText" );
}
}
private function getGroupStats() {
global $wgGroupPermissions, $wgImplicitGroups;
$text = '';
- foreach( $wgGroupPermissions as $group => $permissions ) {
+ foreach ( $wgGroupPermissions as $group => $permissions ) {
# Skip generic * and implicit groups
if ( in_array( $group, $wgImplicitGroups ) || $group == '*' ) {
continue;
# Add a class when a usergroup contains no members to allow hiding these rows
$classZero = '';
$countUsers = SiteStats::numberingroup( $groupname );
- if( $countUsers == 0 ) {
+ if ( $countUsers == 0 ) {
$classZero = ' statistics-group-zero';
}
$text .= $this->formatRow( $grouppage . ' ' . $grouplink,
'LIMIT' => 10,
)
);
- if( $res->numRows() > 0 ) {
+ if ( $res->numRows() > 0 ) {
$text .= Xml::openElement( 'tr' );
$text .= Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-mostpopular' )->parse() );
$text .= Xml::closeElement( 'tr' );
foreach ( $res as $row ) {
$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- if( $title instanceof Title ) {
+ if ( $title instanceof Title ) {
$text .= $this->formatRow( Linker::link( $title ),
$this->getLanguage()->formatNum( $row->page_counter ) );
private function getOtherStats( array $stats ) {
$return = '';
- foreach( $stats as $header => $items ) {
-
+ foreach ( $stats as $header => $items ) {
// Identify the structure used
if ( is_array( $items ) ) {
}
// Collect all items that belong to the same header
- foreach( $items as $key => $value ) {
+ foreach ( $items as $key => $value ) {
$name = $this->msg( $key )->inContentLanguage()->parse();
$number = htmlspecialchars( $value );
$html .= $this->doTagRow( $row->ct_tag, $row->hitcount );
}
- foreach( ChangeTags::listDefinedTags() as $tag ) {
+ foreach ( ChangeTags::listDefinedTags() as $tag ) {
$html .= $this->doTagRow( $tag, 0 );
}
$form->setSubmitTextMsg( 'ipusubmit' );
$form->addPreText( $this->msg( 'unblockiptext' )->parseAsBlock() );
- if( $form->show() ) {
+ if ( $form->show() ) {
switch( $this->type ) {
case Block::TYPE_USER:
case Block::TYPE_IP:
)
);
- if( $this->block instanceof Block ) {
+ if ( $this->block instanceof Block ) {
list( $target, $type ) = $this->block->getTargetAndType();
# Autoblocks are logged as "autoblock #123 because the IP was recently used by
# User:Foo, and we've just got any block, auto or not, that applies to a target
# the user has specified. Someone could be fishing to connect IPs to autoblocks,
# so don't show any distinction between unblocked IPs and autoblocked IPs
- if( $type == Block::TYPE_AUTO && $this->type == Block::TYPE_IP ) {
+ if ( $type == Block::TYPE_AUTO && $this->type == Block::TYPE_IP ) {
$fields['Target']['default'] = $this->target;
unset( $fields['Name'] );
$target = $data['Target'];
$block = Block::newFromTarget( $data['Target'] );
- if( !$block instanceof Block ) {
+ if ( !$block instanceof Block ) {
return array( array( 'ipb_cant_unblock', $target ) );
}
# If the specified IP is a single address, and the block is a range block, don't
# unblock the whole range.
list( $target, $type ) = SpecialBlock::getTargetAndType( $target );
- if( $block->getType() == Block::TYPE_RANGE && $type == Block::TYPE_IP ) {
+ if ( $block->getType() == Block::TYPE_RANGE && $type == Block::TYPE_IP ) {
$range = $block->getTarget();
return array( array( 'ipb_blocked_as_range', $target, $range ) );
}
# If the name was hidden and the blocking user cannot hide
# names, then don't allow any block removals...
- if( !$performer->isAllowed( 'hideuser' ) && $block->mHideName ) {
+ if ( !$performer->isAllowed( 'hideuser' ) && $block->mHideName ) {
return array( 'unblock-hideuser' );
}
}
# Unset _deleted fields as needed
- if( $block->mHideName ) {
+ if ( $block->mHideName ) {
# Something is deeply FUBAR if this is not a User object, but who knows?
$id = $block->getTarget() instanceof User
? $block->getTarget()->getID()
function getOrderFields() {
// For some crazy reason ordering by a constant
// causes a filesort
- if( $this->requestedNamespace === false && count( MWNamespace::getContentNamespaces() ) > 1 )
+ if ( $this->requestedNamespace === false && count( MWNamespace::getContentNamespaces() ) > 1 ) {
return array( 'page_namespace', 'page_title' );
+ }
return array( 'page_title' );
}
// Guess the desired name from the filename if not provided
$this->mDesiredDestName = $request->getText( 'wpDestFile' );
- if( !$this->mDesiredDestName && $request->getFileName( 'wpUploadFile' ) !== null ) {
+ if ( !$this->mDesiredDestName && $request->getFileName( 'wpUploadFile' ) !== null ) {
$this->mDesiredDestName = $request->getFileName( 'wpUploadFile' );
}
$this->mComment = $request->getText( 'wpUploadDescription' );
$this->outputHeader();
# Check uploading enabled
- if( !UploadBase::isEnabled() ) {
+ if ( !UploadBase::isEnabled() ) {
throw new ErrorPageError( 'uploaddisabled', 'uploaddisabledtext' );
}
# Check permissions
$user = $this->getUser();
$permissionRequired = UploadBase::isAllowed( $user );
- if( $permissionRequired !== true ) {
+ if ( $permissionRequired !== true ) {
throw new PermissionsError( $permissionRequired );
}
# Check blocks
- if( $user->isBlocked() ) {
+ if ( $user->isBlocked() ) {
throw new UserBlockedError( $user->getBlock() );
}
$this->processUpload();
} else {
# Backwards compatibility hook
- if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) {
+ if ( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) {
wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
return;
}
$form->setTitle( $this->getTitle() );
# Check the token, but only if necessary
- if(
+ if (
!$this->mTokenOk && !$this->mCancelUpload &&
( $this->mUpload && $this->mUploadClicked )
) {
$title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName );
$user = $this->getUser();
// Show a subtitle link to deleted revisions (to sysops et al only)
- if( $title instanceof Title ) {
+ if ( $title instanceof Title ) {
$count = $title->isDeleted();
if ( $count > 0 && $user->isAllowed( 'deletedhistory' ) ) {
$restorelink = Linker::linkKnown(
$warningHtml = '<h2>' . $this->msg( 'uploadwarning' )->escaped() . "</h2>\n"
. '<ul class="warning">';
- foreach( $warnings as $warning => $args ) {
- if( $warning == 'badfilename' ) {
+ foreach ( $warnings as $warning => $args ) {
+ if ( $warning == 'badfilename' ) {
$this->mDesiredDestName = Title::makeTitle( NS_FILE, $args )->getText();
}
- if( $warning == 'exists' ) {
+ if ( $warning == 'exists' ) {
$msg = "\t<li>" . self::getExistsWarning( $args ) . "</li>\n";
- } elseif( $warning == 'duplicate' ) {
+ } elseif ( $warning == 'duplicate' ) {
$msg = self::getDupeWarning( $args );
- } elseif( $warning == 'duplicate-archive' ) {
+ } elseif ( $warning == 'duplicate-archive' ) {
$msg = "\t<li>" . $this->msg( 'file-deleted-duplicate',
Title::makeTitle( NS_FILE, $args )->getPrefixedText() )->parse()
. "</li>\n";
protected function processUpload() {
// Fetch the file if required
$status = $this->mUpload->fetchFile();
- if( !$status->isOK() ) {
+ if ( !$status->isOK() ) {
$this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
return;
}
- if( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) ) {
+ if ( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) ) {
wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file.\n" );
// This code path is deprecated. If you want to break upload processing
// do so by hooking into the appropriate hooks in UploadBase::verifyUpload
// Verify permissions for this title
$permErrors = $this->mUpload->verifyTitlePermissions( $this->getUser() );
- if( $permErrors !== true ) {
+ if ( $permErrors !== true ) {
$code = array_shift( $permErrors[0] );
$this->showRecoverableUploadError( $this->msg( $code, $permErrors[0] )->parse() );
return;
$this->mLocalFile = $this->mUpload->getLocalFile();
// Check warnings if necessary
- if( !$this->mIgnoreWarning ) {
+ if ( !$this->mIgnoreWarning ) {
$warnings = $this->mUpload->checkWarnings();
- if( $this->showUploadWarning( $warnings ) ) {
+ if ( $this->showUploadWarning( $warnings ) ) {
return;
}
}
// Get the page text if this is not a reupload
- if( !$this->mForReUpload ) {
+ if ( !$this->mForReUpload ) {
$pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
$this->mCopyrightStatus, $this->mCopyrightSource );
} else {
* Thus, forcing them as content messages makes the upload to produce an int: template
* instead of hardcoding it there in the uploader language.
*/
- foreach( array( 'license-header', 'filedesc', 'filestatus', 'filesource' ) as $msgName ) {
+ foreach ( array( 'license-header', 'filedesc', 'filestatus', 'filesource' ) as $msgName ) {
if ( in_array( $msgName, $wgForceUIMsgAsContentMsg ) ) {
$msg[$msgName] = "{{int:$msgName}}";
} else {
* @return Bool|String
*/
protected function getWatchCheck() {
- if( $this->getUser()->getOption( 'watchdefault' ) ) {
+ if ( $this->getUser()->getOption( 'watchdefault' ) ) {
// Watch all edits!
return true;
}
$local = wfLocalFile( $this->mDesiredDestName );
- if( $local && $local->exists() ) {
+ if ( $local && $local->exists() ) {
// We're uploading a new version of an existing file.
// No creation, so don't watch it if we're not already.
return $this->getUser()->isWatched( $local->getTitle() );
$filename = $file->getTitle()->getPrefixedText();
$warning = '';
- if( $exists['warning'] == 'exists' ) {
+ if ( $exists['warning'] == 'exists' ) {
// Exact match
$warning = wfMessage( 'fileexists', $filename )->parse();
- } elseif( $exists['warning'] == 'page-exists' ) {
+ } elseif ( $exists['warning'] == 'page-exists' ) {
// Page exists but file does not
$warning = wfMessage( 'filepageexists', $filename )->parse();
} elseif ( $exists['warning'] == 'exists-normalized' ) {
*/
public static function ajaxGetExistsWarning( $filename ) {
$file = wfFindFile( $filename );
- if( !$file ) {
+ if ( !$file ) {
// Force local file so we have an object to do further checks against
// if there isn't an exact match...
$file = wfLocalFile( $filename );
$gallery = new ImageGallery;
$gallery->setShowBytes( false );
- foreach( $dupes as $file ) {
+ foreach ( $dupes as $file ) {
$gallery->add( $file->getTitle() );
}
return '<li>' .
global $wgCheckFileExtensions, $wgStrictFileExtensions,
$wgFileExtensions, $wgFileBlacklist;
- if( $wgCheckFileExtensions ) {
- if( $wgStrictFileExtensions ) {
+ if ( $wgCheckFileExtensions ) {
+ if ( $wgStrictFileExtensions ) {
# Everything not permitted is banned
$extensionsList =
'<div id="mw-upload-permitted">' .
global $wgUploadStashScalerBaseUrl;
$scalerBaseUrl = $wgUploadStashScalerBaseUrl;
- if( preg_match( '/^\/\//', $scalerBaseUrl ) ) {
+ if ( preg_match( '/^\/\//', $scalerBaseUrl ) ) {
// this is apparently a protocol-relative URL, which makes no sense in this context,
// since this is used for communication that's internal to the application.
// default to http.
$this->mReturnTo = $request->getVal( 'returnto', '' );
$this->mReturnToQuery = $request->getVal( 'returntoquery', '' );
- if( $wgEnableEmail ) {
+ if ( $wgEnableEmail ) {
$this->mEmail = $request->getText( 'wpEmail' );
} else {
$this->mEmail = '';
}
- if( !in_array( 'realname', $wgHiddenPrefs ) ) {
+ if ( !in_array( 'realname', $wgHiddenPrefs ) ) {
$this->mRealName = $request->getText( 'wpRealName' );
} else {
$this->mRealName = '';
}
- if( !$wgAuth->validDomain( $this->mDomain ) ) {
+ if ( !$wgAuth->validDomain( $this->mDomain ) ) {
$this->mDomain = $wgAuth->getDomain();
}
$wgAuth->setDomain( $this->mDomain );
# 2. Do not return to PasswordReset after a successful password change
# but goto Wiki start page (Main_Page) instead ( bug 33997 )
$returnToTitle = Title::newFromText( $this->mReturnTo );
- if( is_object( $returnToTitle ) && (
+ if ( is_object( $returnToTitle ) && (
$returnToTitle->isSpecial( 'Userlogout' )
|| $returnToTitle->isSpecial( 'PasswordReset' ) ) ) {
$this->mReturnTo = '';
if ( !is_null( $this->mCookieCheck ) ) {
$this->onCookieRedirectCheck( $this->mCookieCheck );
return;
- } elseif( $this->mPosted ) {
- if( $this->mCreateaccount ) {
+ } elseif ( $this->mPosted ) {
+ if ( $this->mCreateaccount ) {
$this->addNewAccount();
return;
} elseif ( $this->mCreateaccountMail ) {
}
$status = $this->addNewaccountInternal();
- if( !$status->isGood() ) {
+ if ( !$status->isGood() ) {
$error = $this->getOutput()->parse( $status->getWikiText() );
$this->mainLoginForm( $error );
return;
$out = $this->getOutput();
$out->setPageTitle( $this->msg( 'accmailtitle' ) );
- if( !$result->isGood() ) {
+ if ( !$result->isGood() ) {
$this->mainLoginForm( $this->msg( 'mailerror', $result->getWikiText() )->text() );
} else {
$out->addWikiMsg( 'accmailtext', $u->getName(), $u->getEmail() );
# Create the account and abort if there's a problem doing so
$status = $this->addNewAccountInternal();
- if( !$status->isGood() ) {
+ if ( !$status->isGood() ) {
$error = $this->getOutput()->parse( $status->getWikiText() );
$this->mainLoginForm( $error );
return false;
if ( $this->getUser()->isAnon() ) {
# If we showed up language selection links, and one was in use, be
# smart (and sensible) and save that language as the user's preference
- if( $wgLoginLanguageSelector && $this->mLanguage ) {
+ if ( $wgLoginLanguageSelector && $this->mLanguage ) {
$u->setOption( 'language', $this->mLanguage );
} else {
$out = $this->getOutput();
# Send out an email authentication message if needed
- if( $wgEmailAuthentication && Sanitizer::validateEmail( $u->getEmail() ) ) {
+ if ( $wgEmailAuthentication && Sanitizer::validateEmail( $u->getEmail() ) ) {
$status = $u->sendConfirmationMail();
- if( $status->isGood() ) {
+ if ( $status->isGood() ) {
$out->addWikiMsg( 'confirmemail_oncreate' );
} else {
$out->addWikiText( $status->getWikiText( 'confirmemail_sendfailed' ) );
# If not logged in, assume the new account as the current one and set
# session cookies then show a "welcome" message or a "need cookies"
# message as needed
- if( $this->getUser()->isAnon() ) {
+ if ( $this->getUser()->isAnon() ) {
$u->setCookies();
$wgUser = $u;
// This should set it for OutputPage and the Skin
$this->getContext()->setUser( $u );
wfRunHooks( 'AddNewAccount', array( $u, false ) );
$u->addNewUserLogEntry( 'create' );
- if( $this->hasSessionCookie() ) {
+ if ( $this->hasSessionCookie() ) {
$this->successfulCreation();
} else {
$this->cookieRedirectCheck( 'new' );
$wgMinimalPasswordLength, $wgEmailConfirmToEdit;
// If the user passes an invalid domain, something is fishy
- if( !$wgAuth->validDomain( $this->mDomain ) ) {
+ if ( !$wgAuth->validDomain( $this->mDomain ) ) {
return Status::newFatal( 'wrongpassword' );
}
// cation server before they create an account (otherwise, they can
// create a local account and login as any domain user). We only need
// to check this for domains that aren't local.
- if( 'local' != $this->mDomain && $this->mDomain != '' ) {
- if(
+ if ( 'local' != $this->mDomain && $this->mDomain != '' ) {
+ if (
!$wgAuth->canCreateAccounts() &&
(
!$wgAuth->userExists( $this->mUsername ) ||
$u->setRealName( $this->mRealName );
$abortError = '';
- if( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError ) ) ) {
+ if ( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError ) ) ) {
// Hook point to add extra creation throttles and blocks
wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
return Status::newFatal( new RawMessage( $abortError ) );
}
}
- if( !$wgAuth->addUser( $u, $this->mPassword, $this->mEmail, $this->mRealName ) ) {
+ if ( !$wgAuth->addUser( $u, $this->mPassword, $this->mEmail, $this->mRealName ) ) {
return Status::newFatal( 'externaldberror' );
}
}
$u = User::newFromName( $this->mUsername );
- if( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) {
+ if ( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) {
return self::ILLEGAL;
}
// Give general extensions, such as a captcha, a chance to abort logins
$abort = self::ABORTED;
- if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$this->mAbortLoginErrorMsg ) ) ) {
+ if ( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$this->mAbortLoginErrorMsg ) ) ) {
return $abort;
}
global $wgBlockDisablesLogin;
if ( !$u->checkPassword( $this->mPassword ) ) {
- if( $u->checkTemporaryPassword( $this->mPassword ) ) {
+ if ( $u->checkTemporaryPassword( $this->mPassword ) ) {
// The e-mailed temporary password should not be used for actu-
// al logins; that's a very sloppy habit, and insecure if an
// attacker has a few seconds to click "search" on someone's o-
// As a side-effect, we can authenticate the user's e-mail ad-
// dress if it's not already done, since the temporary password
// was sent via e-mail.
- if( !$u->isEmailConfirmed() ) {
+ if ( !$u->isEmailConfirmed() ) {
$u->confirmEmail();
$u->saveSettings();
}
}
$abortError = '';
- if( !wfRunHooks( 'AbortAutoAccount', array( $user, &$abortError ) ) ) {
+ if ( !wfRunHooks( 'AbortAutoAccount', array( $user, &$abortError ) ) ) {
// Hook point to add extra creation throttles and blocks
wfDebug( "LoginForm::attemptAutoCreate: a hook blocked creation: $abortError\n" );
$this->mAbortLoginErrorMsg = $abortError;
case self::SUCCESS:
# We've verified now, update the real record
$user = $this->getUser();
- if( (bool)$this->mRemember != $user->getBoolOption( 'rememberpassword' ) ) {
+ if ( (bool)$this->mRemember != $user->getBoolOption( 'rememberpassword' ) ) {
$user->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 );
$user->saveSettings();
} else {
$user->invalidateCache();
}
- if( $wgSecureLogin && !$this->mStickHTTPS ) {
+ if ( $wgSecureLogin && !$this->mStickHTTPS ) {
$user->setCookies( null, false );
} else {
$user->setCookies();
$key = wfMemcKey( 'password-throttle', $request->getIP(), md5( $this->mUsername ) );
$wgMemc->delete( $key );
- if( $this->hasSessionCookie() || $this->mSkipCookieCheck ) {
+ if ( $this->hasSessionCookie() || $this->mSkipCookieCheck ) {
/* Replace the language object to provide user interface in
* correct language immediately on this first page load.
*/
$this->mainLoginForm( $this->msg( 'wrongpassword' )->text() );
break;
case self::NOT_EXISTS:
- if( $this->getUser()->isAllowed( 'createaccount' ) ) {
+ if ( $this->getUser()->isAllowed( 'createaccount' ) ) {
$this->mainLoginForm( $this->msg( 'nosuchuser',
wfEscapeWikiText( $this->mUsername ) )->parse() );
} else {
return Status::newFatal( 'noemail', $u->getName() );
}
$ip = $this->getRequest()->getIP();
- if( !$ip ) {
+ if ( !$ip ) {
return Status::newFatal( 'badipaddress' );
}
$injected_html = '';
wfRunHooks( 'UserLoginComplete', array( &$currentUser, &$injected_html ) );
- if( $injected_html !== '' ) {
+ if ( $injected_html !== '' ) {
$this->displaySuccessfulAction( $this->msg( 'loginsuccesstitle' ),
'loginsuccess', $injected_html );
} else {
if ( $wgSecureLogin && !$this->mStickHTTPS ) {
$options = array( 'http' );
$proto = PROTO_HTTP;
- } elseif( $wgSecureLogin ) {
+ } elseif ( $wgSecureLogin ) {
$options = array( 'https' );
$proto = PROTO_HTTPS;
} else {
}
# Don't show a "create account" link if the user can't.
- if( $this->showCreateOrLoginLink( $user ) ) {
+ if ( $this->showCreateOrLoginLink( $user ) ) {
# Pass any language selection on to the mode switch link
- if( $wgLoginLanguageSelector && $this->mLanguage ) {
+ if ( $wgLoginLanguageSelector && $this->mLanguage ) {
$linkq .= '&uselang=' . $this->mLanguage;
}
if ( !$this->mShowVForm ) {
}
# Prepare language selection links as needed
- if( $wgLoginLanguageSelector ) {
+ if ( $wgLoginLanguageSelector ) {
$template->set( 'languages', $this->makeLanguageSelector() );
- if( $this->mLanguage ) {
+ if ( $this->mLanguage ) {
$template->set( 'uselang', $this->mLanguage );
}
}
* @return Boolean
*/
function showCreateOrLoginLink( &$user ) {
- if( $this->mType == 'signup' ) {
+ if ( $this->mType == 'signup' ) {
return true;
- } elseif( $user->isAllowed( 'createaccount' ) ) {
+ } elseif ( $user->isAllowed( 'createaccount' ) ) {
return true;
} else {
return false;
*/
private function renewSessionId() {
global $wgSecureLogin, $wgCookieSecure;
- if( $wgSecureLogin && !$this->mStickHTTPS ) {
+ if ( $wgSecureLogin && !$this->mStickHTTPS ) {
$wgCookieSecure = false;
}
*/
function makeLanguageSelector() {
$msg = $this->msg( 'loginlanguagelinks' )->inContentLanguage();
- if( !$msg->isBlank() ) {
+ if ( !$msg->isBlank() ) {
$langs = explode( "\n", $msg->text() );
$links = array();
- foreach( $langs as $lang ) {
+ foreach ( $langs as $lang ) {
$lang = trim( $lang, '* ' );
$parts = explode( '|', $lang );
if ( count( $parts ) >= 2 ) {
* @return string
*/
function makeLanguageSelectorLink( $text, $lang ) {
- if( $this->getLanguage()->getCode() == $lang ) {
+ if ( $this->getLanguage()->getCode() == $lang ) {
// no link for currently used language
return htmlspecialchars( $text );
}
$query = array( 'uselang' => $lang );
- if( $this->mType == 'signup' ) {
+ if ( $this->mType == 'signup' ) {
$query['type'] = 'signup';
}
- if( $this->mReturnTo !== '' ) {
+ if ( $this->mReturnTo !== '' ) {
$query['returnto'] = $this->mReturnTo;
$query['returntoquery'] = $this->mReturnToQuery;
}
* (e.g. they don't have the userrights permission), then don't
* allow them to use Special:UserRights.
*/
- if( $user->isBlocked() && !$user->isAllowed( 'userrights' ) ) {
+ if ( $user->isBlocked() && !$user->isAllowed( 'userrights' ) ) {
throw new UserBlockedError( $user->getBlock() );
}
$request = $this->getRequest();
- if( $par !== null ) {
+ if ( $par !== null ) {
$this->mTarget = $par;
} else {
$this->mTarget = $request->getVal( 'user' );
* edit their own groups, automatically set them as the
* target.
*/
- if ( !count( $available['add'] ) && !count( $available['remove'] ) )
+ if ( !count( $available['add'] ) && !count( $available['remove'] ) ) {
$this->mTarget = $user->getName();
+ }
}
if ( User::getCanonicalName( $this->mTarget ) == $user->getName() ) {
$this->isself = true;
}
- if( !$this->userCanChangeRights( $user, true ) ) {
+ if ( !$this->userCanChangeRights( $user, true ) ) {
// @todo FIXME: There may be intermediate groups we can mention.
$msg = $user->isAnon() ? 'userrights-nologin' : 'userrights-notallowed';
throw new PermissionsError( null, array( array( $msg ) ) );
$this->switchForm();
}
- if( $request->wasPosted() ) {
+ if ( $request->wasPosted() ) {
// save settings
- if( $request->getCheck( 'saveusergroups' ) ) {
+ if ( $request->getCheck( 'saveusergroups' ) ) {
$reason = $request->getVal( 'user-reason' );
$tok = $request->getVal( 'wpEditToken' );
- if( $user->matchEditToken( $tok, $this->mTarget ) ) {
+ if ( $user->matchEditToken( $tok, $this->mTarget ) ) {
$this->saveUserGroups(
$this->mTarget,
$reason
}
// show some more forms
- if( $this->mTarget !== null ) {
+ if ( $this->mTarget !== null ) {
$this->editUserGroupsForm( $this->mTarget );
}
}
*/
function saveUserGroups( $username, $reason = '' ) {
$status = $this->fetchUser( $username );
- if( !$status->isOK() ) {
+ if ( !$status->isOK() ) {
$this->getOutput()->addWikiText( $status->getWikiText() );
return;
} else {
$newGroups = $oldGroups;
// remove then add groups
- if( $remove ) {
+ if ( $remove ) {
$newGroups = array_diff( $newGroups, $remove );
- foreach( $remove as $group ) {
+ foreach ( $remove as $group ) {
$user->removeGroup( $group );
}
}
- if( $add ) {
+ if ( $add ) {
$newGroups = array_merge( $newGroups, $add );
- foreach( $add as $group ) {
+ foreach ( $add as $group ) {
$user->addGroup( $group );
}
}
wfDebug( 'newGroups: ' . print_r( $newGroups, true ) );
wfRunHooks( 'UserRights', array( &$user, $add, $remove ) );
- if( $newGroups != $oldGroups ) {
+ if ( $newGroups != $oldGroups ) {
$this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
}
return array( $add, $remove );
*/
function editUserGroupsForm( $username ) {
$status = $this->fetchUser( $username );
- if( !$status->isOK() ) {
+ if ( !$status->isOK() ) {
$this->getOutput()->addWikiText( $status->getWikiText() );
return;
} else {
global $wgUserrightsInterwikiDelimiter;
$parts = explode( $wgUserrightsInterwikiDelimiter, $username );
- if( count( $parts ) < 2 ) {
+ if ( count( $parts ) < 2 ) {
$name = trim( $username );
$database = '';
} else {
list( $name, $database ) = array_map( 'trim', $parts );
- if( $database == wfWikiID() ) {
+ if ( $database == wfWikiID() ) {
$database = '';
} else {
- if( !$this->getUser()->isAllowed( 'userrights-interwiki' ) ) {
+ if ( !$this->getUser()->isAllowed( 'userrights-interwiki' ) ) {
return Status::newFatal( 'userrights-no-interwiki' );
}
- if( !UserRightsProxy::validDatabase( $database ) ) {
+ if ( !UserRightsProxy::validDatabase( $database ) ) {
return Status::newFatal( 'userrights-nodatabase', $database );
}
}
}
- if( $name === '' ) {
+ if ( $name === '' ) {
return Status::newFatal( 'nouserspecified' );
}
- if( $name[0] == '#' ) {
+ if ( $name[0] == '#' ) {
// Numeric ID can be specified...
// We'll do a lookup for the name internally.
$id = intval( substr( $name, 1 ) );
- if( $database == '' ) {
+ if ( $database == '' ) {
$name = User::whoIs( $id );
} else {
$name = UserRightsProxy::whoIs( $database, $id );
}
- if( !$name ) {
+ if ( !$name ) {
return Status::newFatal( 'noname' );
}
} else {
$name = User::getCanonicalName( $name );
- if( $name === false ) {
+ if ( $name === false ) {
// invalid name
return Status::newFatal( 'nosuchusershort', $username );
}
}
- if( $database == '' ) {
+ if ( $database == '' ) {
$user = User::newFromName( $name );
} else {
$user = UserRightsProxy::newFromName( $database, $name );
}
- if( !$user || $user->isAnon() ) {
+ if ( !$user || $user->isAnon() ) {
return Status::newFatal( 'nosuchusershort', $username );
}
}
function makeGroupNameList( $ids ) {
- if( empty( $ids ) ) {
+ if ( empty( $ids ) ) {
return $this->msg( 'rightsnone' )->inContentLanguage()->text();
} else {
return implode( ', ', $ids );
function makeGroupNameListForLog( $ids ) {
wfDeprecated( __METHOD__, '1.21' );
- if( empty( $ids ) ) {
+ if ( empty( $ids ) ) {
return '';
} else {
return $this->makeGroupNameList( $ids );
protected function showEditUserGroupsForm( $user, $groups ) {
$list = array();
$membersList = array();
- foreach( $groups as $group ) {
+ foreach ( $groups as $group ) {
$list[] = self::buildGroupLink( $group );
$membersList[] = self::buildGroupMemberLink( $group );
}
$autoList = array();
$autoMembersList = array();
if ( $user instanceof User ) {
- foreach( Autopromote::getAutopromoteGroups( $user ) as $group ) {
+ foreach ( Autopromote::getAutopromoteGroups( $user ) as $group ) {
$autoList[] = self::buildGroupLink( $group );
$autoMembersList[] = self::buildGroupMemberLink( $group );
}
# more easily manage it.
$columns = array( 'unchangeable' => array(), 'changeable' => array() );
- foreach( $allgroups as $group ) {
+ foreach ( $allgroups as $group ) {
$set = in_array( $group, $usergroups );
# Should the checkbox be disabled?
$disabled = !(
'irreversible' => $irreversible
);
- if( $disabled ) {
+ if ( $disabled ) {
$columns['unchangeable'][$group] = $checkbox;
} else {
$columns['changeable'][$group] = $checkbox;
# Build the HTML table
$ret .= Xml::openElement( 'table', array( 'class' => 'mw-userrights-groups' ) ) .
"<tr>\n";
- foreach( $columns as $name => $column ) {
- if( $column === array() )
+ foreach ( $columns as $name => $column ) {
+ if ( $column === array() ) {
continue;
+ }
$ret .= Xml::element( 'th', null, $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text() );
}
$ret .= "</tr>\n<tr>\n";
- foreach( $columns as $column ) {
- if( $column === array() )
+ foreach ( $columns as $column ) {
+ if ( $column === array() ) {
continue;
+ }
$ret .= "\t<td style='vertical-align:top;'>\n";
- foreach( $column as $group => $checkbox ) {
+ foreach ( $column as $group => $checkbox ) {
$attr = $checkbox['disabled'] ? array( 'disabled' => 'disabled' ) : array();
$member = User::getGroupMember( $group, $user->getName() );
$out = $this->getOutput();
$out->allowClickjacking();
- if( $par !== 'Credits' ) {
+ if ( $par !== 'Credits' ) {
$text =
$this->getMediaWikiCredits() .
$this->softwareInformation() .
<th>" . wfMessage( 'version-software-version' )->text() . "</th>
</tr>\n";
- foreach( $software as $name => $version ) {
+ foreach ( $software as $name => $version ) {
$out .= "<tr>
<td>" . $name . "</td>
<td dir=\"ltr\">" . $version . "</td>
wfProfileIn( __METHOD__ );
$gitVersion = self::getVersionLinkedGit();
- if( $gitVersion ) {
+ if ( $gitVersion ) {
$v = $gitVersion;
} else {
$svnVersion = self::getVersionLinkedSvn();
- if( $svnVersion ) {
+ if ( $svnVersion ) {
$v = $svnVersion;
} else {
$v = $wgVersion; // fallback
global $IP;
$info = self::getSvnInfo( $IP );
- if( !isset( $info['checkout-rev'] ) ) {
+ if ( !isset( $info['checkout-rev'] ) ) {
return false;
}
private static function getwgVersionLinked() {
global $wgVersion;
$versionUrl = "";
- if( wfRunHooks( 'SpecialVersionVersionUrl', array( $wgVersion, &$versionUrl ) ) ) {
+ if ( wfRunHooks( 'SpecialVersionVersionUrl', array( $wgVersion, &$versionUrl ) ) ) {
$versionParts = array();
preg_match( "/^(\d+\.\d+)/", $wgVersion, $versionParts );
$versionUrl = "https://www.mediawiki.org/wiki/MediaWiki_{$versionParts[1]}";
$gitInfo = new GitInfo( $IP );
$headSHA1 = $gitInfo->getHeadSHA1();
- if( !$headSHA1 ) {
+ if ( !$headSHA1 ) {
return false;
}
}
$fhooks = $wgParser->getFunctionHooks();
- if( count( $fhooks ) ) {
+ if ( count( $fhooks ) ) {
$out .= $this->openExtType( $this->msg( 'version-parser-function-hooks' )->text(), 'parser-function-hooks' );
$out .= '<tr><td colspan="4">' . $this->listToText( $fhooks ) . "</td></tr>\n";
}
* @return int
*/
function compare( $a, $b ) {
- if( $a['name'] === $b['name'] ) {
+ if ( $a['name'] === $b['name'] ) {
return 0;
} else {
return $this->getLanguage()->lc( $a['name'] ) > $this->getLanguage()->lc( $b['name'] )
}
$gitHeadCommitDate = $gitInfo->getHeadCommitDate();
if ( $gitHeadCommitDate ) {
- $vcsText .= "<br/>" . $wgLang->timeanddate( $gitHeadCommitDate, true );
+ $vcsText .= "<br/>" . $wgLang->timeanddate( $gitHeadCommitDate, true );
}
} else {
$svnInfo = self::getSvnInfo( dirname( $extension['path'] ) );
# Make description text.
$description = isset ( $extension['description'] ) ? $extension['description'] : '';
- if( isset ( $extension['descriptionmsg'] ) ) {
+ if ( isset ( $extension['descriptionmsg'] ) ) {
# Look for a localized description.
$descriptionMsg = $extension['descriptionmsg'];
- if( is_array( $descriptionMsg ) ) {
+ if ( is_array( $descriptionMsg ) ) {
$descriptionMsgKey = $descriptionMsg[0]; // Get the message key
array_shift( $descriptionMsg ); // Shift out the message key to get the parameters only
array_map( "htmlspecialchars", $descriptionMsg ); // For sanity
$ret .= Xml::closeElement( 'table' );
return $ret;
- } else
+ } else {
return '';
+ }
}
private function openExtType( $text, $name = null ) {
$opt = array( 'colspan' => 4 );
$out = '';
- if( $this->firstExtOpened ) {
+ if ( $this->firstExtOpened ) {
// Insert a spacing line
$out .= '<tr class="sv-space">' . Html::element( 'td', $opt ) . "</tr>\n";
}
$this->firstExtOpened = true;
- if( $name ) {
+ if ( $name ) {
$opt['id'] = "sv-$name";
}
*/
function listAuthors( $authors ) {
$list = array();
- foreach( (array)$authors as $item ) {
+ foreach ( (array)$authors as $item ) {
if ( $item == '...' ) {
$list[] = $this->msg( 'version-poweredby-others' )->text();
} elseif ( substr( $item, -5 ) == ' ...]' ) {
* @return Mixed
*/
public static function arrayToString( $list ) {
- if( is_array( $list ) && count( $list ) == 1 ) {
+ if ( is_array( $list ) && count( $list ) == 1 ) {
$list = $list[0];
}
- if( is_object( $list ) ) {
+ if ( is_object( $list ) ) {
$class = wfMessage( 'parentheses' )->params( get_class( $list ) )->escaped();
return $class;
} elseif ( !is_array( $list ) ) {
return $list;
} else {
- if( is_object( $list[0] ) ) {
+ if ( is_object( $list[0] ) ) {
$class = get_class( $list[0] );
} else {
$class = $list[0];
// http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
$entries = $dir . '/.svn/entries';
- if( !file_exists( $entries ) ) {
+ if ( !file_exists( $entries ) ) {
return false;
}
}
// check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4)
- if( preg_match( '/^<\?xml/', $lines[0] ) ) {
+ if ( preg_match( '/^<\?xml/', $lines[0] ) ) {
// subversion is release <= 1.3
- if( !function_exists( 'simplexml_load_file' ) ) {
+ if ( !function_exists( 'simplexml_load_file' ) ) {
// We could fall back to expat... YUCK
return false;
}
$xml = simplexml_load_file( $entries );
wfRestoreWarnings();
- if( $xml ) {
- foreach( $xml->entry as $entry ) {
- if( $xml->entry[0]['name'] == '' ) {
+ if ( $xml ) {
+ foreach ( $xml->entry as $entry ) {
+ if ( $xml->entry[0]['name'] == '' ) {
// The directory entry should always have a revision marker.
- if( $entry['revision'] ) {
+ if ( $entry['revision'] ) {
return array( 'checkout-rev' => intval( $entry['revision'] ) );
}
}
$output = $this->getOutput();
# Anons don't get a watchlist
- if( $user->isAnon() ) {
+ if ( $user->isAnon() ) {
$output->setPageTitle( $this->msg( 'watchnologin' ) );
$output->setRobotPolicy( 'noindex,nofollow' );
$llink = Linker::linkKnown(
$request = $this->getRequest();
$mode = SpecialEditWatchlist::getMode( $request, $par );
- if( $mode !== false ) {
+ if ( $mode !== false ) {
# TODO: localise?
switch( $mode ) {
case SpecialEditWatchlist::EDIT_CLEAR:
// @TODO: use FormOptions!
$defaults = array(
- /* float */ 'days' => floatval( $user->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
+ /* float */ 'days' => floatval( $user->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
/* bool */ 'hideMinor' => (int)$user->getBoolOption( 'watchlisthideminor' ),
- /* bool */ 'hideBots' => (int)$user->getBoolOption( 'watchlisthidebots' ),
+ /* bool */ 'hideBots' => (int)$user->getBoolOption( 'watchlisthidebots' ),
/* bool */ 'hideAnons' => (int)$user->getBoolOption( 'watchlisthideanons' ),
- /* bool */ 'hideLiu' => (int)$user->getBoolOption( 'watchlisthideliu' ),
+ /* bool */ 'hideLiu' => (int)$user->getBoolOption( 'watchlisthideliu' ),
/* bool */ 'hidePatrolled' => (int)$user->getBoolOption( 'watchlisthidepatrolled' ),
- /* bool */ 'hideOwn' => (int)$user->getBoolOption( 'watchlisthideown' ),
- /* bool */ 'extended' => (int)$user->getBoolOption( 'extendwatchlist' ),
+ /* bool */ 'hideOwn' => (int)$user->getBoolOption( 'watchlisthideown' ),
+ /* bool */ 'extended' => (int)$user->getBoolOption( 'extendwatchlist' ),
/* ? */ 'namespace' => '', //means all
- /* ? */ 'invert' => false,
+ /* ? */ 'invert' => false,
/* bool */ 'associated' => false,
);
$this->customFilters = array();
wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
- foreach( $this->customFilters as $key => $params ) {
+ foreach ( $this->customFilters as $key => $params ) {
$defaults[$key] = $params['default'];
}
$values['hideOwn'] = (int)$request->getBool( 'hideOwn', $defaults['hideOwn'] );
$values['hidePatrolled'] = (int)$request->getBool( 'hidePatrolled', $defaults['hidePatrolled'] );
$values['extended'] = (int)$request->getBool( 'extended', $defaults['extended'] );
- foreach( $this->customFilters as $key => $params ) {
+ foreach ( $this->customFilters as $key => $params ) {
$values[$key] = (int)$request->getBool( $key, $defaults[$key] );
}
$values['invert'] = $invert;
$values['associated'] = $associated;
- if( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
+ if ( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
$big = 1000; /* The magical big */
- if( $nitems > $big ) {
+ if ( $nitems > $big ) {
# Set default cutoff shorter
$values['days'] = $defaults['days'] = (12.0 / 24.0); # 12 hours...
} else {
wfAppendToArrayIfNotDefault( $name, $values[$name], $defaults, $nondefaults );
}
- if( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
+ if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
$request->wasPosted() )
{
$user->clearAllNotifications();
# Possible where conditions
$conds = array();
- if( $values['days'] > 0 ) {
+ if ( $values['days'] > 0 ) {
$conds[] = 'rc_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( time() - intval( $values['days'] * 86400 ) ) );
}
# Up estimate of watched items by 15% to compensate for talk pages...
# Toggles
- if( $values['hideOwn'] ) {
+ if ( $values['hideOwn'] ) {
$conds[] = 'rc_user != ' . $user->getId();
}
- if( $values['hideBots'] ) {
+ if ( $values['hideBots'] ) {
$conds[] = 'rc_bot = 0';
}
- if( $values['hideMinor'] ) {
+ if ( $values['hideMinor'] ) {
$conds[] = 'rc_minor = 0';
}
- if( $values['hideLiu'] ) {
+ if ( $values['hideLiu'] ) {
$conds[] = 'rc_user = 0';
}
- if( $values['hideAnons'] ) {
+ if ( $values['hideAnons'] ) {
$conds[] = 'rc_user != 0';
}
if ( $user->useRCPatrol() && $values['hidePatrolled'] ) {
}
# Toggle watchlist content (all recent edits or just the latest)
- if( $values['extended'] ) {
+ if ( $values['extended'] ) {
$limitWatchlist = $user->getIntOption( 'wllimit' );
$usePage = false;
} else {
# Show a message about slave lag, if applicable
$lag = wfGetLB()->safeGetLag( $dbr );
- if( $lag > 0 ) {
+ if ( $lag > 0 ) {
$output->showLagWarning( $lag );
}
# Show watchlist header
$form .= $this->msg( 'watchlist-details' )->numParams( $nitems )->parse() . "\n";
- if( $user->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist ) {
+ if ( $user->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist ) {
$form .= $this->msg( 'wlheader-enotif' )->parseAsBlock() . "\n";
}
- if( $wgShowUpdatedMarker ) {
+ if ( $wgShowUpdatedMarker ) {
$form .= Xml::openElement( 'form', array( 'method' => 'post',
'action' => $this->getTitle()->getLocalURL(),
'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
),
);
$options = array( 'ORDER BY' => 'rc_timestamp DESC' );
- if( $wgShowUpdatedMarker ) {
+ if ( $wgShowUpdatedMarker ) {
$fields[] = 'wl_notificationtimestamp';
}
- if( $limitWatchlist ) {
+ if ( $limitWatchlist ) {
$options['LIMIT'] = $limitWatchlist;
}
$lang = $this->getLanguage();
$wlInfo = '';
- if( $values['days'] > 0 ) {
+ if ( $values['days'] > 0 ) {
$timestamp = wfTimestampNow();
$wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $values['days'] * 24 ) )->params(
$lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->parse() . "<br />\n";
# Spit out some control panel links
$filters = array(
- 'hideMinor' => 'rcshowhideminor',
- 'hideBots' => 'rcshowhidebots',
- 'hideAnons' => 'rcshowhideanons',
- 'hideLiu' => 'rcshowhideliu',
- 'hideOwn' => 'rcshowhidemine',
+ 'hideMinor' => 'rcshowhideminor',
+ 'hideBots' => 'rcshowhidebots',
+ 'hideAnons' => 'rcshowhideanons',
+ 'hideLiu' => 'rcshowhideliu',
+ 'hideOwn' => 'rcshowhidemine',
'hidePatrolled' => 'rcshowhidepatr'
);
foreach ( $this->customFilters as $key => $params ) {
}
$links = array();
- foreach( $filters as $name => $msg ) {
+ foreach ( $filters as $name => $msg ) {
$links[] = $this->showHideLink( $nondefaults, $msg, $name, $values[$name] );
}
'all' => '',
'label' => $this->msg( 'namespace' )->text()
), array(
- 'name' => 'namespace',
- 'id' => 'namespace',
+ 'name' => 'namespace',
+ 'id' => 'namespace',
'class' => 'namespaceselector',
)
) . ' ';
$output->addHTML( $form );
# If there's nothing to show, stop here
- if( $numRows == 0 ) {
+ if ( $numRows == 0 ) {
$output->addWikiMsg( 'watchnochange' );
return;
}
$hours = array( 1, 2, 6, 12 );
$days = array( 1, 3, 7 );
$i = 0;
- foreach( $hours as $h ) {
+ foreach ( $hours as $h ) {
$hours[$i++] = $this->hoursLink( $h, $options );
}
$i = 0;
- foreach( $days as $d ) {
+ foreach ( $days as $d ) {
$days[$i++] = $this->daysLink( $d, $options );
}
return $this->msg( 'wlshowlast' )->rawParams(
$this->opts = $opts;
$this->target = Title::newFromURL( $opts->getValue( 'target' ) );
- if( !$this->target ) {
+ if ( !$this->target ) {
$out->addHTML( $this->whatlinkshereForm() );
return;
}
$hidetrans = $this->opts->getValue( 'hidetrans' );
$hideimages = $target->getNamespace() != NS_FILE || $this->opts->getValue( 'hideimages' );
- $fetchlinks = (!$hidelinks || !$hideredirs);
+ $fetchlinks = ( !$hidelinks || !$hideredirs );
// Make the query
$plConds = array(
'pl_namespace' => $target->getNamespace(),
'pl_title' => $target->getDBkey(),
);
- if( $hideredirs ) {
+ if ( $hideredirs ) {
$plConds['rd_from'] = null;
- } elseif( $hidelinks ) {
+ } elseif ( $hidelinks ) {
$plConds[] = 'rd_from is NOT NULL';
}
'rd_interwiki = ' . $dbr->addQuotes( '' ) . ' OR rd_interwiki IS NULL'
)));
- if( $fetchlinks ) {
+ if ( $fetchlinks ) {
$options['ORDER BY'] = 'pl_from';
$plRes = $dbr->select( array( 'pagelinks', 'page', 'redirect' ), $fields,
$plConds, __METHOD__, $options,
);
}
- if( !$hidetrans ) {
+ if ( !$hidetrans ) {
$options['ORDER BY'] = 'tl_from';
$tlRes = $dbr->select( array( 'templatelinks', 'page', 'redirect' ), $fields,
$tlConds, __METHOD__, $options,
);
}
- if( !$hideimages ) {
+ if ( !$hideimages ) {
$options['ORDER BY'] = 'il_from';
$ilRes = $dbr->select( array( 'imagelinks', 'page', 'redirect' ), $fields,
$ilConds, __METHOD__, $options,
);
}
- if( ( !$fetchlinks || !$plRes->numRows() ) && ( $hidetrans || !$tlRes->numRows() ) && ( $hideimages || !$ilRes->numRows() ) ) {
+ if ( ( !$fetchlinks || !$plRes->numRows() ) && ( $hidetrans || !$tlRes->numRows() ) && ( $hideimages || !$ilRes->numRows() ) ) {
if ( 0 == $level ) {
$out->addHTML( $this->whatlinkshereForm() );
// Show filters only if there are links
- if( $hidelinks || $hidetrans || $hideredirs || $hideimages )
+ if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
$out->addHTML( $this->getFilterPanel() );
+ }
$errMsg = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere';
$out->addWikiMsg( $errMsg, $this->target->getPrefixedText() );
// Read the rows into an array and remove duplicates
// templatelinks comes second so that the templatelinks row overwrites the
// pagelinks row, so we get (inclusion) rather than nothing
- if( $fetchlinks ) {
+ if ( $fetchlinks ) {
foreach ( $plRes as $row ) {
$row->is_template = 0;
$row->is_image = 0;
$rows[$row->page_id] = $row;
}
}
- if( !$hidetrans ) {
+ if ( !$hidetrans ) {
foreach ( $tlRes as $row ) {
$row->is_template = 1;
$row->is_image = 0;
$rows[$row->page_id] = $row;
}
}
- if( !$hideimages ) {
+ if ( !$hideimages ) {
foreach ( $ilRes as $row ) {
$row->is_template = 0;
$row->is_image = 1;
$out->addHTML( $this->listEnd() );
- if( $level == 0 ) {
+ if ( $level == 0 ) {
$out->addHTML( $prevnext );
}
}
}
}
- if( $row->rd_from ) {
+ if ( $row->rd_from ) {
$query = array( 'redirect' => 'no' );
} else {
$query = array();
// Display properties (redirect or template)
$propsText = '';
$props = array();
- if ( $row->rd_from )
+ if ( $row->rd_from ) {
$props[] = $msgcache['isredirect'];
- if ( $row->is_template )
+ }
+ if ( $row->is_template ) {
$props[] = $msgcache['istemplate'];
- if( $row->is_image )
+ }
+ if ( $row->is_image ) {
$props[] = $msgcache['isimage'];
+ }
if ( count( $props ) ) {
$propsText = $this->msg( 'parentheses' )->rawParams( implode( $msgcache['semicolon-separator'], $props ) )->escaped();
protected function wlhLink( Title $target, $text ) {
static $title = null;
- if ( $title === null )
+ if ( $title === null ) {
$title = $this->getTitle();
+ }
return Linker::linkKnown(
$title,
'all' => '',
'label' => $this->msg( 'namespace' )->text()
), array(
- 'name' => 'namespace',
- 'id' => 'namespace',
+ 'name' => 'namespace',
+ 'id' => 'namespace',
'class' => 'namespaceselector',
)
);
$links = array();
$types = array( 'hidetrans', 'hidelinks', 'hideredirs' );
- if( $this->target->getNamespace() == NS_FILE )
+ if ( $this->target->getNamespace() == NS_FILE ) {
$types[] = 'hideimages';
+ }
// Combined message keys: 'whatlinkshere-hideredirs', 'whatlinkshere-hidetrans', 'whatlinkshere-hidelinks', 'whatlinkshere-hideimages'
// To be sure they will be found by grep
- foreach( $types as $type ) {
+ foreach ( $types as $type ) {
$chosen = $this->opts->getValue( $type );
$msg = $chosen ? $show : $hide;
$overrides = array( $type => !$chosen );
global $wgScript;
# Do not show useless input form if special page is cached
- if( $this->isCached() ) {
+ if ( $this->isCached() ) {
return '';
}