| 1 |
<?php |
| 2 |
|
| 3 |
ason |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
namespace MediaWiki\Specials; |
| 24 |
|
| 25 |
use HtmlArmor; |
| 26 |
use MediaWiki\Cache\LinkBatchFactory; |
| 27 |
use MediaWiki\Html\Html; |
| 28 |
use MediaWiki\Language\ILanguageConverter; |
| 29 |
use MediaWiki\Languages\LanguageConverterFactory; |
| 30 |
use MediaWiki\Linker\Linker; |
| 31 |
use MediaWiki\SpecialPage\QueryPage; |
| 32 |
use MediaWiki\Title\Title; |
| 33 |
use Skin; |
| 34 |
use stdClass; |
| 35 |
use Wikimedia\Rdbms\IConnectionProvider; |
| 36 |
use Wikimedia\Rdbms\IDatabase; |
| 37 |
use Wikimedia\Rdbms\IResultWrapper; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
om> |
| 44 |
|
| 45 |
class SpecialUnwatchedPages extends QueryPage { |
| 46 |
|
| 47 |
private LinkBatchFactory $linkBatchFactory; |
| 48 |
private ILanguageConverter $languageConverter; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public function __construct( |
| 56 |
LinkBatchFactory $linkBatchFactory, |
| 57 |
IConnectionProvider $dbProvider, |
| 58 |
LanguageConverterFactory $languageConverterFactory |
| 59 |
) { |
| 60 |
parent::__construct( 'Unwatchedpages', 'unwatchedpages' ); |
| 61 |
$this->linkBatchFactory = $linkBatchFactory; |
| 62 |
$this->setDatabaseProvider( $dbProvider ); |
| 63 |
$this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ); |
| 64 |
} |
| 65 |
|
| 66 |
public function isExpensive() { |
| 67 |
return true; |
| 68 |
} |
| 69 |
|
| 70 |
public function isSyndicated() { |
| 71 |
return false; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public function preprocessResults( $db, $res ) { |
| 81 |
if ( !$res->numRows() ) { |
| 82 |
return; |
| 83 |
} |
| 84 |
|
| 85 |
$batch = $this->linkBatchFactory->newLinkBatch(); |
| 86 |
foreach ( $res as $row ) { |
| 87 |
$batch->add( $row->namespace, $row->title ); |
| 88 |
} |
| 89 |
$batch->execute(); |
| 90 |
|
| 91 |
$res->seek( 0 ); |
| 92 |
} |
| 93 |
|
| 94 |
public function getQueryInfo() { |
| 95 |
$dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
| 96 |
return [ |
| 97 |
'tables' => [ 'page', 'watchlist' ], |
| 98 |
'fields' => [ |
| 99 |
'namespace' => 'page_namespace', |
| 100 |
'title' => 'page_title', |
| 101 |
'value' => 'page_namespace' |
| 102 |
], |
| 103 |
'conds' => [ |
| 104 |
'wl_title' => null, |
| 105 |
'page_is_redirect' => 0, |
| 106 |
$dbr->expr( 'page_namespace', '!=', NS_MEDIAWIKI ), |
| 107 |
], |
| 108 |
'join_conds' => [ 'watchlist' => [ |
| 109 |
'LEFT JOIN', [ 'wl_title = page_title', |
| 110 |
'wl_namespace = page_namespace' ] ] ] |
| 111 |
]; |
| 112 |
} |
| 113 |
|
| 114 |
protected function sortDescending() { |
| 115 |
return false; |
| 116 |
} |
| 117 |
|
| 118 |
protected function getOrderFields() { |
| 119 |
return [ 'page_namespace', 'page_title' ]; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
public function execute( $par ) { |
| 127 |
parent::execute( $par ); |
| 128 |
$this->getOutput()->addModules( 'mediawiki.special.unwatchedPages' ); |
| 129 |
$this->addHelpLink( 'Help:Watchlist' ); |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
public function formatResult( $skin, $result ) { |
| 138 |
$nt = Title::makeTitleSafe( $result->namespace, $result->title ); |
| 139 |
if ( !$nt ) { |
| 140 |
return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], |
| 141 |
Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); |
| 142 |
} |
| 143 |
|
| 144 |
$text = $this->languageConverter->convertHtml( $nt->getPrefixedText() ); |
| 145 |
|
| 146 |
$linkRenderer = $this->getLinkRenderer(); |
| 147 |
|
| 148 |
$plink = $linkRenderer->makeKnownLink( $nt, new HtmlArmor( $text ) ); |
| 149 |
$wlink = $linkRenderer->makeKnownLink( |
| 150 |
$nt, |
| 151 |
$this->msg( 'watch' )->text(), |
| 152 |
[ 'class' => 'mw-watch-link' ], |
| 153 |
[ 'action' => 'watch' ] |
| 154 |
); |
| 155 |
|
| 156 |
return $this->getLanguage()->specialList( $plink, $wlink ); |
| 157 |
} |
| 158 |
|
| 159 |
protected function getGroupName() { |
| 160 |
return 'maintenance'; |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
class_alias( SpecialUnwatchedPages::class, 'SpecialUnwatchedPages' ); |