SpecialUnusedCategories.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Implements Special:Unusedcategories
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. * @ingroup SpecialPage
  22. */
  23. /**
  24. * @ingroup SpecialPage
  25. */
  26. class SpecialUnusedCategories extends QueryPage {
  27. function __construct( $name = 'Unusedcategories' ) {
  28. parent::__construct( $name );
  29. }
  30. public function isExpensive() {
  31. return true;
  32. }
  33. function getPageHeader() {
  34. return $this->msg( 'unusedcategoriestext' )->parseAsBlock();
  35. }
  36. function getOrderFields() {
  37. return [ 'title' ];
  38. }
  39. public function getQueryInfo() {
  40. return [
  41. 'tables' => [ 'page', 'categorylinks', 'page_props' ],
  42. 'fields' => [
  43. 'namespace' => 'page_namespace',
  44. 'title' => 'page_title',
  45. ],
  46. 'conds' => [
  47. 'cl_from IS NULL',
  48. 'page_namespace' => NS_CATEGORY,
  49. 'page_is_redirect' => 0,
  50. 'pp_page IS NULL'
  51. ],
  52. 'join_conds' => [
  53. 'categorylinks' => [ 'LEFT JOIN', 'cl_to = page_title' ],
  54. 'page_props' => [ 'LEFT JOIN', [
  55. 'page_id = pp_page',
  56. 'pp_propname' => 'expectunusedcategory'
  57. ] ]
  58. ]
  59. ];
  60. }
  61. /**
  62. * A should come before Z (T32907)
  63. * @return bool
  64. */
  65. function sortDescending() {
  66. return false;
  67. }
  68. /**
  69. * @param Skin $skin
  70. * @param object $result Result row
  71. * @return string
  72. */
  73. function formatResult( $skin, $result ) {
  74. $title = Title::makeTitle( NS_CATEGORY, $result->title );
  75. return $this->getLinkRenderer()->makeLink( $title, $title->getText() );
  76. }
  77. protected function getGroupName() {
  78. return 'maintenance';
  79. }
  80. public function preprocessResults( $db, $res ) {
  81. $this->executeLBFromResultWrapper( $res );
  82. }
  83. }