* Add AlphabeticPager abstract class
authorDomas Mituzas <midom@users.mediawiki.org>
Sun, 4 Feb 2007 15:35:52 +0000 (15:35 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Sun, 4 Feb 2007 15:35:52 +0000 (15:35 +0000)
* Use AlphabeticPager for Special:Categories
* Introduce 'first' message

RELEASE-NOTES
includes/AutoLoader.php
includes/Pager.php
includes/SpecialCategories.php
languages/messages/MessagesEn.php

index 744b288..3cfe9e7 100644 (file)
@@ -171,6 +171,8 @@ lighter making things easier to read.
 * (bug 6844) Use <ins> and <del> tags to emphase the differences
 * (bug 6684) Fix improper javascript array iteration
 * (bug 4347) use MailAddress object for reply-to
+* Add AlphabeticPager abstract class
+* Use faster AlphabeticPager for Special:Categories
 
 
 == Languages updated ==
index 55a90d3..fb7819c 100644 (file)
@@ -11,6 +11,7 @@ function __autoload($className) {
                'AjaxDispatcher' => 'includes/AjaxDispatcher.php',
                'AjaxCachePolicy' => 'includes/AjaxFunctions.php',
                'AjaxResponse' => 'includes/AjaxResponse.php',
+               'AlphabeticPager' => 'includes/Pager.php',
                'Article' => 'includes/Article.php',
                'AuthPlugin' => 'includes/AuthPlugin.php',
                'BagOStuff' => 'includes/BagOStuff.php',
@@ -158,7 +159,6 @@ function __autoload($className) {
                'IPBlockForm' => 'includes/SpecialBlockip.php',
                'SpecialBookSources' => 'includes/SpecialBooksources.php',
                'BrokenRedirectsPage' => 'includes/SpecialBrokenRedirects.php',
-               'CategoriesPage' => 'includes/SpecialCategories.php',
                'EmailConfirmation' => 'includes/SpecialConfirmemail.php',
                'ContributionsPage' => 'includes/SpecialContributions.php',
                'DeadendPagesPage' => 'includes/SpecialDeadendpages.php',
index 0987cc0..4f133e1 100644 (file)
@@ -386,6 +386,41 @@ abstract class IndexPager implements Pager {
        abstract function getIndexField();
 }
 
+
+/**
+ * IndexPager with an alphabetic list and a formatted navigation bar
+*/
+abstract class AlphabeticPager extends IndexPager {
+       public $mDefaultDirection = false;
+       
+       function __construct() {
+               parent::__construct();
+       }
+       
+       /** 
+        * Shamelessly stolen bits from ReverseChronologicalPager, d
+        * didn't want to do class magic as may be still revamped 
+        */
+       function getNavigationBar() {
+               global $wgLang;
+               
+               $linkTexts = array(
+                       'prev' => wfMsgHtml( "prevn", $this->mLimit ),
+                       'next' => wfMsgHtml( 'nextn', $this->mLimit ),
+                       'first' => wfMsgHtml('first'), /* Introduced the message */
+                       'last' => wfMsgHtml( 'last' )
+               );
+               
+               $pagingLinks = $this->getPagingLinks( $linkTexts );
+               $limitLinks = $this->getLimitLinks();
+               $limits = implode( ' | ', $limitLinks );
+               
+               $this->mNavigationBar = "({$pagingLinks['first']} | {$pagingLinks['last']}) " . wfMsgHtml("viewprevnext", $pagingLinks['prev'], $pagingLinks['next'], $limits);
+               return $this->mNavigationBar;
+               
+       }
+}
+
 /**
  * IndexPager with a formatted navigation bar
  */
index 6e09cc8..4397fff 100644 (file)
@@ -4,64 +4,44 @@
  * @addtogroup SpecialPage
  */
 
-/**
- *
- * @addtogroup SpecialPage
- */
-class CategoriesPage extends QueryPage {
-
-       function getName() {
-               return "Categories";
-       }
-
-       function isExpensive() {
-               return false;
-       }
-
-       function isSyndicated() { return false; }
+function wfSpecialCategories() {
+       global $wgOut;
+
+       $cap = new CategoryPager();
+       $wgOut->addHTML( 
+               wfMsgWikiHtml( 'categoriespagetext' ) .
+               $cap->getNavigationBar()
+               . '<ul>' . $cap->getBody() . '</ul>' .
+               $cap->getNavigationBar()
+               );
+}
 
-       function getPageHeader() {
-               return wfMsgWikiHtml( 'categoriespagetext' );
+class CategoryPager extends AlphabeticPager {
+       function getQueryInfo() {
+               return array(
+                       'tables' => array('categorylinks'),
+                       'fields' => array('cl_to','count(*) count'),
+                       'options' => array('GROUP BY' => 'cl_to')
+                       );
        }
        
-       function getSQL() {
-               $NScat = NS_CATEGORY;
-               $dbr = wfGetDB( DB_SLAVE );
-               $categorylinks = $dbr->tableName( 'categorylinks' );
-               $implicit_groupby = $dbr->implicitGroupby() ? '1' : 'cl_to';
-               $s= "SELECT 'Categories' as type,
-                               {$NScat} as namespace,
-                               cl_to as title,
-                               $implicit_groupby as value,
-                               COUNT(*) as count
-                          FROM $categorylinks
-                          GROUP BY 1,2,3,4";
-               return $s;
+       function getIndexField() {
+               return "cl_to";
        }
-
-       function sortDescending() {
-               return false;
-       }
-
-       function formatResult( $skin, $result ) {
+       
+       function formatRow($result) {
                global $wgLang;
-               $title = Title::makeTitle( NS_CATEGORY, $result->title );
-               $plink = $skin->makeLinkObj( $title, $title->getText() );
-               $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
-                       $wgLang->formatNum( $result->count ) );
-               return wfSpecialList($plink, $nlinks);
+               
+               $title = Title::makeTitle( NS_CATEGORY, $result->cl_to );
+               return ( 
+                       '<li>' .
+                       $this->getSkin()->makeLinkObj( $title, $title->getText() )
+                       . ' ' .
+                       $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
+                       $wgLang->formatNum( $result->count ) )
+                       .
+                       "</li>\n" );
        }
 }
 
-/**
- *
- */
-function wfSpecialCategories() {
-       list( $limit, $offset ) = wfCheckLimits();
-
-       $cap = new CategoriesPage();
-
-       return $cap->doQuery( $offset, $limit );
-}
-
 ?>
index a26a939..4efc4b8 100644 (file)
@@ -1064,6 +1064,7 @@ Please check the URL you used to access this page.",
 'currentrevisionlink'   => 'Current revision',
 'cur'                  => 'cur',
 'next'                 => 'next',
+'first'                        => 'first',
 'last'                 => 'last',
 'orig'                 => 'orig',
 'histlegend'   => 'Diff selection: mark the radio boxes of the versions to compare and hit enter or the button at the bottom.<br />