Localisation updates Cantonese, Chinese and Old/Late Time Chinese
[lhc/web/wiklou.git] / includes / SpecialMostcategories.php
index 2a188d9..5df9c86 100644 (file)
@@ -1,19 +1,16 @@
 <?php
 /**
- * @package MediaWiki
- * @subpackage SpecialPage
+ * @file
+ * @ingroup SpecialPage
  *
  * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
  */
 
-/* */
-require_once 'QueryPage.php';
-
 /**
- * @package MediaWiki
- * @subpackage SpecialPage
+ * implements Special:Mostcategories
+ * @ingroup SpecialPage
  */
 class MostcategoriesPage extends QueryPage {
 
@@ -22,8 +19,8 @@ class MostcategoriesPage extends QueryPage {
        function isSyndicated() { return false; }
 
        function getSQL() {
-               $dbr =& wfGetDB( DB_SLAVE );
-               extract( $dbr->tableNames( 'categorylinks', 'page' ) );
+               $dbr = wfGetDB( DB_SLAVE );
+               list( $categorylinks, $page) = $dbr->tableNamesN( 'categorylinks', 'page' );
                return
                        "
                        SELECT
@@ -34,23 +31,18 @@ class MostcategoriesPage extends QueryPage {
                        FROM $categorylinks
                        LEFT JOIN $page ON cl_from = page_id
                        WHERE page_namespace = " . NS_MAIN . "
-                       GROUP BY cl_from
+                       GROUP BY 1,2,3
                        HAVING COUNT(*) > 1
                        ";
        }
 
        function formatResult( $skin, $result ) {
-               global $wgContLang;
-
-               $nt = Title::makeTitle( $result->namespace, $result->title );
-               $text = $wgContLang->convert( $nt->getPrefixedText() );
-
-               $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
-
-               $nl = wfMsg( 'ncategories', $result->value );
-               $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Categories' ), $nl, 'article=' . $nt->getPrefixedURL() );
-
-               return wfSpecialList($plink, $nlink);
+               global $wgLang;
+               $title = Title::makeTitleSafe( $result->namespace, $result->title );
+               if ( !$title instanceof Title ) { throw new MWException('Invalid title in database'); }
+               $count = wfMsgExt( 'ncategories', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) );
+               $link = $skin->makeKnownLinkObj( $title, $title->getText() );
+               return wfSpecialList( $link, $count );
        }
 }
 
@@ -64,5 +56,3 @@ function wfSpecialMostcategories() {
 
        $wpp->doQuery( $offset, $limit );
 }
-
-?>