15use MediaWiki\Languages\LanguageFactory;
67 LanguageFactory $languageFactory,
75 parent::__construct( $context, $linkRenderer );
76 $this->localisationCache = $localisationCache;
78 $this->mIndexField =
'am_title';
80 $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
82 $this->lang = $languageFactory->getRawLanguage( $opts->
getValue(
'lang' ) );
84 $this->foreign = !$this->lang->equals( $contentLanguage );
86 $filter = $opts->
getValue(
'filter' );
87 if ( $filter ===
'all' ) {
90 $this->custom = ( $filter ===
'unmodified' );
99 $displayPrefix =
$prefix->getDBkey();
100 $this->prefix =
'/^' . preg_quote( $displayPrefix,
'/' ) .
'/i';
102 $this->prefix =
false;
107 if ( $this->foreign ) {
108 $this->suffix =
'/' . $this->lang->getCode();
114 private function getAllMessages(
bool $descending ): array {
115 $messageNames = $this->localisationCache->getSubitemList(
'en',
'messages' );
118 $messageNames = array_map( $this->lang->ucfirst( ... ), $messageNames );
121 rsort( $messageNames );
123 asort( $messageNames );
126 return $messageNames;
152 $res = $dbr->newSelectQueryBuilder()
153 ->select( [
'page_namespace',
'page_title' ] )
156 ->useIndex(
'page_name_title' )
157 ->caller( __METHOD__ )->fetchResultSet();
158 $xNames = array_fill_keys( $messageNames,
true );
160 $pageFlags = $talkFlags = [];
162 foreach ( $res as $s ) {
166 $titleParts = explode(
'/', $s->page_title );
167 if ( count( $titleParts ) === 2 &&
168 $langcode === $titleParts[1] &&
169 isset( $xNames[$titleParts[0]] )
171 $exists = $titleParts[0];
173 } elseif ( isset( $xNames[$s->page_title] ) ) {
174 $exists = $s->page_title;
177 $title = Title::newFromRow( $s );
179 $pageFlags[$exists] =
true;
181 $talkFlags[$exists] =
true;
185 return [
'pages' => $pageFlags,
'talks' => $talkFlags ];
197 $asc = ( $order === self::QUERY_ASCENDING );
199 $messageNames = $this->getAllMessages( $order );
200 $statuses = self::getCustomisedStatuses(
202 $this->lang->getCode(),
209 foreach ( $messageNames as $key ) {
210 $customised = isset( $statuses[
'pages'][$key] );
211 if ( $customised !== $this->custom &&
212 ( ( $asc && ( $key < $offset || !$offset ) ) || ( !$asc && $key > $offset ) ) &&
213 ( ( $this->prefix && preg_match( $this->prefix, $key ) ) || $this->prefix ===
false )
215 $actual = $this->msg( $key )->inLanguage( $this->lang )->plain();
216 $default = $this->msg( $key )->inLanguage( $this->lang )->useDatabase(
false )->plain();
219 'am_actual' => $actual,
220 'am_default' => $default,
221 'am_customised' => $customised,
222 'am_talk_exists' => isset( $statuses[
'talks'][$key] )
227 if ( $count === $limit ) {
237 return Html::openElement(
'table', [
238 'class' => $this->getTableClass(),
239 'id' =>
'mw-allmessagestable'
243 <th rowspan=\"2\">" .
244 $this->msg(
'allmessagesname' )->escaped() .
"
247 $this->msg(
'allmessagesdefault' )->escaped() .
252 $this->msg(
'allmessagescurrent' )->escaped() .
259 return Html::closeElement(
'table' );
268 $linkRenderer = $this->getLinkRenderer();
273 $message = $this->msg( $value )->inLanguage( $this->lang )->useDatabase(
false )->plain();
274 $translation = $linkRenderer->makeExternalLink(
276 'title' =>
'Special:SearchTranslations',
277 'group' =>
'mediawiki',
278 'grouppath' =>
'mediawiki',
279 'language' => $this->lang->getCode(),
280 'query' => $value .
' ' . $message
282 $this->msg(
'allmessages-filter-translate' ),
285 $talkLink = $this->msg(
'talkpagelinktext' )->text();
287 if ( $this->mCurrentRow->am_customised ) {
288 $title = $linkRenderer->makeKnownLink( $title, $this->getLanguage()->lcfirst( $value ) );
290 $title = $linkRenderer->makeBrokenLink(
291 $title, $this->getLanguage()->lcfirst( $value )
294 if ( $this->mCurrentRow->am_talk_exists ) {
295 $talk = $linkRenderer->makeKnownLink( $talk, $talkLink );
297 $talk = $linkRenderer->makeBrokenLink(
303 return $title .
' ' .
304 $this->msg(
'parentheses' )->rawParams( $talk )->escaped() .
306 $this->msg(
'parentheses' )->rawParams( $translation )->escaped();
310 return Sanitizer::escapeHtmlAllowEntities( $value );
322 $s = parent::formatRow( $row );
325 if ( $row->am_customised ) {
326 $s .= Html::openElement(
'tr', $this->getRowAttrs( $row ) );
327 $formatted = strval( $this->formatValue(
'am_actual', $row->am_actual ) );
329 if ( $formatted ===
'' ) {
330 $formatted =
"\u{00A0}";
333 $s .= Html::rawElement(
'td', $this->getCellAttrs(
'am_actual', $row->am_actual ), $formatted )
334 . Html::closeElement(
'tr' );
337 return Html::rawElement(
'tbody', [], $s );
352 if ( $field ===
'am_title' ) {
353 if ( $this->mCurrentRow->am_customised ) {
354 $attr += [
'rowspan' =>
'2' ];
358 'lang' => $this->lang->getHtmlCode(),
359 'dir' => $this->lang->getDir(),
361 if ( $this->mCurrentRow->am_customised ) {
363 $attr += [
'class' => $field ];
373 'am_title' => $this->msg(
'allmessagesname' )->text(),
374 'am_default' => $this->msg(
'allmessagesdefault' )->text()
404class_alias( AllMessagesTablePager::class,
'AllMessagesTablePager' );
407class_alias( AllMessagesTablePager::class,
'MediaWiki\\Pager\\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.