*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\Database;
/**
* Displays information about a page.
$revid = $revision ? $revision->getId() : null;
}
if ( $revid !== null ) {
- $key = self::getCacheKey( $title, $revid );
- ObjectCache::getMainWANInstance()->delete( $key );
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $key = self::getCacheKey( $cache, $title, $revid );
+ $cache->delete( $key );
}
}
// Messages:
// pageinfo-header-basic, pageinfo-header-edits, pageinfo-header-restrictions,
// pageinfo-header-properties, pageinfo-category-info
- $content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n";
+ $content .= $this->makeHeader(
+ $this->msg( "pageinfo-${header}" )->escaped(),
+ "mw-pageinfo-${header}"
+ ) . "\n";
$table = "\n";
foreach ( $infoTable as $infoRow ) {
$name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0];
* @param string $header The header text.
* @return string The HTML.
*/
- protected function makeHeader( $header ) {
- $spanAttribs = [ 'class' => 'mw-headline', 'id' => Sanitizer::escapeId( $header ) ];
+ protected function makeHeader( $header, $canonicalId ) {
+ $spanAttribs = [ 'class' => 'mw-headline', 'id' => Sanitizer::escapeIdForAttribute( $header ) ];
+ $h2Attribs = [ 'id' => Sanitizer::escapeIdForAttribute( $canonicalId ) ];
- return Html::rawElement( 'h2', [], Html::element( 'span', $spanAttribs, $header ) );
+ return Html::rawElement( 'h2', $h2Attribs, Html::element( 'span', $spanAttribs, $header ) );
}
/**
// Language in which the page content is (supposed to be) written
$pageLang = $title->getPageLanguage()->getCode();
+ $pageLangHtml = $pageLang . ' - ' .
+ Language::fetchLanguageName( $pageLang, $lang->getCode() );
+ // Link to Special:PageLanguage with pre-filled page title if user has permissions
if ( $config->get( 'PageLanguageUseDB' )
- && $this->getTitle()->userCan( 'pagelang', $this->getUser() )
+ && $title->userCan( 'pagelang', $user )
) {
- // Link to Special:PageLanguage with pre-filled page title if user has permissions
- $titleObj = SpecialPage::getTitleFor( 'PageLanguage', $title->getPrefixedText() );
- $langDisp = $linkRenderer->makeLink(
- $titleObj,
- $this->msg( 'pageinfo-language' )->text()
- );
- } else {
- // Display just the message
- $langDisp = $this->msg( 'pageinfo-language' )->escaped();
+ $pageLangHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
+ SpecialPage::getTitleValueFor( 'PageLanguage', $title->getPrefixedText() ),
+ $this->msg( 'pageinfo-language-change' )->text()
+ ) )->escaped();
}
- $pageInfo['header-basic'][] = [ $langDisp,
- Language::fetchLanguageName( $pageLang, $lang->getCode() )
- . ' ' . $this->msg( 'parentheses', $pageLang )->escaped() ];
+ $pageInfo['header-basic'][] = [
+ $this->msg( 'pageinfo-language' )->escaped(),
+ $pageLangHtml
+ ];
// Content model of the page
$modelHtml = htmlspecialchars( ContentHandler::getLocalizedName( $title->getContentModel() ) );
// If the user can change it, add a link to Special:ChangeContentModel
- if ( $title->quickUserCan( 'editcontentmodel' ) ) {
+ if ( $config->get( 'ContentHandlerUseDB' )
+ && $title->userCan( 'editcontentmodel', $user )
+ ) {
$modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
SpecialPage::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ),
$this->msg( 'pageinfo-content-model-change' )->text()
$prefixIndex = SpecialPage::getTitleFor(
'Prefixindex', $title->getPrefixedText() . '/' );
$pageInfo['header-basic'][] = [
- Linker::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ),
+ $linkRenderer->makeLink(
+ $prefixIndex,
+ $this->msg( 'pageinfo-subpages-name' )->text()
+ ),
$this->msg( 'pageinfo-subpages-value' )
->numParams(
$pageCounts['subpages']['total'],
}
$expiry = $title->getRestrictionExpiry( $restrictionType );
$formattedexpiry = $this->msg( 'parentheses',
- $this->getLanguage()->formatExpiry( $expiry ) )->escaped();
+ $lang->formatExpiry( $expiry ) )->escaped();
$message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
// Messages: restriction-edit, restriction-move, restriction-create,
protected function pageCounts( Page $page ) {
$fname = __METHOD__;
$config = $this->context->getConfig();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
- return ObjectCache::getMainWANInstance()->getWithSetCallback(
- self::getCacheKey( $page->getTitle(), $page->getLatest() ),
+ return $cache->getWithSetCallback(
+ self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
WANObjectCache::TTL_WEEK,
function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
$title = $page->getTitle();
$real_names = [];
$user_names = [];
$anon_ips = [];
- $linkRenderer = MediaWikiServices::getLinkRenderer();
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
# Sift for real versus user names
/** @var $user User */
}
/**
+ * @param WANObjectCache $cache
* @param Title $title
* @param int $revId
* @return string
*/
- protected static function getCacheKey( Title $title, $revId ) {
- return wfMemcKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION );
+ protected static function getCacheKey( WANObjectCache $cache, Title $title, $revId ) {
+ return $cache->makeKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION );
}
}