- }
- $this->mLastSection = $newSection;
- }
- if ( $inBlockElem &&
- preg_match( "/(<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6)/i", $t ) ) {
- $inBlockElem = false;
- }
- }
- $text .= $t;
- }
- while ( $npl ) {
- $text .= $this->closeList( $pref2{$npl-1} );
- --$npl;
- }
- if ( "" != $this->mLastSection ) {
- if ( "p" != $this->mLastSection ) {
- $text .= "</" . $this->mLastSection . ">";
- }
- $this->mLastSection = "";
- }
- wfProfileOut( $fname );
- return $text;
- }
-
- /* private */ function replaceVariables( $text )
- {
- global $wgLang, $wgCurOut;
- $fname = "OutputPage::replaceVariables";
- wfProfileIn( $fname );
-
- $magic = array();
-
- # Basic variables
- # See Language.php for the definition of each magic word
- # As with sigs, this uses the server's local time -- ensure
- # this is appropriate for your audience!
-
- $magic[MAG_CURRENTMONTH] = date( "m" );
- $magic[MAG_CURRENTMONTHNAME] = $wgLang->getMonthName( date("n") );
- $magic[MAG_CURRENTMONTHNAMEGEN] = $wgLang->getMonthNameGen( date("n") );
- $magic[MAG_CURRENTDAY] = date("j");
- $magic[MAG_CURRENTDAYNAME] = $wgLang->getWeekdayName( date("w")+1 );
- $magic[MAG_CURRENTYEAR] = date( "Y" );
- $magic[MAG_CURRENTTIME] = $wgLang->time( wfTimestampNow(), false );
-
- $this->mContainsOldMagic += MagicWord::replaceMultiple($magic, $text, $text);
-
- $mw =& MagicWord::get( MAG_NUMBEROFARTICLES );
- if ( $mw->match( $text ) ) {
- $v = wfNumberOfArticles();
- $text = $mw->replace( $v, $text );
- if( $mw->getWasModified() ) { $this->mContainsOldMagic++; }
- }
-
- # "Variables" with an additional parameter e.g. {{MSG:wikipedia}}
- # The callbacks are at the bottom of this file
- $wgCurOut = $this;
- $mw =& MagicWord::get( MAG_MSG );
- $text = $mw->substituteCallback( $text, "wfReplaceMsgVar" );
- if( $mw->getWasModified() ) { $this->mContainsNewMagic++; }
-
- $mw =& MagicWord::get( MAG_MSGNW );
- $text = $mw->substituteCallback( $text, "wfReplaceMsgnwVar" );
- if( $mw->getWasModified() ) { $this->mContainsNewMagic++; }
-
- wfProfileOut( $fname );
- return $text;
- }
-
- # Cleans up HTML, removes dangerous tags and attributes
- /* private */ function removeHTMLtags( $text )
- {
- $fname = "OutputPage::removeHTMLtags";
- wfProfileIn( $fname );
- $htmlpairs = array( # Tags that must be closed
- "b", "i", "u", "font", "big", "small", "sub", "sup", "h1",
- "h2", "h3", "h4", "h5", "h6", "cite", "code", "em", "s",
- "strike", "strong", "tt", "var", "div", "center",
- "blockquote", "ol", "ul", "dl", "table", "caption", "pre",
- "ruby", "rt" , "rb" , "rp"
- );
- $htmlsingle = array(
- "br", "p", "hr", "li", "dt", "dd"
- );
- $htmlnest = array( # Tags that can be nested--??
- "table", "tr", "td", "th", "div", "blockquote", "ol", "ul",
- "dl", "font", "big", "small", "sub", "sup"
- );
- $tabletags = array( # Can only appear inside table
- "td", "th", "tr"
- );
-
- $htmlsingle = array_merge( $tabletags, $htmlsingle );
- $htmlelements = array_merge( $htmlsingle, $htmlpairs );
-
- $htmlattrs = $this->getHTMLattrs () ;
-
- # Remove HTML comments
- $text = preg_replace( "/<!--.*-->/sU", "", $text );
-
- $bits = explode( "<", $text );
- $text = array_shift( $bits );
- $tagstack = array(); $tablestack = array();
-
- foreach ( $bits as $x ) {
- $prev = error_reporting( E_ALL & ~( E_NOTICE | E_WARNING ) );
- preg_match( "/^(\\/?)(\\w+)([^>]*)(\\/{0,1}>)([^<]*)$/",
- $x, $regs );
- list( $qbar, $slash, $t, $params, $brace, $rest ) = $regs;
- error_reporting( $prev );
-
- $badtag = 0 ;
- if ( in_array( $t = strtolower( $t ), $htmlelements ) ) {
- # Check our stack
- if ( $slash ) {
- # Closing a tag...
- if ( ! in_array( $t, $htmlsingle ) &&
- ( $ot = array_pop( $tagstack ) ) != $t ) {
- array_push( $tagstack, $ot );
- $badtag = 1;