87 parent::__construct( $context, $linkRenderer );
88 $this->localisationCache = $localisationCache;
90 $this->mIndexField =
'am_title';
96 $this->foreign = !$this->lang->equals( $contentLanguage );
98 $filter = $opts->
getValue(
'filter' );
99 if ( $filter ===
'all' ) {
100 $this->custom =
null;
102 $this->custom = ( $filter ===
'unmodified' );
111 $displayPrefix =
$prefix->getDBkey();
112 $this->prefix =
'/^' . preg_quote( $displayPrefix,
'/' ) .
'/i';
114 $this->prefix =
false;
119 if ( $this->foreign ) {
120 $this->suffix =
'/' . $this->lang->getCode();
126 private function getAllMessages(
bool $descending ): array {
127 $messageNames = $this->localisationCache->getSubitemList(
'en',
'messages' );
130 $messageNames = array_map( [ $this->lang,
'ucfirst' ], $messageNames );
133 rsort( $messageNames );
135 asort( $messageNames );
138 return $messageNames;
164 $res = $dbr->newSelectQueryBuilder()
165 ->select( [
'page_namespace',
'page_title' ] )
168 ->useIndex(
'page_name_title' )
169 ->caller( __METHOD__ )->fetchResultSet();
170 $xNames = array_fill_keys( $messageNames,
true );
172 $pageFlags = $talkFlags = [];
174 foreach ( $res as $s ) {
178 $titleParts = explode(
'/', $s->page_title );
179 if ( count( $titleParts ) === 2 &&
180 $langcode === $titleParts[1] &&
181 isset( $xNames[$titleParts[0]] )
183 $exists = $titleParts[0];
185 } elseif ( isset( $xNames[$s->page_title] ) ) {
186 $exists = $s->page_title;
189 $title = Title::newFromRow( $s );
191 $pageFlags[$exists] =
true;
193 $talkFlags[$exists] =
true;
197 return [
'pages' => $pageFlags,
'talks' => $talkFlags ];
209 $asc = ( $order === self::QUERY_ASCENDING );
211 $messageNames = $this->getAllMessages( $order );
212 $statuses = self::getCustomisedStatuses(
214 $this->lang->getCode(),
221 foreach ( $messageNames as $key ) {
222 $customised = isset( $statuses[
'pages'][$key] );
223 if ( $customised !== $this->custom &&
224 ( ( $asc && ( $key < $offset || !$offset ) ) || ( !$asc && $key > $offset ) ) &&
225 ( ( $this->prefix && preg_match( $this->prefix, $key ) ) || $this->prefix ===
false )
227 $actual = $this->msg( $key )->inLanguage( $this->lang )->plain();
228 $default = $this->msg( $key )->inLanguage( $this->lang )->useDatabase(
false )->plain();
231 'am_actual' => $actual,
232 'am_default' => $default,
233 'am_customised' => $customised,
234 'am_talk_exists' => isset( $statuses[
'talks'][$key] )
239 if ( $count === $limit ) {
248 return Html::openElement(
'table', [
249 'class' => $this->getTableClass(),
250 'id' =>
'mw-allmessagestable'
254 <th rowspan=\"2\">" .
255 $this->msg(
'allmessagesname' )->escaped() .
"
258 $this->msg(
'allmessagesdefault' )->escaped() .
263 $this->msg(
'allmessagescurrent' )->escaped() .
269 return Html::closeElement(
'table' );
278 $linkRenderer = $this->getLinkRenderer();
281 $title = Title::makeTitle(
NS_MEDIAWIKI, $value . $this->suffix );
283 $message = $this->msg( $value )->inLanguage( $this->lang )->useDatabase(
false )->plain();
284 $translation = $linkRenderer->makeExternalLink(
286 'title' =>
'Special:SearchTranslations',
287 'group' =>
'mediawiki',
288 'grouppath' =>
'mediawiki',
289 'language' => $this->lang->getCode(),
290 'query' => $value .
' ' . $message
292 $this->msg(
'allmessages-filter-translate' ),
295 $talkLink = $this->msg(
'talkpagelinktext' )->text();
297 if ( $this->mCurrentRow->am_customised ) {
298 $title = $linkRenderer->makeKnownLink( $title, $this->getLanguage()->lcfirst( $value ) );
300 $title = $linkRenderer->makeBrokenLink(
301 $title, $this->getLanguage()->lcfirst( $value )
304 if ( $this->mCurrentRow->am_talk_exists ) {
305 $talk = $linkRenderer->makeKnownLink( $talk, $talkLink );
307 $talk = $linkRenderer->makeBrokenLink(
313 return $title .
' ' .
314 $this->msg(
'parentheses' )->rawParams( $talk )->escaped() .
316 $this->msg(
'parentheses' )->rawParams( $translation )->escaped();
320 return Sanitizer::escapeHtmlAllowEntities( $value );
332 $s = parent::formatRow( $row );
335 if ( $row->am_customised ) {
336 $s .= Html::openElement(
'tr', $this->getRowAttrs( $row ) );
337 $formatted = strval( $this->formatValue(
'am_actual', $row->am_actual ) );
339 if ( $formatted ===
'' ) {
340 $formatted =
"\u{00A0}";
343 $s .= Html::rawElement(
'td', $this->getCellAttrs(
'am_actual', $row->am_actual ), $formatted )
344 . Html::closeElement(
'tr' );
347 return Html::rawElement(
'tbody', [], $s );
361 if ( $field ===
'am_title' ) {
362 if ( $this->mCurrentRow->am_customised ) {
363 $attr += [
'rowspan' =>
'2' ];
367 'lang' => $this->lang->getHtmlCode(),
368 'dir' => $this->lang->getDir(),
370 if ( $this->mCurrentRow->am_customised ) {
372 $attr += [
'class' => $field ];
381 'am_title' => $this->msg(
'allmessagesname' )->text(),
382 'am_default' => $this->msg(
'allmessagesdefault' )->text()
408class_alias( AllMessagesTablePager::class,
'AllMessagesTablePager' );
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
Caching for the contents of localisation files.
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Interface for objects which can provide a MediaWiki context on request.