}
/**
- * Returns page information in an easily-manipulated format. Array keys are used so extensions
- * may add additional information in arbitrary positions. Array values are arrays with one
- * element to be rendered as a header, arrays with two elements to be rendered as a table row.
+ * Returns an array of info groups (will be rendered as tables), keyed by group ID.
+ * Group IDs are arbitrary and used so that extensions may add additional information in
+ * arbitrary positions (and as message keys for section headers for the tables, prefixed
+ * with 'pageinfo-').
+ * Each info group is a non-associative array of info items (rendered as table rows).
+ * Each info item is an array with two elements: the first describes the type of
+ * information, the second the value for the current page. Both can be strings (will be
+ * interpreted as raw HTML) or messages (will be interpreted as plain text and escaped).
*
* @return array
*/
protected function pageInfo() {
- global $wgContLang;
+ $services = MediaWikiServices::getInstance();
$user = $this->getUser();
$lang = $this->getLanguage();
$title = $this->getTitle();
$id = $title->getArticleID();
$config = $this->context->getConfig();
- $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ $linkRenderer = $services->getLinkRenderer();
$pageCounts = $this->pageCounts( $this->page );
- $pageProperties = [];
$props = PageProps::getInstance()->getAllProperties( $title );
- if ( isset( $props[$id] ) ) {
- $pageProperties = $props[$id];
- }
+ $pageProperties = $props[$id] ?? [];
// Basic information
$pageInfo = [];
$pageInfo['header-basic'] = [];
// Display title
- $displayTitle = $title->getPrefixedText();
- if ( isset( $pageProperties['displaytitle'] ) ) {
- $displayTitle = $pageProperties['displaytitle'];
- }
+ $displayTitle = $pageProperties['displaytitle'] ?? $title->getPrefixedText();
$pageInfo['header-basic'][] = [
$this->msg( 'pageinfo-display-title' ), $displayTitle
}
// Default sort key
- $sortKey = $title->getCategorySortkey();
- if ( isset( $pageProperties['defaultsort'] ) ) {
- $sortKey = $pageProperties['defaultsort'];
- }
+ $sortKey = $pageProperties['defaultsort'] ?? $title->getCategorySortkey();
$sortKey = htmlspecialchars( $sortKey );
$pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-default-sort' ), $sortKey ];
];
// Array of MagicWord objects
- $magicWords = MagicWord::getDoubleUnderscoreArray();
+ $magicWords = $services->getMagicWordFactory()->getDoubleUnderscoreArray();
// Array of magic word IDs
$wordIDs = $magicWords->names;
// Array of IDs => localized magic words
- $localizedWords = $wgContLang->getMagicWords();
+ $localizedWords = $services->getContentLanguage()->getMagicWords();
$listItems = [];
foreach ( $pageProperties as $property => $value ) {