MediaWiki  master
PageQueryPage.php
Go to the documentation of this file.
1 <?php
30 
37 abstract class PageQueryPage extends QueryPage {
38 
40  private $languageConverter = null;
41 
52  public function preprocessResults( $db, $res ) {
54  }
55 
60  final protected function setLanguageConverter( ILanguageConverter $languageConverter ) {
61  $this->languageConverter = $languageConverter;
62  }
63 
70  final protected function getLanguageConverter(): ILanguageConverter {
71  if ( $this->languageConverter === null ) {
72  // Fallback if not provided
73  // TODO Change to wfWarn in a future release
74  $this->languageConverter = MediaWikiServices::getInstance()->getLanguageConverterFactory()
75  ->getLanguageConverter( $this->getContentLanguage() );
76  }
77  return $this->languageConverter;
78  }
79 
89  public function formatResult( $skin, $row ) {
90  $title = Title::makeTitleSafe( $row->namespace, $row->title );
91  if ( $title instanceof Title ) {
92 
93  $text = $this->getLanguageConverter()->convertHtml( $title->getPrefixedText() );
94  return $this->getLinkRenderer()->makeLink( $title, new HtmlArmor( $text ) );
95  } else {
96  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
97  Linker::getInvalidTitleDescription( $this->getContext(), $row->namespace, $row->title ) );
98  }
99  }
100 }
getContext()
if(!defined('MW_SETUP_CALLBACK'))
Definition: WebStart.php:88
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:55
Some internal bits split of from Skin.php.
Definition: Linker.php:67
Service locator for MediaWiki core services.
Represents a title within MediaWiki.
Definition: Title.php:82
Variant of QueryPage which formats 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...
formatResult( $skin, $row)
Format the result as a simple link to the page.
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:65
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Definition: QueryPage.php:925
getContentLanguage()
Shortcut to get content language.
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.