$localSettings = str_replace( "\r\n", "\n", $localSettings );
$f = fopen( "LocalSettings.php", 'xt' );
- if( $f == false ) {
+ if( !$f ) {
print( "</li>\n" );
dieout( "<p>Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
"<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
}
public function add( $key, $value, $exptime = 0 ) {
- if ( $this->get( $key ) == false ) {
+ if ( !$this->get( $key ) ) {
$this->set( $key, $value, $exptime );
return true;
}
function getBaseRevision() {
- if ( $this->mBaseRevision == false ) {
+ if ( !$this->mBaseRevision ) {
$db = wfGetDB( DB_MASTER );
$baseRevision = Revision::loadFromTimestamp(
$db, $this->mTitle, $this->edittime );
pclose( $handle );
unlink( $mytextName ); unlink( $oldtextName ); unlink( $yourtextName );
- if ( $result === '' && $old !== '' && $conflict == false ) {
+ if ( $result === '' && $old !== '' && !$conflict ) {
wfDebug( "Unexpected null result from diff3. Command: $cmd\n" );
$conflict = true;
}
* @param $f Boolean: set to false to disable.
*/
function setShowBytes( $f ) {
- $this->mShowBytes = ( $f == true);
+ $this->mShowBytes = $f;
}
/**
* @param $f Boolean: set to false to disable.
*/
function setShowFilename( $f ) {
- $this->mShowFilename = ( $f == true);
+ $this->mShowFilename = $f;
}
/**
var $mParseWarnings = array();
var $mSquidMaxage = 0;
var $mRevisionId = null;
+ var $mPageIcons = array();
protected $mTitle = null;
/**
$this->addCategoryLinks( $parserOutput->getCategories() );
$this->mNewSectionLink = $parserOutput->getNewSection();
$this->mHideNewSectionLink = $parserOutput->getHideNewSection();
+ $this->mPageIcons = $parserOutput->getPageIcons();
$this->mParseWarnings = $parserOutput->getWarnings();
if ( !$parserOutput->isCacheable() ) {
$tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) );
$tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
+ $icons = '';
+ foreach( $out->mPageIcons as $icon ) {
+ list( $file, $alt ) = $icon;
+ $fileAttr = array( 'src' => $file->createThumb( 16 ) );
+ if( $alt != '' ) {
+ $msg = wfMsg( $alt );
+ if( !wfEmptyMsg( $alt ) ) {
+ $alt = $msg;
+ }
+ $fileAttr['alt'] = htmlspecialchars( $alt );
+ }
+ $icons .= Html::element( 'img', $fileAttr ) . " ";
+ }
+ $tpl->set( 'pageicons', $icons );
+
$nsname = MWNamespace::exists( $this->mTitle->getNamespace() ) ?
MWNamespace::getCanonicalName( $this->mTitle->getNamespace() ) :
$this->mTitle->getNsText();
$this->mRestriction = $restriction;
$this->mListed = $listed;
$this->mIncludable = $includable;
- if ( $function == false ) {
+ if ( !$function ) {
$this->mFunction = 'wfSpecial'.$name;
} else {
$this->mFunction = $function;
}
// internal links should point to same variant as current page (only anonymous users)
- if ( $variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) {
+ if ( !$variant && $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) {
$pref = $wgContLang->getPreferredVariant( false );
if ( $pref != $wgContLang->getCode() )
$variant = $pref;
$dbkey = wfUrlencode( $this->getPrefixedDBkey() );
if ( $query == '' ) {
if ( $variant != false && $wgContLang->hasVariants() ) {
- if ( $wgVariantArticlePath == false ) {
+ if ( !$wgVariantArticlePath ) {
$variantArticlePath = "$wgScript?title=$1&variant=$2"; // default
} else {
$variantArticlePath = $wgVariantArticlePath;
$scBlockExpiryOptions = wfMsg( 'ipboptions' );
foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
- if ( strpos( $option, ':' ) == false )
+ if ( !strpos( $option, ':' ) )
continue;
list ( $show, $value ) = explode( ":", $option );
$expiryarray[$p[0]] = Block::infinity();
} else {
$exp = strtotime( $expiry[$i] );
- if ( $exp < 0 || $exp == false ) {
+ if ( $exp < 0 || !$exp ) {
$this->dieUsageMsg( array( 'invalidexpiry', $expiry[$i] ) );
}
// Rather, turn autocommit off in the begin function and turn on after a commit
db2_autocommit($this->mConn, DB2_AUTOCOMMIT_ON);
- if ( $this->mConn == false ) {
+ if ( !$this->mConn ) {
$this->installPrint( "DB connection error\n" );
$this->installPrint( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" );
$this->installPrint( $this->lastError()."\n" );
$this->mConn = oci_connect( $user, $password, $dbName, $this->defaultCharset, $session_mode );
}
- if ( $this->mConn == false ) {
+ if ( !$this->mConn ) {
wfDebug( "DB connection error\n" );
wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" );
wfDebug( $this->lastError() . "\n" );
return false;
}
- if ( oci_execute( $stmt, $this->execFlags() ) == false ) {
+ if ( !oci_execute( $stmt, $this->execFlags() ) ) {
$e = oci_error( $stmt );
if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) {
$this->reportQueryError( $e['message'], $e['code'], $sql, __FUNCTION__ );
// Avoid the non-standard "REPLACE INTO" syntax
echo "<li>Populating interwiki table</li>\n";
$f = fopen( "../maintenance/interwiki.sql", 'r' );
- if ( $f == false ) {
+ if ( !$f ) {
dieout( "Could not find the interwiki.sql file" );
}
$this->mConn = pg_connect( $connectString );
$phpError = $this->restoreErrorHandler();
- if ( $this->mConn == false ) {
+ if ( !$this->mConn ) {
wfDebug( "DB connection error\n" );
wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" );
wfDebug( $this->lastError()."\n" );
$connectVars['password'] = $password;
@$this->mConn = pg_connect( $this->makeConnectionString( $connectVars ) );
- if ( $this->mConn == false ) {
+ if ( $this->mConn ) {
print "<b>FAILED TO CONNECT!</b></li>";
dieout("</ul>");
}
echo "<li>Populating interwiki table... ";
## Avoid the non-standard "REPLACE INTO" syntax
$f = fopen( "../maintenance/interwiki.sql", 'r' );
- if ($f == false ) {
+ if ( $f ) {
print "<b>FAILED</b></li>";
dieout( "Could not find the interwiki.sql file" );
}
# Use DatabasePostgres's code to populate interwiki from MySQL template
$f = fopen( "$IP/maintenance/interwiki.sql", 'r' );
- if ( $f == false ) {
+ if ( !$f ) {
dieout( "Could not find the interwiki.sql file." );
}
$parser->setFunctionHook( 'subjectpagenamee', array( __CLASS__, 'subjectpagenamee' ), SFH_NO_HASH );
$parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS );
$parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) );
+ $parser->setFunctionHook( 'pageicon', array( __CLASS__, 'pageicon' ) );
if ( $wgAllowDisplayTitle ) {
$parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), SFH_NO_HASH );
}
}
+ public static function pageicon( $parser, $name = '', $alt = '' ) {
+ $file = wfFindFile( $name );
+ if( $file ) {
+ $parser->mOutput->addPageIcon( $file, $alt );
+ }
+ return '';
+ }
+
/**
* Parser function to extension tag adaptor
*/
$mSections = array(), # Table of contents
$mProperties = array(), # Name/value pairs to be cached in the DB
$mTOCHTML = ''; # HTML of the TOC
- private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
+ private $mIndexPolicy = '', # 'index' or 'noindex'? Any other value will result in no change.
+ $mPageIcons = array(); # Array of icons to show for the page (like Protect, Featured, etc)
function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
$containsOldMagic = false, $titletext = '' )
function getWarnings() { return array_keys( $this->mWarnings ); }
function getIndexPolicy() { return $this->mIndexPolicy; }
function getTOCHTML() { return $this->mTOCHTML; }
+ function getPageIcons() { return $this->mPageIcons; }
function containsOldMagic() { return $this->mContainsOldMagic; }
function setText( $text ) { return wfSetVar( $this->mText, $text ); }
}
}
+ /**
+ * Add page icons to the parser output.
+ * @param File $file A valid file
+ * @param String $alt Alt text, if any
+ */
+ function addPageIcon( $file, $alt = '' ) {
+ $this->mPageIcons[] = array( $file, $alt );
+ }
+
/**
* Override the title to be used for display
* -- this is assumed to have been validated
}
$variants = $this->autoConvertToAllVariants( $link );
- if ( $variants == false ) { // give up
+ if ( !$variants ) { // give up
return;
}
'url_path' => array( 0, 'PATH' ),
'url_wiki' => array( 0, 'WIKI' ),
'url_query' => array( 0, 'QUERY' ),
+ 'pageicon' => array( 1, 'pageicon' ),
);
/**
$botgroups = $autopatrolgroups = array();
foreach ( $wgGroupPermissions as $group => $rights ) {
- if ( isset( $rights['bot'] ) && $rights['bot'] == true ) {
+ if ( isset( $rights['bot'] ) && $rights['bot'] ) {
$botgroups[] = $dbw->addQuotes( $group );
}
- if ( $wgUseRCPatrol && isset( $rights['autopatrol'] ) && $rights['autopatrol'] == true ) {
+ if ( $wgUseRCPatrol && isset( $rights['autopatrol'] ) && $rights['autopatrol'] ) {
$autopatrolgroups[] = $dbw->addQuotes( $group );
}
}
$rt = $wgArticle->followRedirect();
- if ( $rt == false || !is_object( $rt ) ) {
+ if ( !$rt || !is_object( $rt ) ) {
// $wgTitle is not a redirect
// Delete any redirect table entry for it
$dbw->delete( 'redirect', array( 'rd_from' => $id ),
while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) {
$offset = 0;
for ( ; ; ) {
- $job = ( $type == false ) ?
- Job::pop( $offset )
- : Job::pop_type( $type );
+ $job = !$type ? Job::pop( $offset ) : Job::pop_type( $type );
- if ( $job == false )
+ if ( !$job )
break;
wfWaitForSlaves( 5 );