class Parser
{
# Cleared with clearState():
- var $mOutput, $mAutonumber, $mLastSection, $mDTopen, $mStripState = array();
- var $mVariables, $mIncludeCount, $mArgStack;
+ var $mOutput, $mAutonumber, $mDTopen, $mStripState = array();
+ var $mVariables, $mIncludeCount, $mArgStack, $mLastSection, $mInPre;
# Temporary:
var $mOptions, $mTitle, $mOutputType;
$stripState = NULL;
$text = $this->strip( $text, $this->mStripState );
$text = $this->internalParse( $text, $linestart );
- # only once and next-to-last
$text = $this->unstrip( $text, $this->mStripState );
- $text = $this->doBlockLevels( $text, $linestart );
- # Clean up special characters, only run once and last
+ # Clean up special characters, only run once, next-to-last before doBlockLevels
$fixtags = array(
"/<hr *>/i" => '<hr/>',
"/<br *>/i" => '<br/>',
- "/<center *>/i"=>'<div style="text-align:center;">',
+ "/<center *>/i"=>'<div class="center">',
"/<\\/center *>/i" => '</div>',
# Clean up spare ampersands; note that we probably ought to be
# more careful about named entities.
);
$text = preg_replace( array_keys($fixtags), array_values($fixtags), $text );
+ # only once and last
+ $text = $this->doBlockLevels( $text, $linestart );
+
$this->mOutput->setText( $text );
wfProfileOut( $fname );
return $this->mOutput;
global $wgLang , $wgUser ;
if ( !$this->mOptions->getUseCategoryMagic() ) return ;
$id = $this->mTitle->getArticleID() ;
- $cat = $wgLang->ucfirst ( wfMsg ( "category" ) ) ;
+ $cns = Namespace::getCategory() ;
+ if ( $this->mTitle->getNamespace() != $cns ) return "" ;
$ti = $this->mTitle->getText() ;
- $ti = explode ( ":" , $ti , 2 ) ;
- if ( $cat != $ti[0] ) return "" ;
- $r = '<br style="clear:both;"/>\n';
+ $r = "<br style=\"clear:both;\"/>\n";
$articles = array() ;
$parents = array () ;
$children = array() ;
-
-# $sk =& $this->mGetSkin();
$sk =& $wgUser->getSkin() ;
$data = array () ;
$res = wfQuery ( $sql2, DB_READ ) ;
while ( $x = wfFetchObject ( $res ) ) $data[] = $x ;
-
foreach ( $data AS $x )
{
$t = $wgLang->getNsText ( $x->cur_namespace ) ;
if ( $t != "" ) $t .= ":" ;
$t .= $x->cur_title ;
- $y = explode ( ":" , $t , 2 ) ;
- if ( count ( $y ) == 2 && $y[0] == $cat ) {
- array_push ( $children , $sk->makeLink ( $t , $y[1] ) ) ;
+ if ( $x->cur_namespace == $cns ) {
+ array_push ( $children , $sk->makeLink ( $t ) ) ;
} else {
array_push ( $articles , $sk->makeLink ( $t ) ) ;
}
if ( count ( $articles ) > 0 )
{
asort ( $articles ) ;
- $h = wfMsg( "category_header", $ti[1] );
+ $h = wfMsg( "category_header", $ti );
$r .= "<h2>{$h}</h2>\n" ;
$r .= implode ( ", " , $articles ) ;
}
$ltr = array () ; # tr attributes
foreach ( $t AS $k => $x )
{
- $x = rtrim ( $x ) ;
+ $x = trim ( $x ) ;
$fc = substr ( $x , 0 , 1 ) ;
if ( "{|" == substr ( $x , 0 , 2 ) )
{
$sk =& $this->mOptions->getSkin();
$text = $sk->transformContent( $text );
- $text .= $this->categoryMagic () ;
+ if ( !isset ( $this->categoryMagicDone ) ) {
+ $text .= $this->categoryMagic () ;
+ $this->categoryMagicDone = true ;
+ }
wfProfileOut( $fname );
return $text;
if ( !$image ) { $image = Namespace::getImage(); }
if ( !$special ) { $special = Namespace::getSpecial(); }
if ( !$media ) { $media = Namespace::getMedia(); }
- if ( !$category ) { $category = wfMsg ( "category" ) ; }
+ if ( !$category ) { $category = Namespace::getCategory(); ; }
$nottalk = !Namespace::isTalk( $this->mTitle->getNamespace() );
$wgLinkCache->addImageLinkObj( $nt );
return $s;
}
+ if ( $ns == $category ) {
+ $t = $nt->getText() ;
+ $nnt = Title::newFromText ( Namespace::getCanonicalName($category).":".$t ) ;
+ $t = $sk->makeLinkObj( $nnt, $t, "", "" , $prefix );
+ $this->mOutput->mCategoryLinks[] = $t ;
+ $s .= $prefix . $trail ;
+ return $s ;
+ }
}
if( ( $nt->getPrefixedText() == $this->mTitle->getPrefixedText() ) &&
( strpos( $link, "#" ) == FALSE ) ) {
return $s;
}
- # Category feature
- $catns = strtoupper ( $nt->getDBkey () ) ;
- $catns = explode ( ":" , $catns ) ;
- if ( count ( $catns ) > 1 ) $catns = array_shift ( $catns ) ;
- else $catns = "" ;
- if ( $catns == strtoupper($category) && $this->mOptions->getUseCategoryMagic() ) {
- $t = explode ( ":" , $nt->getText() ) ;
- array_shift ( $t ) ;
- $t = implode ( ":" , $t ) ;
- $t = $wgLang->ucFirst ( $t ) ;
- $nnt = Title::newFromText ( $category.":".$t ) ;
- $t = $sk->makeLinkObj( $nnt, $t, "", $trail , $prefix );
- $this->mOutput->mCategoryLinks[] = $t ;
- $s .= $prefix . $trail ;
- return $s ;
- }
-
if( $ns == $media ) {
$s .= $prefix . $sk->makeMediaLinkObj( $nt, $text ) . $trail;
$wgLinkCache->addImageLinkObj( $nt );
if ( '' != $this->mLastSection ) {
$result = "</" . $this->mLastSection . ">\n";
}
+ $this->mInPre = false;
$this->mLastSection = "";
return $result;
}
foreach ( $a as $t ) {
$oLine = $t;
$opl = strlen( $lastPref );
- $npl = strspn( $t, "*#:;" );
- $pref = substr( $t, 0, $npl );
- $pref2 = str_replace( ";", ":", $pref );
- $t = substr( $t, $npl );
+ $preCloseMatch = preg_match("/<\\/pre/i", $t );
+ $preOpenMatch = preg_match("/<pre/i", $t );
+ if (!$this->mInPre) {
+ $this->mInPre = !empty($preOpenMatch);
+ }
+ if ( !$this->mInPre ) {
+ $npl = strspn( $t, "*#:;" );
+ $pref = substr( $t, 0, $npl );
+ $pref2 = str_replace( ";", ":", $pref );
+ $t = substr( $t, $npl );
+ } else {
+ $npl = 0;
+ $pref = $pref2 = '';
+ }
+
// list generation
if ( 0 != $npl && 0 == strcmp( $lastPref, $pref2 ) ) {
$text .= $this->nextItem( substr( $pref, -1 ) );
if ( $openmatch or $closematch ) {
if ( $pstack ) { $pstack = false; }
$text .= $this->closeParagraph();
+ if($preOpenMatch and !$preCloseMatch) {
+ $this->mInPre = true;
+ }
if ( $closematch ) {
$inBlockElem = false;
} else {
$fname = "Parser::removeHTMLtags";
wfProfileIn( $fname );
$htmlpairs = array( # Tags that must be closed
- "b", "i", "u", "font", "big", "small", "sub", "sup", "h1",
+ "b", "del", "i", "ins", "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",
/* static */ function newFromUser( &$user )
{
$popts = new ParserOptions;
- $popts->initialiseFromUser( &$user );
+ $popts->initialiseFromUser( $user );
return $popts;
}