wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
$this->showCssOrJsPage();
$outputDone = true;
- } else if ( $rt = Title::newFromRedirectArray( $text ) ) {
- wfDebug( __METHOD__ . ": showing redirect=no page\n" );
- # Viewing a redirect page (e.g. with parameter redirect=no)
- # Don't append the subtitle if this was an old revision
- $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
- # Parse just to get categories, displaytitle, etc.
- $this->mParserOutput = $wgParser->parse( $text, $this->mTitle, $parserOptions );
- $wgOut->addParserOutputNoText( $this->mParserOutput );
- $outputDone = true;
+ } else {
+ $rt = Title::newFromRedirectArray( $text );
+ if ( $rt ) {
+ wfDebug( __METHOD__ . ": showing redirect=no page\n" );
+ # Viewing a redirect page (e.g. with parameter redirect=no)
+ # Don't append the subtitle if this was an old revision
+ $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
+ # Parse just to get categories, displaytitle, etc.
+ $this->mParserOutput = $wgParser->parse( $text, $this->mTitle, $parserOptions );
+ $wgOut->addParserOutputNoText( $this->mParserOutput );
+ $outputDone = true;
+ }
}
break;
case 4:
// Caching...
global $wgMemc;
$key = wfMemcKey( 'valid-tags' );
-
- if ( $tags = $wgMemc->get( $key ) ) {
+ $tags = $wgMemc->get( $key );
+ if ( $tags ) {
return $tags;
}
$parserOptions->setTidy( true );
$parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions );
$previewHTML = $parserOutput->mText;
- } elseif ( $rt = Title::newFromRedirectArray( $this->textbox1 ) ) {
- $previewHTML = $this->mArticle->viewRedirect( $rt, false );
} else {
- $toparse = $this->textbox1;
+ $rt = Title::newFromRedirectArray( $this->textbox1 );
+ if ( $rt ) {
+ $previewHTML = $this->mArticle->viewRedirect( $rt, false );
+ } else {
+ $toparse = $this->textbox1;
- # If we're adding a comment, we need to show the
- # summary as the headline
- if ( $this->section == "new" && $this->summary != "" ) {
- $toparse = "== {$this->summary} ==\n\n" . $toparse;
- }
+ # If we're adding a comment, we need to show the
+ # summary as the headline
+ if ( $this->section == "new" && $this->summary != "" ) {
+ $toparse = "== {$this->summary} ==\n\n" . $toparse;
+ }
- wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
-
- // Parse mediawiki messages with correct target language
- if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- list( /* $unused */, $lang ) = $wgMessageCache->figureMessage( $this->mTitle->getText() );
- $obj = wfGetLangObj( $lang );
- $parserOptions->setTargetLanguage( $obj );
- }
+ wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
+ // Parse mediawiki messages with correct target language
+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
+ list( /* $unused */, $lang ) = $wgMessageCache->figureMessage( $this->mTitle->getText() );
+ $obj = wfGetLangObj( $lang );
+ $parserOptions->setTargetLanguage( $obj );
+ }
- $parserOptions->setTidy( true );
- $parserOptions->enableLimitReport();
- $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
+ $parserOptions->setTidy( true );
+ $parserOptions->enableLimitReport();
+ $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
$this->mTitle, $parserOptions );
- $previewHTML = $parserOutput->getText();
- $this->mParserOutput = $parserOutput;
- $wgOut->addParserOutputNoText( $parserOutput );
+ $previewHTML = $parserOutput->getText();
+ $this->mParserOutput = $parserOutput;
+ $wgOut->addParserOutputNoText( $parserOutput );
- if ( count( $parserOutput->getWarnings() ) ) {
- $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
+ if ( count( $parserOutput->getWarnings() ) ) {
+ $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
+ }
}
}
$wgOut->redirect( '' );
$wgOut->clearHTML();
- if ( $hookResult = $this->runHooks( get_class( $this ) ) ) {
+ $hookResult = $this->runHooks( get_class( $this ) );
+ if ( $hookResult ) {
$wgOut->addHTML( $hookResult );
} else {
$wgOut->addHTML( $this->getHTML() );
$wgOut->output();
} else {
- if ( $hookResult = $this->runHooks( get_class( $this ) . "Raw" ) ) {
+ $hookResult = $this->runHooks( get_class( $this ) . "Raw" );
+ if ( $hookResult ) {
die( $hookResult );
}
protected function person($name, User $user ){
if( $user->isAnon() ){
$this->element( $name, wfMsgExt( 'anonymous', array( 'parsemag' ), 1 ) );
- } else if( $real = $user->getRealName() ) {
- $this->element( $name, $real );
} else {
- $userName = $user->getName();
- $this->pageOrString( $name, $user->getUserPage(), wfMsgExt( 'siteuser', 'parsemag', $userName, $userName ) );
+ $real = $user->getRealName();
+ if( $real ) {
+ $this->element( $name, $real );
+ } else {
+ $userName = $user->getName();
+ $this->pageOrString( $name, $user->getUserPage(), wfMsgExt( 'siteuser', 'parsemag', $userName, $userName ) );
+ }
}
}
} else {
//article doesn't exist or is deleted
if( $wgUser->isAllowed( 'deletedhistory' ) && $wgUser->isAllowed( 'deletedtext' ) ) {
- if( $n = $this->mTitle->isDeleted() ) {
+ $n = $this->mTitle->isDeleted();
+ if( $n ) {
$undelTitle = SpecialPage::getTitleFor( 'Undelete' );
$content_actions['undelete'] = array(
'class' => false,
$retVal = array();
if ( $db->numRows( $res ) ) {
foreach ( $res as $row ) {
- if ( $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ) ) {
+ $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title )
+ if ( $titleObj ) {
$linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest );
$retVal[] = $titleObj;
}
if( $wgRequest->getVal( 'printable' ) === 'yes' ) {
$wgOut->setPrintable();
}
-
- if( $curid = $wgRequest->getInt( 'curid' ) ) {
+ $curid = $wgRequest->getInt( 'curid' );
+ if( $curid ) {
// URLs like this are generated by RC, because rc_title isn't always accurate
$ret = Title::newFromID( $curid );
} elseif( $title == '' && $action != 'delete' ) {
// Interwiki redirects
} else if( $title->getInterwiki() != '' ) {
- if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
+ $rdfrom = $request->getVal( 'rdfrom' );
+ if( $rdfrom ) {
$url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
} else {
$query = $request->getValues();
print( "Error in fieldInfo query: " . $this->getErrors() );
return false;
}
- if ( $meta = $this->fetchRow( $res ) ) {
+ $meta = $this->fetchRow( $res );
+ if ( $meta ) {
return new MssqlField( $meta );
}
return false;
$x1 = $xoff + (int)(($numer + ($xlim-$xoff)*$chunk) / $nchunks);
for ( ; $x < $x1; $x++) {
$line = $flip ? $this->yv[$x] : $this->xv[$x];
- if (empty($ymatches[$line]))
- continue;
+ if (empty($ymatches[$line])) {
+ continue;
+ }
$matches = $ymatches[$line];
reset($matches);
while ( list( $junk, $y ) = each( $matches ) ) {
$retVal = array();
if ( $db->numRows( $res ) ) {
foreach ( $res as $row ) {
- if ( $titleObj = Title::newFromRow( $row ) ) {
+ $titleObj = Title::newFromRow( $row )
+ if ( $titleObj ) {
$linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest );
$retVal[] = $titleObj;
}
}
$key = $this->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $name );
- if ( $thumbUrl = $wgMemc->get($key) ) {
+ $thumbUrl = $wgMemc->get($key);
+ if ( $thumbUrl ) {
wfDebug("Got thumb from local cache. $thumbUrl \n");
return $thumbUrl;
}
$len = $chunk + 1; # Counting down is faster. I'm *so* sorry.
for( $i = -1; --$len; ) {
- if( $remaining = $tailBytes[$c = $str{++$i}] ) {
+ $remaining = $tailBytes[$c = $str{++$i}]
+ if( $remaining ) {
# UTF-8 head byte!
$sequence = $head = $c;
do {
if ( $ns === NS_MEDIAWIKI ) {
return wfEmptyMsg( $page ) ? '' : wfMsgExt( $page, 'content' );
}
- if ( $title = Title::newFromText( $page, $ns ) ) {
+ $title = Title::newFromText( $page, $ns );
+ if ( $title ) {
if ( $title->isValidCssJsSubpage() && $revision = Revision::newFromTitle( $title ) ) {
return $revision->getRawText();
}
$scripts = '';
foreach ( $this->getPages( $context ) as $page => $options ) {
if ( $options['type'] === 'script' ) {
- if ( $script = $this->getContent( $page, $options['ns'] ) ) {
+ $script = $this->getContent( $page, $options['ns'] );
+ if ( $script ) {
$ns = MWNamespace::getCanonicalName( $options['ns'] );
$scripts .= "/*$ns:$page */\n$script\n";
}
foreach ( $this->getPages( $context ) as $page => $options ) {
if ( $options['type'] === 'style' ) {
$media = isset( $options['media'] ) ? $options['media'] : 'all';
- if ( $style = $this->getContent( $page, $options['ns'] ) ) {
+ $style = $this->getContent( $page, $options['ns'] );
+ if ( $style ) {
if ( !isset( $styles[$media] ) ) {
$styles[$media] = '';
}
array ('LIMIT' => 2, 'OFFSET' => $maxPerSubpage - 1, 'ORDER BY' => 'page_title ASC')
);
- if( $s = $dbr->fetchObject( $res ) ) {
+ $s = $dbr->fetchObject( $res );
+ if( $s ) {
array_push( $lines, $s->page_title );
} else {
// Final chunk, but ended prematurely. Go back and find the end.
array_push( $lines, $endTitle );
$done = true;
}
- if( $s = $res->fetchObject() ) {
+ $s = $res->fetchObject();
+ if( $s ) {
array_push( $lines, $s->page_title );
$lastTitle = $s->page_title;
} else {
if( $this->templates ) {
$pageSet = $this->getTemplates( $inputPages, $pageSet );
}
-
- if( $linkDepth = $this->pageLinkDepth ) {
+ $linkDepth = $this->pageLinkDepth;
+ if( $linkDepth ) {
$pageSet = $this->getPageLinks( $inputPages, $pageSet, $linkDepth );
}
# Hardcode this for now.
$limit = 48;
-
- if ( $parval = intval( $par ) ) {
+ $parval = intval( $par );
+ if ( $parval ) {
if ( $parval <= $limit && $parval > 0 ) {
$limit = $parval;
}
}
$invertSort = false;
- if( $until = $wgRequest->getVal( 'until' ) ) {
+ $until = $wgRequest->getVal( 'until' );
+ if( $until ) {
$where[] = "img_timestamp < '" . $dbr->timestamp( $until ) . "'";
}
- if( $from = $wgRequest->getVal( 'from' ) ) {
+ $from = $wgRequest->getVal( 'from' );
+ if( $from ) {
$where[] = "img_timestamp >= '" . $dbr->timestamp( $from ) . "'";
$invertSort = true;
}
$query_options = array();
// left join with watchlist table to highlight watched rows
- if( $uid = $wgUser->getId() ) {
+ $uid = $wgUser->getId();
+ if( $uid ) {
$tables[] = 'watchlist';
$select[] = 'wl_user';
$join_conds['watchlist'] = array( 'LEFT JOIN', "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace" );
$out .= '<tr><td colspan="4">' . $this->listToText( $wgExtensionFunctions ) . "</td></tr>\n";
}
- if ( $cnt = count( $tags = $wgParser->getTags() ) ) {
+ $tags = $wgParser->getTags();
+ $cnt = count( $tags );
+
+ if ( $cnt ) {
for ( $i = 0; $i < $cnt; ++$i ) {
$tags[$i] = "<{$tags[$i]}>";
}
if ( !$f ) {
$this->error( "Can't open file $file\n", true );
}
- while ( $path = trim( fgets( $f ) ) ) {
+ $path = trim( fgets( $f ) );
+ while ( $path ) {
$this->addPath( $path );
}
fclose( $f );
} elseif ( $this->hasOption( 'modified' ) ) {
$this->output( "Retrieving list from Subversion... " );
$parentDir = wfEscapeShellArg( dirname( __FILE__ ) . '/..' );
+ $retval = null;
$output = wfShellExec( "svn status --ignore-externals $parentDir", $retval );
if ( $retval ) {
$this->error( "Error retrieving list from Subversion!\n", true );
*/
private function getHooksFromPath( $path ) {
$hooks = array();
- if ( $dh = opendir( $path ) ) {
+ $dh = opendir( $path );
+ if ( $dh ) {
while ( ( $file = readdir( $dh ) ) !== false ) {
if ( filetype( $path . $file ) == 'file' ) {
$hooks = array_merge( $hooks, $this->getHooksFromFile( $path . $file ) );
*/
private function getBadHooksFromPath( $path ) {
$hooks = array();
- if ( $dh = opendir( $path ) ) {
+ $dh = opendir( $path );
+ if ( $dh ) {
while ( ( $file = readdir( $dh ) ) !== false ) {
# We don't want to read this file as it contains bad calls to wfRunHooks()
if ( filetype( $path . $file ) == 'file' && !$path . $file == __FILE__ ) {
*/
function findFiles( $dir, $exts ) {
if ( is_dir( $dir ) ) {
- if ( $dhl = opendir( $dir ) ) {
+ $dhl = opendir( $dir );
+ if ( $dhl ) {
$files = array();
while ( ( $file = readdir( $dhl ) ) !== false ) {
if ( is_file( $dir . '/' . $file ) ) {
$row->title .= $suffix;
$this->output( "... *** new title {$row->title}\n" );
$title = Title::makeTitleSafe( $row->namespace, $row->title );
- if ( ! $title ) {
+ if ( !$title ) {
$this->output( "... !!! invalid title\n" );
return false;
}
- if ( $id = $title->getArticleId() ) {
+ $id = $title->getArticleId();
+ if ( $id ) {
$this->output( "... *** page exists with ID $id ***\n" );
} else {
break;
"AND rev_timestamp<'{$emit}' ORDER BY rev_timestamp DESC";
$sql2 = $dbw->limitResult( $sql2, 1, false );
$res2 = $dbw->query( $sql2 );
- if ( $row = $dbw->fetchObject( $res2 ) ) {
+ $row = $dbw->fetchObject( $res2 );
+ if ( $row ) {
$lastOldId = intval( $row->rev_id );
# Grab the last text size if available
$lastSize = !is_null( $row->rev_len ) ? intval( $row->rev_len ) : 'NULL';
}
$link = $this->mTitle->getText();
- if( $nstext = $wgContLang->getNsText( $tns ) ) { # add namespace if necessary
+ $nstext = $wgContLang->getNsText( $tns );
+ if( $nstext ) { # add namespace if necessary
$link = $nstext . ':' . $link;
}
$wgUser->isAllowed( 'deletedhistory' ) &&
$wgUser->isAllowed( 'undelete' )
) {
- if( $n = $this->mTitle->isDeleted() ) {
+ $n = $this->mTitle->isDeleted();
+ if( $n ) {
$undelTitle = SpecialPage::getTitleFor( 'Undelete' );
$links['actions']['undelete'] = array(
'class' => false,