Parser improvements: global variable destruction
This commit is contained in:
parent
7f0854126d
commit
db41d9ae7c
6 changed files with 284 additions and 190 deletions
|
|
@ -304,7 +304,7 @@ class Article {
|
||||||
function view()
|
function view()
|
||||||
{
|
{
|
||||||
global $wgUser, $wgOut, $wgLang;
|
global $wgUser, $wgOut, $wgLang;
|
||||||
global $oldid, $diff; # From query
|
global $oldid, $diff, $printable; # From query
|
||||||
global $wgLinkCache, $IP, $wgEnableParserCache;
|
global $wgLinkCache, $IP, $wgEnableParserCache;
|
||||||
|
|
||||||
$fname = "Article::view";
|
$fname = "Article::view";
|
||||||
|
|
@ -356,6 +356,10 @@ class Article {
|
||||||
|
|
||||||
$wgLinkCache->preFill( $this->mTitle );
|
$wgLinkCache->preFill( $this->mTitle );
|
||||||
|
|
||||||
|
if ( $printable == "yes" ) {
|
||||||
|
$wgOut->mParserOptions->setPrintable( true );
|
||||||
|
}
|
||||||
|
|
||||||
if( $wgEnableParserCache && intval($wgUser->getOption( "stubthreshold" )) == 0 ){
|
if( $wgEnableParserCache && intval($wgUser->getOption( "stubthreshold" )) == 0 ){
|
||||||
$wgOut->addWikiText( $text, true, $this );
|
$wgOut->addWikiText( $text, true, $this );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ class EditPage {
|
||||||
global $wpSave, $wpPreview;
|
global $wpSave, $wpPreview;
|
||||||
global $wpMinoredit, $wpEdittime, $wpTextbox2, $wpSection;
|
global $wpMinoredit, $wpEdittime, $wpTextbox2, $wpSection;
|
||||||
global $oldid, $redirect, $section;
|
global $oldid, $redirect, $section;
|
||||||
global $wgLang;
|
global $wgLang, $wgParser, $wgTitle;
|
||||||
global $wgAllowAnonymousMinor;
|
global $wgAllowAnonymousMinor;
|
||||||
|
|
||||||
if(isset($wpSection)) { $section=$wpSection; } else { $wpSection=$section; }
|
if(isset($wpSection)) { $section=$wpSection; } else { $wpSection=$section; }
|
||||||
|
|
||||||
|
|
@ -288,9 +288,17 @@ class EditPage {
|
||||||
}
|
}
|
||||||
$previewtext = wfUnescapeHTML( $wpTextbox1 );
|
$previewtext = wfUnescapeHTML( $wpTextbox1 );
|
||||||
|
|
||||||
|
$parserOptions = ParserOptions::newFromUser( $wgUser );
|
||||||
|
$parserOptions->setUseCategoryMagic( false );
|
||||||
|
$parserOptions->setEditSection( false );
|
||||||
|
$parserOptions->setEditSectionOnRightClick( false );
|
||||||
|
$parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $previewtext ) ."\n\n",
|
||||||
|
$wgTitle, $parserOptions );
|
||||||
|
$previewHTML = $parserOutput->mText;
|
||||||
|
|
||||||
if($wgUser->getOption("previewontop")) {
|
if($wgUser->getOption("previewontop")) {
|
||||||
$wgOut->addHTML($previewhead);
|
$wgOut->addHTML($previewhead);
|
||||||
$wgOut->addWikiText( $this->mArticle->preSaveTransform( $previewtext ) ."\n\n");
|
$wgOut->addHTML($previewHTML);
|
||||||
}
|
}
|
||||||
$wgOut->addHTML( "<br clear=\"all\" />\n" );
|
$wgOut->addHTML( "<br clear=\"all\" />\n" );
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +350,7 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
|
||||||
$wgOut->addHTML( "</form>\n" );
|
$wgOut->addHTML( "</form>\n" );
|
||||||
if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
|
if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
|
||||||
$wgOut->addHTML($previewhead);
|
$wgOut->addHTML($previewhead);
|
||||||
$wgOut->addWikiText( $this->mArticle->preSaveTransform( $previewtext ) );
|
$wgOut->addHTML($previewHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class OutputPage {
|
||||||
var $mDoNothing;
|
var $mDoNothing;
|
||||||
var $mContainsOldMagic, $mContainsNewMagic;
|
var $mContainsOldMagic, $mContainsNewMagic;
|
||||||
var $mIsArticleRelated;
|
var $mIsArticleRelated;
|
||||||
|
var $mParserOptions;
|
||||||
|
|
||||||
function OutputPage()
|
function OutputPage()
|
||||||
{
|
{
|
||||||
|
|
@ -30,6 +31,7 @@ class OutputPage {
|
||||||
$this->mCategoryLinks = array() ;
|
$this->mCategoryLinks = array() ;
|
||||||
$this->mDoNothing = false;
|
$this->mDoNothing = false;
|
||||||
$this->mContainsOldMagic = $this->mContainsNewMagic = 0;
|
$this->mContainsOldMagic = $this->mContainsNewMagic = 0;
|
||||||
|
$this->mParserOptions = ParserOptions::newFromUser( $temp = NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHeader( $name, $val ) { array_push( $this->mHeaders, "$name: $val" ) ; }
|
function addHeader( $name, $val ) { array_push( $this->mHeaders, "$name: $val" ) ; }
|
||||||
|
|
@ -136,6 +138,11 @@ class OutputPage {
|
||||||
function addHeadtext( $text ) { $this->mHeadtext .= $text; }
|
function addHeadtext( $text ) { $this->mHeadtext .= $text; }
|
||||||
function debug( $text ) { $this->mDebugtext .= $text; }
|
function debug( $text ) { $this->mDebugtext .= $text; }
|
||||||
|
|
||||||
|
function setParserOptions( $options )
|
||||||
|
{
|
||||||
|
return wfSetVar( $this->mParserOptions, $options );
|
||||||
|
}
|
||||||
|
|
||||||
# First pass--just handle <nowiki> sections, pass the rest off
|
# First pass--just handle <nowiki> sections, pass the rest off
|
||||||
# to doWikiPass2() which does all the real work.
|
# to doWikiPass2() which does all the real work.
|
||||||
#
|
#
|
||||||
|
|
@ -143,7 +150,7 @@ class OutputPage {
|
||||||
#
|
#
|
||||||
function addWikiText( $text, $linestart = true, $cacheArticle = NULL )
|
function addWikiText( $text, $linestart = true, $cacheArticle = NULL )
|
||||||
{
|
{
|
||||||
global $wgParser, $wgParserCache, $wgUser;
|
global $wgParser, $wgParserCache, $wgUser, $wgTitle;
|
||||||
|
|
||||||
$parserOutput = false;
|
$parserOutput = false;
|
||||||
if ( $cacheArticle ) {
|
if ( $cacheArticle ) {
|
||||||
|
|
@ -151,7 +158,7 @@ class OutputPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $parserOutput === false ) {
|
if ( $parserOutput === false ) {
|
||||||
$parserOutput = $wgParser->parse( $text, $linestart );
|
$parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart );
|
||||||
if ( $cacheArticle ) {
|
if ( $cacheArticle ) {
|
||||||
$wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
|
$wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,26 @@
|
||||||
|
|
||||||
include_once('Tokenizer.php');
|
include_once('Tokenizer.php');
|
||||||
|
|
||||||
# Globals used:
|
# PHP Parser
|
||||||
# objects: $wgUser, $wgTitle, $wgLang, $wgDateFormatter, $wgLinkCache, $wgCurOut, $wgArticle
|
#
|
||||||
|
# Converts wikitext to HTML.
|
||||||
#
|
#
|
||||||
# query: $wpPreview
|
# Globals used:
|
||||||
#
|
# objects: $wgLang, $wgDateFormatter, $wgLinkCache, $wgCurOut
|
||||||
# settings: $wgUseTex, $wgUseCategoryMagic, $wgUseDynamicDates, $wgInterwikiMagic,
|
#
|
||||||
# $wgNamespacesWithSubpages, $wgLanguageCode, $wgUseLinkPrefixCombination
|
# settings: $wgUseTex*, $wgUseCategoryMagic*, $wgUseDynamicDates*, $wgInterwikiMagic*,
|
||||||
|
# $wgNamespacesWithSubpages, $wgLanguageCode, $wgAllowExternalImages*
|
||||||
|
#
|
||||||
|
# * only within ParserOptions
|
||||||
|
|
||||||
class Parser
|
class Parser
|
||||||
{
|
{
|
||||||
|
# Cleared with clearState():
|
||||||
var $mOutput, $mAutonumber, $mLastSection, $mDTopen;
|
var $mOutput, $mAutonumber, $mLastSection, $mDTopen;
|
||||||
|
|
||||||
|
# Temporary:
|
||||||
|
var $mOptions, $mTitle;
|
||||||
|
|
||||||
function Parser()
|
function Parser()
|
||||||
{
|
{
|
||||||
$this->clearState();
|
$this->clearState();
|
||||||
|
|
@ -32,9 +40,8 @@ class Parser
|
||||||
#
|
#
|
||||||
# Returns a ParserOutput
|
# Returns a ParserOutput
|
||||||
#
|
#
|
||||||
function parse( $text, $linestart = true, $clearState = true )
|
function parse( $text, &$title, $options, $linestart = true, $clearState = true )
|
||||||
{
|
{
|
||||||
global $wgUseTeX;
|
|
||||||
$fname = "Parser::parse";
|
$fname = "Parser::parse";
|
||||||
wfProfileIn( $fname );
|
wfProfileIn( $fname );
|
||||||
$unique = "3iyZiyA7iMwg5rhxP0Dcc9oTnj8qD1jm1Sfv4";
|
$unique = "3iyZiyA7iMwg5rhxP0Dcc9oTnj8qD1jm1Sfv4";
|
||||||
|
|
@ -53,7 +60,10 @@ class Parser
|
||||||
if ( $clearState ) {
|
if ( $clearState ) {
|
||||||
$this->clearState();
|
$this->clearState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->mOptions = $options;
|
||||||
|
$this->mTitle =& $title;
|
||||||
|
|
||||||
# Replace any instances of the placeholders
|
# Replace any instances of the placeholders
|
||||||
$text = str_replace( $unique, wfHtmlEscapeFirst( $unique ), $text );
|
$text = str_replace( $unique, wfHtmlEscapeFirst( $unique ), $text );
|
||||||
$text = str_replace( $unique2, wfHtmlEscapeFirst( $unique2 ), $text );
|
$text = str_replace( $unique2, wfHtmlEscapeFirst( $unique2 ), $text );
|
||||||
|
|
@ -72,7 +82,7 @@ class Parser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $wgUseTeX ) {
|
if( $this->mOptions->getUseTeX() ) {
|
||||||
while ( "" != $stripped ) {
|
while ( "" != $stripped ) {
|
||||||
$p = preg_split( "/<\\s*math\\s*>/i", $stripped, 2 );
|
$p = preg_split( "/<\\s*math\\s*>/i", $stripped, 2 );
|
||||||
$stripped2 .= $p[0];
|
$stripped2 .= $p[0];
|
||||||
|
|
@ -130,11 +140,11 @@ class Parser
|
||||||
|
|
||||||
function categoryMagic ()
|
function categoryMagic ()
|
||||||
{
|
{
|
||||||
global $wgTitle , $wgUseCategoryMagic, $wgLang ;
|
global $wgLang ;
|
||||||
if ( !isset ( $wgUseCategoryMagic ) || !$wgUseCategoryMagic ) return ;
|
if ( !$this->mOptions->getUseCategoryMagic() ) return ;
|
||||||
$id = $wgTitle->getArticleID() ;
|
$id = $this->mTitle->getArticleID() ;
|
||||||
$cat = ucfirst ( wfMsg ( "category" ) ) ;
|
$cat = ucfirst ( wfMsg ( "category" ) ) ;
|
||||||
$ti = $wgTitle->getText() ;
|
$ti = $this->mTitle->getText() ;
|
||||||
$ti = explode ( ":" , $ti , 2 ) ;
|
$ti = explode ( ":" , $ti , 2 ) ;
|
||||||
if ( $cat != $ti[0] ) return "" ;
|
if ( $cat != $ti[0] ) return "" ;
|
||||||
$r = "<br break=all>\n" ;
|
$r = "<br break=all>\n" ;
|
||||||
|
|
@ -144,8 +154,7 @@ class Parser
|
||||||
$children = array() ;
|
$children = array() ;
|
||||||
|
|
||||||
|
|
||||||
global $wgUser ;
|
$sk =& $this->mGetSkin();
|
||||||
$sk = $wgUser->getSkin() ;
|
|
||||||
|
|
||||||
$doesexist = false ;
|
$doesexist = false ;
|
||||||
if ( $doesexist ) {
|
if ( $doesexist ) {
|
||||||
|
|
@ -198,145 +207,145 @@ class Parser
|
||||||
return $r ;
|
return $r ;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHTMLattrs ()
|
function getHTMLattrs ()
|
||||||
{
|
|
||||||
$htmlattrs = array( # Allowed attributes--no scripting, etc.
|
|
||||||
"title", "align", "lang", "dir", "width", "height",
|
|
||||||
"bgcolor", "clear", /* BR */ "noshade", /* HR */
|
|
||||||
"cite", /* BLOCKQUOTE, Q */ "size", "face", "color",
|
|
||||||
/* FONT */ "type", "start", "value", "compact",
|
|
||||||
/* For various lists, mostly deprecated but safe */
|
|
||||||
"summary", "width", "border", "frame", "rules",
|
|
||||||
"cellspacing", "cellpadding", "valign", "char",
|
|
||||||
"charoff", "colgroup", "col", "span", "abbr", "axis",
|
|
||||||
"headers", "scope", "rowspan", "colspan", /* Tables */
|
|
||||||
"id", "class", "name", "style" /* For CSS */
|
|
||||||
);
|
|
||||||
return $htmlattrs ;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fixTagAttributes ( $t )
|
|
||||||
{
|
|
||||||
if ( trim ( $t ) == "" ) return "" ; # Saves runtime ;-)
|
|
||||||
$htmlattrs = $this->getHTMLattrs() ;
|
|
||||||
|
|
||||||
# Strip non-approved attributes from the tag
|
|
||||||
$t = preg_replace(
|
|
||||||
"/(\\w+)(\\s*=\\s*([^\\s\">]+|\"[^\">]*\"))?/e",
|
|
||||||
"(in_array(strtolower(\"\$1\"),\$htmlattrs)?(\"\$1\".((\"x\$3\" != \"x\")?\"=\$3\":'')):'')",
|
|
||||||
$t);
|
|
||||||
# Strip javascript "expression" from stylesheets. Brute force approach:
|
|
||||||
# If anythin offensive is found, all attributes of the HTML tag are dropped
|
|
||||||
|
|
||||||
if( preg_match(
|
|
||||||
"/style\\s*=.*(expression|tps*:\/\/|url\\s*\().*/is",
|
|
||||||
wfMungeToUtf8( $t ) ) )
|
|
||||||
{
|
{
|
||||||
$t="";
|
$htmlattrs = array( # Allowed attributes--no scripting, etc.
|
||||||
|
"title", "align", "lang", "dir", "width", "height",
|
||||||
|
"bgcolor", "clear", /* BR */ "noshade", /* HR */
|
||||||
|
"cite", /* BLOCKQUOTE, Q */ "size", "face", "color",
|
||||||
|
/* FONT */ "type", "start", "value", "compact",
|
||||||
|
/* For various lists, mostly deprecated but safe */
|
||||||
|
"summary", "width", "border", "frame", "rules",
|
||||||
|
"cellspacing", "cellpadding", "valign", "char",
|
||||||
|
"charoff", "colgroup", "col", "span", "abbr", "axis",
|
||||||
|
"headers", "scope", "rowspan", "colspan", /* Tables */
|
||||||
|
"id", "class", "name", "style" /* For CSS */
|
||||||
|
);
|
||||||
|
return $htmlattrs ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim ( $t ) ;
|
function fixTagAttributes ( $t )
|
||||||
}
|
{
|
||||||
|
if ( trim ( $t ) == "" ) return "" ; # Saves runtime ;-)
|
||||||
|
$htmlattrs = $this->getHTMLattrs() ;
|
||||||
|
|
||||||
|
# Strip non-approved attributes from the tag
|
||||||
|
$t = preg_replace(
|
||||||
|
"/(\\w+)(\\s*=\\s*([^\\s\">]+|\"[^\">]*\"))?/e",
|
||||||
|
"(in_array(strtolower(\"\$1\"),\$htmlattrs)?(\"\$1\".((\"x\$3\" != \"x\")?\"=\$3\":'')):'')",
|
||||||
|
$t);
|
||||||
|
# Strip javascript "expression" from stylesheets. Brute force approach:
|
||||||
|
# If anythin offensive is found, all attributes of the HTML tag are dropped
|
||||||
|
|
||||||
function doTableStuff ( $t )
|
if( preg_match(
|
||||||
{
|
"/style\\s*=.*(expression|tps*:\/\/|url\\s*\().*/is",
|
||||||
$t = explode ( "\n" , $t ) ;
|
wfMungeToUtf8( $t ) ) )
|
||||||
$td = array () ; # Is currently a td tag open?
|
|
||||||
$ltd = array () ; # Was it TD or TH?
|
|
||||||
$tr = array () ; # Is currently a tr tag open?
|
|
||||||
$ltr = array () ; # tr attributes
|
|
||||||
foreach ( $t AS $k => $x )
|
|
||||||
{
|
{
|
||||||
$x = rtrim ( $x ) ;
|
$t="";
|
||||||
$fc = substr ( $x , 0 , 1 ) ;
|
|
||||||
if ( "{|" == substr ( $x , 0 , 2 ) )
|
|
||||||
{
|
|
||||||
$t[$k] = "<table " . $this->fixTagAttributes ( substr ( $x , 3 ) ) . ">" ;
|
|
||||||
array_push ( $td , false ) ;
|
|
||||||
array_push ( $ltd , "" ) ;
|
|
||||||
array_push ( $tr , false ) ;
|
|
||||||
array_push ( $ltr , "" ) ;
|
|
||||||
}
|
|
||||||
else if ( count ( $td ) == 0 ) { } # Don't do any of the following
|
|
||||||
else if ( "|}" == substr ( $x , 0 , 2 ) )
|
|
||||||
{
|
|
||||||
$z = "</table>\n" ;
|
|
||||||
$l = array_pop ( $ltd ) ;
|
|
||||||
if ( array_pop ( $tr ) ) $z = "</tr>" . $z ;
|
|
||||||
if ( array_pop ( $td ) ) $z = "</{$l}>" . $z ;
|
|
||||||
array_pop ( $ltr ) ;
|
|
||||||
$t[$k] = $z ;
|
|
||||||
}
|
|
||||||
/* else if ( "|_" == substr ( $x , 0 , 2 ) ) # Caption
|
|
||||||
{
|
|
||||||
$z = trim ( substr ( $x , 2 ) ) ;
|
|
||||||
$t[$k] = "<caption>{$z}</caption>\n" ;
|
|
||||||
}*/
|
|
||||||
else if ( "|-" == substr ( $x , 0 , 2 ) ) # Allows for |---------------
|
|
||||||
{
|
|
||||||
$x = substr ( $x , 1 ) ;
|
|
||||||
while ( $x != "" && substr ( $x , 0 , 1 ) == '-' ) $x = substr ( $x , 1 ) ;
|
|
||||||
$z = "" ;
|
|
||||||
$l = array_pop ( $ltd ) ;
|
|
||||||
if ( array_pop ( $tr ) ) $z = "</tr>" . $z ;
|
|
||||||
if ( array_pop ( $td ) ) $z = "</{$l}>" . $z ;
|
|
||||||
array_pop ( $ltr ) ;
|
|
||||||
$t[$k] = $z ;
|
|
||||||
array_push ( $tr , false ) ;
|
|
||||||
array_push ( $td , false ) ;
|
|
||||||
array_push ( $ltd , "" ) ;
|
|
||||||
array_push ( $ltr , $this->fixTagAttributes ( $x ) ) ;
|
|
||||||
}
|
|
||||||
else if ( "|" == $fc || "!" == $fc || "|+" == substr ( $x , 0 , 2 ) ) # Caption
|
|
||||||
{
|
|
||||||
if ( "|+" == substr ( $x , 0 , 2 ) )
|
|
||||||
{
|
|
||||||
$fc = "+" ;
|
|
||||||
$x = substr ( $x , 1 ) ;
|
|
||||||
}
|
|
||||||
$after = substr ( $x , 1 ) ;
|
|
||||||
if ( $fc == "!" ) $after = str_replace ( "!!" , "||" , $after ) ;
|
|
||||||
$after = explode ( "||" , $after ) ;
|
|
||||||
$t[$k] = "" ;
|
|
||||||
foreach ( $after AS $theline )
|
|
||||||
{
|
|
||||||
$z = "" ;
|
|
||||||
if ( $fc != "+" )
|
|
||||||
{
|
|
||||||
$tra = array_pop ( $ltr ) ;
|
|
||||||
if ( !array_pop ( $tr ) ) $z = "<tr {$tra}>\n" ;
|
|
||||||
array_push ( $tr , true ) ;
|
|
||||||
array_push ( $ltr , "" ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
$l = array_pop ( $ltd ) ;
|
|
||||||
if ( array_pop ( $td ) ) $z = "</{$l}>" . $z ;
|
|
||||||
if ( $fc == "|" ) $l = "TD" ;
|
|
||||||
else if ( $fc == "!" ) $l = "TH" ;
|
|
||||||
else if ( $fc == "+" ) $l = "CAPTION" ;
|
|
||||||
else $l = "" ;
|
|
||||||
array_push ( $ltd , $l ) ;
|
|
||||||
$y = explode ( "|" , $theline , 2 ) ;
|
|
||||||
if ( count ( $y ) == 1 ) $y = "{$z}<{$l}>{$y[0]}" ;
|
|
||||||
else $y = $y = "{$z}<{$l} ".$this->fixTagAttributes($y[0]).">{$y[1]}" ;
|
|
||||||
$t[$k] .= $y ;
|
|
||||||
array_push ( $td , true ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Closing open td, tr && table
|
return trim ( $t ) ;
|
||||||
while ( count ( $td ) > 0 )
|
|
||||||
{
|
|
||||||
if ( array_pop ( $td ) ) $t[] = "</td>" ;
|
|
||||||
if ( array_pop ( $tr ) ) $t[] = "</tr>" ;
|
|
||||||
$t[] = "</table>" ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$t = implode ( "\n" , $t ) ;
|
function doTableStuff ( $t )
|
||||||
# $t = $this->removeHTMLtags( $t );
|
{
|
||||||
return $t ;
|
$t = explode ( "\n" , $t ) ;
|
||||||
}
|
$td = array () ; # Is currently a td tag open?
|
||||||
|
$ltd = array () ; # Was it TD or TH?
|
||||||
|
$tr = array () ; # Is currently a tr tag open?
|
||||||
|
$ltr = array () ; # tr attributes
|
||||||
|
foreach ( $t AS $k => $x )
|
||||||
|
{
|
||||||
|
$x = rtrim ( $x ) ;
|
||||||
|
$fc = substr ( $x , 0 , 1 ) ;
|
||||||
|
if ( "{|" == substr ( $x , 0 , 2 ) )
|
||||||
|
{
|
||||||
|
$t[$k] = "<table " . $this->fixTagAttributes ( substr ( $x , 3 ) ) . ">" ;
|
||||||
|
array_push ( $td , false ) ;
|
||||||
|
array_push ( $ltd , "" ) ;
|
||||||
|
array_push ( $tr , false ) ;
|
||||||
|
array_push ( $ltr , "" ) ;
|
||||||
|
}
|
||||||
|
else if ( count ( $td ) == 0 ) { } # Don't do any of the following
|
||||||
|
else if ( "|}" == substr ( $x , 0 , 2 ) )
|
||||||
|
{
|
||||||
|
$z = "</table>\n" ;
|
||||||
|
$l = array_pop ( $ltd ) ;
|
||||||
|
if ( array_pop ( $tr ) ) $z = "</tr>" . $z ;
|
||||||
|
if ( array_pop ( $td ) ) $z = "</{$l}>" . $z ;
|
||||||
|
array_pop ( $ltr ) ;
|
||||||
|
$t[$k] = $z ;
|
||||||
|
}
|
||||||
|
/* else if ( "|_" == substr ( $x , 0 , 2 ) ) # Caption
|
||||||
|
{
|
||||||
|
$z = trim ( substr ( $x , 2 ) ) ;
|
||||||
|
$t[$k] = "<caption>{$z}</caption>\n" ;
|
||||||
|
}*/
|
||||||
|
else if ( "|-" == substr ( $x , 0 , 2 ) ) # Allows for |---------------
|
||||||
|
{
|
||||||
|
$x = substr ( $x , 1 ) ;
|
||||||
|
while ( $x != "" && substr ( $x , 0 , 1 ) == '-' ) $x = substr ( $x , 1 ) ;
|
||||||
|
$z = "" ;
|
||||||
|
$l = array_pop ( $ltd ) ;
|
||||||
|
if ( array_pop ( $tr ) ) $z = "</tr>" . $z ;
|
||||||
|
if ( array_pop ( $td ) ) $z = "</{$l}>" . $z ;
|
||||||
|
array_pop ( $ltr ) ;
|
||||||
|
$t[$k] = $z ;
|
||||||
|
array_push ( $tr , false ) ;
|
||||||
|
array_push ( $td , false ) ;
|
||||||
|
array_push ( $ltd , "" ) ;
|
||||||
|
array_push ( $ltr , $this->fixTagAttributes ( $x ) ) ;
|
||||||
|
}
|
||||||
|
else if ( "|" == $fc || "!" == $fc || "|+" == substr ( $x , 0 , 2 ) ) # Caption
|
||||||
|
{
|
||||||
|
if ( "|+" == substr ( $x , 0 , 2 ) )
|
||||||
|
{
|
||||||
|
$fc = "+" ;
|
||||||
|
$x = substr ( $x , 1 ) ;
|
||||||
|
}
|
||||||
|
$after = substr ( $x , 1 ) ;
|
||||||
|
if ( $fc == "!" ) $after = str_replace ( "!!" , "||" , $after ) ;
|
||||||
|
$after = explode ( "||" , $after ) ;
|
||||||
|
$t[$k] = "" ;
|
||||||
|
foreach ( $after AS $theline )
|
||||||
|
{
|
||||||
|
$z = "" ;
|
||||||
|
if ( $fc != "+" )
|
||||||
|
{
|
||||||
|
$tra = array_pop ( $ltr ) ;
|
||||||
|
if ( !array_pop ( $tr ) ) $z = "<tr {$tra}>\n" ;
|
||||||
|
array_push ( $tr , true ) ;
|
||||||
|
array_push ( $ltr , "" ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$l = array_pop ( $ltd ) ;
|
||||||
|
if ( array_pop ( $td ) ) $z = "</{$l}>" . $z ;
|
||||||
|
if ( $fc == "|" ) $l = "TD" ;
|
||||||
|
else if ( $fc == "!" ) $l = "TH" ;
|
||||||
|
else if ( $fc == "+" ) $l = "CAPTION" ;
|
||||||
|
else $l = "" ;
|
||||||
|
array_push ( $ltd , $l ) ;
|
||||||
|
$y = explode ( "|" , $theline , 2 ) ;
|
||||||
|
if ( count ( $y ) == 1 ) $y = "{$z}<{$l}>{$y[0]}" ;
|
||||||
|
else $y = $y = "{$z}<{$l} ".$this->fixTagAttributes($y[0]).">{$y[1]}" ;
|
||||||
|
$t[$k] .= $y ;
|
||||||
|
array_push ( $td , true ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Closing open td, tr && table
|
||||||
|
while ( count ( $td ) > 0 )
|
||||||
|
{
|
||||||
|
if ( array_pop ( $td ) ) $t[] = "</td>" ;
|
||||||
|
if ( array_pop ( $tr ) ) $t[] = "</tr>" ;
|
||||||
|
$t[] = "</table>" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$t = implode ( "\n" , $t ) ;
|
||||||
|
# $t = $this->removeHTMLtags( $t );
|
||||||
|
return $t ;
|
||||||
|
}
|
||||||
|
|
||||||
# Well, OK, it's actually about 14 passes. But since all the
|
# Well, OK, it's actually about 14 passes. But since all the
|
||||||
# hard lifting is done inside PHP's regex code, it probably
|
# hard lifting is done inside PHP's regex code, it probably
|
||||||
|
|
@ -344,7 +353,6 @@ function doTableStuff ( $t )
|
||||||
#
|
#
|
||||||
function doWikiPass2( $text, $linestart )
|
function doWikiPass2( $text, $linestart )
|
||||||
{
|
{
|
||||||
global $wgUser, $wgLang, $wgUseDynamicDates;
|
|
||||||
$fname = "OutputPage::doWikiPass2";
|
$fname = "OutputPage::doWikiPass2";
|
||||||
wfProfileIn( $fname );
|
wfProfileIn( $fname );
|
||||||
|
|
||||||
|
|
@ -357,9 +365,9 @@ function doTableStuff ( $t )
|
||||||
$text = $this->doHeadings( $text );
|
$text = $this->doHeadings( $text );
|
||||||
$text = $this->doBlockLevels( $text, $linestart );
|
$text = $this->doBlockLevels( $text, $linestart );
|
||||||
|
|
||||||
if($wgUseDynamicDates) {
|
if($this->mOptions->getUseDynamicDates()) {
|
||||||
global $wgDateFormatter;
|
global $wgDateFormatter;
|
||||||
$text = $wgDateFormatter->reformat( $wgUser->getOption("date"), $text );
|
$text = $wgDateFormatter->reformat( $this->mOptions->getDateFormat(), $text );
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = $this->replaceExternalLinks( $text );
|
$text = $this->replaceExternalLinks( $text );
|
||||||
|
|
@ -370,7 +378,7 @@ function doTableStuff ( $t )
|
||||||
$text = $this->magicRFC( $text );
|
$text = $this->magicRFC( $text );
|
||||||
$text = $this->formatHeadings( $text );
|
$text = $this->formatHeadings( $text );
|
||||||
|
|
||||||
$sk = $wgUser->getSkin();
|
$sk =& $this->mOptions->getSkin();
|
||||||
$text = $sk->transformContent( $text );
|
$text = $sk->transformContent( $text );
|
||||||
$text .= $this->categoryMagic () ;
|
$text .= $this->categoryMagic () ;
|
||||||
|
|
||||||
|
|
@ -410,10 +418,6 @@ function doTableStuff ( $t )
|
||||||
|
|
||||||
/* private */ function subReplaceExternalLinks( $s, $protocol, $autonumber )
|
/* private */ function subReplaceExternalLinks( $s, $protocol, $autonumber )
|
||||||
{
|
{
|
||||||
global $wgUser, $printable;
|
|
||||||
global $wgAllowExternalImages;
|
|
||||||
|
|
||||||
|
|
||||||
$unique = "4jzAfzB8hNvf4sqyO9Edd8pSmk9rE2in0Tgw3";
|
$unique = "4jzAfzB8hNvf4sqyO9Edd8pSmk9rE2in0Tgw3";
|
||||||
$uc = "A-Za-z0-9_\\/~%\\-+&*#?!=()@\\x80-\\xFF";
|
$uc = "A-Za-z0-9_\\/~%\\-+&*#?!=()@\\x80-\\xFF";
|
||||||
|
|
||||||
|
|
@ -433,9 +437,9 @@ function doTableStuff ( $t )
|
||||||
"((?i){$images})([^{$uc}]|$)/";
|
"((?i){$images})([^{$uc}]|$)/";
|
||||||
|
|
||||||
$e2 = "/(^|[^\\[])({$protocol}:)(([".$uc."]|[".$sep."][".$uc."])+)([^". $uc . $sep. "]|[".$sep."]|$)/";
|
$e2 = "/(^|[^\\[])({$protocol}:)(([".$uc."]|[".$sep."][".$uc."])+)([^". $uc . $sep. "]|[".$sep."]|$)/";
|
||||||
$sk = $wgUser->getSkin();
|
$sk =& $this->mOptions->getSkin();
|
||||||
|
|
||||||
if ( $autonumber and $wgAllowExternalImages) { # Use img tags only for HTTP urls
|
if ( $autonumber and $this->mOptions->getAllowExternalImages() ) { # Use img tags only for HTTP urls
|
||||||
$s = preg_replace( $e1, "\\1" . $sk->makeImage( "{$unique}:\\3" .
|
$s = preg_replace( $e1, "\\1" . $sk->makeImage( "{$unique}:\\3" .
|
||||||
"/\\4.\\5", "\\4.\\5" ) . "\\6", $s );
|
"/\\4.\\5", "\\4.\\5" ) . "\\6", $s );
|
||||||
}
|
}
|
||||||
|
|
@ -466,7 +470,7 @@ function doTableStuff ( $t )
|
||||||
$s .= "[{$protocol}:" . $line;
|
$s .= "[{$protocol}:" . $line;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( $printable == "yes") $paren = " (<i>" . htmlspecialchars ( $link ) . "</i>)";
|
if ( $this->mOptions->getPrintable() ) $paren = " (<i>" . htmlspecialchars ( $link ) . "</i>)";
|
||||||
else $paren = "";
|
else $paren = "";
|
||||||
$la = $sk->getExternalLinkAttributes( $link, $text );
|
$la = $sk->getExternalLinkAttributes( $link, $text );
|
||||||
$s .= "<a href='{$link}'{$la}>{$text}</a>{$paren}{$trail}";
|
$s .= "<a href='{$link}'{$la}>{$text}</a>{$paren}{$trail}";
|
||||||
|
|
@ -641,17 +645,15 @@ function doTableStuff ( $t )
|
||||||
|
|
||||||
/* private */ function handleInternalLink( $line )
|
/* private */ function handleInternalLink( $line )
|
||||||
{
|
{
|
||||||
global $wgTitle, $wgUser, $wgLang;
|
global $wgLang, $wgLinkCache;
|
||||||
global $wgLinkCache, $wgInterwikiMagic, $wgUseCategoryMagic;
|
|
||||||
global $wgNamespacesWithSubpages, $wgLanguageCode;
|
global $wgNamespacesWithSubpages, $wgLanguageCode;
|
||||||
static $fname = "OutputPage::replaceInternalLinks" ;
|
static $fname = "OutputPage::replaceInternalLinks" ;
|
||||||
wfProfileIn( $fname );
|
wfProfileIn( $fname );
|
||||||
|
|
||||||
wfProfileIn( "$fname-setup" );
|
wfProfileIn( "$fname-setup" );
|
||||||
static $tc = FALSE;
|
static $tc = FALSE;
|
||||||
static $sk = FALSE;
|
|
||||||
if ( !$tc ) { $tc = Title::legalChars() . "#"; }
|
if ( !$tc ) { $tc = Title::legalChars() . "#"; }
|
||||||
if ( !$sk ) { $sk = $wgUser->getSkin(); }
|
$sk =& $this->mOptions->getSkin();
|
||||||
|
|
||||||
# Match a link having the form [[namespace:link|alternate]]trail
|
# Match a link having the form [[namespace:link|alternate]]trail
|
||||||
static $e1 = FALSE;
|
static $e1 = FALSE;
|
||||||
|
|
@ -668,13 +670,12 @@ function doTableStuff ( $t )
|
||||||
static $special = FALSE;
|
static $special = FALSE;
|
||||||
static $media = FALSE;
|
static $media = FALSE;
|
||||||
static $category = FALSE;
|
static $category = FALSE;
|
||||||
static $nottalk = "";
|
|
||||||
if ( !$image ) { $image = Namespace::getImage(); }
|
if ( !$image ) { $image = Namespace::getImage(); }
|
||||||
if ( !$special ) { $special = Namespace::getSpecial(); }
|
if ( !$special ) { $special = Namespace::getSpecial(); }
|
||||||
if ( !$media ) { $media = Namespace::getMedia(); }
|
if ( !$media ) { $media = Namespace::getMedia(); }
|
||||||
if ( !$category ) { $category = wfMsg ( "category" ) ; }
|
if ( !$category ) { $category = wfMsg ( "category" ) ; }
|
||||||
if ( $nottalk=="" ) { $nottalk = !Namespace::isTalk( $wgTitle->getNamespace() ); }
|
|
||||||
|
$nottalk = !Namespace::isTalk( $this->mTitle->getNamespace() );
|
||||||
|
|
||||||
wfProfileOut( "$fname-setup" );
|
wfProfileOut( "$fname-setup" );
|
||||||
|
|
||||||
|
|
@ -708,8 +709,8 @@ function doTableStuff ( $t )
|
||||||
} else {
|
} else {
|
||||||
$noslash=substr($m[1],1);
|
$noslash=substr($m[1],1);
|
||||||
}
|
}
|
||||||
if($wgNamespacesWithSubpages[$wgTitle->getNamespace()]) { # subpages allowed here
|
if($wgNamespacesWithSubpages[$this->mTitle->getNamespace()]) { # subpages allowed here
|
||||||
$link = $wgTitle->getPrefixedText(). "/" . trim($noslash);
|
$link = $this->mTitle->getPrefixedText(). "/" . trim($noslash);
|
||||||
if( "" == $text ) {
|
if( "" == $text ) {
|
||||||
$text= $m[1];
|
$text= $m[1];
|
||||||
} # this might be changed for ugliness reasons
|
} # this might be changed for ugliness reasons
|
||||||
|
|
@ -743,7 +744,7 @@ function doTableStuff ( $t )
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ( $nt->getPrefixedText() == $wgTitle->getPrefixedText() ) &&
|
if( ( $nt->getPrefixedText() == $this->mTitle->getPrefixedText() ) &&
|
||||||
( strpos( $link, "#" ) == FALSE ) ) {
|
( strpos( $link, "#" ) == FALSE ) ) {
|
||||||
$s .= $prefix . "<strong>" . $text . "</strong>" . $trail;
|
$s .= $prefix . "<strong>" . $text . "</strong>" . $trail;
|
||||||
return $s;
|
return $s;
|
||||||
|
|
@ -1110,15 +1111,14 @@ function doTableStuff ( $t )
|
||||||
* */
|
* */
|
||||||
/* private */ function formatHeadings( $text )
|
/* private */ function formatHeadings( $text )
|
||||||
{
|
{
|
||||||
global $wgUser,$wgArticle,$wgTitle,$wpPreview;
|
$nh=$this->mOptions->getNumberHeadings();
|
||||||
$nh=$wgUser->getOption( "numberheadings" );
|
$st=$this->mOptions->getShowToc();
|
||||||
$st=$wgUser->getOption( "showtoc" );
|
if(!$this->mTitle->userCanEdit()) {
|
||||||
if(!$wgTitle->userCanEdit()) {
|
|
||||||
$es=0;
|
$es=0;
|
||||||
$esr=0;
|
$esr=0;
|
||||||
} else {
|
} else {
|
||||||
$es=$wgUser->getID() && $wgUser->getOption( "editsection" );
|
$es=$this->mOptions->getEditSection();
|
||||||
$esr=$wgUser->getID() && $wgUser->getOption( "editsectiononrightclick" );
|
$esr=$this->mOptions->getEditSectionOnRightClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
# Inhibit editsection links if requested in the page
|
# Inhibit editsection links if requested in the page
|
||||||
|
|
@ -1136,10 +1136,10 @@ function doTableStuff ( $t )
|
||||||
|
|
||||||
# never add the TOC to the Main Page. This is an entry page that should not
|
# never add the TOC to the Main Page. This is an entry page that should not
|
||||||
# be more than 1-2 screens large anyway
|
# be more than 1-2 screens large anyway
|
||||||
if($wgTitle->getPrefixedText()==wfMsg("mainpage")) {$st=0;}
|
if($this->mTitle->getPrefixedText()==wfMsg("mainpage")) {$st=0;}
|
||||||
|
|
||||||
# We need this to perform operations on the HTML
|
# We need this to perform operations on the HTML
|
||||||
$sk=$wgUser->getSkin();
|
$sk =& $this->mOptions->getSkin();
|
||||||
|
|
||||||
# Get all headlines for numbering them and adding funky stuff like [edit]
|
# Get all headlines for numbering them and adding funky stuff like [edit]
|
||||||
# links
|
# links
|
||||||
|
|
@ -1206,7 +1206,7 @@ function doTableStuff ( $t )
|
||||||
if($st) {
|
if($st) {
|
||||||
$toc.=$sk->tocLine($anchor,$tocline,$toclevel);
|
$toc.=$sk->tocLine($anchor,$tocline,$toclevel);
|
||||||
}
|
}
|
||||||
if($es && !isset($wpPreview)) {
|
if($es) {
|
||||||
$head[$c].=$sk->editSectionLink($c+1);
|
$head[$c].=$sk->editSectionLink($c+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1220,7 +1220,7 @@ function doTableStuff ( $t )
|
||||||
|
|
||||||
// Add the edit section link
|
// Add the edit section link
|
||||||
|
|
||||||
if($esr && !isset($wpPreview)) {
|
if($esr) {
|
||||||
$head[$c]=$sk->editSectionScript($c+1,$head[$c]);
|
$head[$c]=$sk->editSectionScript($c+1,$head[$c]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1241,7 +1241,7 @@ function doTableStuff ( $t )
|
||||||
$i=0;
|
$i=0;
|
||||||
|
|
||||||
foreach($blocks as $block) {
|
foreach($blocks as $block) {
|
||||||
if(($es) && !isset($wpPreview) && $c>0 && $i==0) {
|
if(($es) && $c>0 && $i==0) {
|
||||||
# This is the [edit] link that appears for the top block of text when
|
# This is the [edit] link that appears for the top block of text when
|
||||||
# section editing is enabled
|
# section editing is enabled
|
||||||
$full.=$sk->editSectionLink(0);
|
$full.=$sk->editSectionLink(0);
|
||||||
|
|
@ -1323,6 +1323,80 @@ class ParserOutput
|
||||||
function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic, $com ); }
|
function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic, $com ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ParserOptions
|
||||||
|
{
|
||||||
|
# All variables are private
|
||||||
|
var $mUseTeX; # Use texvc to expand <math> tags
|
||||||
|
var $mUseCategoryMagic; # Treat [[Category:xxxx]] tags specially
|
||||||
|
var $mUseDynamicDates; # Use $wgDateFormatter to format dates
|
||||||
|
var $mInterwikiMagic; # Interlanguage links are removed and returned in an array
|
||||||
|
var $mAllowExternalImages; # Allow external images inline
|
||||||
|
var $mSkin; # Reference to the preferred skin
|
||||||
|
var $mDateFormat; # Date format index
|
||||||
|
var $mEditSection; # Create "edit section" links
|
||||||
|
var $mEditSectionOnRightClick; # Generate JavaScript to edit section on right click
|
||||||
|
var $mPrintable; # Generate printable output
|
||||||
|
var $mNumberHeadings; # Automatically number headings
|
||||||
|
var $mShowToc; # Show table of contents
|
||||||
|
|
||||||
|
function getUseTeX() { return $this->mUseTeX; }
|
||||||
|
function getUseCategoryMagic() { return $this->mUseCategoryMagic; }
|
||||||
|
function getUseDynamicDates() { return $this->mUseDynamicDates; }
|
||||||
|
function getInterwikiMagic() { return $this->mInterwikiMagic; }
|
||||||
|
function getAllowExternalImages() { return $this->mAllowExternalImages; }
|
||||||
|
function getSkin() { return $this->mSkin; }
|
||||||
|
function getDateFormat() { return $this->mDateFormat; }
|
||||||
|
function getEditSection() { return $this->mEditSection; }
|
||||||
|
function getEditSectionOnRightClick() { return $this->mEditSectionOnRightClick; }
|
||||||
|
function getPrintable() { return $this->mPrintable; }
|
||||||
|
function getNumberHeadings() { return $this->mNumberHeadings; }
|
||||||
|
function getShowToc() { return $this->mShowToc; }
|
||||||
|
|
||||||
|
function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX, $x ); }
|
||||||
|
function setUseCategoryMagic( $x ) { return wfSetVar( $this->mUseCategoryMagic, $x ); }
|
||||||
|
function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); }
|
||||||
|
function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic, $x ); }
|
||||||
|
function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages, $x ); }
|
||||||
|
function setSkin( $x ) { return wfSetRef( $this->mSkin, $x ); }
|
||||||
|
function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); }
|
||||||
|
function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); }
|
||||||
|
function setEditSectionOnRightClick( $x ) { return wfSetVar( $this->mEditSectionOnRightClick, $x ); }
|
||||||
|
function setPrintable( $x ) { return wfSetVar( $this->mPrintable, $x ); }
|
||||||
|
function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); }
|
||||||
|
function setShowToc( $x ) { return wfSetVar( $this->mShowToc, $x ); }
|
||||||
|
|
||||||
|
/* static */ function newFromUser( &$user )
|
||||||
|
{
|
||||||
|
$popts = new ParserOptions;
|
||||||
|
$popts->initialiseFromUser( &$user );
|
||||||
|
return $popts;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initialiseFromUser( &$userInput )
|
||||||
|
{
|
||||||
|
global $wgUseTeX, $wgUseCategoryMagic, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
|
||||||
|
|
||||||
|
if ( !$userInput ) {
|
||||||
|
$user = new User;
|
||||||
|
} else {
|
||||||
|
$user =& $userInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mUseTeX = $wgUseTeX;
|
||||||
|
$this->mUseCategoryMagic = $wgUseCategoryMagic;
|
||||||
|
$this->mUseDynamicDates = $wgUseDynamicDates;
|
||||||
|
$this->mInterwikiMagic = $wgInterwikiMagic;
|
||||||
|
$this->mAllowExternalImages = $wgAllowExternalImages;
|
||||||
|
$this->mSkin =& $user->getSkin();
|
||||||
|
$this->mDateFormat = $user->getOption( "date" );
|
||||||
|
$this->mEditSection = $user->getOption( "editsection" );
|
||||||
|
$this->mEditSectionOnRightClick = $user->getOption( "editsectiononrightclick" );
|
||||||
|
$this->mPrintable = false;
|
||||||
|
$this->mNumberHeadings = $user->getOption( "numberheadings" );
|
||||||
|
$this->mShowToc = $user->getOption( "showtoc" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Regex callbacks, used in OutputPage::replaceVariables
|
# Regex callbacks, used in OutputPage::replaceVariables
|
||||||
|
|
||||||
# Just get rid of the dangerous stuff
|
# Just get rid of the dangerous stuff
|
||||||
|
|
|
||||||
|
|
@ -127,9 +127,6 @@ include_once( "Language.php" );
|
||||||
|
|
||||||
$wgMessageCache = new MessageCache;
|
$wgMessageCache = new MessageCache;
|
||||||
|
|
||||||
$wgOut = new OutputPage();
|
|
||||||
wfDebug( "\n\n" );
|
|
||||||
|
|
||||||
$wgLangClass = "Language" . ucfirst( $wgLanguageCode );
|
$wgLangClass = "Language" . ucfirst( $wgLanguageCode );
|
||||||
if( ! class_exists( $wgLangClass ) ) {
|
if( ! class_exists( $wgLangClass ) ) {
|
||||||
include_once( "LanguageUtf8.php" );
|
include_once( "LanguageUtf8.php" );
|
||||||
|
|
@ -142,6 +139,9 @@ if ( !is_object($wgLang) ) {
|
||||||
}
|
}
|
||||||
$wgMessageCache->initialise( $wgUseMemCached, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname );
|
$wgMessageCache->initialise( $wgUseMemCached, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname );
|
||||||
|
|
||||||
|
$wgOut = new OutputPage();
|
||||||
|
wfDebug( "\n\n" );
|
||||||
|
|
||||||
if ( $wgUseDynamicDates ) {
|
if ( $wgUseDynamicDates ) {
|
||||||
include_once( "DateFormatter.php" );
|
include_once( "DateFormatter.php" );
|
||||||
global $wgDateFormatter;
|
global $wgDateFormatter;
|
||||||
|
|
@ -160,6 +160,7 @@ $wgMagicWords = array();
|
||||||
$wgMwRedir =& MagicWord::get( MAG_REDIRECT );
|
$wgMwRedir =& MagicWord::get( MAG_REDIRECT );
|
||||||
$wgParserCache = new ParserCache();
|
$wgParserCache = new ParserCache();
|
||||||
$wgParser = new Parser();
|
$wgParser = new Parser();
|
||||||
|
$wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
|
||||||
|
|
||||||
wfProfileOut( "$fname-misc" );
|
wfProfileOut( "$fname-misc" );
|
||||||
wfProfileOut( $fname );
|
wfProfileOut( $fname );
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
class Tokenizer {
|
class Tokenizer {
|
||||||
/* private */ var $mText, $mPos, $mTextLength;
|
/* private */ var $mText, $mPos, $mTextLength;
|
||||||
/* private */ var $mCount, $mM, $mMPos;
|
/* private */ var $mCount, $mM, $mMPos; # What is M meant to stand for?
|
||||||
|
|
||||||
/* private */ function Tokenizer()
|
/* private */ function Tokenizer()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue