# $wgLanguageCode = "de";
$wgUseTeX = false;
+$wgUseCategoryMagic = true ;
$wgLocalInterwiki = "w";
var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
var $mSubtitle, $mRedirect, $mAutonumber, $mHeadtext;
- var $mLastModified;
+ var $mLastModified, $mCategoryLinks;
var $mDTopen, $mLastSection; # Used for processing DL, PRE
var $mLanguageLinks, $mSupressQuickbar;
$this->mIsarticle = $this->mPrintable = true;
$this->mSupressQuickbar = $this->mDTopen = $this->mPrintable = false;
$this->mLanguageLinks = array();
+ $this->mCategoryLinks = array() ;
$this->mAutonumber = 0;
}
$wgOut->addHTML( "\n<p>$r\n" );
}
+
+function categoryMagic ()
+{
+global $wgTitle , $wgUseCategoryMagic ;
+if ( !isset ( $wgUseCategoryMagic ) || !$wgUseCategoryMagic ) return ;
+$id = $wgTitle->getArticleID() ;
+$cat = ucfirst ( wfMsg ( "category" ) ) ;
+$ti = $wgTitle->getText() ;
+$ti = explode ( ":" , $ti , 2 ) ;
+if ( $cat != $ti[0] ) return "" ;
+$r = "<br break=all>\n" ;
+
+$articles = array() ;
+$parents = array () ;
+$children = array() ;
+
+
+global $wgUser ;
+$sk = $wgUser->getSkin() ;
+$sql = "SELECT l_from FROM links WHERE l_to={$id}" ;
+$res = wfQuery ( $sql ) ;
+while ( $x = wfFetchObject ( $res ) )
+{
+# $t = new Title ;
+# $t->newFromDBkey ( $x->l_from ) ;
+# $t = $t->getText() ;
+ $t = $x->l_from ;
+ $y = explode ( ":" , $t , 2 ) ;
+ if ( count ( $y ) == 2 && $y[0] == $cat )
+ {
+ array_push ( $children , $sk->makeLink ( $t , $y[1] ) ) ;
+ }
+ else array_push ( $articles , $sk->makeLink ( $t ) ) ;
+}
+wfFreeResult ( $res ) ;
+
+# Children
+ if ( count ( $children ) > 0 )
+ {
+ asort ( $children ) ;
+ $r .= "<h2>".wfMsg("subcategories")."</h2>\n" ;
+ $r .= implode ( ", " , $children ) ;
+ }
+
+# Articles
+ if ( count ( $articles ) > 0 )
+ {
+ asort ( $articles ) ;
+ $h = str_replace ( "$1" , $ti[1] , wfMsg("category_header") ) ;
+ $r .= "<h2>{$h}</h2>\n" ;
+ $r .= implode ( ", " , $articles ) ;
+ }
+
+
+return $r ;
+}
+
+
# Well, OK, it's actually about 14 passes. But since all the
# hard lifting is done inside PHP's regex code, it probably
# wouldn't speed things up much to add a real parser.
$sk = $wgUser->getSkin();
$text = $sk->transformContent( $text );
+ $text .= $this->categoryMagic () ;
wfProfileOut();
return $text;
"Standard", "Nostalgia", "CologneBlue"
);
+# For some odd PHP bug, this function can't be part of a class
+function getCategories ()
+{
+ global $wgOut , $wgTitle , $wgUseCategoryMagic , $wgUser ;
+ if ( !isset ( $wgUseCategoryMagic ) || !$wgUseCategoryMagic ) return "" ;
+ if ( count ( $wgOut->mCategoryLinks ) == 0 ) return "" ;
+ if ( !$wgOut->isArticle() ) return "" ;
+ $sk = $wgUser->getSkin() ;
+ $s = "" ;
+ $s .= "\n<br>\n";
+ $s .= $sk->makeKnownLink ( "Special:Categories" , "Categories" , "article=".$wgTitle->getDBkey() ) ;
+ $t = implode ( " | " , $wgOut->mCategoryLinks ) ;
+ if ( $t != "" ) $s .= " : " ;
+ $s .= $t ;
+ return $s ;
+}
+
+
class RecentChangesClass {
var $secureName , $displayName , $link , $namespace ;
var $oldid , $diffid , $timestamp , $curlink , $lastlink , $usertalklink , $versionlink ;
$s .= "\n<div id='article'>";
$s .= $this->pageTitle();
- $s .= $this->pageSubtitle() . "\n<p>";
+ $s .= $this->pageSubtitle() ;
+ $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
+ $s .= "\n<p>";
wfProfileOut();
return $s;
}
--- /dev/null
+<?
+
+function wfSpecialCategories()
+{
+ global $wgUser, $wgOut , $wgLang ;
+ global $article , $category ;
+ $sk = $wgUser->getSkin() ;
+ $sc = "Special:Categories" ;
+ $r = "" ;
+ $r .= "<OL>\n" ;
+ $cat = ucfirst ( wfMsg ( "category" ) ) ;
+ $sql = "SELECT cur_title FROM cur WHERE cur_title LIKE \"{$cat}:%\"" ;
+ $res = wfQuery ( $sql ) ;
+ while ( $x = wfFetchObject ( $res ) )
+ {
+ $t = explode ( ":" , $x->cur_title , 2 ) ;
+ $t = $t[1] ;
+ $r .= "<li>" ;
+ $r .= $sk->makeKnownLink ( $x->cur_title , $t ) ;
+ $r .= "</li>\n" ;
+ }
+ wfFreeResult ( $res ) ;
+ $r .= "</OL>\n" ;
+
+ $r .= "<hr>\n" ;
+ $sql = "SELECT DISTINCT bl_to FROM brokenlinks WHERE bl_to LIKE \"{$cat}:%\"" ;
+ $res = wfQuery ( $sql ) ;
+ $r .= "<OL>\n" ;
+ while ( $x = wfFetchObject ( $res ) )
+ {
+ $t = explode ( ":" , $x->bl_to , 2 ) ;
+ $t = $t[1] ;
+ $r .= "<li>" ;
+ $r .= $sk->makeBrokenLink ( $x->bl_to , $t ) ;
+ $r .= "</li>\n" ;
+ }
+ wfFreeResult ( $res ) ;
+ $r .= "</OL>\n" ;
+
+ $wgOut->addHTML ( $r ) ;
+}
+
+?>
"Whatlinkshere" => "",
"Recentchangeslinked" => "",
"Movepage" => "",
- "Booksources" => "External book sources"
+ "Booksources" => "External book sources",
+"Categories" => "Page categories",
);
/* private */ $wgSysopSpecialPagesEn = array(
# Bits of text used by many pages:
#
+"categories" => "Page categories",
+"category" => "category",
+"category_header" => "Articles in category \"$1\"",
+"subcategories" => "Subcategories",
+
"linktrail" => "/^([a-z]+)(.*)\$/sD",
"mainpage" => "Main Page",
"mainpagetext" => "Wiki software successfully installed.",