MediaWiki master
PageQueryPage.php
Go to the documentation of this file.
1<?php
10namespace MediaWiki\SpecialPage;
11
18use stdClass;
22
29abstract class PageQueryPage extends QueryPage {
30
32 private $languageConverter = null;
33
44 public function preprocessResults( $db, $res ) {
45 $this->executeLBFromResultWrapper( $res );
46 }
47
52 final protected function setLanguageConverter( ILanguageConverter $languageConverter ) {
53 $this->languageConverter = $languageConverter;
54 }
55
62 final protected function getLanguageConverter(): ILanguageConverter {
63 if ( $this->languageConverter === null ) {
64 // Fallback if not provided
65 // TODO Change to wfWarn in a future release
66 $this->languageConverter = MediaWikiServices::getInstance()->getLanguageConverterFactory()
67 ->getLanguageConverter( $this->getContentLanguage() );
68 }
69 return $this->languageConverter;
70 }
71
81 public function formatResult( $skin, $row ) {
82 $title = Title::makeTitleSafe( $row->namespace, $row->title );
83 if ( $title instanceof Title ) {
84
85 $text = $this->getLanguageConverter()->convertHtml( $title->getPrefixedText() );
86 return $this->getLinkRenderer()->makeLink( $title, new HtmlArmor( $text ) );
87 } else {
88 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
89 Linker::getInvalidTitleDescription( $this->getContext(), $row->namespace, $row->title ) );
90 }
91 }
92}
93
95class_alias( PageQueryPage::class, 'PageQueryPage' );
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:68
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
Some internal bits split of from Skin.php.
Definition Linker.php:47
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
The base class for all skins.
Definition Skin.php:52
Variant of QueryPage which formats the result as a simple link to the page.
formatResult( $skin, $row)
Format the result as a simple link to the page.
setLanguageConverter(ILanguageConverter $languageConverter)
preprocessResults( $db, $res)
Run a LinkBatch to pre-cache LinkCache information, like page existence and information for stub colo...
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition QueryPage.php:77
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
getContentLanguage()
Shortcut to get content language.
Represents a title within MediaWiki.
Definition Title.php:70
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:18
The shared interface for all language converters.
A database connection without write operations.
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)