From 109231249977aeaace9a89c72e392c08ef136efa Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Sun, 4 Feb 2007 15:35:52 +0000 Subject: [PATCH] * Add AlphabeticPager abstract class * Use AlphabeticPager for Special:Categories * Introduce 'first' message --- RELEASE-NOTES | 2 + includes/AutoLoader.php | 2 +- includes/Pager.php | 35 +++++++++++++ includes/SpecialCategories.php | 84 ++++++++++++------------------- languages/messages/MessagesEn.php | 1 + 5 files changed, 71 insertions(+), 53 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 744b2882ad..3cfe9e7819 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -171,6 +171,8 @@ lighter making things easier to read. * (bug 6844) Use and 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 == diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 55a90d347d..fb7819cb74 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -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', diff --git a/includes/Pager.php b/includes/Pager.php index 0987cc066c..4f133e1695 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -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 */ diff --git a/includes/SpecialCategories.php b/includes/SpecialCategories.php index 6e09cc826d..4397fff94b 100644 --- a/includes/SpecialCategories.php +++ b/includes/SpecialCategories.php @@ -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() + . '
    ' . $cap->getBody() . '
' . + $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 ( + '
  • ' . + $this->getSkin()->makeLinkObj( $title, $title->getText() ) + . ' ' . + $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'), + $wgLang->formatNum( $result->count ) ) + . + "
  • \n" ); } } -/** - * - */ -function wfSpecialCategories() { - list( $limit, $offset ) = wfCheckLimits(); - - $cap = new CategoriesPage(); - - return $cap->doQuery( $offset, $limit ); -} - ?> diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index a26a93993b..4efc4b8933 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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.
    -- 2.20.1