diff --git a/LocalSettings.sample b/LocalSettings.sample
index 17d5dbf9235..0e13281edd0 100644
--- a/LocalSettings.sample
+++ b/LocalSettings.sample
@@ -47,6 +47,7 @@ $wgDBtransactions = false; # Set to true if using InnoDB tables
# $wgLanguageCode = "de";
$wgUseTeX = false;
+$wgUseCategoryMagic = true ;
$wgLocalInterwiki = "w";
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 5a0337f7e2f..1b1f105e25a 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -119,7 +119,7 @@ class OutputPage {
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;
@@ -134,6 +134,7 @@ class OutputPage {
$this->mIsarticle = $this->mPrintable = true;
$this->mSupressQuickbar = $this->mDTopen = $this->mPrintable = false;
$this->mLanguageLinks = array();
+ $this->mCategoryLinks = array() ;
$this->mAutonumber = 0;
}
@@ -664,6 +665,64 @@ class OutputPage {
$wgOut->addHTML( "\n
$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 = "
\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 .= "
";
$s .= $this->pageTitle();
- $s .= $this->pageSubtitle() . "\n
";
+ $s .= $this->pageSubtitle() ;
+ $s .= getCategories(); // For some odd reason, zhis can't be a function of the object
+ $s .= "\n
";
wfProfileOut();
return $s;
}
diff --git a/includes/SpecialCategories.php b/includes/SpecialCategories.php
new file mode 100644
index 00000000000..831cc9bda8b
--- /dev/null
+++ b/includes/SpecialCategories.php
@@ -0,0 +1,43 @@
+
+
+function wfSpecialCategories()
+{
+ global $wgUser, $wgOut , $wgLang ;
+ global $article , $category ;
+ $sk = $wgUser->getSkin() ;
+ $sc = "Special:Categories" ;
+ $r = "" ;
+ $r .= "
\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 .= "- " ;
+ $r .= $sk->makeKnownLink ( $x->cur_title , $t ) ;
+ $r .= "
\n" ;
+ }
+ wfFreeResult ( $res ) ;
+ $r .= "
\n" ;
+
+ $r .= "
\n" ;
+ $sql = "SELECT DISTINCT bl_to FROM brokenlinks WHERE bl_to LIKE \"{$cat}:%\"" ;
+ $res = wfQuery ( $sql ) ;
+ $r .= "
\n" ;
+ while ( $x = wfFetchObject ( $res ) )
+ {
+ $t = explode ( ":" , $x->bl_to , 2 ) ;
+ $t = $t[1] ;
+ $r .= "- " ;
+ $r .= $sk->makeBrokenLink ( $x->bl_to , $t ) ;
+ $r .= "
\n" ;
+ }
+ wfFreeResult ( $res ) ;
+ $r .= "
\n" ;
+
+ $wgOut->addHTML ( $r ) ;
+}
+
+?>
diff --git a/languages/Language.php b/languages/Language.php
index 5553b577653..4f7b5c386ce 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -274,7 +274,8 @@ this (alternative: like this
?).",
"Whatlinkshere" => "",
"Recentchangeslinked" => "",
"Movepage" => "",
- "Booksources" => "External book sources"
+ "Booksources" => "External book sources",
+"Categories" => "Page categories",
);
/* private */ $wgSysopSpecialPagesEn = array(
@@ -293,6 +294,11 @@ this (alternative: like this
?).",
# 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.",