Fix #1064 by implementing the new Special:Unusedcategories (thanks avar for the name)
authorAntoine Musso <hashar@users.mediawiki.org>
Sat, 9 Jul 2005 19:19:10 +0000 (19:19 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sat, 9 Jul 2005 19:19:10 +0000 (19:19 +0000)
RELEASE-NOTES
includes/SpecialPage.php
includes/SpecialUnusedcategories.php [new file with mode: 0644]
languages/Language.php

index 9968572..0d390b6 100644 (file)
@@ -549,6 +549,8 @@ of MediaWiki:Newpagetext) to &action=edit, if page is new.
   interesting errors with signitures.
 * (bug 2764) Number format for Nds
 * (bug 1553) Stop forcing lowercase in Monobook skin for German language.
+* (bug 1064) Implements Special:Unusedcategories
+
   
 === Caveats ===
 
index 2487405..5f67310 100644 (file)
@@ -44,6 +44,7 @@ $wgSpecialPages = array(
        'Lonelypages'       => new SpecialPage( 'Lonelypages' ),
        'Uncategorizedpages'=> new SpecialPage( 'Uncategorizedpages' ),
        'Uncategorizedcategories'=> new SpecialPage( 'Uncategorizedcategories' ),
+       'Unusedcategories'      => new SpecialPage( 'Unusedcategories' ),
        'Unusedimages'      => new SpecialPage( 'Unusedimages' ),
        'Wantedpages'   => new SpecialPage( 'Wantedpages' ),
        'Shortpages'    => new SpecialPage( 'Shortpages' ),
diff --git a/includes/SpecialUnusedcategories.php b/includes/SpecialUnusedcategories.php
new file mode 100644 (file)
index 0000000..9696db9
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+
+/** */
+require_once('QueryPage.php');
+
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+class UnusedCategoriesPage extends QueryPage {
+
+       function getName() {
+               return 'Unusedcategories';
+       }
+
+       function getPageHeader() {
+               return '<p>'.wfMsg('unusedcategoriestext')."</p><br />\n";
+       }
+
+       function getSQL() {
+               $NScat = NS_CATEGORY;
+               $dbr =& wfGetDB( DB_SLAVE );
+               extract( $dbr->tableNames( 'categorylinks','page' ));
+               return "SELECT DISTINCT 'Unusedcategories' as type,
+                               {$NScat} as namespace, page_title as title, 1 as value
+                               FROM $page
+                               LEFT JOIN $categorylinks ON page_title=cl_to
+                               WHERE cl_from IS NULL
+                               AND page_namespace = {$NScat}
+                               AND page_is_redirect = 0";
+       }
+
+       function formatResult( $skin, $result ) {
+               global $wgLang;
+               $title = Title::makeTitle( NS_CATEGORY, $result->title );
+               return $skin->makeLinkObj( $title, $title->getText() );
+       }
+}
+
+/** constructor */
+function wfSpecialUnusedCategories() {
+       list( $limit, $offset ) = wfCheckLimits();
+       $uc = new UnusedCategoriesPage();
+       return $uc->doQuery( $offset, $limit );
+}
+?>
index 7d29c8a..1b3cae2 100644 (file)
@@ -1117,6 +1117,7 @@ That comes to '''$5''' average edits per page, and '''$6''' views per edit.",
 'lonelypages'  => 'Orphaned pages',
 'uncategorizedpages'   => 'Uncategorized pages',
 'uncategorizedcategories'      => 'Uncategorized categories',
+'unusedcategories' => 'Unused categories',
 'unusedimages' => 'Unused files',
 'popularpages' => 'Popular pages',
 'nviews'               => '$1 views',
@@ -1156,6 +1157,8 @@ That comes to '''$5''' average edits per page, and '''$6''' views per edit.",
 'unusedimagestext' => '<p>Please note that other web sites may link to an image with
 a direct URL, and so may still be listed here despite being
 in active use.</p>',
+'unusedcategoriestext' => '<p>The following categorie pages exist although no other article or category make use of them.</p>',
+
 'booksources'  => 'Book sources',
 'categoriespagetext' => 'The following categories exist in the wiki.',
 'data' => 'Data',