massive double to single quotes conversion. I have not noticed any bug after a lot of testing

This commit is contained in:
Antoine Musso 2004-08-22 17:24:50 +00:00
parent 16514740cf
commit 3d60242fb5
49 changed files with 2439 additions and 2442 deletions

View file

@ -45,7 +45,7 @@ class Article {
$flagsField = $prefix . 'flags';
if ( isset( $row->$flagsField ) ) {
$flags = explode( ",", $row->$flagsField );
$flags = explode( ',', $row->$flagsField );
} else {
$flags = array();
}
@ -349,11 +349,11 @@ class Article {
$t = $this->mTitle->getPrefixedText();
if ( isset( $oldid ) ) {
$oldid = IntVal( $oldid );
$t .= ",oldid={$oldid}";
$t .= ',oldid='.$oldid;
}
if ( isset( $redirect ) ) {
$redirect = ($redirect == 'no') ? 'no' : 'yes';
$t .= ",redirect={$redirect}";
$t .= ',redirect='.$redirect;
}
$this->mContent = wfMsg( 'missingarticle', $t );
@ -371,6 +371,7 @@ class Article {
# not to by either the function parameter or the query
if ( ( 'no' != $redirect ) && ( false == $noredir ) ) {
$rt = Title::newFromRedirect( $s->cur_text );
# process if title object is valid and not special:userlogout
if ( $rt && ! ( $rt->getNamespace() == NS_SPECIAL && $rt->getText() == 'Userlogout' ) ) {
# Gotta hand redirects to special pages differently:
# Fill the HTTP response "Location" header and ignore
@ -482,7 +483,7 @@ class Article {
$this->mCounter = $s->cur_counter;
$this->mTimestamp = wfTimestamp(TS_MW,$s->cur_timestamp);
$this->mTouched = wfTimestamp(TS_MW,$s->cur_touched);
$this->mTitle->mRestrictions = explode( ",", trim( $s->cur_restrictions ) );
$this->mTitle->mRestrictions = explode( ',', trim( $s->cur_restrictions ) );
$this->mTitle->mRestrictionsLoaded = true;
} else { # oldid set, retrieve historical version
$s = $dbr->selectRow( 'old', $this->getOldContentFields(), array( 'old_id' => $oldid ),
@ -540,7 +541,7 @@ class Article {
if ( -1 == $this->mCounter ) {
$id = $this->getID();
$dbr =& $this->getDB();
$this->mCounter = $dbr->selectField( 'cur', 'cur_counter', "cur_id={$id}",
$this->mCounter = $dbr->selectField( 'cur', 'cur_counter', 'cur_id='.$id,
'Article::getCount', $this->getSelectOptions() );
}
return $this->mCounter;
@ -733,12 +734,12 @@ class Article {
$wgOut->addHTML( '<pre>'.htmlspecialchars($this->mContent)."\n</pre>" );
} else if ( $rt = Title::newFromRedirect( $text ) ) {
# Display redirect
$imageUrl = "$wgStylePath/images/redirect.png";
$imageUrl = $wgStylePath.'/images/redirect.png';
$targetUrl = $rt->escapeLocalURL();
$titleText = htmlspecialchars( $rt->getPrefixedText() );
$link = $sk->makeLinkObj( $rt );
$wgOut->addHTML( "<img valign=\"center\" src=\"$imageUrl\">" .
"<span class=\"redirectText\">$link</span>" );
$wgOut->addHTML( '<img valign="center" src="'.$imageUrl.'">' .
'<span class="redirectText">'.$link.'</span>' );
} else if ( $pcache ) {
# Display content and save to parser cache
$wgOut->addPrimaryWikiText( $text, $this );
@ -755,7 +756,7 @@ class Article {
{
$wgOut->addHTML( wfMsg ( 'markaspatrolledlink',
$sk->makeKnownLinkObj ( $this->mTitle, wfMsg ( 'markaspatrolledtext' ),
"action=markpatrolled&rcid={$rcid}" )
'action=markpatrolled&rcid='.$rcid )
) );
}
@ -1087,7 +1088,7 @@ class Article {
function validate () {
global $wgOut, $wgUseValidation;
if( $wgUseValidation ) {
$wgOut->setPagetitle( wfMsg( 'validate' ) . ": " . $this->mTitle->getPrefixedText() );
$wgOut->setPagetitle( wfMsg( 'validate' ) . ': ' . $this->mTitle->getPrefixedText() );
$wgOut->setRobotpolicy( 'noindex,follow' );
if( $this->mTitle->getNamespace() != 0 ) {
$wgOut->addHTML( wfMsg( 'val_validate_article_namespace_only' ) );
@ -1096,7 +1097,7 @@ class Article {
$v = new Validation;
$v->validate_form( $this->mTitle->getDBkey() );
} else {
$wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
$wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
}
}
@ -1210,7 +1211,7 @@ class Article {
);
$log = new LogPage( wfMsg( 'protectlogpage' ), wfMsg( 'protectlogtext' ) );
if ( $limit === "" ) {
if ( $limit === '' ) {
$log->addEntry( wfMsg( 'unprotectedarticle', $this->mTitle->getPrefixedText() ), $reason );
} else {
$log->addEntry( wfMsg( 'protectedarticle', $this->mTitle->getPrefixedText() ), $reason );
@ -1458,7 +1459,7 @@ class Article {
function doDelete( $reason ) {
global $wgOut, $wgUser, $wgLang;
$fname = 'Article::doDelete';
wfDebug( "$fname\n" );
wfDebug( $fname."\n" );
if ( $this->doDeleteArticle( $reason ) ) {
$deleted = $this->mTitle->getPrefixedText();
@ -1470,7 +1471,7 @@ class Article {
$loglink = $sk->makeKnownLink( $wgLang->getNsText( NS_WIKIPEDIA ) .
':' . wfMsg( 'dellogpage' ), wfMsg( 'deletionlog' ) );
$text = wfMsg( "deletedtext", $deleted, $loglink );
$text = wfMsg( 'deletedtext', $deleted, $loglink );
$wgOut->addHTML( '<p>' . $text . "</p>\n" );
$wgOut->returnToMain( false );
@ -1603,7 +1604,7 @@ class Article {
function rollback() {
global $wgUser, $wgLang, $wgOut, $wgRequest;
$fname = "Article::rollback";
$fname = 'Article::rollback';
if ( ! $wgUser->isSysop() ) {
$wgOut->sysopRequired();
@ -1979,7 +1980,7 @@ class Article {
$fname = 'Article::info';
if ( !$wgAllowPageInfo ) {
$wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
$wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
return;
}
@ -1991,18 +1992,18 @@ class Article {
$wl_clause = array( 'wl_title' => $wgTitle->getDBkey(), 'wl_namespace' => $basenamespace );
$fullTitle = $wgTitle->makeName($basenamespace, $wgTitle->getDBKey());
$wgOut->setPagetitle( $fullTitle );
$wgOut->setSubtitle( wfMsg( "infosubtitle" ));
$wgOut->setSubtitle( wfMsg( 'infosubtitle' ));
# first, see if the page exists at all.
$exists = $dbr->selectField( 'cur', 'COUNT(*)', $cur_clause, $fname, $this->getSelectOptions() );
if ($exists < 1) {
$wgOut->addHTML( wfMsg("noarticletext") );
$wgOut->addHTML( wfMsg('noarticletext') );
} else {
$numwatchers = $dbr->selectField( 'watchlist', 'COUNT(*)', $wl_clause, $fname,
$this->getSelectOptions() );
$wgOut->addHTML( "<ul><li>" . wfMsg("numwatchers", $numwatchers) . "</li>" );
$wgOut->addHTML( "<ul><li>" . wfMsg("numwatchers", $numwatchers) . '</li>' );
$old = $dbr->selectField( 'old', 'COUNT(*)', $old_clause, $fname, $this->getSelectOptions() );
$wgOut->addHTML( "<li>" . wfMsg("numedits", $old + 1) . "</li>");
$wgOut->addHTML( "<li>" . wfMsg('numedits', $old + 1) . '</li>');
# to find number of distinct authors, we need to do some
# funny stuff because of the cur/old table split:
@ -2028,9 +2029,9 @@ class Article {
# number of edits
if ($exists > 0) {
$old = $dbr->selectField( 'old', 'COUNT(*)', $old_clause, $fname, $this->getSelectOptions() );
$wgOut->addHTML( "<li>" . wfMsg("numtalkedits", $old + 1) . "</li>");
$wgOut->addHTML( '<li>' . wfMsg("numtalkedits", $old + 1) . '</li>');
}
$wgOut->addHTML( "<li>" . wfMsg("numauthors", $authors) . "</li>" );
$wgOut->addHTML( '<li>' . wfMsg("numauthors", $authors) . '</li>' );
# number of authors
if ($exists > 0) {
@ -2040,7 +2041,7 @@ class Article {
$old_clause + array( 'old_user_text<>' . $dbr->addQuotes( $cur_author ) ),
$fname, $this->getSelectOptions() );
$wgOut->addHTML( "<li>" . wfMsg("numtalkauthors", $authors) . "</li></ul>" );
$wgOut->addHTML( '<li>' . wfMsg('numtalkauthors', $authors) . '</li></ul>' );
}
}
}

View file

@ -47,7 +47,7 @@ class Block
}
# Get a ban from the DB, with either the given address or the given username
function load( $address = "", $user = 0, $killExpired = true )
function load( $address = '', $user = 0, $killExpired = true )
{
$fname = 'Block::load';
@ -62,7 +62,7 @@ class Block
}
$ipblocks = $db->tableName( 'ipblocks' );
if ( 0 == $user && $address=="" ) {
if ( 0 == $user && $address=='' ) {
$sql = "SELECT * from $ipblocks $options";
} elseif ($address=="") {
$sql = "SELECT * FROM $ipblocks WHERE ipb_user={$user} $options";
@ -174,7 +174,7 @@ class Block
$fname = 'Block::delete';
$dbw =& wfGetDB( DB_MASTER );
if ( $this->mAddress == "" ) {
if ( $this->mAddress == '' ) {
$condition = array( 'ipb_id' => $this->mId );
} else {
$condition = array( 'ipb_address' => $this->mAddress );

View file

@ -24,18 +24,18 @@ function showCreditsPage($article)
{
global $wgOut;
$fname = "showCreditsPage";
$fname = 'showCreditsPage';
wfProfileIn( $fname );
$wgOut->setPageTitle( $article->mTitle->getPrefixedText() );
$wgOut->setSubtitle( wfMsg( "creditspage" ) );
$wgOut->setSubtitle( wfMsg( 'creditspage' ) );
$wgOut->setArticleFlag( false );
$wgOut->setArticleRelated( true );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
if( $article->mTitle->getArticleID() == 0 ) {
$s = wfMsg( "nocredits" );
$s = wfMsg( 'nocredits' );
} else {
$s = getCredits($article, -1);
}
@ -159,14 +159,14 @@ function getContributorCredits($article, $cnt, $showIfMax) {
function creditLink($user_name, $link_text = '') {
global $wgUser, $wgLang;
$skin = $wgUser->getSkin();
return $skin->makeLink($wgLang->getNsText(NS_USER) . ":" . $user_name,
return $skin->makeLink($wgLang->getNsText(NS_USER) . ':' . $user_name,
(empty($link_text)) ? $user_name : $link_text);
}
function creditOthersLink($article) {
global $wgUser, $wgLang;
$skin = $wgUser->getSkin();
return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), "action=credits");
return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits');
}
?>

View file

@ -3,25 +3,25 @@
# This file deals with MySQL interface functions
# and query specifics/optimisations
#
require_once( "CacheManager.php" );
require_once( 'CacheManager.php' );
define( "LIST_COMMA", 0 );
define( "LIST_AND", 1 );
define( "LIST_SET", 2 );
define( 'LIST_COMMA', 0 );
define( 'LIST_AND', 1 );
define( 'LIST_SET', 2 );
# Number of times to re-try an operation in case of deadlock
define( "DEADLOCK_TRIES", 4 );
define( 'DEADLOCK_TRIES', 4 );
# Minimum time to wait before retry, in microseconds
define( "DEADLOCK_DELAY_MIN", 500000 );
define( 'DEADLOCK_DELAY_MIN', 500000 );
# Maximum time to wait before retry
define( "DEADLOCK_DELAY_MAX", 1500000 );
define( 'DEADLOCK_DELAY_MAX', 1500000 );
class Database {
#------------------------------------------------------------------------------
# Variables
#------------------------------------------------------------------------------
/* private */ var $mLastQuery = "";
/* private */ var $mLastQuery = '';
/* private */ var $mServer, $mUser, $mPassword, $mConn, $mDBname;
/* private */ var $mOut, $mOpened = false;
@ -143,7 +143,7 @@ class Database {
$success = false;
@/**/$this->mConn = mysql_connect( $server, $user, $password );
if ( $dbName != "" ) {
if ( $dbName != '' ) {
if ( $this->mConn !== false ) {
$success = @/**/mysql_select_db( $dbName, $this->mConn );
if ( !$success ) {
@ -184,7 +184,7 @@ class Database {
}
}
/* private */ function reportConnectionError( $msg = "")
/* private */ function reportConnectionError( $msg = '')
{
if ( $this->mFailFunction ) {
if ( !is_int( $this->mFailFunction ) ) {
@ -198,14 +198,14 @@ class Database {
# Usually aborts on failure
# If errors are explicitly ignored, returns success
function query( $sql, $fname = "", $tempIgnore = false )
function query( $sql, $fname = '', $tempIgnore = false )
{
global $wgProfiling, $wgCommandLineMode;
if ( $wgProfiling ) {
# generalizeSQL will probably cut down the query to reasonable
# logging size most of the time. The substr is really just a sanity check.
$profName = "query: " . substr( Database::generalizeSQL( $sql ), 0, 255 );
$profName = 'query: ' . substr( Database::generalizeSQL( $sql ), 0, 255 );
wfProfileIn( $profName );
}
@ -213,7 +213,7 @@ class Database {
if ( $this->debug() ) {
$sqlx = substr( $sql, 0, 500 );
$sqlx = wordwrap(strtr($sqlx,"\t\n"," "));
$sqlx = wordwrap(strtr($sqlx,"\t\n",' '));
wfDebug( "SQL: $sqlx\n" );
}
# Add a comment for easy SHOW PROCESSLIST interpretation
@ -287,7 +287,7 @@ class Database {
@/**/$row = mysql_fetch_object( $res );
# FIXME: HACK HACK HACK HACK debug
if( mysql_errno() ) {
wfDebugDieBacktrace( "Error in fetchObject(): " . htmlspecialchars( mysql_error() ) );
wfDebugDieBacktrace( 'Error in fetchObject(): ' . htmlspecialchars( mysql_error() ) );
}
return $row;
}
@ -295,7 +295,7 @@ class Database {
function fetchRow( $res ) {
@/**/$row = mysql_fetch_array( $res );
if (mysql_errno() ) {
wfDebugDieBacktrace( "Error in fetchRow(): " . htmlspecialchars( mysql_error() ) );
wfDebugDieBacktrace( 'Error in fetchRow(): ' . htmlspecialchars( mysql_error() ) );
}
return $row;
}
@ -303,7 +303,7 @@ class Database {
function numRows( $res ) {
@/**/$n = mysql_num_rows( $res );
if( mysql_errno() ) {
wfDebugDieBacktrace( "Error in numRows(): " . htmlspecialchars( mysql_error() ) );
wfDebugDieBacktrace( 'Error in numRows(): ' . htmlspecialchars( mysql_error() ) );
}
return $n;
}
@ -318,7 +318,7 @@ class Database {
# Simple UPDATE wrapper
# Usually aborts on failure
# If errors are explicitly ignored, returns success
function set( $table, $var, $value, $cond, $fname = "Database::set" )
function set( $table, $var, $value, $cond, $fname = 'Database::set' )
{
$table = $this->tableName( $table );
$sql = "UPDATE $table SET $var = '" .
@ -326,14 +326,14 @@ class Database {
return !!$this->query( $sql, DB_MASTER, $fname );
}
function getField( $table, $var, $cond="", $fname = "Database::get", $options = array() ) {
return $this->selectField( $table, $var, $cond, $fname = "Database::get", $options = array() );
function getField( $table, $var, $cond='', $fname = 'Database::get', $options = array() ) {
return $this->selectField( $table, $var, $cond, $fname = 'Database::get', $options = array() );
}
# Simple SELECT wrapper, returns a single field, input must be encoded
# Usually aborts on failure
# If errors are explicitly ignored, returns FALSE on failure
function selectField( $table, $var, $cond="", $fname = "Database::selectField", $options = array() )
function selectField( $table, $var, $cond='', $fname = 'Database::selectField', $options = array() )
{
if ( !is_array( $options ) ) {
$options = array( $options );
@ -385,19 +385,19 @@ class Database {
}
# SELECT wrapper
function select( $table, $vars, $conds="", $fname = "Database::select", $options = array() )
function select( $table, $vars, $conds='', $fname = 'Database::select', $options = array() )
{
if ( is_array( $vars ) ) {
$vars = implode( ",", $vars );
$vars = implode( ',', $vars );
}
if ($table!="")
$from = " FROM " .$this->tableName( $table );
if ($table!='')
$from = ' FROM ' .$this->tableName( $table );
else
$from = "";
$from = '';
list( $useIndex, $tailOpts ) = $this->makeSelectOptions( $options );
if ( $conds !== false && $conds != "" ) {
if ( $conds !== false && $conds != '' ) {
if ( is_array( $conds ) ) {
$conds = $this->makeList( $conds, LIST_AND );
}
@ -408,7 +408,7 @@ class Database {
return $this->query( $sql, $fname );
}
function getArray( $table, $vars, $conds, $fname = "Database::getArray", $options = array() ) {
function getArray( $table, $vars, $conds, $fname = 'Database::getArray', $options = array() ) {
return $this->selectRow( $table, $vars, $conds, $fname, $options );
}
@ -421,7 +421,7 @@ class Database {
# Takes an array of selected variables, and a condition map, which is ANDed
# e.g. selectRow( "cur", array( "cur_id" ), array( "cur_namespace" => 0, "cur_title" => "Astronomy" ) )
# would return an object where $obj->cur_id is the ID of the Astronomy article
function selectRow( $table, $vars, $conds, $fname = "Database::selectRow", $options = array() ) {
function selectRow( $table, $vars, $conds, $fname = 'Database::selectRow', $options = array() ) {
$options['LIMIT'] = 1;
$res = $this->select( $table, $vars, $conds, $fname, $options );
if ( $res === false || !$this->numRows( $res ) ) {
@ -441,17 +441,17 @@ class Database {
# as to avoid crashing php on some large strings.
# $sql = preg_replace ( "/'([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\"/", "'X'", $sql);
$sql = str_replace ( "\\\\", "", $sql);
$sql = str_replace ( "\\'", "", $sql);
$sql = str_replace ( "\\\"", "", $sql);
$sql = str_replace ( "\\\\", '', $sql);
$sql = str_replace ( "\\'", '', $sql);
$sql = str_replace ( "\\\"", '', $sql);
$sql = preg_replace ("/'.*'/s", "'X'", $sql);
$sql = preg_replace ('/".*"/s', "'X'", $sql);
# All newlines, tabs, etc replaced by single space
$sql = preg_replace ( "/\s+/", " ", $sql);
$sql = preg_replace ( "/\s+/", ' ', $sql);
# All numbers => N
$sql = preg_replace ('/-?[0-9]+/s', "N", $sql);
$sql = preg_replace ('/-?[0-9]+/s', 'N', $sql);
return $sql;
}
@ -459,10 +459,10 @@ class Database {
# Determines whether a field exists in a table
# Usually aborts on failure
# If errors are explicitly ignored, returns NULL on failure
function fieldExists( $table, $field, $fname = "Database::fieldExists" )
function fieldExists( $table, $field, $fname = 'Database::fieldExists' )
{
$table = $this->tableName( $table );
$res = $this->query( "DESCRIBE $table", DB_SLAVE, $fname );
$res = $this->query( 'DESCRIBE '.$table, DB_SLAVE, $fname );
if ( !$res ) {
return NULL;
}
@ -481,7 +481,7 @@ class Database {
# Determines whether an index exists
# Usually aborts on failure
# If errors are explicitly ignored, returns NULL on failure
function indexExists( $table, $index, $fname = "Database::indexExists" )
function indexExists( $table, $index, $fname = 'Database::indexExists' )
{
$info = $this->indexInfo( $table, $index, $fname );
if ( is_null( $info ) ) {
@ -491,12 +491,12 @@ class Database {
}
}
function indexInfo( $table, $index, $fname = "Database::indexInfo" ) {
function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
# SHOW INDEX works in MySQL 3.23.58, but SHOW INDEXES does not.
# SHOW INDEX should work for 3.x and up:
# http://dev.mysql.com/doc/mysql/en/SHOW_INDEX.html
$table = $this->tableName( $table );
$sql = "SHOW INDEX FROM $table";
$sql = 'SHOW INDEX FROM '.$table;
$res = $this->query( $sql, $fname );
if ( !$res ) {
return NULL;
@ -549,8 +549,8 @@ class Database {
return !$indexInfo->Non_unique;
}
function insertArray( $table, $a, $fname = "Database::insertArray", $options = array() ) {
return $this->insert( $table, $a, $fname = "Database::insertArray", $options = array() );
function insertArray( $table, $a, $fname = 'Database::insertArray', $options = array() ) {
return $this->insert( $table, $a, $fname = 'Database::insertArray', $options = array() );
}
# INSERT wrapper, inserts an array into a table
@ -560,7 +560,7 @@ class Database {
#
# Usually aborts on failure
# If errors are explicitly ignored, returns success
function insert( $table, $a, $fname = "Database::insert", $options = array() )
function insert( $table, $a, $fname = 'Database::insert', $options = array() )
{
# No rows to insert, easy just return now
if ( !count( $a ) ) {
@ -588,7 +588,7 @@ class Database {
if ( $first ) {
$first = false;
} else {
$sql .= ",";
$sql .= ',';
}
$sql .= '(' . $this->makeList( $row ) . ')';
}
@ -598,12 +598,12 @@ class Database {
return !!$this->query( $sql, $fname );
}
function updateArray( $table, $values, $conds, $fname = "Database::updateArray" ) {
function updateArray( $table, $values, $conds, $fname = 'Database::updateArray' ) {
return $this->update( $table, $values, $conds, $fname );
}
# UPDATE wrapper, takes a condition array and a SET array
function update( $table, $values, $conds, $fname = "Database::update" )
function update( $table, $values, $conds, $fname = 'Database::update' )
{
$table = $this->tableName( $table );
$sql = "UPDATE $table SET " . $this->makeList( $values, LIST_SET );
@ -622,13 +622,13 @@ class Database {
}
$first = true;
$list = "";
$list = '';
foreach ( $a as $field => $value ) {
if ( !$first ) {
if ( $mode == LIST_AND ) {
$list .= " AND ";
$list .= ' AND ';
} else {
$list .= ",";
$list .= ',';
}
} else {
$first = false;
@ -637,7 +637,7 @@ class Database {
$list .= "($value)";
} else {
if ( $mode == LIST_AND || $mode == LIST_SET ) {
$list .= "$field=";
$list .= $field.'=';
}
$list .= $this->addQuotes( $value );
}
@ -654,7 +654,7 @@ class Database {
function startTimer( $timeout )
{
global $IP;
if( function_exists( "mysql_thread_id" ) ) {
if( function_exists( 'mysql_thread_id' ) ) {
# This will kill the query if it's still running after $timeout seconds.
$tid = mysql_thread_id( $this->mConn );
exec( "php $IP/killthread.php $timeout $tid &>/dev/null &" );
@ -708,7 +708,7 @@ class Database {
# USE INDEX clause
# PostgreSQL doesn't have them and returns ""
function useIndexClause( $index ) {
return "USE INDEX ($index)";
return 'USE INDEX ('.$index.')';
}
# REPLACE query wrapper
@ -720,7 +720,7 @@ class Database {
# It may be more efficient to leave off unique indexes which are unlikely to collide.
# However if you do this, you run the risk of encountering errors which wouldn't have
# occurred in MySQL
function replace( $table, $uniqueIndexes, $rows, $fname = "Database::replace" ) {
function replace( $table, $uniqueIndexes, $rows, $fname = 'Database::replace' ) {
$table = $this->tableName( $table );
# Single row case
@ -728,15 +728,15 @@ class Database {
$rows = array( $rows );
}
$sql = "REPLACE INTO $table (" . implode( ',', array_flip( $rows[0] ) ) .") VALUES ";
$sql = "REPLACE INTO $table (" . implode( ',', array_flip( $rows[0] ) ) .') VALUES ';
$first = true;
foreach ( $rows as $row ) {
if ( $first ) {
$first = false;
} else {
$sql .= ",";
$sql .= ',';
}
$sql .= "(" . $this->makeList( $row ) . ")";
$sql .= '(' . $this->makeList( $row ) . ')';
}
return $this->query( $sql, $fname );
}
@ -754,7 +754,7 @@ class Database {
# join condition matches, set $conds='*'
#
# DO NOT put the join condition in $conds
function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = "Database::deleteJoin" ) {
function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'Database::deleteJoin' ) {
if ( !$conds ) {
wfDebugDieBacktrace( 'Database::deleteJoin() called with empty $conds' );
}
@ -763,7 +763,7 @@ class Database {
$joinTable = $this->tableName( $joinTable );
$sql = "DELETE $delTable FROM $delTable, $joinTable WHERE $delVar=$joinVar ";
if ( $conds != '*' ) {
$sql .= " AND " . $this->makeList( $conds, LIST_AND );
$sql .= ' AND ' . $this->makeList( $conds, LIST_AND );
}
return $this->query( $sql, $fname );
@ -773,7 +773,7 @@ class Database {
function textFieldSize( $table, $field ) {
$table = $this->tableName( $table );
$sql = "SHOW COLUMNS FROM $table LIKE \"$field\";";
$res = $this->query( $sql, "Database::textFieldSize" );
$res = $this->query( $sql, 'Database::textFieldSize' );
$row = $this->fetchObject( $res );
$this->freeResult( $res );
@ -790,14 +790,14 @@ class Database {
}
# Use $conds == "*" to delete all rows
function delete( $table, $conds, $fname = "Database::delete" ) {
function delete( $table, $conds, $fname = 'Database::delete' ) {
if ( !$conds ) {
wfDebugDieBacktrace( "Database::delete() called with no conditions" );
wfDebugDieBacktrace( 'Database::delete() called with no conditions' );
}
$table = $this->tableName( $table );
$sql = "DELETE FROM $table ";
if ( $conds != '*' ) {
$sql .= "WHERE " . $this->makeList( $conds, LIST_AND );
$sql .= 'WHERE ' . $this->makeList( $conds, LIST_AND );
}
return $this->query( $sql, $fname );
}
@ -809,17 +809,17 @@ class Database {
function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect' ) {
$destTable = $this->tableName( $destTable );
$srcTable = $this->tableName( $srcTable );
$sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ")" .
" SELECT " . implode( ',', $varMap ) .
$sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' .
' SELECT ' . implode( ',', $varMap ) .
" FROM $srcTable";
if ( $conds != '*' ) {
$sql .= " WHERE " . $this->makeList( $conds, LIST_AND );
$sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
}
return $this->query( $sql, $fname );
}
function limitResult($limit,$offset) {
return " LIMIT ".(is_numeric($offset)?"{$offset},":"")."{$limit} ";
return ' LIMIT '.(is_numeric($offset)?"{$offset},":"")."{$limit} ";
}
function wasDeadlock() {
@ -829,7 +829,7 @@ class Database {
function deadlockLoop() {
$myFname = 'Database::deadlockLoop';
$this->query( "BEGIN", $myFname );
$this->query( 'BEGIN', $myFname );
$args = func_get_args();
$function = array_shift( $args );
$oldIgnore = $dbw->ignoreErrors( true );
@ -856,11 +856,11 @@ class Database {
} while( $dbw->wasDeadlock && --$tries > 0 );
$this->ignoreErrors( $oldIgnore );
if ( $tries <= 0 ) {
$this->query( "ROLLBACK", $myFname );
$this->query( 'ROLLBACK', $myFname );
$this->reportQueryError( $error, $errno, $sql, $fname );
return false;
} else {
$this->query( "COMMIT", $myFname );
$this->query( 'COMMIT', $myFname );
return $retVal;
}
}
@ -869,7 +869,7 @@ class Database {
function masterPosWait( $file, $pos, $timeout ) {
$encFile = $this->strencode( $file );
$sql = "SELECT MASTER_POS_WAIT('$encFile', $pos, $timeout)";
$res = $this->query( $sql, "Database::masterPosWait" );
$res = $this->query( $sql, 'Database::masterPosWait' );
if ( $res && $row = $this->fetchRow( $res ) ) {
$this->freeResult( $res );
return $row[0];
@ -957,14 +957,14 @@ function wfEmergencyAbort( &$conn, $error ) {
global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding, $wgSiteNotice, $wgOutputEncoding;
if( !headers_sent() ) {
header( "HTTP/1.0 500 Internal Server Error" );
header( "Content-type: text/html; charset=$wgOutputEncoding" );
header( 'HTTP/1.0 500 Internal Server Error' );
header( 'Content-type: text/html; charset='.$wgOutputEncoding );
/* Don't cache error pages! They cause no end of trouble... */
header( "Cache-control: none" );
header( "Pragma: nocache" );
header( 'Cache-control: none' );
header( 'Pragma: nocache' );
}
$msg = $wgSiteNotice;
if($msg == "") $msg = wfMsgNoDB( "noconnect", $error );
if($msg == '') $msg = wfMsgNoDB( 'noconnect', $error );
$text = $msg;
if($wgUseFileCache) {
@ -975,20 +975,20 @@ function wfEmergencyAbort( &$conn, $error ) {
$t = Title::newFromURL( $title );
} elseif (@/**/$_REQUEST['search']) {
$search = $_REQUEST['search'];
echo wfMsgNoDB( "searchdisabled" );
echo wfMsgNoDB( "googlesearch", htmlspecialchars( $search ), $wgInputEncoding );
echo wfMsgNoDB( 'searchdisabled' );
echo wfMsgNoDB( 'googlesearch', htmlspecialchars( $search ), $wgInputEncoding );
wfErrorExit();
} else {
$t = Title::newFromText( wfMsgNoDB( "mainpage" ) );
$t = Title::newFromText( wfMsgNoDB( 'mainpage' ) );
}
}
$cache = new CacheManager( $t );
if( $cache->isFileCached() ) {
$msg = "<p style='color: red'><b>$msg<br />\n" .
wfMsgNoDB( "cachederror" ) . "</b></p>\n";
$msg = '<p style="color: red"><b>'.$msg."<br />\n" .
wfMsgNoDB( 'cachederror' ) . "</b></p>\n";
$tag = "<div id='article'>";
$tag = '<div id="article">';
$text = str_replace(
$tag,
$tag . $msg,

View file

@ -7,12 +7,12 @@
# Usually aborts on failure
# If errors are explicitly ignored, returns success
function wfQuery( $sql, $db, $fname = "" )
function wfQuery( $sql, $db, $fname = '' )
{
global $wgOut;
if ( !is_numeric( $db ) ) {
# Someone has tried to call this the old way
$wgOut->fatalError( wfMsgNoDB( "wrong_wfQuery_params", $db, $sql ) );
$wgOut->fatalError( wfMsgNoDB( 'wrong_wfQuery_params', $db, $sql ) );
}
$c =& wfGetDB( $db );
if ( $c !== false ) {
@ -22,7 +22,7 @@ function wfQuery( $sql, $db, $fname = "" )
}
}
function wfSingleQuery( $sql, $dbi, $fname = "" )
function wfSingleQuery( $sql, $dbi, $fname = '' )
{
$db =& wfGetDB( $dbi );
$res = $db->query($sql, $fname );
@ -200,7 +200,7 @@ function wfSetSQL( $table, $var, $value, $cond, $dbi = DB_MASTER )
}
}
function wfGetSQL( $table, $var, $cond="", $dbi = DB_LAST )
function wfGetSQL( $table, $var, $cond='', $dbi = DB_LAST )
{
$db =& wfGetDB( $dbi );
if ( $db !== false ) {
@ -230,7 +230,7 @@ function wfIndexExists( $table, $index, $dbi = DB_LAST )
}
}
function wfInsertArray( $table, $array, $fname = "wfInsertArray", $dbi = DB_MASTER )
function wfInsertArray( $table, $array, $fname = 'wfInsertArray', $dbi = DB_MASTER )
{
$db =& wfGetDB( $dbi );
if ( $db !== false ) {
@ -240,7 +240,7 @@ function wfInsertArray( $table, $array, $fname = "wfInsertArray", $dbi = DB_MAST
}
}
function wfGetArray( $table, $vars, $conds, $fname = "wfGetArray", $dbi = DB_LAST )
function wfGetArray( $table, $vars, $conds, $fname = 'wfGetArray', $dbi = DB_LAST )
{
$db =& wfGetDB( $dbi );
if ( $db !== false ) {
@ -250,7 +250,7 @@ function wfGetArray( $table, $vars, $conds, $fname = "wfGetArray", $dbi = DB_LAS
}
}
function wfUpdateArray( $table, $values, $conds, $fname = "wfUpdateArray", $dbi = DB_MASTER )
function wfUpdateArray( $table, $values, $conds, $fname = 'wfUpdateArray', $dbi = DB_MASTER )
{
$db =& wfGetDB( $dbi );
if ( $db !== false ) {

View file

@ -14,7 +14,7 @@
#
# Hashar
require_once( "Database.php" );
require_once( 'Database.php' );
class DatabasePgsql extends Database {
var $mInsertId = NULL;
@ -49,7 +49,7 @@ class DatabasePgsql extends Database {
$success = false;
if ( "" != $dbName ) {
if ( '' != $dbName ) {
# start a database connection
@$this->mConn = pg_connect("host=$server dbname=$dbName user=$user password=$password");
if ( $this->mConn == false ) {
@ -79,7 +79,7 @@ class DatabasePgsql extends Database {
return $this->mLastResult=pg_query( $this->mConn , $sql);
}
function queryIgnore( $sql, $fname = "" ) {
function queryIgnore( $sql, $fname = '' ) {
return $this->query( $sql, $fname, true );
}
@ -96,7 +96,7 @@ class DatabasePgsql extends Database {
# hashar : not sure if the following test really trigger if the object
# fetching failled.
if( pg_last_error($this->mConn) ) {
wfDebugDieBacktrace( "SQL error: " . htmlspecialchars( pg_last_error($this->mConn) ) );
wfDebugDieBacktrace( 'SQL error: ' . htmlspecialchars( pg_last_error($this->mConn) ) );
}
return $row;
}
@ -104,7 +104,7 @@ class DatabasePgsql extends Database {
function fetchRow( $res ) {
@$row = pg_fetch_array( $res );
if( pg_last_error($this->mConn) ) {
wfDebugDieBacktrace( "SQL error: " . htmlspecialchars( pg_last_error($this->mConn) ) );
wfDebugDieBacktrace( 'SQL error: ' . htmlspecialchars( pg_last_error($this->mConn) ) );
}
return $row;
}
@ -112,7 +112,7 @@ class DatabasePgsql extends Database {
function numRows( $res ) {
@$n = pg_num_rows( $res );
if( pg_last_error($this->mConn) ) {
wfDebugDieBacktrace( "SQL error: " . htmlspecialchars( pg_last_error($this->mConn) ) );
wfDebugDieBacktrace( 'SQL error: ' . htmlspecialchars( pg_last_error($this->mConn) ) );
}
return $n;
}
@ -134,7 +134,7 @@ class DatabasePgsql extends Database {
# Returns information about an index
# If errors are explicitly ignored, returns NULL on failure
function indexInfo( $table, $index, $fname = "Database::indexExists" )
function indexInfo( $table, $index, $fname = 'Database::indexExists' )
{
$sql = "SELECT indexname FROM pg_indexes WHERE tablename='$table'";
$res = $this->query( $sql, $fname );
@ -152,7 +152,7 @@ class DatabasePgsql extends Database {
function fieldInfo( $table, $field )
{
wfDebugDieBacktrace( "Database::fieldInfo() error : mysql_fetch_field() not implemented for postgre" );
wfDebugDieBacktrace( 'Database::fieldInfo() error : mysql_fetch_field() not implemented for postgre' );
/*
$res = $this->query( "SELECT * FROM '$table' LIMIT 1" );
$n = pg_num_fields( $res );
@ -167,7 +167,7 @@ class DatabasePgsql extends Database {
return false;*/
}
function insertArray( $table, $a, $fname = "Database::insertArray", $options = array() ) {
function insertArray( $table, $a, $fname = 'Database::insertArray', $options = array() ) {
# PostgreSQL doesn't support options
# We have a go at faking one of them
# TODO: DELAYED, LOW_PRIORITY
@ -193,7 +193,7 @@ class DatabasePgsql extends Database {
function startTimer( $timeout )
{
global $IP;
wfDebugDieBacktrace( "Database::startTimer() error : mysql_thread_id() not implemented for postgre" );
wfDebugDieBacktrace( 'Database::startTimer() error : mysql_thread_id() not implemented for postgre' );
/*$tid = mysql_thread_id( $this->mConn );
exec( "php $IP/killthread.php $timeout $tid &>/dev/null &" );*/
}
@ -219,7 +219,7 @@ class DatabasePgsql extends Database {
# Return the next in a sequence, save the value for retrieval via insertId()
function nextSequenceValue( $seqName ) {
$value = $this->getField(""," nextval('" . $seqName . "')");
$value = $this->getField(''," nextval('" . $seqName . "')");
$this->mInsertId = $value;
return $value;
}
@ -239,7 +239,7 @@ class DatabasePgsql extends Database {
# It may be more efficient to leave off unique indexes which are unlikely to collide.
# However if you do this, you run the risk of encountering errors which wouldn't have
# occurred in MySQL
function replace( $table, $uniqueIndexes, $rows, $fname = "Database::replace" ) {
function replace( $table, $uniqueIndexes, $rows, $fname = 'Database::replace' ) {
$table = $this->tableName( $table );
# Single row case
@ -256,7 +256,7 @@ class DatabasePgsql extends Database {
if ( $first ) {
$first = false;
} else {
$sql .= ") OR (";
$sql .= ') OR (';
}
if ( is_array( $index ) ) {
$first2 = true;
@ -265,15 +265,15 @@ class DatabasePgsql extends Database {
if ( $first2 ) {
$first2 = false;
} else {
$sql .= " AND ";
$sql .= ' AND ';
}
$sql .= "$col=" . $this->addQuotes( $row[$col] );
$sql .= $col.'=' . $this->addQuotes( $row[$col] );
}
} else {
$sql .= "$index=" . $this->addQuotes( $row[$index] );
$sql .= $index.'=' . $this->addQuotes( $row[$index] );
}
}
$sql .= ")";
$sql .= ')';
$this->query( $sql, $fname );
}
@ -294,9 +294,9 @@ class DatabasePgsql extends Database {
$joinTable = $this->tableName( $joinTable );
$sql = "DELETE FROM $delTable WHERE $delVar IN (SELECT $joinVar FROM $joinTable ";
if ( $conds != '*' ) {
$sql .= "WHERE " . $this->makeList( $conds, LIST_AND );
$sql .= 'WHERE ' . $this->makeList( $conds, LIST_AND );
}
$sql .= ")";
$sql .= ')';
$this->query( $sql, $fname );
}

View file

@ -1,17 +1,17 @@
<?php
define("DF_ALL", -1);
define("DF_NONE", 0);
define("DF_MDY", 1);
define("DF_DMY", 2);
define("DF_YMD", 3);
define("DF_ISO1", 4);
define("DF_LASTPREF", 4);
define('DF_ALL', -1);
define('DF_NONE', 0);
define('DF_MDY', 1);
define('DF_DMY', 2);
define('DF_YMD', 3);
define('DF_ISO1', 4);
define('DF_LASTPREF', 4);
define("DF_ISO2", 5);
define("DF_YDM", 6);
define("DF_DM", 7);
define("DF_MD", 8);
define("DF_LAST", 8);
define('DF_ISO2', 5);
define('DF_YDM', 6);
define('DF_DM', 7);
define('DF_MD', 8);
define('DF_LAST', 8);
# To do: preferences, OutputPage

View file

@ -10,7 +10,7 @@
# depends on it.
# This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
if( defined( "MEDIAWIKI" ) ) {
if( defined( 'MEDIAWIKI' ) ) {
$wgVersion = '1.4-prealpha';

View file

@ -8,27 +8,27 @@ define( 'DBO_TRX', 8 );
define( 'DBO_DEFAULT', 16 );
# Virtual namespaces; these don't appear in the page database:
define("NS_MEDIA", -2);
define("NS_SPECIAL", -1);
define('NS_MEDIA', -2);
define('NS_SPECIAL', -1);
# Real namespaces:
define("NS_MAIN", 0);
define("NS_TALK", 1);
define("NS_USER", 2);
define("NS_USER_TALK", 3);
define("NS_WP", 4);
define("NS_WIKIPEDIA", 4);
define("NS_WP_TALK", 5);
define("NS_WIKIPEDIA_TALK", 5);
define("NS_IMAGE", 6);
define("NS_IMAGE_TALK", 7);
define("NS_MEDIAWIKI", 8);
define("NS_MEDIAWIKI_TALK", 9);
define("NS_TEMPLATE", 10);
define("NS_TEMPLATE_TALK", 11);
define("NS_HELP", 12);
define("NS_HELP_TALK", 13);
define("NS_CATEGORY", 14);
define("NS_CATEGORY_TALK", 15);
define('NS_MAIN', 0);
define('NS_TALK', 1);
define('NS_USER', 2);
define('NS_USER_TALK', 3);
define('NS_WP', 4);
define('NS_WIKIPEDIA', 4);
define('NS_WP_TALK', 5);
define('NS_WIKIPEDIA_TALK', 5);
define('NS_IMAGE', 6);
define('NS_IMAGE_TALK', 7);
define('NS_MEDIAWIKI', 8);
define('NS_MEDIAWIKI_TALK', 9);
define('NS_TEMPLATE', 10);
define('NS_TEMPLATE_TALK', 11);
define('NS_HELP', 12);
define('NS_HELP_TALK', 13);
define('NS_CATEGORY', 14);
define('NS_CATEGORY_TALK', 15);
?>

View file

@ -20,16 +20,16 @@ class DifferenceEngine {
function showDiffPage()
{
global $wgUser, $wgTitle, $wgOut, $wgLang, $wgOnlySysopsCanPatrol, $wgUseRCPatrol;
$fname = "DifferenceEngine::showDiffPage";
$fname = 'DifferenceEngine::showDiffPage';
wfProfileIn( $fname );
$t = $wgTitle->getPrefixedText() . " (Diff: {$this->mOldid}, " .
"{$this->mNewid})";
$mtext = wfMsg( "missingarticle", $t );
$mtext = wfMsg( 'missingarticle', $t );
$wgOut->setArticleFlag( false );
if ( ! $this->loadText() ) {
$wgOut->setPagetitle( wfMsg( "errorpagetitle" ) );
$wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) );
$wgOut->addHTML( $mtext );
wfProfileOut( $fname );
return;
@ -41,10 +41,10 @@ class DifferenceEngine {
if( $oldTitle == $newTitle ) {
$wgOut->setPageTitle( $newTitle );
} else {
$wgOut->setPageTitle( $oldTitle . ", " . $newTitle );
$wgOut->setPageTitle( $oldTitle . ', ' . $newTitle );
}
$wgOut->setSubtitle( wfMsg( "difference" ) );
$wgOut->setRobotpolicy( "noindex,follow" );
$wgOut->setSubtitle( wfMsg( 'difference' ) );
$wgOut->setRobotpolicy( 'noindex,follow' );
if ( !( $this->mOldPage->userCanRead() && $this->mNewPage->userCanRead() ) ) {
$wgOut->loginToUse();
@ -55,7 +55,7 @@ class DifferenceEngine {
$sk = $wgUser->getSkin();
$talk = $wgLang->getNsText( NS_TALK );
$contribs = wfMsg( "contribslink" );
$contribs = wfMsg( 'contribslink' );
$this->mOldComment = $sk->formatComment($this->mOldComment);
$this->mNewComment = $sk->formatComment($this->mNewComment);
@ -64,23 +64,23 @@ class DifferenceEngine {
$newUserLink = $sk->makeLinkObj( Title::makeTitle( NS_USER, $this->mNewUser ), $this->mNewUser );
$oldUTLink = $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $this->mOldUser ), $talk );
$newUTLink = $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $this->mNewUser ), $talk );
$oldContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, "Contributions" ), $contribs,
"target=" . urlencode($this->mOldUser) );
$newContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, "Contributions" ), $contribs,
"target=" . urlencode($this->mNewUser) );
$oldContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Contributions' ), $contribs,
'target=' . urlencode($this->mOldUser) );
$newContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Contributions' ), $contribs,
'target=' . urlencode($this->mNewUser) );
if ( !$this->mNewid && $wgUser->isSysop() ) {
$rollback = "&nbsp;&nbsp;&nbsp;<strong>[" . $sk->makeKnownLinkObj( $wgTitle, wfMsg( "rollbacklink" ),
"action=rollback&from=" . urlencode($this->mNewUser) ) . "]</strong>";
$rollback = '&nbsp;&nbsp;&nbsp;<strong>[' . $sk->makeKnownLinkObj( $wgTitle, wfMsg( 'rollbacklink' ),
'action=rollback&from=' . urlencode($this->mNewUser) ) . ']</strong>';
} else {
$rollback = "";
$rollback = '';
}
if ( $wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->getID() != 0 &&
( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
{
$patrol = " [" . $sk->makeKnownLinkObj( $wgTitle, wfMsg( 'markaspatrolleddiff' ),
"action=markpatrolled&rcid={$this->mRcidMarkPatrolled}" ) . "]";
$patrol = ' [' . $sk->makeKnownLinkObj( $wgTitle, wfMsg( 'markaspatrolleddiff' ),
"action=markpatrolled&rcid={$this->mRcidMarkPatrolled}" ) . ']';
} else {
$patrol = "";
$patrol = '';
}
$oldHeader = "<strong>{$this->mOldtitle}</strong><br />$oldUserLink " .
@ -112,7 +112,7 @@ cellpadding='0' cellspacing='4px' class='diff'><tr>
{$ntitle}</td>
</tr>\n" );
if ( $wgUseExternalDiffEngine ) {
dl("php_wikidiff.so");
dl('php_wikidiff.so');
$wgOut->addHTML( wikidiff_do_diff( $otext, $ntext, 2) );
} else {
$ota = explode( "\n", $otext);
@ -132,12 +132,12 @@ cellpadding='0' cellspacing='4px' class='diff'><tr>
function loadText()
{
global $wgTitle, $wgOut, $wgLang;
$fname = "DifferenceEngine::loadText";
$fname = 'DifferenceEngine::loadText';
$dbr =& wfGetDB( DB_SLAVE );
if ( 0 == $this->mNewid || 0 == $this->mOldid ) {
$wgOut->setArticleFlag( true );
$this->mNewtitle = wfMsg( "currentrev" );
$this->mNewtitle = wfMsg( 'currentrev' );
$id = $wgTitle->getArticleID();
$s = $dbr->getArray( 'cur', array( 'cur_text', 'cur_user_text', 'cur_comment' ),
@ -162,7 +162,7 @@ cellpadding='0' cellspacing='4px' class='diff'><tr>
$t = $wgLang->timeanddate( $s->old_timestamp, true );
$this->mNewPage = Title::MakeTitle( $s->old_namespace, $s->old_title );
$this->mNewtitle = wfMsg( "revisionasof", $t );
$this->mNewtitle = wfMsg( 'revisionasof', $t );
$this->mNewUser = $s->old_user_text;
$this->mNewComment = $s->old_comment;
}
@ -188,7 +188,7 @@ cellpadding='0' cellspacing='4px' class='diff'><tr>
$this->mOldtext = Article::getRevisionText( $s );
$t = $wgLang->timeanddate( $s->old_timestamp, true );
$this->mOldtitle = wfMsg( "revisionasof", $t );
$this->mOldtitle = wfMsg( 'revisionasof', $t );
$this->mOldUser = $s->old_user_text;
$this->mOldComment = $s->old_comment;
@ -210,7 +210,7 @@ class _DiffOp {
var $closing;
function reverse() {
trigger_error("pure virtual", E_USER_ERROR);
trigger_error('pure virtual', E_USER_ERROR);
}
function norig() {
@ -809,7 +809,7 @@ class Diff
}
$lcs = $this->lcs();
trigger_error("Diff okay: LCS = $lcs", E_USER_NOTICE);
trigger_error('Diff okay: LCS = '.$lcs, E_USER_NOTICE);
}
}
@ -966,7 +966,7 @@ class DiffFormatter
elseif ($edit->type == 'change')
$this->_changed($edit->orig, $edit->closing);
else
trigger_error("Unknown edit type", E_USER_ERROR);
trigger_error('Unknown edit type', E_USER_ERROR);
}
$this->_end_block();
}
@ -1007,10 +1007,10 @@ class DiffFormatter
}
function _added($lines) {
$this->_lines($lines, ">");
$this->_lines($lines, '>');
}
function _deleted($lines) {
$this->_lines($lines, "<");
$this->_lines($lines, '<');
}
function _changed($orig, $closing) {
@ -1137,8 +1137,8 @@ class TableDiffFormatter extends DiffFormatter
}
function _block_header( $xbeg, $xlen, $ybeg, $ylen ) {
$l1 = wfMsg( "lineno", $xbeg );
$l2 = wfMsg( "lineno", $ybeg );
$l1 = wfMsg( 'lineno', $xbeg );
$l2 = wfMsg( 'lineno', $ybeg );
$r = '<tr><td colspan="2" align="left"><strong>'.$l1."</strong></td>\n" .
'<td colspan="2" align="left"><strong>'.$l2."</strong></td></tr>\n";
@ -1153,7 +1153,7 @@ class TableDiffFormatter extends DiffFormatter
function _end_block() {
}
function _lines( $lines, $prefix=' ', $color="white" ) {
function _lines( $lines, $prefix=' ', $color='white' ) {
}
function addedLine( $line ) {

View file

@ -13,8 +13,8 @@ class EditPage {
# Form values
var $save = false, $preview = false;
var $minoredit = false, $watchthis = false;
var $textbox1 = "", $textbox2 = "", $summary = "";
var $edittime = "", $section = "";
var $textbox1 = '', $textbox2 = '', $summary = '';
var $edittime = '', $section = '';
var $oldid = 0;
function EditPage( $article ) {
@ -47,18 +47,18 @@ class EditPage {
}
if ( wfReadOnly() ) {
if( $this->save || $this->preview ) {
$this->editForm( "preview" );
$this->editForm( 'preview' );
} else {
$wgOut->readOnlyPage( $this->mArticle->getContent( true ) );
}
return;
}
if ( $this->save ) {
$this->editForm( "save" );
$this->editForm( 'save' );
} else if ( $this->preview ) {
$this->editForm( "preview" );
$this->editForm( 'preview' );
} else { # First time through
$this->editForm( "initial" );
$this->editForm( 'initial' );
}
}
@ -66,12 +66,12 @@ class EditPage {
# These fields need to be checked for encoding.
# Also remove trailing whitespace, but don't remove _initial_
# whitespace from the text boxes. This may be significant formatting.
$this->textbox1 = rtrim( $request->getText( "wpTextbox1" ) );
$this->textbox2 = rtrim( $request->getText( "wpTextbox2" ) );
$this->summary = trim( $request->getText( "wpSummary" ) );
$this->textbox1 = rtrim( $request->getText( 'wpTextbox1' ) );
$this->textbox2 = rtrim( $request->getText( 'wpTextbox2' ) );
$this->summary = trim( $request->getText( 'wpSummary' ) );
$this->edittime = $request->getVal( 'wpEdittime' );
if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = "";
if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = '';
$this->preview = $request->getCheck( 'wpPreview' );
$this->save = $request->wasPosted() && !$this->preview;
@ -117,11 +117,11 @@ class EditPage {
$isCssJsSubpage = (Namespace::getUser() == $wgTitle->getNamespace() and preg_match("/\\.(css|js)$/", $wgTitle->getText() ));
if(!$this->mTitle->getArticleID()) { # new article
$wgOut->addWikiText(wfmsg("newarticletext"));
$wgOut->addWikiText(wfmsg('newarticletext'));
}
if( Namespace::isTalk( $this->mTitle->getNamespace() ) ) {
$wgOut->addWikiText(wfmsg("talkpagetext"));
$wgOut->addWikiText(wfmsg('talkpagetext'));
}
# Attempt submission here. This will check for edit conflicts,
@ -129,7 +129,7 @@ class EditPage {
# that edit() already checked just in case someone tries to sneak
# in the back door with a hand-edited submission URL.
if ( "save" == $formtype ) {
if ( 'save' == $formtype ) {
# Check for spam
if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
$this->spamPage ( $matches );
@ -156,8 +156,8 @@ class EditPage {
$aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
if ( 0 == $aid ) {
# Don't save a new article if it's blank.
if ( ( "" == $this->textbox1 ) ||
( wfMsg( "newarticletext" ) == $this->textbox1 ) ) {
if ( ( '' == $this->textbox1 ) ||
( wfMsg( 'newarticletext' ) == $this->textbox1 ) ) {
$wgOut->redirect( $this->mTitle->getFullURL() );
return;
}
@ -170,7 +170,7 @@ class EditPage {
$this->mArticle->clear(); # Force reload of dates, etc.
$this->mArticle->forUpdate( true ); # Lock the article
if( ( $this->section != "new" ) &&
if( ( $this->section != 'new' ) &&
($this->mArticle->getTimestamp() != $this->edittime ) ) {
$isConflict = true;
}
@ -190,7 +190,7 @@ class EditPage {
// Successful merge! Maybe we should tell the user the good news?
$isConflict = false;
} else {
$this->section = "";
$this->section = '';
$this->textbox1 = $text;
}
}
@ -231,33 +231,33 @@ class EditPage {
# First time through: get contents, set time for conflict
# checking, etc.
if ( "initial" == $formtype ) {
if ( 'initial' == $formtype ) {
$this->edittime = $this->mArticle->getTimestamp();
$this->textbox1 = $this->mArticle->getContent( true );
$this->summary = "";
$this->summary = '';
$this->proxyCheck();
}
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
# Enabled article-related sidebar, toplinks, etc.
$wgOut->setArticleRelated( true );
if ( $isConflict ) {
$s = wfMsg( "editconflict", $this->mTitle->getPrefixedText() );
$s = wfMsg( 'editconflict', $this->mTitle->getPrefixedText() );
$wgOut->setPageTitle( $s );
$wgOut->addHTML( wfMsg( "explainconflict" ) );
$wgOut->addHTML( wfMsg( 'explainconflict' ) );
$this->textbox2 = $this->textbox1;
$this->textbox1 = $this->mArticle->getContent( true );
$this->edittime = $this->mArticle->getTimestamp();
} else {
$s = wfMsg( "editing", $this->mTitle->getPrefixedText() );
$s = wfMsg( 'editing', $this->mTitle->getPrefixedText() );
if( $this->section != "" ) {
if( $this->section == "new" ) {
$s.=wfMsg("commentedit");
if( $this->section != '' ) {
if( $this->section == 'new' ) {
$s.=wfMsg('commentedit');
} else {
$s.=wfMsg("sectionedit");
$s.=wfMsg('sectionedit');
}
if(!$this->preview) {
$sectitle=preg_match("/^=+(.*?)=+/mi",
@ -271,49 +271,49 @@ class EditPage {
$wgOut->setPageTitle( $s );
if ( $this->oldid ) {
$this->mArticle->setOldSubtitle();
$wgOut->addHTML( wfMsg( "editingold" ) );
$wgOut->addHTML( wfMsg( 'editingold' ) );
}
}
if( wfReadOnly() ) {
$wgOut->addHTML( "<strong>" .
wfMsg( "readonlywarning" ) .
$wgOut->addHTML( '<strong>' .
wfMsg( 'readonlywarning' ) .
"</strong>" );
} else if ( $isCssJsSubpage and "preview" != $formtype) {
$wgOut->addHTML( wfMsg( "usercssjsyoucanpreview" ));
} else if ( $isCssJsSubpage and 'preview' != $formtype) {
$wgOut->addHTML( wfMsg( 'usercssjsyoucanpreview' ));
}
if( $this->mTitle->isProtected() ) {
$wgOut->addHTML( "<strong>" . wfMsg( "protectedpagewarning" ) .
$wgOut->addHTML( '<strong>' . wfMsg( 'protectedpagewarning' ) .
"</strong><br />\n" );
}
$kblength = (int)(strlen( $this->textbox1 ) / 1024);
if( $kblength > 29 ) {
$wgOut->addHTML( "<strong>" .
wfMsg( "longpagewarning", $kblength )
. "</strong>" );
$wgOut->addHTML( '<strong>' .
wfMsg( 'longpagewarning', $kblength )
. '</strong>' );
}
$rows = $wgUser->getOption( "rows" );
$cols = $wgUser->getOption( "cols" );
$rows = $wgUser->getOption( 'rows' );
$cols = $wgUser->getOption( 'cols' );
$ew = $wgUser->getOption( "editwidth" );
$ew = $wgUser->getOption( 'editwidth' );
if ( $ew ) $ew = " style=\"width:100%\"";
else $ew = "" ;
else $ew = '';
$q = "action=submit";
$q = 'action=submit';
#if ( "no" == $redirect ) { $q .= "&redirect=no"; }
$action = $this->mTitle->escapeLocalURL( $q );
$summary = wfMsg( "summary" );
$subject = wfMsg("subject");
$minor = wfMsg( "minoredit" );
$watchthis = wfMsg ("watchthis");
$save = wfMsg( "savearticle" );
$prev = wfMsg( "showpreview" );
$summary = wfMsg('summary');
$subject = wfMsg('subject');
$minor = wfMsg('minoredit');
$watchthis = wfMsg ('watchthis');
$save = wfMsg('savearticle');
$prev = wfMsg('showpreview');
$cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(),
wfMsg( "cancel" ) );
wfMsg('cancel') );
$edithelpurl = $sk->makeUrl( wfMsg( 'edithelppage' ));
$edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
@ -321,21 +321,21 @@ class EditPage {
global $wgRightsText;
$copywarn = "<div id=\"editpage-copywarn\">\n" .
wfMsg( $wgRightsText ? "copyrightwarning" : "copyrightwarning2",
"[[" . wfMsg( "copyrightpage" ) . "]]",
wfMsg( $wgRightsText ? 'copyrightwarning' : 'copyrightwarning2',
'[[' . wfMsg( 'copyrightpage' ) . ']]',
$wgRightsText ) . "\n</div>";
if( $wgUser->getOption("showtoolbar") and !$isCssJsSubpage ) {
if( $wgUser->getOption('showtoolbar') and !$isCssJsSubpage ) {
# prepare toolbar for edit buttons
$toolbar = $sk->getEditToolbar();
} else {
$toolbar = "";
$toolbar = '';
}
// activate checkboxes if user wants them to be always active
if( !$this->preview ) {
if( $wgUser->getOption( "watchdefault" ) ) $this->watchthis = true;
if( $wgUser->getOption( "minordefault" ) ) $this->minoredit = true;
if( $wgUser->getOption( 'watchdefault' ) ) $this->watchthis = true;
if( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true;
// activate checkbox also if user is already watching the page,
// require wpWatchthis to be unset so that second condition is not
@ -343,7 +343,7 @@ class EditPage {
if( !$this->watchthis && $this->mTitle->userIsWatching() ) $this->watchthis = true;
}
$minoredithtml = "";
$minoredithtml = '';
if ( 0 != $wgUser->getID() || $wgAllowAnonymousMinor ) {
$minoredithtml =
@ -352,7 +352,7 @@ class EditPage {
"<label for='wpMinoredit' title='".wfMsg('tooltip-minoredit')."'>{$minor}</label>";
}
$watchhtml = "";
$watchhtml = '';
if ( 0 != $wgUser->getID() ) {
$watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'".($this->watchthis?" checked='checked'":"").
@ -360,13 +360,13 @@ class EditPage {
"<label for='wpWatchthis' title='".wfMsg('tooltip-watch')."'>{$watchthis}</label>";
}
$checkboxhtml = $minoredithtml . $watchhtml . "<br />";
$checkboxhtml = $minoredithtml . $watchhtml . '<br />';
if ( "preview" == $formtype) {
$previewhead="<h2>" . wfMsg( "preview" ) . "</h2>\n<p><center><font color=\"#cc0000\">" .
wfMsg( "note" ) . wfMsg( "previewnote" ) . "</font></center></p>\n";
if ( 'preview' == $formtype) {
$previewhead='<h2>' . wfMsg( 'preview' ) . "</h2>\n<p><center><font color=\"#cc0000\">" .
wfMsg( 'note' ) . wfMsg( 'previewnote' ) . "</font></center></p>\n";
if ( $isConflict ) {
$previewhead.="<h2>" . wfMsg( "previewconflict" ) .
$previewhead.='<h2>' . wfMsg( 'previewconflict' ) .
"</h2>\n";
}
@ -391,7 +391,7 @@ class EditPage {
$wgTitle, $parserOptions );
$previewHTML = $parserOutput->mText;
if($wgUser->getOption("previewontop")) {
if($wgUser->getOption('previewontop')) {
$wgOut->addHTML($previewhead);
$wgOut->addHTML($previewHTML);
}
@ -404,17 +404,17 @@ class EditPage {
# if this is a comment, show a subject line at the top, which is also the edit summary.
# Otherwise, show a summary field at the bottom
$summarytext = htmlspecialchars( $wgLang->recodeForEdit( $this->summary ) ); # FIXME
if( $this->section == "new" ) {
if( $this->section == 'new' ) {
$commentsubject="{$subject}: <input tabindex='1' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
$editsummary = "";
$editsummary = '';
} else {
$commentsubject = "";
$commentsubject = '';
$editsummary="{$summary}: <input tabindex='3' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
}
if( !$this->preview ) {
# Don't select the edit box on preview; this interferes with seeing what's going on.
$wgOut->setOnloadHandler( "document.editform.wpTextbox1.focus()" );
$wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' );
}
# Prepare a list of templates used by this page
$db =& wfGetDB( DB_SLAVE );
@ -434,7 +434,7 @@ class EditPage {
}
$templates .= '</ul>';
} else {
$templates = "";
$templates = '';
}
$wgOut->addHTML( "
{$toolbar}
@ -481,8 +481,8 @@ htmlspecialchars( $wgLang->recodeForEdit( $this->textbox1 ) ) .
{
global $wgOut, $wgUser, $wgLang, $wgIP;
$wgOut->setPageTitle( wfMsg( "blockedtitle" ) );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setPageTitle( wfMsg( 'blockedtitle' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$id = $wgUser->blockedBy();
@ -494,10 +494,10 @@ htmlspecialchars( $wgLang->recodeForEdit( $this->textbox1 ) ) .
} else {
$name = $id;
}
$link = "[[" . $wgLang->getNsText( Namespace::getUser() ) .
$link = '[[' . $wgLang->getNsText( Namespace::getUser() ) .
":{$name}|{$name}]]";
$wgOut->addWikiText( wfMsg( "blockedtext", $link, $reason, $ip, $name ) );
$wgOut->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
$wgOut->returnToMain( false );
}
@ -507,19 +507,19 @@ htmlspecialchars( $wgLang->recodeForEdit( $this->textbox1 ) ) .
{
global $wgOut, $wgUser, $wgLang;
$wgOut->setPageTitle( wfMsg( "whitelistedittitle" ) );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikiText( wfMsg( "whitelistedittext" ) );
$wgOut->addWikiText( wfMsg( 'whitelistedittext' ) );
$wgOut->returnToMain( false );
}
function spamPage ( $matches = array() )
{
global $wgOut;
$wgOut->setPageTitle( wfMsg( "spamprotectiontitle" ) );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikiText( wfMsg( 'spamprotectiontext' ) );
@ -543,7 +543,7 @@ htmlspecialchars( $wgLang->recodeForEdit( $this->textbox1 ) ) .
# Get MemCached key
$skip = false;
if ( $wgUseMemCached ) {
$mcKey = "$wgDBname:proxy:ip:$wgIP";
$mcKey = $wgDBname.':proxy:ip:'.$wgIP;
$mcValue = $wgMemc->get( $mcKey );
if ( $mcValue ) {
$skip = true;
@ -552,12 +552,12 @@ htmlspecialchars( $wgLang->recodeForEdit( $this->textbox1 ) ) .
# Fork the processes
if ( !$skip ) {
$title = Title::makeTitle( NS_SPECIAL, "Blockme" );
$title = Title::makeTitle( NS_SPECIAL, 'Blockme' );
$iphash = md5( $wgIP . $wgProxyKey );
$url = $title->getFullURL( "ip=$iphash" );
$url = $title->getFullURL( 'ip='.$iphash );
foreach ( $wgProxyPorts as $port ) {
$params = implode( " ", array(
$params = implode( ' ', array(
escapeshellarg( $wgProxyScriptPath ),
escapeshellarg( $wgIP ),
escapeshellarg( $port ),

View file

@ -90,10 +90,10 @@ function wfLocalUrl( $a, $q = '' )
if( '' == $q ) {
$a = $wgScript;
} else {
$a = "{$wgScript}?{$q}";
$a = $wgScript.'?'.$q;
}
} else if ( '' == $q ) {
$a = str_replace( "$1", $a, $wgArticlePath );
$a = str_replace( '$1', $a, $wgArticlePath );
} else if ($wgScript != '' ) {
$a = "{$wgScript}?title={$a}&{$q}";
} else { //XXX hackish solution for toplevel wikis
@ -202,7 +202,7 @@ function wfDebug( $text, $logonly = false )
if ( isset( $wgOut ) && $wgDebugComments && !$logonly ) {
$wgOut->debug( $text );
}
if ( "" != $wgDebugLogFile && !$wgProfileOnly ) {
if ( '' != $wgDebugLogFile && !$wgProfileOnly ) {
error_log( $text, 3, $wgDebugLogFile );
}
}
@ -211,7 +211,7 @@ function wfDebug( $text, $logonly = false )
function wfLogDBError( $text ) {
global $wgDBerrorLog;
if ( $wgDBerrorLog ) {
$text = date("D M j G:i:s T Y") . "\t$text";
$text = date('D M j G:i:s T Y') . "\t".$text;
error_log( $text, 3, $wgDBerrorLog );
}
}
@ -222,7 +222,7 @@ function logProfilingData()
global $wgProfiling, $wgProfileStack, $wgProfileLimit, $wgUser;
$now = wfTime();
list( $usec, $sec ) = explode( " ", $wgRequestTime );
list( $usec, $sec ) = explode( ' ', $wgRequestTime );
$start = (float)$sec + (float)$usec;
$elapsed = $now - $start;
if ( $wgProfiling ) {
@ -252,13 +252,13 @@ function logProfilingData()
function wfReadOnly() {
global $wgReadOnlyFile;
if ( "" == $wgReadOnlyFile ) {
if ( '' == $wgReadOnlyFile ) {
return false;
}
return is_file( $wgReadOnlyFile );
}
$wgReplacementKeys = array( "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9" );
$wgReplacementKeys = array( '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9' );
# Get a message from anywhere
function wfMsg( $key ) {
@ -357,10 +357,10 @@ function wfDebugDieBacktrace( $msg = '' ) {
if ( $wgCommandLineMode ) {
$msg .= "$file line {$call['line']} calls ";
} else {
$msg .= '<li>' . $file . " line " . $call['line'] . ' calls ';
$msg .= '<li>' . $file . ' line ' . $call['line'] . ' calls ';
}
if( !empty( $call['class'] ) ) $msg .= $call['class'] . '::';
$msg .= $call['function'] . "()";
$msg .= $call['function'] . '()';
if ( $wgCommandLineMode ) {
$msg .= "\n";
@ -400,13 +400,13 @@ function wfViewPrevNext( $offset, $limit, $link, $query = '', $atend = false )
$po = $offset - $limit;
if ( $po < 0 ) { $po = 0; }
$q = "limit={$limit}&offset={$po}";
if ( '' != $query ) { $q .= "&{$query}"; }
if ( '' != $query ) { $q .= '&'.$query; }
$plink = '<a href="' . wfLocalUrlE( $link, $q ) . "\">{$prev}</a>";
} else { $plink = $prev; }
$no = $offset + $limit;
$q = "limit={$limit}&offset={$no}";
if ( "" != $query ) { $q .= "&{$query}"; }
$q = 'limit='.$limit.'&offset='.$no;
if ( '' != $query ) { $q .= '&'.$query; }
if ( $atend ) {
$nlink = $next;
@ -426,8 +426,8 @@ function wfNumLink( $offset, $limit, $link, $query = '' )
{
global $wgUser, $wgLang;
if ( '' == $query ) { $q = ''; }
else { $q = "{$query}&"; }
$q .= "limit={$limit}&offset={$offset}";
else { $q = $query.'&'; }
$q .= 'limit='.$limit.'&offset='.$offset;
$fmtLimit = $wgLang->formatNum( $limit );
$s = '<a href="' . wfLocalUrlE( $link, $q ) . "\">{$fmtLimit}</a>";
@ -553,7 +553,7 @@ function wfArrayToCGI( $array1, $array2 = NULL )
if ( '' != $cgi ) {
$cgi .= '&';
}
$cgi .= "{$key}={$value}";
$cgi .= $key.'='.$value;
}
}
return $cgi;
@ -762,20 +762,20 @@ function wfTimestamp2Unix( $ts ) {
}
function wfUnix2Timestamp( $unixtime ) {
return gmdate( "YmdHis", $unixtime );
return gmdate( 'YmdHis', $unixtime );
}
function wfTimestampNow() {
# return NOW
return gmdate( "YmdHis" );
return gmdate( 'YmdHis' );
}
# Sorting hack for MySQL 3, which doesn't use index sorts for DESC
function wfInvertTimestamp( $ts ) {
return strtr(
$ts,
"0123456789",
"9876543210"
'0123456789',
'9876543210'
);
}
@ -805,9 +805,9 @@ function wfRestoreWarnings() {
}
# Autodetect, convert and provide timestamps of various types
define("TS_UNIX",0); # Standard unix timestamp (number of seconds since 1 Jan 1970)
define("TS_MW",1); # Mediawiki concatenated string timestamp (yyyymmddhhmmss)
define("TS_DB",2); # Standard database timestamp (yyyy-mm-dd hh:mm:ss)
define('TS_UNIX',0); # Standard unix timestamp (number of seconds since 1 Jan 1970)
define('TS_MW',1); # Mediawiki concatenated string timestamp (yyyymmddhhmmss)
define('TS_DB',2); # Standard database timestamp (yyyy-mm-dd hh:mm:ss)
function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
if (preg_match("/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/",$ts,$da)) {
@ -830,10 +830,10 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
return $uts;
break;
case TS_MW:
return gmdate( "YmdHis", $uts );
return gmdate( 'YmdHis', $uts );
break;
case TS_DB:
return gmdate( "Y-m-d H:i:s", $uts );
return gmdate( 'Y-m-d H:i:s', $uts );
break;
default:
return;

View file

@ -29,7 +29,7 @@ class Image
$this->title = Title::makeTitle( Namespace::getImage(), $this->name );
//$this->imagePath = wfImagePath( $name );
$hash = md5( $this->title->getDBkey() );
$this->imagePath = $wgUploadDirectory . "/" . $hash{0} . "/" .substr( $hash, 0, 2 ) . "/{$name}";
$this->imagePath = $wgUploadDirectory . '/' . $hash{0} . '/' .substr( $hash, 0, 2 ) . "/{$name}";
$this->url = $this->wfImageUrl( $name );
@ -41,8 +41,8 @@ class Image
$this->height = $gis[1];
$this->type = $gis[2];
$this->attr = $gis[3];
if ( isset( $gis["bits"] ) ) {
$this->bits = $gis["bits"];
if ( isset( $gis['bits'] ) ) {
$this->bits = $gis['bits'];
} else {
$this->bits = 0;
}
@ -109,7 +109,7 @@ class Image
return $this->fileExists;
}
function thumbUrl( $width, $subdir="thumb" ) {
function thumbUrl( $width, $subdir='thumb' ) {
global $wgUploadPath;
$name = $this->thumbName( $width );
@ -139,19 +139,19 @@ class Image
$width = IntVal( $width );
$thumbName = $this->thumbName( $width );
$thumbPath = wfImageThumbDir( $thumbName )."/".$thumbName;
$thumbPath = wfImageThumbDir( $thumbName ).'/'.$thumbName;
$thumbUrl = $this->thumbUrl( $width );
if ( ! $this->exists() )
{
# If there is no image, there will be no thumbnail
return "";
return '';
}
# Sanity check $width
if( $width <= 0 ) {
# BZZZT
return "";
return '';
}
if( $width > $this->width ) {
@ -196,7 +196,7 @@ class Image
$src_image = imagecreatefromxbm( $this->imagePath );
break;
default:
return "Image type not supported";
return 'Image type not supported';
break;
}
$height = floor( $this->height * ( $width/$this->width ) );
@ -236,7 +236,7 @@ class Image
# no disk space is available or some other error occurs
#
$thumbstat = stat( $thumbPath );
if( $thumbstat["size"] == 0 )
if( $thumbstat['size'] == 0 )
{
unlink( $thumbPath );
}
@ -263,7 +263,7 @@ class Image
// 2, ... return next old version from above query
function nextHistoryLine()
{
$fname = "Image::nextHistoryLine()";
$fname = 'Image::nextHistoryLine()';
$dbr =& wfGetDB( DB_SLAVE );
if ( $this->historyLine == 0 ) {// called for the first time, return line from cur
$this->historyRes = $dbr->select( 'image',
@ -324,7 +324,7 @@ function wfImageArchiveDir( $fname , $subdir='archive')
# Suppress warning messages here; if the file itself can't
# be written we'll worry about it then.
$archive = "{$wgUploadDirectory}/{$subdir}";
$archive = $wgUploadDirectory.'/'.$subdir;
if ( ! is_dir( $archive ) ) { @mkdir( $archive, 0777 ); }
$archive .= '/' . $hash{0};
if ( ! is_dir( $archive ) ) { @mkdir( $archive, 0777 ); }
@ -455,8 +455,8 @@ function wfImageArchiveUrl( $name )
global $wgUploadPath;
$hash = md5( substr( $name, 15) );
$url = "{$wgUploadPath}/archive/" . $hash{0} . "/" .
substr( $hash, 0, 2 ) . "/{$name}";
$url = $wgUploadPath.'/archive/' . $hash{0} . '/' .
substr( $hash, 0, 2 ) . '/'.$name;
return wfUrlencode($url);
}

View file

@ -4,7 +4,7 @@
Special handling for image description pages
*/
require_once( "Image.php" );
require_once( 'Image.php' );
class ImagePage extends Article {
@ -34,15 +34,15 @@ class ImagePage extends Article {
global $wgOut, $wgUser, $wgRequest, $wgMaxImageWidth, $wgUseImageResize;
$this->img = Image::newFromTitle( $this->mTitle );
$url = $this->img->getUrl();
$anchoropen = "";
$anchorclose = "";
$anchoropen = '';
$anchorclose = '';
if ( $this->img->exists() ) {
$sk = $wgUser->getSkin();
if ( $this->img->getType() != "" ) {
if ( $this->img->getType() != '' ) {
# image
$width = $this->img->getWidth();
$height = $this->img->getHeight();
@ -91,7 +91,7 @@ class ImagePage extends Article {
$line->img_user_text, $line->img_size, $line->img_description );
}
$s .= $sk->endImageHistoryList();
} else { $s=""; }
} else { $s=''; }
$wgOut->addHTML( $s );
}
@ -99,7 +99,7 @@ class ImagePage extends Article {
{
global $wgUser, $wgOut;
$wgOut->addHTML( "<h2>" . wfMsg( "imagelinks" ) . "</h2>\n" );
$wgOut->addHTML( '<h2>' . wfMsg( 'imagelinks' ) . "</h2>\n" );
$dbr =& wfGetDB( DB_SLAVE );
$cur = $dbr->tableName( 'cur' );
@ -110,10 +110,10 @@ class ImagePage extends Article {
$res = $dbr->query( $sql, DB_SLAVE, "Article::imageLinks" );
if ( 0 == $dbr->numRows( $res ) ) {
$wgOut->addHtml( "<p>" . wfMsg( "nolinkstoimage" ) . "</p>\n" );
$wgOut->addHtml( '<p>' . wfMsg( "nolinkstoimage" ) . "</p>\n" );
return;
}
$wgOut->addHTML( "<p>" . wfMsg( "linkstoimage" ) . "</p>\n<ul>" );
$wgOut->addHTML( '<p>' . wfMsg( 'linkstoimage' ) . "</p>\n<ul>" );
$sk = $wgUser->getSkin();
while ( $s = $dbr->fetchObject( $res ) ) {
@ -144,10 +144,10 @@ class ImagePage extends Article {
}
# Better double-check that it hasn't been deleted yet!
$wgOut->setPagetitle( wfMsg( "confirmdelete" ) );
$wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
if ( !is_null( $image ) ) {
if ( "" == trim( $image ) ) {
$wgOut->fatalError( wfMsg( "cannotdelete" ) );
if ( '' == trim( $image ) ) {
$wgOut->fatalError( wfMsg( 'cannotdelete' ) );
return;
}
}
@ -159,11 +159,11 @@ class ImagePage extends Article {
}
if ( !is_null( $image ) ) {
$q = "&image=" . urlencode( $image );
$q = '&image=' . urlencode( $image );
} else if ( !is_null( $oldimage ) ) {
$q = "&oldimage=" . urlencode( $oldimage );
$q = '&oldimage=' . urlencode( $oldimage );
} else {
$q = "";
$q = '';
}
return $this->confirmDelete( $q, $wgRequest->getText( 'wpReason' ) );
}
@ -172,7 +172,7 @@ class ImagePage extends Article {
{
global $wgOut, $wgUser, $wgLang, $wgRequest;
global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
$fname = "Article::doDelete";
$fname = 'Article::doDelete';
$reason = $wgRequest->getVal( 'wpReason' );
$image = $wgRequest->getVal( 'image' );
@ -237,17 +237,17 @@ class ImagePage extends Article {
$this->doDeleteArticle( $reason ); # ignore errors
$deleted = $this->mTitle->getPrefixedText();
}
$wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$sk = $wgUser->getSkin();
$loglink = $sk->makeKnownLink( $wgLang->getNsText(
Namespace::getWikipedia() ) .
":" . wfMsg( "dellogpage" ), wfMsg( "deletionlog" ) );
':' . wfMsg( 'dellogpage' ), wfMsg( 'deletionlog' ) );
$text = wfMsg( "deletedtext", $deleted, $loglink );
$text = wfMsg( 'deletedtext', $deleted, $loglink );
$wgOut->addHTML( "<p>" . $text . "</p>\n" );
$wgOut->addHTML( '<p>' . $text . "</p>\n" );
$wgOut->returnToMain( false );
}
@ -270,7 +270,7 @@ class ImagePage extends Article {
$oldimage = $wgRequest->getText( 'oldimage' );
if ( strlen( $oldimage ) < 16 ) {
$wgOut->unexpectedValueError( "oldimage", $oldimage );
$wgOut->unexpectedValueError( 'oldimage', $oldimage );
return;
}
if ( wfReadOnly() ) {
@ -294,7 +294,7 @@ class ImagePage extends Article {
$oldver = wfTimestampNow() . "!{$name}";
$dbr =& wfGetDB( DB_SLAVE );
$size = $dbr->getField( "oldimage", "oi_size", "oi_archive_name='" .
$size = $dbr->getField( 'oldimage', 'oi_size', 'oi_archive_name=\'' .
$dbr->strencode( $oldimage ) . "'" );
if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
@ -314,9 +314,9 @@ class ImagePage extends Article {
wfPurgeSquidServers($urlArr);
}
$wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->addHTML( wfMsg( "imagereverted" ) );
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$wgOut->addHTML( wfMsg( 'imagereverted' ) );
$wgOut->returnToMain( false );
}
}

View file

@ -18,7 +18,7 @@ class LinkCache {
/* private */ function getKey( $title ) {
global $wgDBname;
return "$wgDBname:lc:title:$title";
return $wgDBname.':lc:title:'.$title;
}
function LinkCache()
@ -123,13 +123,13 @@ class LinkCache {
$id = $this->getGoodLinkID( $title );
if ( 0 != $id ) { return $id; }
$fname = "LinkCache::addLinkObj";
$fname = 'LinkCache::addLinkObj';
wfProfileIn( $fname );
$ns = $nt->getNamespace();
$t = $nt->getDBkey();
if ( "" == $title ) {
if ( '' == $title ) {
wfProfileOut( $fname );
return 0;
}
@ -164,7 +164,7 @@ class LinkCache {
{
global $wgEnablePersistentLC;
$fname = "LinkCache::preFill";
$fname = 'LinkCache::preFill';
wfProfileIn( $fname );
# Note -- $fromtitle is a Title *object*
@ -307,7 +307,7 @@ class LinkCache {
}
$cacheobj = false;
if( function_exists( "gzuncompress" ) )
if( function_exists( 'gzuncompress' ) )
$cacheobj = @gzuncompress( $raw );
if($cacheobj == FALSE){
@ -327,7 +327,7 @@ class LinkCache {
/* private */ function saveToLinkscc( $pid ){
global $wgCompressedPersistentLC;
if( $wgCompressedPersistentLC and function_exists( "gzcompress" ) ) {
if( $wgCompressedPersistentLC and function_exists( 'gzcompress' ) ) {
$ser = gzcompress( serialize( $this ), 3 );
} else {
$ser = serialize( $this );
@ -341,7 +341,7 @@ class LinkCache {
/* static */ function linksccClearLinksTo( $pid ){
global $wgEnablePersistentLC;
if ( $wgEnablePersistentLC ) {
$fname = "LinkCache::linksccClearLinksTo";
$fname = 'LinkCache::linksccClearLinksTo';
$pid = intval( $pid );
$dbw =& wfGetDB( DB_MASTER );
# Delete linkscc rows which link to here

View file

@ -20,7 +20,7 @@ class LinksUpdate {
/* Update link tables with outgoing links from an updated article */
/* Relies on the 'link cache' to be filled out */
$fname = "LinksUpdate::doUpdate";
$fname = 'LinksUpdate::doUpdate';
wfProfileIn( $fname );
$del = array();
@ -39,7 +39,7 @@ class LinksUpdate {
# Delete where necessary
if ( count( $del ) ) {
$sql = "DELETE FROM $links WHERE l_from={$this->mId} AND l_to IN(".
implode( ",", $del ) . ")";
implode( ',', $del ) . ')';
$dbw->query( $sql, $fname );
}
} else {
@ -51,7 +51,7 @@ class LinksUpdate {
}
# Do the insertion
$sql = "";
$sql = '';
if ( 0 != count( $add ) ) {
$arr=array();
foreach($add as $lt=>$lid)
@ -76,11 +76,11 @@ class LinksUpdate {
if ( $first ) {
$first = false;
} else {
$sql .= ",";
$sql .= ',';
}
$sql .= $dbw->addQuotes( $badTitle );
}
$sql .= ")";
$sql .= ')';
$dbw->query( $sql, $fname );
}
} else {
@ -92,7 +92,7 @@ class LinksUpdate {
}
# Do additions
$sql = "";
$sql = '';
if ( 0 != count ( $add ) ) {
$arr=array();
foreach( $add as $blt ) {
@ -114,7 +114,7 @@ class LinksUpdate {
$add = $wgLinkCache->getImageLinks();
# Do the insertion
$sql = "";
$sql = '';
$image = Namespace::getImage();
if ( 0 != count ( $add ) ) {
$sql = "INSERT IGNORE INTO $imagelinks (il_from,il_to) VALUES ";
@ -126,13 +126,13 @@ class LinksUpdate {
$nt->invalidateCache();
$iname = $dbw->strencode( $iname );
if ( ! $first ) { $sql .= ","; }
if ( ! $first ) { $sql .= ','; }
$first = false;
$sql .= "({$this->mId},'{$iname}')";
}
}
if ( "" != $sql ) {
if ( '' != $sql ) {
$dbw->query( $sql, $fname );
}
@ -146,7 +146,7 @@ class LinksUpdate {
$add = $wgLinkCache->getCategoryLinks();
# Do the insertion
$sql = "";
$sql = '';
if ( 0 != count ( $add ) ) {
$sql = "INSERT IGNORE INTO $categorylinks (cl_from,cl_to,cl_sortkey) VALUES ";
$first = true;
@ -156,14 +156,14 @@ class LinksUpdate {
if( !$nt ) continue;
$nt->invalidateCache();
if ( ! $first ) { $sql .= ","; }
if ( ! $first ) { $sql .= ','; }
$first = false;
$sql .= "({$this->mId},'" . $dbw->strencode( $cname ) .
"','" . $dbw->strencode( $sortkey ) . "')";
}
}
if ( "" != $sql ) {
if ( '' != $sql ) {
$dbw->query( $sql, $fname );
}
}
@ -178,7 +178,7 @@ class LinksUpdate {
# Old inefficient update function
# Used for rebuilding the link table
global $wgLinkCache, $wgDBtransactions, $wgUseCategoryMagic;
$fname = "LinksUpdate::doDumbUpdate";
$fname = 'LinksUpdate::doDumbUpdate';
wfProfileIn( $fname );
@ -192,7 +192,7 @@ class LinksUpdate {
$dbw->query( $sql, $fname );
$a = $wgLinkCache->getGoodLinks();
$sql = "";
$sql = '';
if ( 0 != count( $a ) ) {
$sql = "INSERT IGNORE INTO $links (l_from,l_to) VALUES ";
$first = true;
@ -203,7 +203,7 @@ class LinksUpdate {
$sql .= "({$this->mId},{$lid})";
}
}
if ( "" != $sql ) {
if ( '' != $sql ) {
$dbw->query( $sql, $fname );
}
@ -211,7 +211,7 @@ class LinksUpdate {
$dbw->query( $sql, $fname );
$a = $wgLinkCache->getBadLinks();
$sql = "";
$sql = '';
if ( 0 != count ( $a ) ) {
$sql = "INSERT IGNORE INTO $brokenlinks (bl_from,bl_to) VALUES ";
$first = true;
@ -223,7 +223,7 @@ class LinksUpdate {
$sql .= "({$this->mId},'{$blt}')";
}
}
if ( "" != $sql ) {
if ( '' != $sql ) {
$dbw->query( $sql, $fname );
}
@ -231,7 +231,7 @@ class LinksUpdate {
$dbw->query( $sql, $fname );
$a = $wgLinkCache->getImageLinks();
$sql = "";
$sql = '';
if ( 0 != count ( $a ) ) {
$sql = "INSERT IGNORE INTO $imagelinks (il_from,il_to) VALUES ";
$first = true;
@ -243,7 +243,7 @@ class LinksUpdate {
$sql .= "({$this->mId},'{$iname}')";
}
}
if ( "" != $sql ) {
if ( '' != $sql ) {
$dbw->query( $sql, $fname );
}
@ -255,7 +255,7 @@ class LinksUpdate {
$add = $wgLinkCache->getCategoryLinks();
# Do the insertion
$sql = "";
$sql = '';
if ( 0 != count ( $add ) ) {
$sql = "INSERT IGNORE INTO $categorylinks (cl_from,cl_to,cl_sortkey) VALUES ";
$first = true;
@ -272,7 +272,7 @@ class LinksUpdate {
"','" . $dbw->strencode( $sortkey ) . "')";
}
}
if ( "" != $sql ) {
if ( '' != $sql ) {
$dbw->query( $sql, $fname );
}
}
@ -283,7 +283,7 @@ class LinksUpdate {
function fixBrokenLinks() {
/* Update any brokenlinks *to* this page */
/* Call for a newly created page, or just to make sure state is consistent */
$fname = "LinksUpdate::fixBrokenLinks";
$fname = 'LinksUpdate::fixBrokenLinks';
$dbw =& wfGetDB( DB_MASTER );
$cur = $dbw->tableName( 'cur' );
@ -306,7 +306,7 @@ class LinksUpdate {
$sql .= "({$row->bl_from},{$this->mId})";
$sql2 .= $row->bl_from;
}
$sql2 .= ")";
$sql2 .= ')';
$dbw->query( $sql, $fname );
$dbw->query( $sql2, $fname );

View file

@ -1,30 +1,30 @@
<?php
# Database load balancing object
require_once( "Database.php" );
require_once( 'Database.php' );
# Valid database indexes
# Operation-based indexes
define( "DB_SLAVE", -1 ); # Read from the slave (or only server)
define( "DB_MASTER", -2 ); # Write to master (or only server)
define( "DB_LAST", -3 ); # Whatever database was used last
define( 'DB_SLAVE', -1 ); # Read from the slave (or only server)
define( 'DB_MASTER', -2 ); # Write to master (or only server)
define( 'DB_LAST', -3 ); # Whatever database was used last
# Obsolete aliases
define( "DB_READ", -1 );
define( "DB_WRITE", -2 );
define( 'DB_READ', -1 );
define( 'DB_WRITE', -2 );
# Task-based indexes
# ***NOT USED YET, EXPERIMENTAL***
# These may be defined in $wgDBservers. If they aren't, the default reader or writer will be used
# Even numbers are always readers, odd numbers are writers
define( "DB_TASK_FIRST", 1000 ); # First in list
define( "DB_SEARCH_R", 1000 ); # Search read
define( "DB_SEARCH_W", 1001 ); # Search write
define( "DB_ASKSQL_R", 1002 ); # Special:Asksql read
define( "DB_WATCHLIST_R", 1004 ); # Watchlist read
define( "DB_TASK_LAST", 1004) ; # Last in list
define( 'DB_TASK_FIRST', 1000 ); # First in list
define( 'DB_SEARCH_R', 1000 ); # Search read
define( 'DB_SEARCH_W', 1001 ); # Search write
define( 'DB_ASKSQL_R', 1002 ); # Special:Asksql read
define( 'DB_WATCHLIST_R', 1004 ); # Watchlist read
define( 'DB_TASK_LAST', 1004) ; # Last in list
define( "MASTER_WAIT_TIMEOUT", 15 ); # Time to wait for a slave to synchronise
define( 'MASTER_WAIT_TIMEOUT', 15 ); # Time to wait for a slave to synchronise
class LoadBalancer {
/* private */ var $mServers, $mConnections, $mLoads;
@ -135,7 +135,7 @@ class LoadBalancer {
# If a DB_SLAVE connection has been opened already, waits
# Otherwise sets a variable telling it to wait if such a connection is opened
function waitFor( $file, $pos ) {
$fname = "LoadBalancer::waitFor";
$fname = 'LoadBalancer::waitFor';
wfProfileIn( $fname );
wfDebug( "User master pos: $file $pos\n" );
@ -162,7 +162,7 @@ class LoadBalancer {
$retVal = false;
$key = "masterpos:" . $index;
$key = 'masterpos:' . $index;
$memcPos = $wgMemc->get( $key );
if ( $memcPos ) {
list( $file, $pos ) = explode( ' ', $memcPos );
@ -192,7 +192,7 @@ class LoadBalancer {
# Get a connection by index
function &getConnection( $i, $fail = true )
{
$fname = "LoadBalancer::getConnection";
$fname = 'LoadBalancer::getConnection';
wfProfileIn( $fname );
/*
# Task-based index
@ -300,7 +300,7 @@ class LoadBalancer {
if ( $this->mFailFunction ) {
$conn->failFunction( $this->mFailFunction );
} else {
$conn->failFunction( "wfEmergencyAbort" );
$conn->failFunction( 'wfEmergencyAbort' );
}
$conn->reportConnectionError();
$reporting = false;

View file

@ -11,7 +11,7 @@ class LogPage {
{
# For now, assume title is correct dbkey
# and log pages always go in Wikipedia namespace
$this->mTitle = str_replace( " ", "_", $title );
$this->mTitle = str_replace( ' ', '_', $title );
$this->mId = 0;
$this->mUpdateRecentChanges = true ;
$this->mContentLoaded = false;
@ -56,7 +56,7 @@ class LogPage {
if( wfReadOnly() ) return;
global $wgUser;
$fname = "LogPage::saveContent";
$fname = 'LogPage::saveContent';
$dbw =& wfGetDB( DB_MASTER );
$uid = $wgUser->getID();
@ -110,7 +110,7 @@ class LogPage {
return true;
}
function addEntry( $action, $comment, $textaction = "" )
function addEntry( $action, $comment, $textaction = '' )
{
global $wgLang, $wgUser;
@ -121,7 +121,7 @@ class LogPage {
$ut = $wgUser->getName();
$uid = $wgUser->getID();
if( $uid ) {
$ul = "[[" .
$ul = '[[' .
$wgLang->getNsText( Namespace::getUser() ) .
":{$ut}|{$ut}]]";
} else {
@ -135,8 +135,8 @@ class LogPage {
$before = $m[1];
$after = $m[2];
} else {
$before = "";
$after = "";
$before = '';
$after = '';
}
if($textaction)
@ -144,12 +144,12 @@ class LogPage {
else
$this->mComment = $action;
if ( "" == $comment ) {
$inline = "";
if ( '' == $comment ) {
$inline = '';
} else {
$inline = " <em>({$comment_esc})</em>";
# comment gets escaped again, so we use the unescaped version
$this->mComment .= ": {$comment}";
$this->mComment .= ': '.$comment;
}
$this->mContent = "{$before}<ul><li>{$d} {$ul} {$action}{$inline}</li>\n{$after}";
@ -158,7 +158,7 @@ class LogPage {
return $this->saveContent();
}
function replaceContent( $text, $comment = "" )
function replaceContent( $text, $comment = '' )
{
$this->mContent = $text;
$this->mComment = $comment;
@ -173,10 +173,10 @@ class LogPage {
# Client cache fresh and headers sent, nothing more to do.
return;
}
$func = ( $rawhtml ? "addHTML" : "addWikiText" );
$func = ( $rawhtml ? 'addHTML' : 'addWikiText' );
$wgOut->$func(
"<p>" . wfMsg( "perfdisabled" ) . "</p>\n\n" .
"<p>" . wfMsg( "perfdisabledsub", $wgLang->timeanddate( $this->getTimestamp() ) ) . "</p>\n\n" .
"<p>" . wfMsg( 'perfdisabled' ) . "</p>\n\n" .
"<p>" . wfMsg( 'perfdisabledsub', $wgLang->timeanddate( $this->getTimestamp() ) ) . "</p>\n\n" .
"<hr />\n\n" .
$this->getContent()
);

View file

@ -13,40 +13,40 @@
/*private*/ $wgMagicFound = false;
define("MAG_REDIRECT", 0);
define("MAG_NOTOC", 1);
define("MAG_START", 2);
define("MAG_CURRENTMONTH", 3);
define("MAG_CURRENTMONTHNAME", 4);
define("MAG_CURRENTDAY", 5);
define("MAG_CURRENTDAYNAME", 6);
define("MAG_CURRENTYEAR", 7);
define("MAG_CURRENTTIME", 8);
define("MAG_NUMBEROFARTICLES", 9);
define("MAG_CURRENTMONTHNAMEGEN", 10);
define("MAG_MSG", 11);
define("MAG_SUBST", 12);
define("MAG_MSGNW", 13);
define("MAG_NOEDITSECTION", 14);
define("MAG_END", 15);
define("MAG_IMG_THUMBNAIL", 16);
define("MAG_IMG_RIGHT", 17);
define("MAG_IMG_LEFT", 18);
define("MAG_IMG_NONE", 19);
define("MAG_IMG_WIDTH", 20);
define("MAG_IMG_CENTER", 21);
define("MAG_INT", 22);
define("MAG_FORCETOC", 23);
define("MAG_SITENAME", 24);
define("MAG_NS", 25);
define("MAG_LOCALURL", 26);
define("MAG_LOCALURLE", 27);
define("MAG_SERVER", 28);
define("MAG_IMG_FRAMED", 29);
define("MAG_PAGENAME", 30);
define("MAG_PAGENAMEE", 31);
define("MAG_NAMESPACE", 32);
define("MAG_TOC", 33);
define('MAG_REDIRECT', 0);
define('MAG_NOTOC', 1);
define('MAG_START', 2);
define('MAG_CURRENTMONTH', 3);
define('MAG_CURRENTMONTHNAME', 4);
define('MAG_CURRENTDAY', 5);
define('MAG_CURRENTDAYNAME', 6);
define('MAG_CURRENTYEAR', 7);
define('MAG_CURRENTTIME', 8);
define('MAG_NUMBEROFARTICLES', 9);
define('MAG_CURRENTMONTHNAMEGEN', 10);
define('MAG_MSG', 11);
define('MAG_SUBST', 12);
define('MAG_MSGNW', 13);
define('MAG_NOEDITSECTION', 14);
define('MAG_END', 15);
define('MAG_IMG_THUMBNAIL', 16);
define('MAG_IMG_RIGHT', 17);
define('MAG_IMG_LEFT', 18);
define('MAG_IMG_NONE', 19);
define('MAG_IMG_WIDTH', 20);
define('MAG_IMG_CENTER', 21);
define('MAG_INT', 22);
define('MAG_FORCETOC', 23);
define('MAG_SITENAME', 24);
define('MAG_NS', 25);
define('MAG_LOCALURL', 26);
define('MAG_LOCALURLE', 27);
define('MAG_SERVER', 28);
define('MAG_IMG_FRAMED', 29);
define('MAG_PAGENAME', 30);
define('MAG_PAGENAMEE', 31);
define('MAG_NAMESPACE', 32);
define('MAG_TOC', 33);
$wgVariableIDs = array(
MAG_CURRENTMONTH,
@ -105,9 +105,9 @@ class MagicWord {
# Preliminary initialisation
/* private */ function initRegex() {
$variableClass = Title::legalChars();
$escSyn = array_map( "preg_quote", $this->mSynonyms );
$this->mBaseRegex = implode( "|", $escSyn );
$case = $this->mCaseSensitive ? "" : "i";
$escSyn = array_map( 'preg_quote', $this->mSynonyms );
$this->mBaseRegex = implode( '|', $escSyn );
$case = $this->mCaseSensitive ? '' : 'i';
$this->mRegex = "/{$this->mBaseRegex}/{$case}";
$this->mRegexStart = "/^{$this->mBaseRegex}/{$case}";
$this->mVariableRegex = str_replace( "\\$1", "([$variableClass]*?)", $this->mRegex );

View file

@ -9,11 +9,11 @@
class MathRenderer {
var $mode = MW_MATH_MODERN;
var $tex = "";
var $inputhash = "";
var $hash = "";
var $html = "";
var $mathml = "";
var $tex = '';
var $inputhash = '';
var $hash = '';
var $html = '';
var $mathml = '';
var $conservativeness = 0;
function MathRenderer( $tex ) {
@ -37,39 +37,39 @@ class MathRenderer {
# Ensure that the temp and output directories are available before continuing...
if( !file_exists( $wgMathDirectory ) ) {
if( !@mkdir( $wgMathDirectory ) ) {
return $this->_error( "math_bad_output" );
return $this->_error( 'math_bad_output' );
}
} elseif( !is_dir( $wgMathDirectory ) || !is_writable( $wgMathDirectory ) ) {
return $this->_error( "math_bad_output" );
return $this->_error( 'math_bad_output' );
}
if( !file_exists( $wgTmpDirectory ) ) {
if( !@mkdir( $wgTmpDirectory ) ) {
return $this->_error( "math_bad_tmpdir" );
return $this->_error( 'math_bad_tmpdir' );
}
} elseif( !is_dir( $wgTmpDirectory ) || !is_writable( $wgTmpDirectory ) ) {
return $this->_error( "math_bad_tmpdir" );
return $this->_error( 'math_bad_tmpdir' );
}
if( !is_executable( $wgTexvc ) ) {
return $this->_error( "math_notexvc" );
return $this->_error( 'math_notexvc' );
}
$cmd = $wgTexvc." ".
wfEscapeShellArg($wgTmpDirectory)." ".
wfEscapeShellArg($wgMathDirectory)." ".
wfEscapeShellArg($this->tex)." ".
$cmd = $wgTexvc.' '.
wfEscapeShellArg($wgTmpDirectory).' '.
wfEscapeShellArg($wgMathDirectory).' '.
wfEscapeShellArg($this->tex).' '.
wfEscapeShellArg($wgInputEncoding);
wfDebug( "TeX: $cmd" );
wfDebug( 'TeX: '.$cmd );
$contents = `$cmd`;
if (strlen($contents) == 0) {
return $this->_error( "math_unknown_error" );
return $this->_error( 'math_unknown_error' );
}
$retval = substr ($contents, 0, 1);
if (($retval == "C") || ($retval == "M") || ($retval == "L")) {
if ($retval == "C")
if (($retval == 'C') || ($retval == 'M') || ($retval == 'L')) {
if ($retval == 'C')
$this->conservativeness = 2;
else if ($retval == "M")
else if ($retval == 'M')
$this->conservativeness = 1;
else
$this->conservativeness = 0;
@ -79,46 +79,46 @@ class MathRenderer {
$this->html = substr($outdata, 0, $i);
$this->mathml = substr($outdata, $i+1);
} else if (($retval == "c") || ($retval == "m") || ($retval == "l")) {
} else if (($retval == 'c') || ($retval == 'm') || ($retval == 'l')) {
$this->html = substr ($contents, 33);
if ($retval == "c")
if ($retval == 'c')
$this->conservativeness = 2;
else if ($retval == "m")
else if ($retval == 'm')
$this->conservativeness = 1;
else
$this->conservativeness = 0;
$this->mathml = NULL;
} else if ($retval == "X") {
} else if ($retval == 'X') {
$outhtml = NULL;
$this->mathml = substr ($contents, 33);
$this->conservativeness = 0;
} else if ($retval == "+") {
} else if ($retval == '+') {
$this->outhtml = NULL;
$this->mathml = NULL;
$this->conservativeness = 0;
} else {
$errbit = htmlspecialchars( substr($contents, 1) );
switch( $retval ) {
case "E": return $this->_error( "math_lexing_error", $errbit );
case "S": return $this->_error( "math_syntax_error", $errbit );
case "F": return $this->_error( "math_unknown_function", $errbit );
default: return $this->_error( "math_unknown_error", $errbit );
case 'E': return $this->_error( 'math_lexing_error', $errbit );
case 'S': return $this->_error( 'math_syntax_error', $errbit );
case 'F': return $this->_error( 'math_unknown_function', $errbit );
default: return $this->_error( 'math_unknown_error', $errbit );
}
}
$this->hash = substr ($contents, 1, 32);
if (!preg_match("/^[a-f0-9]{32}$/", $this->hash)) {
return $this->_error( "math_unknown_error" );
return $this->_error( 'math_unknown_error' );
}
if( !file_exists( "$wgMathDirectory/{$this->hash}.png" ) ) {
return $this->_error( "math_image_error" );
return $this->_error( 'math_image_error' );
}
# Now save it back to the DB:
$outmd5_sql = pack("H32", $this->hash);
$outmd5_sql = pack('H32', $this->hash);
$md5_sql = pack("H32", $this->md5); # Binary packed, not hex
$md5_sql = pack('H32', $this->md5); # Binary packed, not hex
$dbw =& wfGetDB( DB_MASTER );
$dbw->replace( 'math', array( 'math_inputhash' ),
@ -136,9 +136,9 @@ class MathRenderer {
return $this->_doRender();
}
function _error( $msg, $append = "" ) {
$mf = htmlspecialchars( wfMsg( "math_failure" ) );
$munk = htmlspecialchars( wfMsg( "math_unknown_error" ) );
function _error( $msg, $append = '' ) {
$mf = htmlspecialchars( wfMsg( 'math_failure' ) );
$munk = htmlspecialchars( wfMsg( 'math_unknown_error' ) );
$errmsg = htmlspecialchars( wfMsg( $msg ) );
$source = htmlspecialchars($this->tex);
return "<strong class='error'>$mf ($errmsg$append): $source</strong>\n";
@ -158,7 +158,7 @@ class MathRenderer {
if( $rpage !== false ) {
# Tailing 0x20s can get dropped by the database, add it back on if necessary:
$xhash = unpack( "H32md5", $rpage->math_outputhash . " " );
$xhash = unpack( 'H32md5', $rpage->math_outputhash . " " );
$this->hash = $xhash ['md5'];
$this->conservativeness = $rpage->math_html_conservativeness;
@ -200,7 +200,7 @@ class MathRenderer {
function renderMath( $tex ) {
global $wgUser;
$math = new MathRenderer( $tex );
$math->setOutputMode( $wgUser->getOption("math"));
$math->setOutputMode( $wgUser->getOption('math'));
return $math->render();
}

View file

@ -28,7 +28,7 @@ function memsess_close() {
function memsess_read( $id ) {
global $wgMemc;
$data = $wgMemc->get( memsess_key( $id ) );
if( ! $data ) return "";
if( ! $data ) return '';
return $data;
}
@ -49,6 +49,6 @@ function memsess_gc( $maxlifetime ) {
return true;
}
session_set_save_handler( "memsess_open", "memsess_close", "memsess_read", "memsess_write", "memsess_destroy", "memsess_gc" );
session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read', 'memsess_write', 'memsess_destroy', 'memsess_gc' );
?>

View file

@ -3,9 +3,9 @@
# Message cache
# Performs various useful MediaWiki namespace-related functions
define( "MSG_LOAD_TIMEOUT", 60);
define( "MSG_LOCK_TIMEOUT", 10);
define( "MSG_WAIT_TIMEOUT", 10);
define( 'MSG_LOAD_TIMEOUT', 60);
define( 'MSG_LOCK_TIMEOUT', 10);
define( 'MSG_WAIT_TIMEOUT', 10);
class MessageCache
{
@ -16,22 +16,22 @@ class MessageCache
var $mInitialised = false;
function initialise( &$memCached, $useDB, $expiry, $memcPrefix ) {
$fname = "MessageCache::initialise";
$fname = 'MessageCache::initialise';
wfProfileIn( $fname );
$this->mUseCache = !is_null( $memCached );
$this->mMemc = &$memCached;
$this->mDisable = !$useDB;
$this->mExpiry = $expiry;
$this->mDisableTransform = false;
$this->mMemcKey = "$memcPrefix:messages";
$this->mMemcKey = $memcPrefix.':messages';
$this->mKeys = false; # initialised on demand
$this->mInitialised = true;
wfProfileIn( "$fname-parseropt" );
wfProfileIn( $fname.'-parseropt' );
$this->mParserOptions = ParserOptions::newFromUser( $u=NULL );
wfProfileOut( "$fname-parseropt" );
wfProfileIn( "$fname-parser" );
wfProfileOut( $fname.'-parseropt' );
wfProfileIn( $fname.'-parser' );
$this->mParser = new Parser;
wfProfileOut( "$fname-parser" );
wfProfileOut( $fname.'-parser' );
$this->load();
wfProfileOut( $fname );
@ -47,14 +47,14 @@ class MessageCache
wfDebug( "MessageCache::load(): disabled\n" );
return true;
}
$fname = "MessageCache::load";
$fname = 'MessageCache::load';
wfProfileIn( $fname );
$success = true;
if ( $this->mUseCache ) {
wfProfileIn( "$fname-fromcache" );
wfProfileIn( $fname.'-fromcache' );
$this->mCache = $this->mMemc->get( $this->mMemcKey );
wfProfileOut( "$fname-fromcache" );
wfProfileOut( $fname.'-fromcache' );
# If there's nothing in memcached, load all the messages from the database
if ( !$this->mCache ) {
@ -63,18 +63,18 @@ class MessageCache
# Other threads don't need to load the messages if another thread is doing it.
$success = $this->mMemc->set( $this->mMemcKey, "loading", MSG_LOAD_TIMEOUT );
if ( $success ) {
wfProfileIn( "$fname-load" );
wfProfileIn( $fname.'-load' );
$this->loadFromDB();
wfProfileOut( "$fname-load" );
wfProfileOut( $fname.'-load' );
# Save in memcached
# Keep trying if it fails, this is kind of important
wfProfileIn( "$fname-save" );
wfProfileIn( $fname.'-save' );
for ( $i=0; $i<20 && !$this->mMemc->set( $this->mMemcKey, $this->mCache, $this->mExpiry ); $i++ ) {
usleep(mt_rand(500000,1500000));
}
wfProfileOut( "$fname-save" );
wfProfileOut( $fname.'-save' );
if ( $i == 20 ) {
$this->mMemc->set( $this->mMemcKey, "error", 86400 );
$this->mMemc->set( $this->mMemcKey, 'error', 86400 );
wfDebug( "MemCached set error in MessageCache: restart memcached server!\n" );
}
}
@ -106,7 +106,7 @@ class MessageCache
# Loads all cacheable messages from the database
function loadFromDB()
{
$fname = "MessageCache::loadFromDB";
$fname = 'MessageCache::loadFromDB';
$dbr =& wfGetDB( DB_SLAVE );
$res = $dbr->select( 'cur',
array( 'cur_title', 'cur_text' ),
@ -161,7 +161,7 @@ class MessageCache
return true;
}
$lockKey = $this->mMemcKey . "lock";
$lockKey = $this->mMemcKey . 'lock';
for ($i=0; $i < MSG_WAIT_TIMEOUT && !$this->mMemc->add( $lockKey, 1, MSG_LOCK_TIMEOUT ); $i++ ) {
sleep(1);
}
@ -174,7 +174,7 @@ class MessageCache
return;
}
$lockKey = $this->mMemcKey . "lock";
$lockKey = $this->mMemcKey . 'lock';
$this->mMemc->delete( $lockKey );
}
@ -199,9 +199,9 @@ class MessageCache
# If it wasn't in the cache, load each message from the DB individually
if ( !$message && $useDB) {
$dbr =& wfGetDB( DB_SLAVE );
$result = $dbr->getArray( "cur", array("cur_text"),
array( "cur_namespace" => NS_MEDIAWIKI, "cur_title" => $title ),
"MessageCache::get" );
$result = $dbr->getArray( 'cur', array('cur_text'),
array( 'cur_namespace' => NS_MEDIAWIKI, 'cur_title' => $title ),
'MessageCache::get' );
if ( $result ) {
$message = $result->cur_text;
}
@ -218,7 +218,7 @@ class MessageCache
}
# Try the English array
if ( !$message && $wgLanguageCode != "en" ) {
if ( !$message && $wgLanguageCode != 'en' ) {
$message = Language::getMessage( $key );
}
@ -234,7 +234,7 @@ class MessageCache
function transform( $message ) {
if( !$this->mDisableTransform ) {
if ( strstr( $message, "{{" ) !== false ) {
if ( strstr( $message, '{{' ) !== false ) {
$message = $this->mParser->transformMsg( $message, $this->mParserOptions );
}
}

View file

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
define("RDF_TYPE_PREFS", "application/rdf+xml,text/xml;q=0.7,application/xml;q=0.5,text/rdf;q=0.1");
define('RDF_TYPE_PREFS', "application/rdf+xml,text/xml;q=0.7,application/xml;q=0.5,text/rdf;q=0.1");
function wfDublinCoreRdf($article) {
@ -151,21 +151,21 @@ function wfCreativeCommonsRdf($article) {
foreach ($terms as $term) {
switch ($term) {
case 're':
ccTerm('permits', "Reproduction"); break;
ccTerm('permits', 'Reproduction'); break;
case 'di':
ccTerm('permits', "Distribution"); break;
ccTerm('permits', 'Distribution'); break;
case 'de':
ccTerm('permits', "DerivativeWorks"); break;
ccTerm('permits', 'DerivativeWorks'); break;
case 'nc':
ccTerm('prohibits', "CommercialUse"); break;
ccTerm('prohibits', 'CommercialUse'); break;
case 'no':
ccTerm('requires', "Notice"); break;
ccTerm('requires', 'Notice'); break;
case 'by':
ccTerm('requires', "Attribution"); break;
ccTerm('requires', 'Attribution'); break;
case 'sa':
ccTerm('requires', "ShareAlike"); break;
ccTerm('requires', 'ShareAlike'); break;
case 'sc':
ccTerm('requires', "SourceCode"); break;
ccTerm('requires', 'SourceCode'); break;
}
}
}
@ -184,8 +184,8 @@ function wfCreativeCommonsRdf($article) {
}
/* private */ function dcDate($timestamp) {
return substr($timestamp, 0, 4) . "-"
. substr($timestamp, 4, 2) . "-"
return substr($timestamp, 0, 4) . '-'
. substr($timestamp, 4, 2) . '-'
. substr($timestamp, 6, 2);
}
@ -212,11 +212,11 @@ function wfCreativeCommonsRdf($article) {
print " <dc:{$name} rdf:resource=\"{$url}\" />\n";
}
/* private */ function dcPerson($name, $id, $user_name="", $user_real_name="") {
/* private */ function dcPerson($name, $id, $user_name='', $user_real_name='') {
global $wgLang;
if ($id == 0) {
dcElement($name, wfMsg("anonymous"));
dcElement($name, wfMsg('anonymous'));
} else if ( !empty($user_real_name) ) {
dcElement($name, $user_real_name);
} else {
@ -224,7 +224,7 @@ function wfCreativeCommonsRdf($article) {
if( empty( $user_name ) ) {
$user_name = User::whoIs($id);
}
dcPageOrString($name, $wgLang->getNsText(NS_USER) . ":" . $user_name, wfMsg("siteuser", $user_name));
dcPageOrString($name, $wgLang->getNsText(NS_USER) . ':' . $user_name, wfMsg('siteuser', $user_name));
}
}
@ -283,11 +283,11 @@ function wfCreativeCommonsRdf($article) {
/* Handle the GPL and LGPL, too. */
$knownLicenses["http://creativecommons.org/licenses/GPL/2.0/"] =
$knownLicenses['http://creativecommons.org/licenses/GPL/2.0/'] =
array('de', 're', 'di', 'no', 'sa', 'sc');
$knownLicenses["http://creativecommons.org/licenses/LGPL/2.1/"] =
$knownLicenses['http://creativecommons.org/licenses/LGPL/2.1/'] =
array('de', 're', 'di', 'no', 'sa', 'sc');
$knownLicenses["http://www.gnu.org/copyleft/fdl.html"] =
$knownLicenses['http://www.gnu.org/copyleft/fdl.html'] =
array('de', 're', 'di', 'no', 'sa', 'sc');
return $knownLicenses;

View file

@ -1,7 +1,7 @@
<?php
# This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
if( defined( "MEDIAWIKI" ) ) {
if( defined( 'MEDIAWIKI' ) ) {
# This is a utility class with only static functions
# for dealing with namespaces that encodes all the
@ -13,23 +13,23 @@ if( defined( "MEDIAWIKI" ) ) {
# These are synonyms for the names given in the language file
# Users and translators should not change them
/* private */ $wgCanonicalNamespaceNames = array(
NS_MEDIA => "Media",
NS_SPECIAL => "Special",
NS_TALK => "Talk",
NS_USER => "User",
NS_USER_TALK => "User_talk",
NS_WIKIPEDIA => "Project",
NS_WIKIPEDIA_TALK => "Project_talk",
NS_IMAGE => "Image",
NS_IMAGE_TALK => "Image_talk",
NS_MEDIAWIKI => "MediaWiki",
NS_MEDIAWIKI_TALK => "MediaWiki_talk",
NS_TEMPLATE => "Template",
NS_TEMPLATE_TALK => "Template_talk",
NS_HELP => "Help",
NS_HELP_TALK => "Help_talk",
NS_CATEGORY => "Category",
NS_CATEGORY_TALK => "Category_talk"
NS_MEDIA => 'Media',
NS_SPECIAL => 'Special',
NS_TALK => 'Talk',
NS_USER => 'User',
NS_USER_TALK => 'User_talk',
NS_WIKIPEDIA => 'Project',
NS_WIKIPEDIA_TALK => 'Project_talk',
NS_IMAGE => 'Image',
NS_IMAGE_TALK => 'Image_talk',
NS_MEDIAWIKI => 'MediaWiki',
NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
NS_TEMPLATE => 'Template',
NS_TEMPLATE_TALK => 'Template_talk',
NS_HELP => 'Help',
NS_HELP_TALK => 'Help_talk',
NS_CATEGORY => 'Category',
NS_CATEGORY_TALK => 'Category_talk'
);
class Namespace {

View file

@ -196,7 +196,7 @@ CREATE TABLE objectcache (
*/
class /* abstract */ SqlBagOStuff extends BagOStuff {
var $table;
function SqlBagOStuff($tablename = "objectcache") {
function SqlBagOStuff($tablename = 'objectcache') {
$this->table = $tablename;
}
@ -214,7 +214,7 @@ class /* abstract */ SqlBagOStuff extends BagOStuff {
$this->_debug("get: retrieved data; exp time is " . $row->exptime);
return unserialize($row->value);
} else {
$this->_debug("get: no matching rows");
$this->_debug('get: no matching rows');
}
return false;
}
@ -248,13 +248,13 @@ class /* abstract */ SqlBagOStuff extends BagOStuff {
// ewwww
for($i=0;$i<count($reps);$i++) {
$sql = str_replace(
"$" . $i,
'$' . $i,
$this->_strencode($reps[$i]),
$sql);
}
$res = $this->_doquery($sql);
if($res == false) {
$this->_debug("query failed: " . $this->_dberror($res));
$this->_debug('query failed: ' . $this->_dberror($res));
}
return $res;
}
@ -265,11 +265,11 @@ class /* abstract */ SqlBagOStuff extends BagOStuff {
}
function _doquery($sql) {
die( "abstract function SqlBagOStuff::_doquery() must be defined" );
die( 'abstract function SqlBagOStuff::_doquery() must be defined' );
}
function _fetchrow($res) {
die( "abstract function SqlBagOStuff::_fetchrow() must be defined" );
die( 'abstract function SqlBagOStuff::_fetchrow() must be defined' );
}
function _freeresult($result) {
@ -279,15 +279,15 @@ class /* abstract */ SqlBagOStuff extends BagOStuff {
function _dberror($result) {
/* stub */
return "unknown error";
return 'unknown error';
}
function _maxdatetime() {
die( "abstract function SqlBagOStuff::_maxdatetime() must be defined" );
die( 'abstract function SqlBagOStuff::_maxdatetime() must be defined' );
}
function _fromunixtime() {
die( "abstract function SqlBagOStuff::_fromunixtime() must be defined" );
die( 'abstract function SqlBagOStuff::_fromunixtime() must be defined' );
}
function expireall() {
@ -305,7 +305,7 @@ class /* abstract */ SqlBagOStuff extends BagOStuff {
class MediaWikiBagOStuff extends SqlBagOStuff {
function _doquery($sql) {
$dbw =& wfGetDB( DB_MASTER );
return $dbw->query($sql, "MediaWikiBagOStuff:_doquery");
return $dbw->query($sql, 'MediaWikiBagOStuff:_doquery');
}
function _fetchobject($result) {
$dbw =& wfGetDB( DB_MASTER );
@ -320,10 +320,10 @@ class MediaWikiBagOStuff extends SqlBagOStuff {
return $dbw->lastError();
}
function _maxdatetime() {
return "9999-12-31 12:59:59";
return '9999-12-31 12:59:59';
}
function _fromunixtime($ts) {
return gmdate( "Y-m-d H:i:s", $ts );
return gmdate( 'Y-m-d H:i:s', $ts );
}
function _strencode($s) {
$dbw =& wfGetDB( DB_MASTER );

View file

@ -1,11 +1,11 @@
<?php
# This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
if( defined( "MEDIAWIKI" ) ) {
if( defined( 'MEDIAWIKI' ) ) {
# See design.doc
if($wgUseTeX) require_once( "Math.php" );
if($wgUseTeX) require_once( 'Math.php' );
define( 'RLH_FOR_UPDATE', 1 );
@ -63,7 +63,7 @@ class OutputPage {
function addMetadataLink( $linkarr ) {
# note: buggy CC software only reads first "meta" link
static $haveMeta = false;
$linkarr["rel"] = ($haveMeta) ? "alternate meta" : "meta";
$linkarr['rel'] = ($haveMeta) ? 'alternate meta' : 'meta';
$this->addLink( $linkarr );
$haveMeta = true;
}
@ -84,14 +84,14 @@ class OutputPage {
wfDebug( "-- bad client, not caching\n", false );
return;
}
if( $wgUser->getOption( "nocache" ) ) {
if( $wgUser->getOption( 'nocache' ) ) {
wfDebug( "USER DISABLED CACHE\n", false );
return;
}
$lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix( max( $timestamp, $wgUser->mTouched ) ) ) . " GMT";
if( !empty( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) ) {
if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
# IE sends sizes after the date like this:
# Wed, 20 Aug 2003 06:51:19 GMT; length=5202
# this breaks strtotime().
@ -151,10 +151,10 @@ class OutputPage {
if(!empty($action)) {
$taction = $this->getPageTitleActionText();
if( !empty( $taction ) ) {
$name .= " - $taction";
$name .= ' - '.$taction;
}
}
$this->setHTMLTitle( $name . " - " . wfMsg( "wikititlesuffix" ) );
$this->setHTMLTitle( $name . ' - ' . wfMsg( 'wikititlesuffix' ) );
}
function getHTMLTitle() { return $this->mHTMLtitle; }
function getPageTitle() { return $this->mPagetitle; }
@ -278,9 +278,9 @@ class OutputPage {
function sendCacheControl() {
global $wgUseSquid, $wgUseESI;
# FIXME: This header may cause trouble with some versions of Internet Explorer
header( "Vary: Accept-Encoding, Cookie" );
header( 'Vary: Accept-Encoding, Cookie' );
if( $this->mEnableClientCache ) {
if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) &&
if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
! $this->isPrintable() && $this->mSquidMaxage != 0 )
{
if ( $wgUseESI ) {
@ -315,9 +315,9 @@ class OutputPage {
# In general, the absence of a last modified header should be enough to prevent
# the client from using its cache. We send a few other things just to make sure.
header( "Expires: -1" );
header( "Cache-Control: no-cache, no-store, max-age=0, must-revalidate" );
header( "Pragma: no-cache" );
header( 'Expires: -1' );
header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
header( 'Pragma: no-cache' );
}
}
@ -332,13 +332,13 @@ class OutputPage {
if( $this->mDoNothing ){
return;
}
$fname = "OutputPage::output";
$fname = 'OutputPage::output';
wfProfileIn( $fname );
$sk = $wgUser->getSkin();
if ( "" != $this->mRedirect ) {
if( substr( $this->mRedirect, 0, 4 ) != "http" ) {
if ( '' != $this->mRedirect ) {
if( substr( $this->mRedirect, 0, 4 ) != 'http' ) {
# Standards require redirect URLs to be absolute
global $wgServer;
$this->mRedirect = $wgServer . $this->mRedirect;
@ -347,7 +347,7 @@ class OutputPage {
if( !$wgDebugRedirects ) {
header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
}
$this->mLastModified = gmdate( "D, j M Y H:i:s" ) . " GMT";
$this->mLastModified = gmdate( 'D, j M Y H:i:s' ) . ' GMT';
}
$this->sendCacheControl();
@ -358,7 +358,7 @@ class OutputPage {
print "<p>Location: <a href=\"$url\">$url</a></p>\n";
print "</body>\n</html>\n";
} else {
header( "Location: {$this->mRedirect}" );
header( 'Location: '.$this->mRedirect );
}
if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
return;
@ -373,11 +373,11 @@ class OutputPage {
$sk->postParseLinkColour( false );
header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
header( "Content-language: {$wgLanguageCode}" );
header( 'Content-language: '.$wgLanguageCode );
$exp = time() + $wgCookieExpiration;
foreach( $this->mCookies as $name => $val ) {
setcookie( $name, $val, $exp, "/" );
setcookie( $name, $val, $exp, '/' );
}
$sk->outputPage( $this );
@ -451,13 +451,13 @@ class OutputPage {
global $wgRequestTime;
$now = wfTime();
list( $usec, $sec ) = explode( " ", $wgRequestTime );
list( $usec, $sec ) = explode( ' ', $wgRequestTime );
$start = (float)$sec + (float)$usec;
$elapsed = $now - $start;
# Use real server name if available, so we know which machine
# in a server farm generated the current page.
if ( function_exists( "posix_uname" ) ) {
if ( function_exists( 'posix_uname' ) ) {
$uname = @posix_uname();
} else {
$uname = false;
@ -479,17 +479,17 @@ class OutputPage {
{
global $wgTitle;
$this->mDebugtext .= "Original title: " .
$this->mDebugtext .= 'Original title: ' .
$wgTitle->getPrefixedText() . "\n";
$this->setPageTitle( wfMsg( $title ) );
$this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
$this->setRobotpolicy( "noindex,nofollow" );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$this->enableClientCache( false );
$this->mRedirect = "";
$this->mRedirect = '';
$this->mBodytext = "";
$this->addHTML( "<p>" . wfMsg( $msg ) . "</p>\n" );
$this->mBodytext = '';
$this->addHTML( '<p>' . wfMsg( $msg ) . "</p>\n" );
$this->returnToMain( false );
$this->output();
@ -500,15 +500,15 @@ class OutputPage {
{
global $wgUser;
$this->setPageTitle( wfMsg( "sysoptitle" ) );
$this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
$this->setRobotpolicy( "noindex,nofollow" );
$this->setPageTitle( wfMsg( 'sysoptitle' ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$this->mBodytext = "";
$this->mBodytext = '';
$sk = $wgUser->getSkin();
$ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
$this->addHTML( wfMsg( "sysoptext", $ap ) );
$ap = $sk->makeKnownLink( wfMsg( 'administrators' ), '' );
$this->addHTML( wfMsg( 'sysoptext', $ap ) );
$this->returnToMain();
}
@ -516,15 +516,15 @@ class OutputPage {
{
global $wgUser;
$this->setPageTitle( wfMsg( "developertitle" ) );
$this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
$this->setRobotpolicy( "noindex,nofollow" );
$this->setPageTitle( wfMsg( 'developertitle' ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$this->mBodytext = "";
$this->mBodytext = '';
$sk = $wgUser->getSkin();
$ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
$this->addHTML( wfMsg( "developertext", $ap ) );
$ap = $sk->makeKnownLink( wfMsg( 'administrators' ), '' );
$this->addHTML( wfMsg( 'developertext', $ap ) );
$this->returnToMain();
}
@ -532,19 +532,19 @@ class OutputPage {
{
global $wgUser, $wgTitle, $wgLang;
$this->setPageTitle( wfMsg( "loginreqtitle" ) );
$this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
$this->setRobotpolicy( "noindex,nofollow" );
$this->setPageTitle( wfMsg( 'loginreqtitle' ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->setArticleFlag( false );
$this->mBodytext = "";
$this->addWikiText( wfMsg( "loginreqtext" ) );
$this->mBodytext = '';
$this->addWikiText( wfMsg( 'loginreqtext' ) );
# We put a comment in the .html file so a Sysop can diagnose the page the
# user can't see.
$this->addHTML( "\n<!--" .
$wgLang->getNsText( $wgTitle->getNamespace() ) .
":" .
$wgTitle->getDBkey() . "-->" );
':' .
$wgTitle->getDBkey() . '-->' );
$this->returnToMain(); # Flip back to the main page after 10 seconds.
}
@ -552,22 +552,22 @@ class OutputPage {
{
global $wgUser, $wgCommandLineMode;
$this->setPageTitle( wfMsgNoDB( "databaseerror" ) );
$this->setRobotpolicy( "noindex,nofollow" );
$this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$this->enableClientCache( false );
$this->mRedirect = "";
$this->mRedirect = '';
if ( $wgCommandLineMode ) {
$msg = wfMsgNoDB( "dberrortextcl", htmlspecialchars( $sql ),
$msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
} else {
$msg = wfMsgNoDB( "dberrortext", htmlspecialchars( $sql ),
$msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
}
if ( $wgCommandLineMode || !is_object( $wgUser )) {
print "$msg\n";
print $msg."\n";
wfErrorExit();
}
$this->mBodytext = $msg;
@ -579,24 +579,24 @@ class OutputPage {
{
global $wgUser, $wgReadOnlyFile;
$this->setRobotpolicy( "noindex,nofollow" );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
if( $protected ) {
$this->setPageTitle( wfMsg( "viewsource" ) );
$this->addWikiText( wfMsg( "protectedtext" ) );
$this->setPageTitle( wfMsg( 'viewsource' ) );
$this->addWikiText( wfMsg( 'protectedtext' ) );
} else {
$this->setPageTitle( wfMsg( "readonly" ) );
$this->setPageTitle( wfMsg( 'readonly' ) );
$reason = file_get_contents( $wgReadOnlyFile );
$this->addWikiText( wfMsg( "readonlytext", $reason ) );
$this->addWikiText( wfMsg( 'readonlytext', $reason ) );
}
if( is_string( $source ) ) {
if( strcmp( $source, "" ) == 0 ) {
$source = wfMsg( "noarticletext" );
if( strcmp( $source, '' ) == 0 ) {
$source = wfMsg( 'noarticletext' );
}
$rows = $wgUser->getOption( "rows" );
$cols = $wgUser->getOption( "cols" );
$rows = $wgUser->getOption( 'rows' );
$cols = $wgUser->getOption( 'cols' );
$text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
htmlspecialchars( $source ) . "\n</textarea>";
$this->addHTML( $text );
@ -611,7 +611,7 @@ class OutputPage {
$this->setRobotpolicy( "noindex,nofollow" );
$this->setArticleRelated( false );
$this->enableClientCache( false );
$this->mRedirect = "";
$this->mRedirect = '';
$this->mBodytext = $message;
$this->output();
@ -620,27 +620,27 @@ class OutputPage {
function unexpectedValueError( $name, $val )
{
$this->fatalError( wfMsg( "unexpected", $name, $val ) );
$this->fatalError( wfMsg( 'unexpected', $name, $val ) );
}
function fileCopyError( $old, $new )
{
$this->fatalError( wfMsg( "filecopyerror", $old, $new ) );
$this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
}
function fileRenameError( $old, $new )
{
$this->fatalError( wfMsg( "filerenameerror", $old, $new ) );
$this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
}
function fileDeleteError( $name )
{
$this->fatalError( wfMsg( "filedeleteerror", $name ) );
$this->fatalError( wfMsg( 'filedeleteerror', $name ) );
}
function fileNotFoundError( $name )
{
$this->fatalError( wfMsg( "filenotfound", $name ) );
$this->fatalError( wfMsg( 'filenotfound', $name ) );
}
// return from error messages or notes
@ -655,15 +655,15 @@ class OutputPage {
}
$sk = $wgUser->getSkin();
if ( "" == $returnto ) {
$returnto = wfMsg( "mainpage" );
if ( '' == $returnto ) {
$returnto = wfMsg( 'mainpage' );
}
$link = $sk->makeKnownLink( $returnto, "" );
$link = $sk->makeKnownLink( $returnto, '' );
$r = wfMsg( "returnto", $link );
$r = wfMsg( 'returnto', $link );
if ( $auto ) {
$titleObj = Title::newFromText( $returnto );
$wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->escapeFullURL() );
$wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
}
$wgOut->addHTML( "\n<p>$r</p>\n" );
}
@ -677,14 +677,14 @@ class OutputPage {
$bad = array_keys ( $wgLinkCache->mBadLinks ) ;
$a = array_merge ( $good , $bad ) ;
$a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
$a = implode ( "," , $a ) ;
$a = implode ( ',' , $a ) ;
$strip = array(
"/<.*?" . ">/" => '',
"/[_]/" => ' '
);
$a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
$wgOut->addMeta ( "KEYWORDS" , $a ) ;
$wgOut->addMeta ( 'KEYWORDS' , $a ) ;
}
/* private */ function headElement()
@ -696,7 +696,7 @@ class OutputPage {
if( $xml ) {
$ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
} else {
$ret = "";
$ret = '';
}
$ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
@ -707,9 +707,9 @@ class OutputPage {
if( $xml ) {
$xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
} else {
$xmlbits = "";
$xmlbits = '';
}
$rtl = $wgLang->isRTL() ? " dir='RTL'" : "";
$rtl = $wgLang->isRTL() ? " dir='RTL'" : '';
$ret .= "<html $xmlbits lang=\"$wgLanguageCode\" $rtl>\n";
$ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle ) . "</title>\n";
array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
@ -717,7 +717,7 @@ class OutputPage {
$ret .= $this->getHeadLinks();
global $wgStylePath;
if( $this->isPrintable() ) {
$media = "";
$media = '';
} else {
$media = "media='print'";
}
@ -735,18 +735,18 @@ class OutputPage {
function getHeadLinks() {
global $wgRequest, $wgStylePath;
$ret = "";
$ret = '';
foreach ( $this->mMetatags as $tag ) {
if ( 0 == strcasecmp( "http:", substr( $tag[0], 0, 5 ) ) ) {
$a = "http-equiv";
if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
$a = 'http-equiv';
$tag[0] = substr( $tag[0], 5 );
} else {
$a = "name";
$a = 'name';
}
$ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
}
$p = $this->mRobotpolicy;
if ( "" == $p ) { $p = "index,follow"; }
if ( '' == $p ) { $p = 'index,follow'; }
$ret .= "<meta name=\"robots\" content=\"$p\" />\n";
if ( count( $this->mKeywords ) > 0 ) {
@ -758,7 +758,7 @@ class OutputPage {
htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords ))) . "\" />\n";
}
foreach ( $this->mLinktags as $tag ) {
$ret .= "<link";
$ret .= '<link';
foreach( $tag as $attr => $val ) {
$ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
}
@ -766,9 +766,9 @@ class OutputPage {
}
if( $this->isSyndicated() ) {
# FIXME: centralize the mime-type and name information in Feed.php
$link = $wgRequest->escapeAppendQuery( "feed=rss" );
$link = $wgRequest->escapeAppendQuery( 'feed=rss' );
$ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
$link = $wgRequest->escapeAppendQuery( "feed=atom" );
$link = $wgRequest->escapeAppendQuery( 'feed=atom' );
$ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
}
# FIXME: get these working
@ -805,12 +805,12 @@ class OutputPage {
$colours = array();
# Get placeholders from body
wfProfileIn( "$fname-match" );
wfProfileIn( $fname.'-match' );
preg_match_all( "/<!--LINK (.*?) (.*?) (.*?) (.*?)-->/", $text, $tmpLinks );
wfProfileOut( "$fname-match" );
wfProfileOut( $fname.'-match' );
if ( !empty( $tmpLinks[0] ) ) {
wfProfileIn( "$fname-check" );
wfProfileIn( $fname.'-check' );
$dbr =& wfGetDB( DB_SLAVE );
$cur = $dbr->tableName( 'cur' );
$sk = $wgUser->getSkin();
@ -856,16 +856,16 @@ class OutputPage {
$current = $val;
$query .= ")) OR (cur_namespace=$val AND cur_title IN(";
} else {
$query .= ", ";
$query .= ', ';
}
$query .= $dbr->addQuotes( $dbkeys[$key] );
}
}
if ( $query ) {
$query .= "))";
$query .= '))';
if ( $options & RLH_FOR_UPDATE ) {
$query .= " FOR UPDATE";
$query .= ' FOR UPDATE';
}
$res = $dbr->query( $query, $fname );
@ -891,10 +891,10 @@ class OutputPage {
}
}
}
wfProfileOut( "$fname-check" );
wfProfileOut( $fname.'-check' );
# Construct search and replace arrays
wfProfileIn( "$fname-construct" );
wfProfileIn( $fname.'-construct' );
global $outputReplace;
$outputReplace = array();
foreach ( $namespaces as $key => $ns ) {
@ -911,16 +911,16 @@ class OutputPage {
$outputReplace[$searchkey] = $sk->makeStubLinkObj( $title, $texts[$key], $queries[$key] );
}
}
wfProfileOut( "$fname-construct" );
wfProfileOut( $fname.'-construct' );
# Do the thing
wfProfileIn( "$fname-replace" );
wfProfileIn( $fname.'-replace' );
$text = preg_replace_callback(
'/(<!--LINK .*? .*? .*? .*?-->)/',
"outputReplaceMatches",
$text);
wfProfileOut( "$fname-replace" );
wfProfileOut( $fname.'-replace' );
}
wfProfileOut( $fname );
return $colours;

View file

@ -25,17 +25,17 @@ class PageHistory {
# Client cache fresh and headers sent, nothing more to do.
return;
}
$fname = "PageHistory::history";
$fname = 'PageHistory::history';
wfProfileIn( $fname );
$wgOut->setPageTitle( $this->mTitle->getPRefixedText() );
$wgOut->setSubtitle( wfMsg( "revhistory" ) );
$wgOut->setSubtitle( wfMsg( 'revhistory' ) );
$wgOut->setArticleFlag( false );
$wgOut->setArticleRelated( true );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
if( $this->mTitle->getArticleID() == 0 ) {
$wgOut->addHTML( wfMsg( "nohistory" ) );
$wgOut->addHTML( wfMsg( 'nohistory' ) );
wfProfileOut( $fname );
return;
}
@ -80,7 +80,7 @@ class PageHistory {
$numbar = wfViewPrevNext(
$offset, $limit,
$this->mTitle->getPrefixedText(),
"action=history", $atend );
'action=history', $atend );
$s = $numbar;
if($this->linesonpage > 0) {
$submitpart1 = '<input class="historysubmit" type="submit" accesskey="'.wfMsg('accesskey-compareselectedversions').
@ -119,8 +119,8 @@ class PageHistory {
function beginHistoryList()
{
global $wgTitle;
$this->lastdate = $this->lastline = "";
$s = "\n<p>" . wfMsg( "histlegend" ).'</p>';
$this->lastdate = $this->lastline = '';
$s = "\n<p>" . wfMsg( 'histlegend' ).'</p>';
$s .="\n<form action=\"" . $wgTitle->escapeLocalURL( '-' ) . "\" method=\"get\">";
$s .= "<input type=\"hidden\" name=\"title\" value=\"".htmlspecialchars($wgTitle->getPrefixedDbKey())."\"/>\n";
$s .= !empty($this->submitbuttonhtml1) ? $this->submitbuttonhtml1."\n":'';
@ -130,9 +130,9 @@ class PageHistory {
function endHistoryList( $skip = false )
{
$last = wfMsg( "last" );
$last = wfMsg( 'last' );
$s = $skip ? "" : preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
$s = $skip ? '' : preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline );
$s .= "</ul>";
$s .= !empty($this->submitbuttonhtml2) ? $this->submitbuttonhtml2."\n":'';
$s .= "</form>\n";
@ -144,44 +144,44 @@ class PageHistory {
global $wgLang;
$artname = Title::makeName( $ns, $ttl );
$last = wfMsg( "last" );
$cur = wfMsg( "cur" );
$cr = wfMsg( "currentrev" );
$last = wfMsg( 'last' );
$cur = wfMsg( 'cur' );
$cr = wfMsg( 'currentrev' );
if ( $oid && $this->lastline ) {
$ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->mSkin->makeKnownLink(
$artname, $last, "diff=\\1&oldid={$oid}",'' ,'' ,' tabindex="'.$counter.'"' ), $this->lastline );
} else {
$ret = "";
$ret = '';
}
$dt = $wgLang->timeanddate( $ts, true );
if ( $oid ) {
$q = "oldid={$oid}";
$q = 'oldid='.$oid;
} else {
$q = "";
$q = '';
}
$link = $this->mSkin->makeKnownLink( $artname, $dt, $q );
if ( 0 == $u ) {
$ul = $this->mSkin->makeKnownLink( $wgLang->specialPage( "Contributions" ),
htmlspecialchars( $ut ), "target=" . urlencode( $ut ) );
$ul = $this->mSkin->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
htmlspecialchars( $ut ), 'target=' . urlencode( $ut ) );
} else {
$ul = $this->mSkin->makeLink( $wgLang->getNsText(
Namespace::getUser() ) . ":{$ut}", htmlspecialchars( $ut ) );
Namespace::getUser() ) . ':'.$ut , htmlspecialchars( $ut ) );
}
$s = "<li>";
$s = '<li>';
if ( $oid ) {
$curlink = $this->mSkin->makeKnownLink( $artname, $cur,
"diff=0&oldid={$oid}" );
'diff=0&oldid='.$oid );
} else {
$curlink = $cur;
}
$arbitrary = "";
$arbitrary = '';
if( $this->linesonpage > 1) {
# XXX: move title texts to javascript
$checkmark = "";
$checkmark = '';
if ( !$oid ) {
$arbitrary = '<input type="radio" style="visibility:hidden" name="oldid" value="'.$oid.'" title="'.wfMsg('selectolderversionfordiff').'" />';
$checkmark = ' checked="checked"';
@ -196,7 +196,7 @@ class PageHistory {
$s .= $isminor ? ' <span class="minor">'.wfMsg( "minoreditletter" ).'</span>': '' ;
if ( "" != $c && "*" != $c ) {
if ( '' != $c && '*' != $c ) {
$c = $this->mSkin->formatcomment($c);
$s .= " <em>(" . $c . ")</em>";

View file

@ -32,13 +32,13 @@
# the generated page would be proportional to the square of the input size.
# Hence, we limit the number of inclusions of any given page, thus bringing any
# attack back to O(N).
define( "MAX_INCLUDE_REPEAT", 100 );
define( "MAX_INCLUDE_SIZE", 1000000 ); // 1 Million
define( 'MAX_INCLUDE_REPEAT', 100 );
define( 'MAX_INCLUDE_SIZE', 1000000 ); // 1 Million
# Allowed values for $mOutputType
define( "OT_HTML", 1 );
define( "OT_WIKI", 2 );
define( "OT_MSG" , 3 );
define( 'OT_HTML', 1 );
define( 'OT_WIKI', 2 );
define( 'OT_MSG' , 3 );
# string parameter for extractTags which will cause it
# to strip HTML comments in addition to regular
@ -108,7 +108,7 @@ class Parser
#
function parse( $text, &$title, $options, $linestart = true, $clearState = true ) {
global $wgUseTidy;
$fname = "Parser::parse";
$fname = 'Parser::parse';
wfProfileIn( $fname );
if ( $clearState ) {
@ -176,7 +176,7 @@ class Parser
# If $tag is set to STRIP_COMMENTS, the function will extract
# <!-- HTML comments -->
/* static */ function extractTags($tag, $text, &$content, $uniq_prefix = ""){
/* static */ function extractTags($tag, $text, &$content, $uniq_prefix = ''){
$rnd = $uniq_prefix . '-' . $tag . Parser::getRandomString();
if ( !$content ) {
$content = array( );
@ -239,7 +239,7 @@ class Parser
# Raw and unchecked for validity.
$html_content[$marker] = $content;
} else {
$html_content[$marker] = "<html>$content</html>";
$html_content[$marker] = '<html>'.$content.'</html>';
}
}
}
@ -250,7 +250,7 @@ class Parser
if( $render ){
$nowiki_content[$marker] = wfEscapeHTMLTagsOnly( $content );
} else {
$nowiki_content[$marker] = "<nowiki>$content</nowiki>";
$nowiki_content[$marker] = '<nowiki>'.$content.'</nowiki>';
}
}
@ -261,10 +261,10 @@ class Parser
if( $this->mOptions->getUseTeX() ) {
$math_content[$marker] = renderMath( $content );
} else {
$math_content[$marker] = "&lt;math&gt;$content&lt;math&gt;";
$math_content[$marker] = '&lt;math&gt;'.$content.'&lt;math&gt;';
}
} else {
$math_content[$marker] = "<math>$content</math>";
$math_content[$marker] = '<math>'.$content.'</math>';
}
}
@ -274,7 +274,7 @@ class Parser
if( $render ){
$pre_content[$marker] = '<pre>' . wfEscapeHTMLTagsOnly( $content ) . '</pre>';
} else {
$pre_content[$marker] = "<pre>$content</pre>";
$pre_content[$marker] = '<pre>'.$content.'</pre>';
}
}
@ -282,7 +282,7 @@ class Parser
if($stripcomments) {
$text = Parser::extractTags(STRIP_COMMENTS, $text, $comment_content, $uniq_prefix);
foreach( $comment_content as $marker => $content ){
$comment_content[$marker] = "<!--$content-->";
$comment_content[$marker] = '<!--'.$content.'-->';
}
}
@ -400,7 +400,7 @@ class Parser
"(in_array(strtolower(\"\$1\"),\$htmlattrs)?(\"\$1\".((\"x\$3\" != \"x\")?\"=\$3\":'')):'')",
$t);
$t = str_replace ( "<></>" , "" , $t ) ; # This should fix bug 980557
$t = str_replace ( '<></>' , '' , $t ) ; # This should fix bug 980557
# Strip javascript "expression" from stylesheets. Brute force approach:
# If anythin offensive is found, all attributes of the HTML tag are dropped
@ -481,8 +481,8 @@ class Parser
if ( preg_match( '/^(:*)\{\|(.*)$/', $x, $matches ) ) {
$indent_level = strlen( $matches[1] );
$t[$k] = "\n" .
str_repeat( "<dl><dd>", $indent_level ) .
"<table " . $this->fixTagAttributes ( $matches[2] ) . '>' ;
str_repeat( '<dl><dd>', $indent_level ) .
'<table ' . $this->fixTagAttributes ( $matches[2] ) . '>' ;
array_push ( $td , false ) ;
array_push ( $ltd , '' ) ;
array_push ( $tr , false ) ;
@ -495,7 +495,7 @@ class Parser
if ( array_pop ( $tr ) ) $z = '</tr>' . $z ;
if ( array_pop ( $td ) ) $z = '</'.$l.'>' . $z ;
array_pop ( $ltr ) ;
$t[$k] = $z . str_repeat( "</dd></dl>", $indent_level );
$t[$k] = $z . str_repeat( '</dd></dl>', $indent_level );
}
else if ( '|-' == substr ( $x , 0 , 2 ) ) { # Allows for |---------------
$x = substr ( $x , 1 ) ;
@ -706,9 +706,9 @@ class Parser
{
$x1 = substr ($arr[$i-1], -1);
$x2 = substr ($arr[$i-1], -2, 1);
if ($x1 == " ") {
if ($x1 == ' ') {
if ($firstspace == -1) $firstspace = $i;
} else if ($x2 == " ") {
} else if ($x2 == ' ') {
if ($firstsingleletterword == -1) $firstsingleletterword = $i;
} else {
if ($firstmultiletterword == -1) $firstmultiletterword = $i;
@ -758,41 +758,41 @@ class Parser
if (strlen ($r) == 2)
{
if ($state == 'em')
{ $output .= "</em>"; $state = ''; }
{ $output .= '</em>'; $state = ''; }
else if ($state == 'strongem')
{ $output .= "</em>"; $state = 'strong'; }
{ $output .= '</em>'; $state = 'strong'; }
else if ($state == 'emstrong')
{ $output .= "</strong></em><strong>"; $state = 'strong'; }
{ $output .= '</strong></em><strong>'; $state = 'strong'; }
else if ($state == 'both')
{ $output .= "<strong><em>{$buffer}</em>"; $state = 'strong'; }
{ $output .= '<strong><em>'.$buffer.'</em>'; $state = 'strong'; }
else # $state can be 'strong' or ''
{ $output .= "<em>"; $state .= 'em'; }
{ $output .= '<em>'; $state .= 'em'; }
}
else if (strlen ($r) == 3)
{
if ($state == 'strong')
{ $output .= "</strong>"; $state = ''; }
{ $output .= '</strong>'; $state = ''; }
else if ($state == 'strongem')
{ $output .= "</em></strong><em>"; $state = 'em'; }
{ $output .= '</em></strong><em>'; $state = 'em'; }
else if ($state == 'emstrong')
{ $output .= "</strong>"; $state = 'em'; }
{ $output .= '</strong>'; $state = 'em'; }
else if ($state == 'both')
{ $output .= "<em><strong>{$buffer}</strong>"; $state = 'em'; }
{ $output .= '<em><strong>'.$buffer.'</strong>'; $state = 'em'; }
else # $state can be 'em' or ''
{ $output .= "<strong>"; $state .= 'strong'; }
{ $output .= '<strong>'; $state .= 'strong'; }
}
else if (strlen ($r) == 5)
{
if ($state == 'strong')
{ $output .= "</strong><em>"; $state = 'em'; }
{ $output .= '</strong><em>'; $state = 'em'; }
else if ($state == 'em')
{ $output .= "</em><strong>"; $state = 'strong'; }
{ $output .= '</em><strong>'; $state = 'strong'; }
else if ($state == 'strongem')
{ $output .= "</em></strong>"; $state = ''; }
{ $output .= '</em></strong>'; $state = ''; }
else if ($state == 'emstrong')
{ $output .= "</strong></em>"; $state = ''; }
{ $output .= '</strong></em>'; $state = ''; }
else if ($state == 'both')
{ $output .= "<em><strong>{$buffer}</strong></em>"; $state = ''; }
{ $output .= '<em><strong>'.$buffer.'</strong></em>'; $state = ''; }
else # ($state == '')
{ $buffer = ''; $state = 'both'; }
}
@ -807,7 +807,7 @@ class Parser
if ($state == 'strongem')
$output .= '</strong>';
if ($state == 'both')
$output .= "<strong><em>{$buffer}</em></strong>";
$output .= '<strong><em>'.$buffer.'</em></strong>';
return $output;
}
}
@ -846,7 +846,7 @@ class Parser
if ( $text == '' ) {
# Autonumber if allowed
if ( strpos( HTTP_PROTOCOLS, $protocol ) !== false ) {
$text = "[" . ++$this->mAutonumber . "]";
$text = '[' . ++$this->mAutonumber . ']';
} else {
# Otherwise just use the URL
$text = htmlspecialchars( $url );
@ -862,7 +862,7 @@ class Parser
$encUrl = htmlspecialchars( $url );
# Bit in parentheses showing the URL for the printable version
if( $url == $text || preg_match( "!$protocol://" . preg_quote( $text, "/" ) . "/?$!", $url ) ) {
if( $url == $text || preg_match( "!$protocol://" . preg_quote( $text, '/' ) . "/?$!", $url ) ) {
$paren = '';
} else {
# Expand the URL for printable version
@ -1092,7 +1092,7 @@ class Parser
if ( $ns == NS_CATEGORY ) {
$t = $nt->getText() ;
$nnt = Title::newFromText ( Namespace::getCanonicalName(NS_CATEGORY).":".$t ) ;
$nnt = Title::newFromText ( Namespace::getCanonicalName(NS_CATEGORY).':'.$t ) ;
$wgLinkCache->suspend(); # Don't save in links/brokenlinks
$pPLC=$sk->postParseLinkColour();
@ -1279,7 +1279,7 @@ class Parser
# FIXME: This is dupe of code above
if( preg_match( '/^(.*?(?:\s|&nbsp;)):(.*)$/', $t, $match ) ) {
$term = $match[1];
$output .= $term . $this->nextItem( ":" );
$output .= $term . $this->nextItem( ':' );
$t = $match[2];
}
}
@ -1307,7 +1307,7 @@ class Parser
$inBlockElem = true;
}
} else if ( !$inBlockElem && !$this->mInPre ) {
if ( " " == $t{0} and ( $this->mLastSection == 'pre' or trim($t) != '' ) ) {
if ( ' ' == $t{0} and ( $this->mLastSection == 'pre' or trim($t) != '' ) ) {
// pre
if ($this->mLastSection != 'pre') {
$paragraphStack = false;
@ -1472,8 +1472,8 @@ class Parser
$argc = count($args);
$i = 0;
for ( $i = 0; $i < $argc-1; $i++ ) {
if ( substr_count ( $args[$i], "[[" ) != substr_count ( $args[$i], "]]" ) ) {
$args[$i] .= "|".$args[$i+1];
if ( substr_count ( $args[$i], '[[' ) != substr_count ( $args[$i], ']]' ) ) {
$args[$i] .= '|'.$args[$i+1];
array_splice($args, $i+1, 1);
$i--;
$argc--;
@ -2007,7 +2007,7 @@ class Parser
}
# give headline the correct <h#> tag
@$head[$headlineCount] .= "<a name=\"$anchor\"></a><h".$level.$matches[2][$headlineCount] .$headline."</h".$level.">";
@$head[$headlineCount] .= "<a name=\"$anchor\"></a><h".$level.$matches[2][$headlineCount] .$headline.'</h'.$level.'>';
$headlineCount++;
}
@ -2057,7 +2057,7 @@ class Parser
$fname = 'Parser::magicISBN';
wfProfileIn( $fname );
$a = split( 'ISBN ', " $text" );
$a = split( 'ISBN ', ' '.$text );
if ( count ( $a ) < 2 ) {
wfProfileOut( $fname );
return $text;
@ -2083,7 +2083,7 @@ class Parser
} else {
$titleObj = Title::makeTitle( NS_SPECIAL, 'Booksources' );
$text .= '<a href="' .
$titleObj->escapeLocalUrl( "isbn={$num}" ) .
$titleObj->escapeLocalUrl( 'isbn='.$num ) .
"\" class=\"internal\">ISBN $isbn</a>";
$text .= $x;
}
@ -2099,13 +2099,13 @@ class Parser
wfProfileIn( $fname );
# These next five lines are only for the ~35000 U.S. Census Rambot pages...
$directions = array ( "N" => "North" , "S" => "South" , "E" => "East" , "W" => "West" ) ;
$directions = array ( 'N' => 'North' , 'S' => 'South' , 'E' => 'East' , 'W' => 'West' ) ;
$text = preg_replace ( "/(\d+)&deg;(\d+)'(\d+)\" {$directions['N']}, (\d+)&deg;(\d+)'(\d+)\" {$directions['W']}/" , "(GEO +\$1.\$2.\$3:-\$4.\$5.\$6)" , $text ) ;
$text = preg_replace ( "/(\d+)&deg;(\d+)'(\d+)\" {$directions['N']}, (\d+)&deg;(\d+)'(\d+)\" {$directions['E']}/" , "(GEO +\$1.\$2.\$3:+\$4.\$5.\$6)" , $text ) ;
$text = preg_replace ( "/(\d+)&deg;(\d+)'(\d+)\" {$directions['S']}, (\d+)&deg;(\d+)'(\d+)\" {$directions['W']}/" , "(GEO +\$1.\$2.\$3:-\$4.\$5.\$6)" , $text ) ;
$text = preg_replace ( "/(\d+)&deg;(\d+)'(\d+)\" {$directions['S']}, (\d+)&deg;(\d+)'(\d+)\" {$directions['E']}/" , "(GEO +\$1.\$2.\$3:+\$4.\$5.\$6)" , $text ) ;
$a = split( 'GEO ', " $text" );
$a = split( 'GEO ', ' '.$text );
if ( count ( $a ) < 2 ) {
wfProfileOut( $fname );
return $text;
@ -2126,12 +2126,12 @@ class Parser
$num = str_replace( '+', '', $geo );
$num = str_replace( ' ', '', $num );
if ( '' == $num || count ( explode ( ":" , $num , 3 ) ) < 2 ) {
if ( '' == $num || count ( explode ( ':' , $num , 3 ) ) < 2 ) {
$text .= "GEO $blank$x";
} else {
$titleObj = Title::makeTitle( NS_SPECIAL, 'Geo' );
$text .= '<a href="' .
$titleObj->escapeLocalUrl( "coordinates={$num}" ) .
$titleObj->escapeLocalUrl( 'coordinates='.$num ) .
"\" class=\"internal\">GEO $geo</a>";
$text .= $x;
}
@ -2166,7 +2166,7 @@ class Parser
$url = wfmsg( 'rfcurl' );
$url = str_replace( '$1', $rfc, $url);
$sk =& $this->mOptions->getSkin();
$la = $sk->getExternalLinkAttributes( $url, "RFC {$rfc}" );
$la = $sk->getExternalLinkAttributes( $url, 'RFC '.$rfc );
$text .= "<a href='{$url}'{$la}>RFC {$rfc}</a>{$x}";
}
}
@ -2316,14 +2316,14 @@ class ParserOutput
var $mText, $mLanguageLinks, $mCategoryLinks, $mContainsOldMagic;
var $mCacheTime; # Used in ParserCache
function ParserOutput( $text = "", $languageLinks = array(), $categoryLinks = array(),
function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
$containsOldMagic = false )
{
$this->mText = $text;
$this->mLanguageLinks = $languageLinks;
$this->mCategoryLinks = $categoryLinks;
$this->mContainsOldMagic = $containsOldMagic;
$this->mCacheTime = "";
$this->mCacheTime = '';
}
function getText() { return $this->mText; }
@ -2396,7 +2396,7 @@ class ParserOptions
function initialiseFromUser( &$userInput ) {
global $wgUseTeX, $wgUseCategoryMagic, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
$fname = "ParserOptions::initialiseFromUser";
$fname = 'ParserOptions::initialiseFromUser';
wfProfileIn( $fname );
if ( !$userInput ) {
$user = new User;
@ -2410,9 +2410,9 @@ class ParserOptions
$this->mUseDynamicDates = $wgUseDynamicDates;
$this->mInterwikiMagic = $wgInterwikiMagic;
$this->mAllowExternalImages = $wgAllowExternalImages;
wfProfileIn( "$fname-skin" );
wfProfileIn( $fname.'-skin' );
$this->mSkin =& $user->getSkin();
wfProfileOut( "$fname-skin" );
wfProfileOut( $fname.'-skin' );
$this->mDateFormat = $user->getOption( 'date' );
$this->mEditSection = $user->getOption( 'editsection' );
$this->mEditSectionOnRightClick = $user->getOption( 'editsectiononrightclick' );

View file

@ -12,7 +12,7 @@ class ParserCache
function get( &$article, &$user ) {
global $wgMemc, $wgCacheEpoch;
$fname = "ParserCache::get";
$fname = 'ParserCache::get';
wfProfileIn( $fname );
$hash = $user->getPageRenderingHash();

View file

@ -4,27 +4,27 @@
// the base class for an element
class element {
var $name = "";
var $name = '';
var $attrs = array();
var $children = array();
function myPrint() {
echo "<UL>";
echo '<UL>';
echo "<LI> <B> Name: </B> $this->name";
// print attributes
echo "<LI> <B> Attributes: </B>";
echo '<LI> <B> Attributes: </B>';
foreach ($this->attrs as $name => $value) {
echo "$name => $value; " ;
}
// print children
foreach ($this->children as $child) {
if ( is_string($child) ) {
echo "<LI> $child";
echo '<LI> '.$child;
} else {
$child->myPrint();
}
}
echo "</UL>";
echo '</UL>';
}
}
@ -76,10 +76,10 @@ class xml2php {
$ancStack = array();
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "wgXMLstartElement", "wgXMLendElement");
xml_set_character_data_handler($xml_parser, "wgXMLcharacterData");
if (!($fp = fopen($filename, "r"))) {
die("could not open XML input");
xml_set_element_handler($xml_parser, 'wgXMLstartElement', 'wgXMLendElement');
xml_set_character_data_handler($xml_parser, 'wgXMLcharacterData');
if (!($fp = fopen($filename, 'r'))) {
die('could not open XML input');
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
@ -103,4 +103,4 @@ $result->myPrint();
return 0;
?>
?>

View file

@ -6,7 +6,7 @@ function wfProfileIn( $functionname )
$wgProfiler->profileIn( $functionname );
}
function wfProfileOut( $functionname = "missing" )
function wfProfileOut( $functionname = 'missing' )
{
global $wgProfiler;
$wgProfiler->profileOut( $functionname );
@ -46,8 +46,8 @@ class Profiler
function profileIn( $functionname )
{
global $wgDebugFunctionEntry;
if ( $wgDebugFunctionEntry && function_exists( "wfDebug" ) ) {
wfDebug( str_repeat( " ", count( $this->mWorkStack ) ) . "Entering $functionname\n" );
if ( $wgDebugFunctionEntry && function_exists( 'wfDebug' ) ) {
wfDebug( str_repeat( ' ', count( $this->mWorkStack ) ) . 'Entering '.$functionname."\n" );
}
array_push( $this->mWorkStack, array($functionname, count( $this->mWorkStack ), microtime(), memory_get_usage() ) );
}
@ -57,8 +57,8 @@ class Profiler
$memory = memory_get_usage();
global $wgDebugProfiling, $wgDebugFunctionEntry;
if ( $wgDebugFunctionEntry && function_exists( "wfDebug" ) ) {
wfDebug( str_repeat( " ", count( $this->mWorkStack ) - 1 ) . "Exiting $functionname\n" );
if ( $wgDebugFunctionEntry && function_exists( 'wfDebug' ) ) {
wfDebug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting '.$functionname."\n" );
}
$bit = array_pop( $this->mWorkStack );
@ -67,7 +67,7 @@ class Profiler
wfDebug( "Profiling error, !\$bit: $functionname\n" );
} else {
if ( $wgDebugProfiling ) {
if ( $functionname == "close" ) {
if ( $functionname == 'close' ) {
wfDebug( "Profile section ended by close(): {$bit[0]}\n" );
} elseif ( $bit[0] != $functionname ) {
wfDebug( "Profiling error: in({$bit[0]}), out($functionname)\n" );
@ -82,7 +82,7 @@ class Profiler
function close()
{
while ( count( $this->mWorkStack ) ) {
$this->profileOut( "close" );
$this->profileOut( 'close' );
}
}
@ -99,27 +99,27 @@ class Profiler
$format = "%-" . ($width - 34) . "s %6d %6.3f %6.3f %6.3f%% %6d\n";
$titleFormat = "%-" . ($width - 34) . "s %9s %9s %9s %9s %6s\n";
$prof = "\nProfiling data\n";
$prof .= sprintf( $titleFormat, "Name", "Calls", "Total", "Each", "%", "Mem" );
$prof .= sprintf( $titleFormat, 'Name', 'Calls', 'Total', 'Each', '%', 'Mem' );
$this->mCollated = array();
$this->mCalls = array();
$this->mMemory = array();
# Estimate profiling overhead
$profileCount = count( $this->mStack );
wfProfileIn( "-overhead-total" );
wfProfileIn( '-overhead-total' );
for ($i=0; $i<$profileCount ; $i++) {
wfProfileIn( "-overhead-internal" );
wfProfileOut( "-overhead-internal" );
wfProfileIn( '-overhead-internal' );
wfProfileOut( '-overhead-internal' );
}
wfProfileOut( "-overhead-total" );
wfProfileOut( '-overhead-total' );
# Collate
foreach ( $this->mStack as $entry ) {
$fname = $entry[0];
$thislevel = $entry[1];
$start = explode( " ", $entry[2]);
$start = explode( ' ', $entry[2]);
$start = (float)$start[0] + (float)$start[1];
$end = explode( " ", $entry[4]);
$end = explode( ' ', $entry[4]);
$end = (float)$end[0] + (float)$end[1];
$elapsed = $end - $start;
@ -136,16 +136,16 @@ class Profiler
$this->mMemory[$fname] += $memory;
}
$total = @$this->mCollated["-total"];
$overhead = $this->mCollated["-overhead-internal"] / $profileCount;
$this->mCalls["-overhead-total"] = $profileCount;
$total = @$this->mCollated['-total'];
$overhead = $this->mCollated['-overhead-internal'] / $profileCount;
$this->mCalls['-overhead-total'] = $profileCount;
# Output
arsort( $this->mCollated, SORT_NUMERIC );
foreach ( $this->mCollated as $fname => $elapsed ) {
$calls = $this->mCalls[$fname];
# Adjust for overhead
if ( $fname[0] != "-" ) {
if ( $fname[0] != '-' ) {
$elapsed -= $overhead * $calls;
}
@ -194,5 +194,5 @@ class Profiler
$wgProfiler = new Profiler();
$wgProfiler->profileIn( "-total" );
$wgProfiler->profileIn( '-total' );
?>

View file

@ -126,7 +126,7 @@ class QueryPage {
FROM $querycache WHERE qc_type='$type'";
}
if( $wgMiserMode ) {
$wgOut->addWikiText( wfMsg( "perfcached" ) );
$wgOut->addWikiText( wfMsg( 'perfcached' ) );
}
}
if ( $res === false ) {
@ -158,7 +158,7 @@ class QueryPage {
$s .= "<li{$attr}>{$format}</li>\n";
}
$dbr->freeResult( $res );
$s .= "</ol>";
$s .= '</ol>';
$wgOut->addHTML( $s );
$wgOut->addHTML( "<p>{$sl}</p>\n" );
}
@ -230,7 +230,7 @@ class QueryPage {
}
if( isset( $row->text ) ) {
$text = "<p>" . htmlspecialchars( wfMsg( "summary" ) ) . ": " . $text . "</p>\n<hr />\n<div>" .
$text = '<p>' . htmlspecialchars( wfMsg( 'summary' ) ) . ': ' . $text . "</p>\n<hr />\n<div>" .
nl2br( htmlspecialchars( $row->text ) ) . "</div>";;
}
return $text;
@ -252,7 +252,7 @@ class QueryPage {
}
function feedDesc() {
return wfMsg( "fromwikipedia" );
return wfMsg( 'fromwikipedia' );
}
function feedUrl() {
@ -270,7 +270,7 @@ class PageQueryPage extends QueryPage {
function formatResult( $skin, $result ) {
$nt = Title::makeTitle( $result->namespace, $result->title );
return $skin->makeKnownLinkObj( $nt, "" );
return $skin->makeKnownLinkObj( $nt, '' );
}
}

View file

@ -1,11 +1,11 @@
<?php
# Utility class for creating new RC entries
define( "RC_EDIT", 0);
define( "RC_NEW", 1);
define( "RC_MOVE", 2);
define( "RC_LOG", 3);
define( "RC_MOVE_OVER_REDIRECT", 4);
define( 'RC_EDIT', 0);
define( 'RC_NEW', 1);
define( 'RC_MOVE', 2);
define( 'RC_LOG', 3);
define( 'RC_MOVE_OVER_REDIRECT', 4);
/*
@ -88,7 +88,7 @@ class RecentChange
function save()
{
global $wgUseRCQueue, $wgRCQueueID, $wgLocalInterwiki, $wgPutIPinRC;
$fname = "RecentChange::save";
$fname = 'RecentChange::save';
$dbw =& wfGetDB( DB_MASTER );
if ( !is_array($this->mExtra) ) {
@ -105,7 +105,7 @@ class RecentChange
$this->mAttribs['rc_cur_time']=$dbw->timestamp($this->mAttribs['rc_cur_time']);
# Insert new row
$dbw->insertArray( "recentchanges", $this->mAttribs, $fname );
$dbw->insertArray( 'recentchanges', $this->mAttribs, $fname );
# Update old rows, if necessary
if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
@ -146,7 +146,7 @@ class RecentChange
# Marks a certain row as patrolled
function markPatrolled( $rcid )
{
$fname = "RecentChange::markPatrolled";
$fname = 'RecentChange::markPatrolled';
$dbw =& wfGetDB( DB_MASTER );
@ -163,7 +163,7 @@ class RecentChange
/*static*/ function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
$oldId, $lastTimestamp, $bot = "default", $ip = '' )
{
if ( $bot == "default " ) {
if ( $bot == 'default ' ) {
$bot = $user->isBot();
}
@ -208,7 +208,7 @@ class RecentChange
global $wgIP;
$ip = empty( $wgIP ) ? '' : $wgIP;
}
if ( $bot == "default" ) {
if ( $bot == 'default' ) {
$bot = $user->isBot();
}
@ -332,16 +332,16 @@ class RecentChange
function loadFromCurRow( $row )
{
$this->mAttribs = array(
"rc_timestamp" => $row->cur_timestamp,
"rc_cur_time" => $row->cur_timestamp,
"rc_user" => $row->cur_user,
"rc_user_text" => $row->cur_user_text,
"rc_namespace" => $row->cur_namespace,
"rc_title" => $row->cur_title,
"rc_comment" => $row->cur_comment,
"rc_minor" => !!$row->cur_minor_edit,
"rc_type" => $row->cur_is_new ? RC_NEW : RC_EDIT,
"rc_cur_id" => $row->cur_id,
'rc_timestamp' => $row->cur_timestamp,
'rc_cur_time' => $row->cur_timestamp,
'rc_user' => $row->cur_user,
'rc_user_text' => $row->cur_user_text,
'rc_namespace' => $row->cur_namespace,
'rc_title' => $row->cur_title,
'rc_comment' => $row->cur_comment,
'rc_minor' => !!$row->cur_minor_edit,
'rc_type' => $row->cur_is_new ? RC_NEW : RC_EDIT,
'rc_cur_id' => $row->cur_id,
'rc_this_oldid' => 0,
'rc_last_oldid' => 0,
'rc_bot' => 0,
@ -365,12 +365,12 @@ class RecentChange
$trail = "curid=" . (int)($this->mAttribs['rc_cur_id']) .
"&oldid=" . (int)($this->mAttribs['rc_last_oldid']);
if ( $forceCur ) {
$trail .= "&diff=0" ;
$trail .= '&diff=0' ;
} else {
$trail .= "&diff=" . (int)($this->mAttribs['rc_this_oldid']);
$trail .= '&diff=' . (int)($this->mAttribs['rc_this_oldid']);
}
} else {
$trail = "";
$trail = '';
}
return $trail;
}

View file

@ -1,8 +1,8 @@
<?php
# See search.doc
define( "MW_SEARCH_OK", true );
define( "MW_SEARCH_BAD_QUERY", false );
define( 'MW_SEARCH_OK', true );
define( 'MW_SEARCH_BAD_QUERY', false );
class SearchEngine {
/* private */ var $rawText, $filteredText, $searchTerms;
@ -20,7 +20,7 @@ class SearchEngine {
# We display the query, so let's strip it for safety
#
global $wgDBmysql4;
$lc = SearchEngine::legalSearchChars() . "()";
$lc = SearchEngine::legalSearchChars() . '()';
if( $wgDBmysql4 ) {
$lc .= "\"~<>*+-";
}
@ -33,19 +33,19 @@ class SearchEngine {
# Return a partial WHERE clause to limit the search to the given namespaces
function queryNamespaces() {
$namespaces = implode( ",", $this->namespacesToSearch );
if ($namespaces == "") {
$namespaces = "0";
$namespaces = implode( ',', $this->namespacesToSearch );
if ($namespaces == '') {
$namespaces = '0';
}
return "AND cur_namespace IN (" . $namespaces . ")";
return "AND cur_namespace IN (" . $namespaces . ')';
}
# Return a partial WHERE clause to include or exclude redirects from results
function searchRedirects() {
if ( $this->doSearchRedirects ) {
return "";
return '';
} else {
return "AND cur_is_redirect=0 ";
return 'AND cur_is_redirect=0 ';
}
}
@ -55,7 +55,7 @@ class SearchEngine {
if ($wgUser->getID()) {
// User is logged in so we retrieve his default namespaces
return $wgUser->getOption( "searchNs".$i );
return $wgUser->getOption( 'searchNs'.$i );
} else {
// User is not logged in so we give him the global default namespaces
return !empty($wgNamespacesToBeSearchedDefault[ $i ]);
@ -72,11 +72,11 @@ class SearchEngine {
$searchx = $wgRequest->getVal( 'searchx' );
$listredirs = $wgRequest->getVal( 'redirs' );
$ret = wfMsg("powersearchtext"); # Text to be returned
$tempText = ""; # Temporary text, for substitution into $ret
$ret = wfMsg('powersearchtext'); # Text to be returned
$tempText = ''; # Temporary text, for substitution into $ret
if( isset( $_REQUEST["searchx"] ) ) {
$this->addToQuery["searchx"] = "1";
if( isset( $_REQUEST['searchx'] ) ) {
$this->addToQuery['searchx'] = '1';
}
# Do namespace checkboxes
@ -87,7 +87,7 @@ class SearchEngine {
continue;
}
$formVar = "ns$i";
$formVar = 'ns'.$i;
# Initialise checkboxValues, either from defaults or from
# a previous invocation
@ -97,46 +97,46 @@ class SearchEngine {
$checkboxValue = $wgRequest->getVal( $formVar );
}
$checked = "";
$checked = '';
if ( $checkboxValue == 1 ) {
$checked = " checked='checked'";
$this->addToQuery["ns{$i}"] = 1;
$checked = ' checked="checked"';
$this->addToQuery['ns'.$i] = 1;
array_push( $this->namespacesToSearch, $i );
}
$name = str_replace( "_", " ", $namespaces[$i] );
if ( "" == $name ) {
$name = wfMsg( "blanknamespace" );
$name = str_replace( '_', ' ', $namespaces[$i] );
if ( '' == $name ) {
$name = wfMsg( 'blanknamespace' );
}
if ( $tempText !== "" ) {
$tempText .= " ";
if ( $tempText !== '' ) {
$tempText .= ' ';
}
$tempText .= "<input type='checkbox' value=\"1\" name=\"" .
"ns{$i}\"{$checked} />{$name}\n";
}
$ret = str_replace ( "$1", $tempText, $ret );
$ret = str_replace ( '$1', $tempText, $ret );
# List redirects checkbox
$checked = "";
$checked = '';
if ( $listredirs == 1 ) {
$this->addToQuery["redirs"] = 1;
$checked = " checked='checked'";
$this->addToQuery['redirs'] = 1;
$checked = ' checked="checked"';
}
$tempText = "<input type='checkbox' value='1' name=\"redirs\"{$checked} />\n";
$ret = str_replace( "$2", $tempText, $ret );
$ret = str_replace( '$2', $tempText, $ret );
# Search field
$tempText = "<input type='text' name=\"search\" value=\"" .
htmlspecialchars( $search ) ."\" width='80' />\n";
htmlspecialchars( $search ) ."\" width=\"80\" />\n";
$ret = str_replace( "$3", $tempText, $ret );
# Searchx button
$tempText = "<input type='submit' name=\"searchx\" value=\"" .
wfMsg("powersearch") . "\" />\n";
$ret = str_replace( "$9", $tempText, $ret );
$tempText = '<input type="submit" name="searchx" value="' .
wfMsg('powersearch') . "\" />\n";
$ret = str_replace( '$9', $tempText, $ret );
$action = $sk->escapeSearchLink();
$ret = "<br /><br />\n<form id=\"powersearch\" method=\"get\" " .
@ -152,17 +152,17 @@ class SearchEngine {
function setupPage() {
global $wgOut;
$wgOut->setPageTitle( wfMsg( "searchresults" ) );
$wgOut->setSubtitle( wfMsg( "searchquery", htmlspecialchars( $this->rawText ) ) );
$wgOut->setPageTitle( wfMsg( 'searchresults' ) );
$wgOut->setSubtitle( wfMsg( 'searchquery', htmlspecialchars( $this->rawText ) ) );
$wgOut->setArticleRelated( false );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
}
# Perform the search and construct the results page
function showResults() {
global $wgUser, $wgTitle, $wgOut, $wgLang;
global $wgDisableTextSearch, $wgInputEncoding;
$fname = "SearchEngine::showResults";
$fname = 'SearchEngine::showResults';
$search = $this->rawText;
@ -171,19 +171,19 @@ class SearchEngine {
$this->setupPage();
$sk = $wgUser->getSkin();
$wgOut->addWikiText( wfMsg( "searchresulttext" ) );
$wgOut->addWikiText( wfMsg( 'searchresulttext' ) );
if ( !$this->parseQuery() ) {
$wgOut->addWikiText(
"==" . wfMsg( "badquery" ) . "==\n" .
wfMsg( "badquerytext" ) );
'==' . wfMsg( 'badquery' ) . "==\n" .
wfMsg( 'badquerytext' ) );
return;
}
list( $limit, $offset ) = wfCheckLimits( 20, "searchlimit" );
list( $limit, $offset ) = wfCheckLimits( 20, 'searchlimit' );
if ( $wgDisableTextSearch ) {
$wgOut->addHTML( wfMsg( "searchdisabled" ) );
$wgOut->addHTML( wfMsg( "googlesearch",
$wgOut->addHTML( wfMsg( 'searchdisabled' ) );
$wgOut->addHTML( wfMsg( 'googlesearch',
htmlspecialchars( $this->rawText ),
htmlspecialchars( $wgInputEncoding ) ) );
return;
@ -203,21 +203,21 @@ class SearchEngine {
$wgOut->addHTML( "<p>{$top}</p>\n" );
# For powersearch
$a2l = "";
$a2l = '';
$akk = array_keys( $this->addToQuery );
foreach ( $akk AS $ak ) {
$a2l .= "&{$ak}={$this->addToQuery[$ak]}" ;
}
$prevnext = wfViewPrevNext( $offset, $limit, "",
"search=" . wfUrlencode( $this->filteredText ) . $a2l );
$prevnext = wfViewPrevNext( $offset, $limit, '',
'search=' . wfUrlencode( $this->filteredText ) . $a2l );
$wgOut->addHTML( "<br />{$prevnext}\n" );
$foundsome = $this->showMatches( $titleMatches, $offset, "notitlematches", "titlematches" )
|| $this->showMatches( $textMatches, $offset, "notextmatches", "textmatches" );
$foundsome = $this->showMatches( $titleMatches, $offset, 'notitlematches', 'titlematches' )
|| $this->showMatches( $textMatches, $offset, 'notextmatches', 'textmatches' );
if ( !$foundsome ) {
$wgOut->addWikiText( wfMsg( "nonefound" ) );
$wgOut->addWikiText( wfMsg( 'nonefound' ) );
}
$wgOut->addHTML( "<p>{$prevnext}</p>\n" );
$wgOut->addHTML( $powersearch );
@ -243,26 +243,26 @@ class SearchEngine {
global $wgDBminWordLen, $wgLang;
# on non mysql4 database: get list of words we don't want to search for
require_once( "FulltextStoplist.php" );
require_once( 'FulltextStoplist.php' );
$lc = SearchEngine::legalSearchChars() . "()";
$lc = SearchEngine::legalSearchChars() . '()';
$q = preg_replace( "/([()])/", " \\1 ", $this->filteredText );
$q = preg_replace( "/\\s+/", " ", $q );
$w = explode( " ", trim( $q ) );
$w = explode( ' ', trim( $q ) );
$last = $cond = "";
$last = $cond = '';
foreach ( $w as $word ) {
$word = $wgLang->stripForSearch( $word );
if ( "and" == $word || "or" == $word || "not" == $word
|| "(" == $word || ")" == $word ) {
$cond .= " " . strtoupper( $word );
$last = "";
if ( 'and' == $word || 'or' == $word || 'not' == $word
|| '(' == $word || ')' == $word ) {
$cond .= ' ' . strtoupper( $word );
$last = '';
} else if ( strlen( $word ) < $wgDBminWordLen ) {
continue;
} else if ( FulltextStoplist::inList( $word ) ) {
continue;
} else {
if ( "" != $last ) { $cond .= " AND"; }
if ( '' != $last ) { $cond .= ' AND'; }
$cond .= " (MATCH (##field##) AGAINST ('" .
$this->db->strencode( $word ). "'))";
$last = $word;
@ -273,11 +273,11 @@ class SearchEngine {
return MW_SEARCH_BAD_QUERY;
}
$this->titleCond = "(" . str_replace( "##field##",
"si_title", $cond ) . " )";
$this->titleCond = '(' . str_replace( '##field##',
'si_title', $cond ) . ' )';
$this->textCond = "(" . str_replace( "##field##",
"si_text", $cond ) . " AND (cur_is_redirect=0) )";
$this->textCond = '(' . str_replace( '##field##',
'si_text', $cond ) . ' AND (cur_is_redirect=0) )';
return MW_SEARCH_OK;
}
@ -285,16 +285,16 @@ class SearchEngine {
function parseQuery4() {
global $wgLang;
$lc = SearchEngine::legalSearchChars();
$searchon = "";
$searchon = '';
$this->searchTerms = array();
# FIXME: This doesn't handle parenthetical expressions.
if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
$this->filteredText, $m, PREG_SET_ORDER ) ) {
foreach( $m as $terms ) {
if( $searchon !== "" ) $searchon .= " ";
if( $this->strictMatching && ($terms[1] == "") ) {
$terms[1] = "+";
if( $searchon !== '' ) $searchon .= ' ';
if( $this->strictMatching && ($terms[1] == '') ) {
$terms[1] = '+';
}
$searchon .= $terms[1] . $wgLang->stripForSearch( $terms[2] );
if( $terms[3] ) {
@ -329,7 +329,7 @@ class SearchEngine {
"{$searchnamespaces} {$redircond} " .
$this->db->limitResult( $limit, $offset );
$res = $this->db->query( $sql, "SearchEngine::getMatches" );
$res = $this->db->query( $sql, 'SearchEngine::getMatches' );
$matches = array();
while ( $row = $this->db->fetchObject( $res ) ) {
$matches[] = $row;
@ -368,13 +368,13 @@ class SearchEngine {
}
$sk = $wgUser->getSkin();
$contextlines = $wgUser->getOption( "contextlines" );
if ( "" == $contextlines ) { $contextlines = 5; }
$contextchars = $wgUser->getOption( "contextchars" );
if ( "" == $contextchars ) { $contextchars = 50; }
$contextlines = $wgUser->getOption( 'contextlines' );
if ( '' == $contextlines ) { $contextlines = 5; }
$contextchars = $wgUser->getOption( 'contextchars' );
if ( '' == $contextchars ) { $contextchars = 50; }
$link = $sk->makeKnownLink( $t, "" );
$size = wfMsg( "nbytes", strlen( $row->cur_text ) );
$link = $sk->makeKnownLink( $t, '' );
$size = wfMsg( 'nbytes', strlen( $row->cur_text ) );
$wgOut->addHTML( "<li>{$link} ({$size})" );
$lines = explode( "\n", $row->cur_text );
@ -391,18 +391,18 @@ class SearchEngine {
continue;
}
$pre = $wgLang->truncate( $m[1], -$contextchars, "..." );
$pre = $wgLang->truncate( $m[1], -$contextchars, '...' );
if ( count( $m ) < 3 ) {
$post = "";
$post = '';
} else {
$post = $wgLang->truncate( $m[3], $contextchars, "..." );
$post = $wgLang->truncate( $m[3], $contextchars, '...' );
}
$found = $m[2];
$line = htmlspecialchars( $pre . $found . $post );
$pat2 = "/(" . implode( "|", $this->searchTerms ) . ")/i";
$pat2 = '/(' . implode( '|', $this->searchTerms ) . ")/i";
$line = preg_replace( $pat2,
"<span class='searchmatch'>\\1</span>", $line );
@ -451,7 +451,7 @@ class SearchEngine {
function goResult() {
global $wgOut, $wgGoToEdit;
global $wgDisableTextSearch;
$fname = "SearchEngine::goResult";
$fname = 'SearchEngine::goResult';
# Try to go to page as entered.
#
@ -475,16 +475,16 @@ class SearchEngine {
# If the feature is enabled, go straight to the edit page
if ( $wgGoToEdit ) {
$wgOut->redirect( $t->getFullURL( "action=edit" ) );
$wgOut->redirect( $t->getFullURL( 'action=edit' ) );
return;
}
if( $t ) {
$editurl = $t->escapeLocalURL( "action=edit" );
$editurl = $t->escapeLocalURL( 'action=edit' );
} else {
$editurl = ""; # ??
$editurl = ''; # ??
}
$wgOut->addHTML( "<p>" . wfMsg("nogomatch", $editurl ) . "</p>\n" );
$wgOut->addHTML( '<p>' . wfMsg('nogomatch', $editurl ) . "</p>\n" );
# Try a fuzzy title search
$anyhit = false;
@ -506,25 +506,25 @@ class SearchEngine {
$this->setupPage();
$sstr = ucfirst($search);
$sstr = str_replace(" ", "_", $sstr);
$sstr = str_replace(' ', '_', $sstr);
$fuzzymatches = SearchEngine::fuzzyTitles( $sstr, $namespace );
$fuzzymatches = array_slice($fuzzymatches, 0, 10);
$slen = strlen( $search );
$wikitext = "";
$wikitext = '';
foreach($fuzzymatches as $res){
$t = str_replace("_", " ", $res[1]);
$t = str_replace('_', ' ', $res[1]);
$tfull = $wgLang->getNsText( $namespace ) . ":$t|$t";
if( $namespace == NS_MAIN )
$tfull = "$t";
$distance = $res[0];
$closeness = (strlen( $search ) - $distance) / strlen( $search );
$percent = intval( $closeness * 100 ) . "%";
$stars = str_repeat("*", ceil(5 * $closeness) );
$percent = intval( $closeness * 100 ) . '%';
$stars = str_repeat('*', ceil(5 * $closeness) );
$wikitext .= "* [[$tfull]] $percent ($stars)\n";
}
if( $wikitext ){
if( $namespace != NS_MAIN )
$wikitext = "=== " . $wgLang->getNsText( $namespace ) . " ===\n" . $wikitext;
$wikitext = '=== ' . $wgLang->getNsText( $namespace ) . " ===\n" . $wikitext;
$wgOut->addWikiText( $wikitext );
return true;
}
@ -552,7 +552,7 @@ class SearchEngine {
$cnt++;
}
}
usort($result, "SearchEngine_pcmp");
usort($result, 'SearchEngine_pcmp');
return $result;
}

View file

@ -30,11 +30,11 @@ class SearchUpdate {
if( $wgDisableSearchUpdate || !$this->mId ) {
return false;
}
$fname = "SearchUpdate::doUpdate";
$fname = 'SearchUpdate::doUpdate';
wfProfileIn( $fname );
require_once( 'SearchEngine.php' );
$lc = SearchEngine::legalSearchChars() . "&#;";
$lc = SearchEngine::legalSearchChars() . '&#;';
$db =& wfGetDB( DB_MASTER );
$searchindex = $db->tableName( 'searchindex' );
@ -52,9 +52,9 @@ class SearchUpdate {
# Language-specific strip/conversion
$text = $wgLang->stripForSearch( $this->mText );
wfProfileIn( "$fname-regexps" );
wfProfileIn( $fname.'-regexps' );
$text = preg_replace( "/<\\/?\\s*[A-Za-z][A-Za-z0-9]*\\s*([^>]*?)>/",
" ", strtolower( " " . $text /*$this->mText*/ . " " ) ); # Strip HTML markup
' ', strtolower( " " . $text /*$this->mText*/ . " " ) ); # Strip HTML markup
$text = preg_replace( "/(^|\\n)\\s*==\\s+([^\\n]+)\\s+==\\s/sD",
"\\2 \\2 \\2 ", $text ); # Emphasize headings
@ -104,7 +104,7 @@ class SearchUpdate {
$sql = "REPLACE INTO $searchindex (si_page,si_title,si_text) VALUES ({$this->mId},'" .
$db->strencode( Title::indexTitle( $this->mNamespace, $this->mTitle ) ) . "','" .
$db->strencode( $text ) . "')";
$db->query( $sql, "SearchUpdate::doUpdate" );
$db->query( $sql, 'SearchUpdate::doUpdate' );
wfProfileOut( $fname );
}
}

View file

@ -1,7 +1,7 @@
<?php
# This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
if( defined( "MEDIAWIKI" ) ) {
if( defined( 'MEDIAWIKI' ) ) {
# The main wiki script and things like database
# conversion and maintenance scripts all share a

View file

@ -13,7 +13,7 @@ class SiteConfiguration {
$retval = $this->settings[$setting][$wiki];
} elseif ( array_key_exists( $suffix, $this->settings[$setting] ) ) {
$retval = $this->settings[$setting][$suffix];
} elseif ( array_key_exists( "default", $this->settings[$setting] ) ) {
} elseif ( array_key_exists( 'default', $this->settings[$setting] ) ) {
$retval = $this->settings[$setting]['default'];
} else {
$retval = NULL;

View file

@ -17,28 +17,28 @@ class SiteStatsUpdate {
{
$a = array();
if ( $this->mViews < 0 ) { $m = "-1"; }
else if ( $this->mViews > 0 ) { $m = "+1"; }
else $m = "";
if ( $this->mViews < 0 ) { $m = '-1'; }
else if ( $this->mViews > 0 ) { $m = '+1'; }
else $m = '';
array_push( $a, "ss_total_views=(ss_total_views$m)" );
if ( $this->mEdits < 0 ) { $m = "-1"; }
else if ( $this->mEdits > 0 ) { $m = "+1"; }
else $m = "";
if ( $this->mEdits < 0 ) { $m = '-1'; }
else if ( $this->mEdits > 0 ) { $m = '+1'; }
else $m = '';
array_push( $a, "ss_total_edits=(ss_total_edits$m)" );
if ( $this->mGood < 0 ) { $m = "-1"; }
else if ( $this->mGood > 0 ) { $m = "+1"; }
else $m = "";
if ( $this->mGood < 0 ) { $m = '-1'; }
else if ( $this->mGood > 0 ) { $m = '+1'; }
else $m = '';
array_push( $a, "ss_good_articles=(ss_good_articles$m)" );
$db =& wfGetDB( DB_MASTER );
$site_stats = $db->tableName( 'site_stats' );
$lowpri = $db->lowPriorityOption();
$sql = "UPDATE $lowpri $site_stats SET " . implode ( ",", $a ) .
" WHERE ss_row_id=1";
$db->query( $sql, "SiteStatsUpdate::doUpdate" );
$sql = "UPDATE $lowpri $site_stats SET " . implode ( ',', $a ) .
' WHERE ss_row_id=1';
$db->query( $sql, 'SiteStatsUpdate::doUpdate' );
}
}

View file

@ -22,6 +22,8 @@ function wfSpecialRecentchanges( $par )
$hideliu = $wgRequest->getBool( 'hideliu', false ) ? 1 : 0;
$hidepatrolled = $wgRequest->getBool( 'hidepatrolled', false ) ? 1 : 0;
list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
# Get query parameters from path
if( $par ) {
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
@ -33,6 +35,8 @@ function wfSpecialRecentchanges( $par )
if( in_array( 'hidepatrolled', $bits) ) $hidepatrolled = 1;
}
# Database connection and caching
$dbr =& wfGetDB( DB_SLAVE );
extract( $dbr->tableNames( 'recentchanges', 'watchlist' ) );
@ -44,20 +48,11 @@ function wfSpecialRecentchanges( $par )
return;
}
# The next few lines can probably be commented out now that wfMsg can get text from the DB
/* $rctext = $dbr->selectField( 'cur', 'cur_text',
array( 'cur_namespace' => NS_WIKIPEDIA, 'cur_title' => 'Recentchanges' ),
$fname
);
if( !$rctext ) {
$rctext = wfMsg( "recentchangestext" );
} */
# Output header
$rctext = wfMsg( "recentchangestext" );
$wgOut->addWikiText( $rctext );
list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
$now = wfTimestampNow();
$cutoff_unixtime = time() - ( $days * 86400 );
$cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
@ -69,6 +64,7 @@ function wfSpecialRecentchanges( $par )
}
$sk = $wgUser->getSkin();
$showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ));
$hidem = ( $hideminor ) ? 'AND rc_minor=0' : '';
@ -77,7 +73,7 @@ function wfSpecialRecentchanges( $par )
$hidem .= ( $hidepatrolled )? ' AND rc_patrolled=0' : '';
$urlparams = array( 'hideminor' => $hideminor, 'hideliu' => $hideliu,
'hidebots' => $hidebots, 'hidepatrolled' => $hidepatrolled );
'hidebots' => $hidebots, 'hidepatrolled' => $hidepatrolled);
$hideparams = wfArrayToCGI( $urlparams );
$minorLink = $sk->makeKnownLink( $wgLang->specialPage( 'Recentchanges' ),

View file

@ -86,7 +86,7 @@ class SquidUpdate {
/* static */ function purge( $urlArr ) {
global $wgSquidServers;
if ( $wgSquidServers == "echo" ) {
if ( $wgSquidServers == 'echo' ) {
echo implode("<br>\n", $urlArr);
return;
}
@ -126,7 +126,7 @@ class SquidUpdate {
$failed = true;
$totalsockets -= $sockspersq;
} else {
$msg ="PURGE " . $firsturl . " HTTP/1.0\r\n".
$msg = 'PURGE ' . $firsturl . " HTTP/1.0\r\n".
"Connection: Keep-Alive\r\n\r\n";
#$this->debug($msg);
@fputs($socket,$msg);
@ -169,7 +169,7 @@ class SquidUpdate {
}
}
$urindex = $r + $urlspersocket * ($s - $sockspersq * floor($s / $sockspersq));
$msg = "PURGE " . $urlArr[$urindex] . " HTTP/1.0\r\n".
$msg = 'PURGE ' . $urlArr[$urindex] . " HTTP/1.0\r\n".
"Connection: Keep-Alive\r\n\r\n";
#$this->debug($msg);
@fputs($sockets[$s],$msg);

View file

@ -238,8 +238,8 @@ class Title {
global $wgLang;
$n = $wgLang->getNsText( $ns );
if ( "" == $n ) { return $title; }
else { return "{$n}:{$title}"; }
if ( '' == $n ) { return $title; }
else { return $n.':'.$title; }
}
# Arguably static
@ -261,13 +261,13 @@ class Title {
}
$dbr =& wfGetDB( DB_SLAVE );
$res = $dbr->select( 'interwiki', array( 'iw_url', 'iw_local' ), array( 'iw_prefix' => $key ), $fname );
if(!$res) return "";
if(!$res) return '';
$s = $dbr->fetchObject( $res );
if(!$s) {
# Cache non-existence: create a blank object and save it to memcached
$s = (object)false;
$s->iw_url = "";
$s->iw_url = '';
$s->iw_local = 0;
}
$wgMemc->set( $k, $s, $wgInterwikiExpiry );
@ -545,7 +545,7 @@ class Title {
# Compatibility with old settings
if( $this->getNamespace() == NS_MAIN ) {
if( in_array( ":" . $name, $wgWhitelistRead ) ) return true;
if( in_array( ':' . $name, $wgWhitelistRead ) ) return true;
}
return false;
}
@ -669,7 +669,7 @@ class Title {
# Initialisation
if ( $imgpre === false ) {
$imgpre = ':' . $wgLang->getNsText( Namespace::getImage() ) . ":";
$imgpre = ':' . $wgLang->getNsText( Namespace::getImage() ) . ':';
# % is needed as well
$rxTc = '/[^' . Title::legalChars() . ']/';
}
@ -805,7 +805,7 @@ class Title {
$links = $db->tableName( 'links' );
$sql = "SELECT cur_namespace,cur_title,cur_id FROM $cur,$links WHERE l_from=cur_id AND l_to={$id} $options";
$res = $db->query( $sql, "Title::getLinksTo" );
$res = $db->query( $sql, 'Title::getLinksTo' );
$retVal = array();
if ( $db->numRows( $res ) ) {
while ( $row = $db->fetchObject( $res ) ) {
@ -907,7 +907,7 @@ class Title {
$sql = "UPDATE categorylinks SET cl_sortkey=" . $dbw->addQuotes( $nt->getPrefixedText() ) .
" WHERE cl_from=" . $dbw->addQuotes( $this->getArticleID() ) .
" AND cl_sortkey=" . $dbw->addQuotes( $this->getPrefixedText() );
$dbw->query( $sql, "SpecialMovepage::doSubmit" );
$dbw->query( $sql, 'SpecialMovepage::doSubmit' );
# Update watchlists
@ -923,7 +923,7 @@ class Title {
# Update search engine
$u = new SearchUpdate( $oldid, $nt->getPrefixedDBkey() );
$u->doUpdate();
$u = new SearchUpdate( $newid, $this->getPrefixedDBkey(), "" );
$u = new SearchUpdate( $newid, $this->getPrefixedDBkey(), '' );
$u->doUpdate();
return true;
@ -934,7 +934,7 @@ class Title {
/* private */ function moveOverExistingRedirect( &$nt ) {
global $wgUser, $wgLinkCache, $wgUseSquid, $wgMwRedir;
$fname = 'Title::moveOverExistingRedirect';
$comment = wfMsg( "1movedto2", $this->getPrefixedText(), $nt->getPrefixedText() );
$comment = wfMsg( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
$now = wfTimestampNow();
$won = wfInvertTimestamp( $now );
@ -966,7 +966,7 @@ class Title {
'inverse_timestamp' => $won,
'cur_namespace' => $this->getNamespace(),
'cur_title' => $this->getDBkey(),
'cur_text' => $wgMwRedir->getSynonym( 0 ) . " [[" . $nt->getPrefixedText() . "]]\n",
'cur_text' => $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n",
'cur_comment' => $comment,
'cur_user' => $wgUser->getID(),
'cur_minor_edit' => 0,
@ -1189,7 +1189,7 @@ class Title {
return false;
}
$fname = "Title::createRedirect";
$fname = 'Title::createRedirect';
$dbw =& wfGetDB( DB_MASTER );
$now = wfTimestampNow();
$won = wfInvertTimestamp( $now );
@ -1280,7 +1280,7 @@ class Title {
foreach ( array_reverse($stack) as $child => $parent )
{
# make a link of that parent
$result .= $sk->makeLink($wgLang->getNSText ( Namespace::getCategory() ).":".$parent,$parent);
$result .= $sk->makeLink($wgLang->getNSText ( Namespace::getCategory() ).':'.$parent,$parent);
$result .= ' &gt; ';
$lastchild = $child;
}

View file

@ -67,7 +67,7 @@ class Tokenizer {
// still one token from the last round around. Return that one first.
$token = array_shift( $this->mQueuedToken );
} else if ( $this->mPos > $this->mTextLength ) {
// If no text is left, return "false".
// If no text is left, return 'false'.
$token = false;
} else {
@ -185,7 +185,7 @@ class Tokenizer {
// strip blank from Token
$token['text'] = substr( $token['text'], 0, -1 );
$queueToken['type'] = 'blank';
$queueToken['text'] = " {$ch}";
$queueToken['text'] = ' '.$ch;
$this->mQueuedToken[] = $queueToken;
$this->mPos ++;
break 2; // switch + while
@ -202,7 +202,7 @@ class Tokenizer {
case '8':
case '9':
if ( ($this->mTextLength >= $this->mPos +2)
&& ($this->mText[$this->mPos+1] == " ")
&& ($this->mText[$this->mPos+1] == ' ')
&& ctype_digit( $this->mText[$this->mPos+2] ) )
{
$queueToken['type'] = 'blank';
@ -235,10 +235,10 @@ class Tokenizer {
break;
case '&': //extensions like <timeline>, since HTML stripping has already been done,
//those look like &lt;timeline&gt;
if ( $this->continues( "lt;timeline&gt;" ) )
if ( $this->continues( 'lt;timeline&gt;' ) )
{
$queueToken['type'] = "<timeline>";
$queueToken['text'] = "&lt;timeline&gt;";
$queueToken['type'] = '<timeline>';
$queueToken['text'] = '&lt;timeline&gt;';
$this->mQueuedToken[] = $queueToken;
$this->mPos += 16;
break 2; // switch + while

View file

@ -1,11 +1,11 @@
<?php
# See deferred.doc
require_once( "UserUpdate.php" );
require_once( "ViewCountUpdate.php" );
require_once( "SiteStatsUpdate.php" );
require_once( "LinksUpdate.php" );
require_once( "SearchUpdate.php" );
require_once( "UserTalkUpdate.php" );
require_once( "SquidUpdate.php" );
require_once( 'UserUpdate.php' );
require_once( 'ViewCountUpdate.php' );
require_once( 'SiteStatsUpdate.php' );
require_once( 'LinksUpdate.php' );
require_once( 'SearchUpdate.php' );
require_once( 'UserTalkUpdate.php' );
require_once( 'SquidUpdate.php' );
?>

View file

@ -12,33 +12,33 @@ function userMailer( $to, $from, $subject, $body )
if (is_array( $wgSMTP ))
{
require_once( "Mail.php" );
require_once( 'Mail.php' );
$timestamp = time();
$headers["From"] = $from;
$headers['From'] = $from;
/* removing to: field as it should be set by the send() function below
UNTESTED - Hashar */
// $headers["To"] = $qto;
$headers["Subject"] = $subject;
$headers["MIME-Version"] = "1.0";
$headers["Content-type"] = "text/plain; charset={$wgOutputEncoding}";
$headers["Content-transfer-encoding"] = "8bit";
$headers["Message-ID"] = "<{$timestamp}" . $wgUser->getName() . "@" . $wgSMTP["IDHost"] . ">";
$headers["X-Mailer"] = "MediaWiki interuser e-mailer";
$headers['Subject"] = $subject;
$headers['MIME-Version'] = '1.0';
$headers['Content-type'] = 'text/plain; charset='.$wgOutputEncoding;
$headers['Content-transfer-encoding'] = '8bit';
$headers['Message-ID'] = "<{$timestamp}" . $wgUser->getName() . '@' . $wgSMTP['IDHost'] . '>';
$headers['X-Mailer'] = 'MediaWiki interuser e-mailer';
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $wgSMTP);
$mail_object =& Mail::factory('smtp', $wgSMTP);
$mailResult =& $mail_object->send($to, $headers, $body);
# Based on the result return an error string,
if ($mailResult === true)
return "";
return '';
else if (is_object($mailResult))
return $mailResult->getMessage();
else
return "Mail object return unknown error.";
return 'Mail object return unknown error.';
}
else
@ -50,8 +50,8 @@ function userMailer( $to, $from, $subject, $body )
"From: {$from}\n" .
"X-Mailer: MediaWiki interuser e-mailer";
$wgErrorString = "";
set_error_handler( "mailErrorHandler" );
$wgErrorString = '';
set_error_handler( 'mailErrorHandler' );
mail( $to, $subject, $body, $headers );
restore_error_handler();

View file

@ -9,14 +9,14 @@ class UserTalkUpdate {
{
$this->mAction = $action;
$this->mNamespace = $ns;
$this->mTitle = str_replace( "_", " ", $title );
$this->mTitle = str_replace( '_', ' ', $title );
}
function doUpdate()
{
global $wgUser, $wgLang, $wgMemc, $wgDBname;
$fname = "UserTalkUpdate::doUpdate";
$fname = 'UserTalkUpdate::doUpdate';
# If namespace isn't User_talk:, do nothing.

File diff suppressed because it is too large Load diff

View file

@ -89,7 +89,7 @@ class WebRequest {
return isset( $val );
}
function getText( $name, $default = "" ) {
function getText( $name, $default = '' ) {
return $this->getGPCText( $_REQUEST, $name, $default );
}
@ -114,7 +114,7 @@ class WebRequest {
}
function checkSessionCookie() {
return isset( $_COOKIE[ini_get("session.name")] );
return isset( $_COOKIE[ini_get('session.name')] );
}
function getRequestURL() {
@ -129,12 +129,12 @@ class WebRequest {
# Take an arbitrary query and rewrite the present URL to include it
function appendQuery( $query ) {
global $wgTitle;
$basequery = "";
$basequery = '';
foreach( $_GET as $var => $val ) {
if( $var == "title" ) continue;
$basequery .= "&" . urlencode( $var ) . "=" . urlencode( $val );
if( $var == 'title' ) continue;
$basequery .= '&' . urlencode( $var ) . '=' . urlencode( $val );
}
$basequery .= "&" . $query;
$basequery .= '&' . $query;
# Trim the extra &
$basequery = substr( $basequery, 1 );

View file

@ -5,16 +5,16 @@
$wgCommandLineMode = true;
unset( $IP );
ini_set( "allow_url_fopen", 0 ); # For security...
require_once( "./LocalSettings.php" );
ini_set( 'allow_url_fopen', 0 ); # For security...
require_once( './LocalSettings.php' );
# Windows requires ';' as separator, ':' for Unix
$sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
ini_set( "include_path", "$IP$sep$include_path" );
$sep = strchr( $include_path = ini_get( 'include_path' ), ';' ) ? ';' : ':';
ini_set( 'include_path', "$IP$sep$include_path" );
require_once( "Setup.php" );
require_once( 'Setup.php' );
$wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
$wgTitle = Title::newFromText( wfMsg( 'badtitle' ) );
$wgArticle = new Article($wgTitle);
if ( !$argv[1] || !$argv[2] ) {
@ -31,6 +31,6 @@ sleep( $s );
# Kill DB thread
$conn = Database::newFromParams( $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname );
$conn->query( "KILL $tid" );
$conn->query( 'KILL '.$tid );
?>

View file

@ -4,8 +4,8 @@
# Exit if there are not enough parameters, or if it's not command line mode
$output = "";
if ( ( isset( $_REQUEST ) && array_key_exists( "argv", $_REQUEST ) ) || count( $argv ) < 4 ) {
$output = '';
if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
$output .= "Incorrect parameters\n";
} else {