ProtectedTitlesPager.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. * http://www.gnu.org/copyleft/gpl.html
  17. *
  18. * @file
  19. * @ingroup Pager
  20. */
  21. /**
  22. * @ingroup Pager
  23. */
  24. class ProtectedTitlesPager extends AlphabeticPager {
  25. /**
  26. * @var SpecialProtectedtitles
  27. */
  28. public $mForm;
  29. /**
  30. * @var array
  31. */
  32. public $mConds;
  33. /** @var string|null */
  34. private $level;
  35. /** @var int|null */
  36. private $namespace;
  37. /**
  38. * @param SpecialProtectedtitles $form
  39. * @param array $conds
  40. * @param string|null $type
  41. * @param string|null $level
  42. * @param int|null $namespace
  43. * @param string|null $sizetype
  44. * @param int|null $size
  45. */
  46. public function __construct( $form, $conds, $type, $level, $namespace,
  47. $sizetype = '', $size = 0
  48. ) {
  49. $this->mForm = $form;
  50. $this->mConds = $conds;
  51. $this->level = $level;
  52. $this->namespace = $namespace;
  53. parent::__construct( $form->getContext() );
  54. }
  55. protected function getStartBody() {
  56. # Do a link batch query
  57. $this->mResult->seek( 0 );
  58. $lb = new LinkBatch;
  59. foreach ( $this->mResult as $row ) {
  60. $lb->add( $row->pt_namespace, $row->pt_title );
  61. }
  62. $lb->execute();
  63. return '';
  64. }
  65. /**
  66. * @return Title
  67. */
  68. function getTitle() {
  69. return $this->mForm->getPageTitle();
  70. }
  71. function formatRow( $row ) {
  72. return $this->mForm->formatRow( $row );
  73. }
  74. /**
  75. * @return array
  76. */
  77. function getQueryInfo() {
  78. $conds = $this->mConds;
  79. $conds[] = 'pt_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) .
  80. ' OR pt_expiry IS NULL';
  81. if ( $this->level ) {
  82. $conds['pt_create_perm'] = $this->level;
  83. }
  84. if ( $this->namespace !== null ) {
  85. $conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace );
  86. }
  87. return [
  88. 'tables' => 'protected_titles',
  89. 'fields' => [ 'pt_namespace', 'pt_title', 'pt_create_perm',
  90. 'pt_expiry', 'pt_timestamp' ],
  91. 'conds' => $conds
  92. ];
  93. }
  94. function getIndexField() {
  95. return 'pt_timestamp';
  96. }
  97. }