SpecialWithoutinterwiki.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * @file
  4. * @ingroup SpecialPage
  5. */
  6. /**
  7. * Special page lists pages without language links
  8. *
  9. * @ingroup SpecialPage
  10. * @author Rob Church <robchur@gmail.com>
  11. */
  12. class WithoutInterwikiPage extends PageQueryPage {
  13. private $prefix = '';
  14. function getName() {
  15. return 'Withoutinterwiki';
  16. }
  17. function getPageHeader() {
  18. global $wgScript, $wgMiserMode;
  19. # Do not show useless input form if wiki is running in misermode
  20. if( $wgMiserMode ) {
  21. return '';
  22. }
  23. $prefix = $this->prefix;
  24. $t = SpecialPage::getTitleFor( $this->getName() );
  25. return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
  26. Xml::openElement( 'fieldset' ) .
  27. Xml::element( 'legend', null, wfMsg( 'withoutinterwiki-legend' ) ) .
  28. Xml::hidden( 'title', $t->getPrefixedText() ) .
  29. Xml::inputLabel( wfMsg( 'allpagesprefix' ), 'prefix', 'wiprefix', 20, $prefix ) . ' ' .
  30. Xml::submitButton( wfMsg( 'withoutinterwiki-submit' ) ) .
  31. Xml::closeElement( 'fieldset' ) .
  32. Xml::closeElement( 'form' );
  33. }
  34. function sortDescending() {
  35. return false;
  36. }
  37. function isExpensive() {
  38. return true;
  39. }
  40. function isSyndicated() {
  41. return false;
  42. }
  43. function getSQL() {
  44. $dbr = wfGetDB( DB_SLAVE );
  45. list( $page, $langlinks ) = $dbr->tableNamesN( 'page', 'langlinks' );
  46. $prefix = $this->prefix ? "AND page_title LIKE '" . $dbr->escapeLike( $this->prefix ) . "%'" : '';
  47. return
  48. "SELECT 'Withoutinterwiki' AS type,
  49. page_namespace AS namespace,
  50. page_title AS title,
  51. page_title AS value
  52. FROM $page
  53. LEFT JOIN $langlinks
  54. ON ll_from = page_id
  55. WHERE ll_title IS NULL
  56. AND page_namespace=" . NS_MAIN . "
  57. AND page_is_redirect = 0
  58. {$prefix}";
  59. }
  60. function setPrefix( $prefix = '' ) {
  61. $this->prefix = $prefix;
  62. }
  63. }
  64. function wfSpecialWithoutinterwiki() {
  65. global $wgRequest, $wgContLang, $wgCapitalLinks;
  66. list( $limit, $offset ) = wfCheckLimits();
  67. if( $wgCapitalLinks ) {
  68. $prefix = $wgContLang->ucfirst( $wgRequest->getVal( 'prefix' ) );
  69. } else {
  70. $prefix = $wgRequest->getVal( 'prefix' );
  71. }
  72. $wip = new WithoutInterwikiPage();
  73. $wip->setPrefix( $prefix );
  74. $wip->doQuery( $offset, $limit );
  75. }