MediaWiki master
PageQueryPage.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\SpecialPage;
25
26use HtmlArmor;
32use Skin;
33use stdClass;
36
43abstract class PageQueryPage extends QueryPage {
44
46 private $languageConverter = null;
47
58 public function preprocessResults( $db, $res ) {
59 $this->executeLBFromResultWrapper( $res );
60 }
61
66 final protected function setLanguageConverter( ILanguageConverter $languageConverter ) {
67 $this->languageConverter = $languageConverter;
68 }
69
76 final protected function getLanguageConverter(): ILanguageConverter {
77 if ( $this->languageConverter === null ) {
78 // Fallback if not provided
79 // TODO Change to wfWarn in a future release
80 $this->languageConverter = MediaWikiServices::getInstance()->getLanguageConverterFactory()
81 ->getLanguageConverter( $this->getContentLanguage() );
82 }
83 return $this->languageConverter;
84 }
85
95 public function formatResult( $skin, $row ) {
96 $title = Title::makeTitleSafe( $row->namespace, $row->title );
97 if ( $title instanceof Title ) {
98
99 $text = $this->getLanguageConverter()->convertHtml( $title->getPrefixedText() );
100 return $this->getLinkRenderer()->makeLink( $title, new HtmlArmor( $text ) );
101 } else {
102 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
103 Linker::getInvalidTitleDescription( $this->getContext(), $row->namespace, $row->title ) );
104 }
105 }
106}
107
112class_alias( PageQueryPage::class, 'PageQueryPage' );
getContext()
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
Some internal bits split of from Skin.php.
Definition Linker.php:65
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
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:88
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:78
The base class for all skins.
Definition Skin.php:58
The shared interface for all language converters.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)