SpecialMostcategories.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * @file
  4. * @ingroup SpecialPage
  5. *
  6. * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  7. * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
  8. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
  9. */
  10. /**
  11. * implements Special:Mostcategories
  12. * @ingroup SpecialPage
  13. */
  14. class MostcategoriesPage extends QueryPage {
  15. function getName() { return 'Mostcategories'; }
  16. function isExpensive() { return true; }
  17. function isSyndicated() { return false; }
  18. function getSQL() {
  19. $dbr = wfGetDB( DB_SLAVE );
  20. list( $categorylinks, $page) = $dbr->tableNamesN( 'categorylinks', 'page' );
  21. return
  22. "
  23. SELECT
  24. 'Mostcategories' as type,
  25. page_namespace as namespace,
  26. page_title as title,
  27. COUNT(*) as value
  28. FROM $categorylinks
  29. LEFT JOIN $page ON cl_from = page_id
  30. WHERE page_namespace = " . NS_MAIN . "
  31. GROUP BY page_namespace, page_title
  32. HAVING COUNT(*) > 1
  33. ";
  34. }
  35. function formatResult( $skin, $result ) {
  36. global $wgLang;
  37. $title = Title::makeTitleSafe( $result->namespace, $result->title );
  38. $count = wfMsgExt( 'ncategories', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) );
  39. $link = $skin->link( $title );
  40. return wfSpecialList( $link, $count );
  41. }
  42. }
  43. /**
  44. * constructor
  45. */
  46. function wfSpecialMostcategories() {
  47. list( $limit, $offset ) = wfCheckLimits();
  48. $wpp = new MostcategoriesPage();
  49. $wpp->doQuery( $offset, $limit );
  50. }