SpecialUncategorizedPages.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Implements Special:Uncategorizedpages
  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. use MediaWiki\MediaWikiServices;
  24. /**
  25. * A special page looking for page without any category.
  26. *
  27. * @ingroup SpecialPage
  28. * @todo FIXME: Make $requestedNamespace selectable, unify all subclasses into one
  29. */
  30. class SpecialUncategorizedPages extends PageQueryPage {
  31. /** @var int|false */
  32. protected $requestedNamespace = false;
  33. function __construct( $name = 'Uncategorizedpages' ) {
  34. parent::__construct( $name );
  35. $this->addHelpLink( 'Help:Categories' );
  36. }
  37. function sortDescending() {
  38. return false;
  39. }
  40. function isExpensive() {
  41. return true;
  42. }
  43. function isSyndicated() {
  44. return false;
  45. }
  46. function getQueryInfo() {
  47. return [
  48. 'tables' => [ 'page', 'categorylinks' ],
  49. 'fields' => [
  50. 'namespace' => 'page_namespace',
  51. 'title' => 'page_title',
  52. ],
  53. // default for page_namespace is all content namespaces (if requestedNamespace is false)
  54. // otherwise, page_namespace is requestedNamespace
  55. 'conds' => [
  56. 'cl_from IS NULL',
  57. 'page_namespace' => $this->requestedNamespace !== false
  58. ? $this->requestedNamespace
  59. : MediaWikiServices::getInstance()->getNamespaceInfo()->
  60. getContentNamespaces(),
  61. 'page_is_redirect' => 0
  62. ],
  63. 'join_conds' => [
  64. 'categorylinks' => [ 'LEFT JOIN', 'cl_from = page_id' ]
  65. ]
  66. ];
  67. }
  68. function getOrderFields() {
  69. // For some crazy reason ordering by a constant
  70. // causes a filesort
  71. if ( $this->requestedNamespace === false &&
  72. count( MediaWikiServices::getInstance()->getNamespaceInfo()->
  73. getContentNamespaces() ) > 1
  74. ) {
  75. return [ 'page_namespace', 'page_title' ];
  76. }
  77. return [ 'page_title' ];
  78. }
  79. protected function getGroupName() {
  80. return 'maintenance';
  81. }
  82. }