SpecialWithoutInterwiki.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * Implements Special:Withoutinterwiki
  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. * @author Rob Church <robchur@gmail.com>
  23. */
  24. use MediaWiki\MediaWikiServices;
  25. /**
  26. * Special page lists pages without language links
  27. *
  28. * @ingroup SpecialPage
  29. */
  30. class SpecialWithoutInterwiki extends PageQueryPage {
  31. private $prefix = '';
  32. function __construct( $name = 'Withoutinterwiki' ) {
  33. parent::__construct( $name );
  34. }
  35. function execute( $par ) {
  36. $this->prefix = Title::capitalize(
  37. $this->getRequest()->getVal( 'prefix', $par ), NS_MAIN );
  38. parent::execute( $par );
  39. }
  40. function getPageHeader() {
  41. # Do not show useless input form if special page is cached
  42. if ( $this->isCached() ) {
  43. return '';
  44. }
  45. $formDescriptor = [
  46. 'prefix' => [
  47. 'label-message' => 'allpagesprefix',
  48. 'name' => 'prefix',
  49. 'id' => 'wiprefix',
  50. 'type' => 'text',
  51. 'size' => 20,
  52. 'default' => $this->prefix
  53. ]
  54. ];
  55. $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
  56. $htmlForm->setWrapperLegend( '' )
  57. ->setSubmitTextMsg( 'withoutinterwiki-submit' )
  58. ->setMethod( 'get' )
  59. ->prepareForm()
  60. ->displayForm( false );
  61. }
  62. function sortDescending() {
  63. return false;
  64. }
  65. function getOrderFields() {
  66. return [ 'page_namespace', 'page_title' ];
  67. }
  68. function isExpensive() {
  69. return true;
  70. }
  71. function isSyndicated() {
  72. return false;
  73. }
  74. function getQueryInfo() {
  75. $query = [
  76. 'tables' => [ 'page', 'langlinks' ],
  77. 'fields' => [
  78. 'namespace' => 'page_namespace',
  79. 'title' => 'page_title',
  80. ],
  81. 'conds' => [
  82. 'll_title IS NULL',
  83. 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
  84. getContentNamespaces(),
  85. 'page_is_redirect' => 0
  86. ],
  87. 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
  88. ];
  89. if ( $this->prefix ) {
  90. $dbr = wfGetDB( DB_REPLICA );
  91. $query['conds'][] = 'page_title ' . $dbr->buildLike( $this->prefix, $dbr->anyString() );
  92. }
  93. return $query;
  94. }
  95. protected function getGroupName() {
  96. return 'maintenance';
  97. }
  98. }