/**
* @param OutputPage $out
*/
- function initPage( OutputPage $out ) {
-
+ public function initPage( OutputPage $out ) {
$this->preloadExistence();
-
}
/**
/**
* Preload the existence of three commonly-requested pages in a single query
*/
- function preloadExistence() {
+ protected function preloadExistence() {
$titles = [];
- $user = $this->getUser();
- $title = $this->getRelevantTitle();
-
// User/talk link
+ $user = $this->getUser();
if ( $user->isLoggedIn() ) {
$titles[] = $user->getUserPage();
$titles[] = $user->getTalkPage();
}
// Check, if the page can hold some kind of content, otherwise do nothing
- if ( !$title->canExist() ) {
- // nothing
- } elseif ( $title->isTalkPage() ) {
- $titles[] = $title->getSubjectPage();
- } else {
- $titles[] = $title->getTalkPage();
+ $title = $this->getRelevantTitle();
+ if ( $title->canExist() ) {
+ if ( $title->isTalkPage() ) {
+ $titles[] = $title->getSubjectPage();
+ } else {
+ $titles[] = $title->getTalkPage();
+ }
}
Hooks::run( 'SkinPreloadExistence', [ &$titles, $this ] );
- if ( count( $titles ) ) {
+ if ( $titles ) {
$lb = new LinkBatch( $titles );
$lb->setCaller( __METHOD__ );
$lb->execute();
}
/**
+ * @param OutputPage $out Defaults to $this->getOutput() if left as null
* @return string
*/
- function subPageSubtitle() {
- $out = $this->getOutput();
+ function subPageSubtitle( $out = null ) {
+ if ( $out === null ) {
+ $out = $this->getOutput();
+ }
+ $title = $out->getTitle();
$subpages = '';
if ( !Hooks::run( 'SkinSubPageSubtitle', [ &$subpages, $this, $out ] ) ) {
return $subpages;
}
- if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) {
- $ptext = $this->getTitle()->getPrefixedText();
- if ( preg_match( '/\//', $ptext ) ) {
+ if ( $out->isArticle() && MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+ $ptext = $title->getPrefixedText();
+ if ( strpos( $ptext, '/' ) !== false ) {
$links = explode( '/', $ptext );
array_pop( $links );
$c = 0;
$lines = explode( "\n", $text );
$heading = '';
+ $messageTitle = $this->getConfig()->get( 'EnableSidebarCache' )
+ ? Title::newMainPage() : $this->getTitle();
foreach ( $lines as $line ) {
if ( strpos( $line, '*' ) !== 0 ) {
$line = trim( $line, '* ' );
if ( strpos( $line, '|' ) !== false ) { // sanity check
- $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
+ $line = MessageCache::singleton()->transform( $line, false, null, $messageTitle );
$line = array_map( 'trim', explode( '|', $line, 2 ) );
if ( count( $line ) !== 2 ) {
// Second sanity check, could be hit by people doing
$extraAttribs = [];
- $msgLink = $this->msg( $line[0] )->inContentLanguage();
+ $msgLink = $this->msg( $line[0] )->title( $messageTitle )->inContentLanguage();
if ( $msgLink->exists() ) {
$link = $msgLink->text();
if ( $link == '-' ) {
} else {
$link = $line[0];
}
- $msgText = $this->msg( $line[1] );
+ $msgText = $this->msg( $line[1] )->title( $messageTitle );
if ( $msgText->exists() ) {
$text = $msgText->text();
} else {
return $result;
}
- /** @deprecated in 1.21 */
- public function commentBlock( $comment, $title = null, $local = false, $wikiId = null ) {
- wfDeprecated( __METHOD__, '1.21' );
- return Linker::commentBlock( $comment, $title, $local, $wikiId );
- }
-
- /** @deprecated in 1.21 */
- public function generateRollback(
- $rev,
- IContextSource $context = null,
- $options = [ 'verify' ]
- ) {
- wfDeprecated( __METHOD__, '1.21' );
- return Linker::generateRollback( $rev, $context, $options );
- }
-
- /** @deprecated in 1.21 */
- public function link( $target, $html = null, $customAttribs = [], $query = [], $options = [] ) {
- wfDeprecated( __METHOD__, '1.21' );
- return Linker::link( $target, $html, $customAttribs, $query, $options );
- }
-
- /** @deprecated in 1.21 */
- public function linkKnown(
- $target,
- $html = null,
- $customAttribs = [],
- $query = [],
- $options = [ 'known', 'noclasses' ]
- ) {
- wfDeprecated( __METHOD__, '1.21' );
- return Linker::linkKnown( $target, $html, $customAttribs, $query, $options );
- }
-
- /** @deprecated in 1.21 */
- public function userLink( $userId, $userName, $altUserName = false ) {
- wfDeprecated( __METHOD__, '1.21' );
- return Linker::userLink( $userId, $userName, $altUserName );
- }
-
- /** @deprecated in 1.21 */
- public function userToolLinks(
- $userId,
- $userText,
- $redContribsWhenNoEdits = false,
- $flags = 0,
- $edits = null
- ) {
- wfDeprecated( __METHOD__, '1.21' );
- return Linker::userToolLinks( $userId, $userText, $redContribsWhenNoEdits, $flags, $edits );
- }
-
}