From: Jack Phoenix Date: Tue, 23 Mar 2010 16:11:37 +0000 (+0000) Subject: move newtalk stuff from SkinTemplate to its own function in Skin X-Git-Tag: 1.31.0-rc.0~37380 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=f624235d70144e8ba0a79ee6a798c84723cf8175;p=lhc%2Fweb%2Fwiklou.git move newtalk stuff from SkinTemplate to its own function in Skin --- diff --git a/includes/Skin.php b/includes/Skin.php index 3244573f73..5c49a1a05e 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -2181,4 +2181,61 @@ CSS; public function commonPrintStylesheet() { return true; } + + /** + * Gets new talk page messages for the current user. + * @return MediaWiki message or if no new talk page messages, nothing + */ + function getNewtalks() { + global $wgUser, $wgOut; + $newtalks = $wgUser->getNewMessageLinks(); + + if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) { + $userTitle = $this->mUser->getUserPage(); + $userTalkTitle = $userTitle->getTalkPage(); + + if( !$userTalkTitle->equals( $this->mTitle ) ) { + $newMessagesLink = $this->link( + $userTalkTitle, + wfMsgHtml( 'newmessageslink' ), + array(), + array( 'redirect' => 'no' ), + array( 'known', 'noclasses' ) + ); + + $newMessagesDiffLink = $this->link( + $userTalkTitle, + wfMsgHtml( 'newmessagesdifflink' ), + array(), + array( 'diff' => 'cur' ), + array( 'known', 'noclasses' ) + ); + + $ntl = wfMsg( + 'youhavenewmessages', + $newMessagesLink, + $newMessagesDiffLink + ); + # Disable Squid cache + $wgOut->setSquidMaxage( 0 ); + } + } elseif( count( $newtalks ) ) { + // _>" " for BC <= 1.16 + $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) ); + $msgs = array(); + foreach( $newtalks as $newtalk ) { + $msgs[] = Xml::element( + 'a', + array( 'href' => $newtalk['link'] ), $newtalk['wiki'] + ); + } + $parts = implode( $sep, $msgs ); + $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts ); + $wgOut->setSquidMaxage( 0 ); + } else { + $ntl = ''; + } + return $ntl; + } + } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 9b4a287839..7d4588155d 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -311,8 +311,8 @@ class SkinTemplate extends Skin { // Users can have their language set differently than the // content of the wiki. For these users, tell the web browser // that interface elements are in a different language. - $tpl->set( 'userlangattributes', ''); - $tpl->set( 'specialpageattributes', ''); + $tpl->set( 'userlangattributes', '' ); + $tpl->set( 'specialpageattributes', '' ); $lang = $wgLang->getCode(); $dir = $wgLang->getDir(); @@ -323,60 +323,17 @@ class SkinTemplate extends Skin { // The content of SpecialPages should be presented in the // user's language. Content of regular pages should not be touched. - if($this->mTitle->isSpecialPage()) { + if( $this->mTitle->isSpecialPage() ) { $tpl->set( 'specialpageattributes', $attrs ); } } - $newtalks = $wgUser->getNewMessageLinks(); + $newtalks = $this->getNewtalks(); - if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) { - $usertitle = $this->mUser->getUserPage(); - $usertalktitle = $usertitle->getTalkPage(); - - if( !$usertalktitle->equals( $this->mTitle ) ) { - $newmessageslink = $this->link( - $usertalktitle, - wfMsgHtml( 'newmessageslink' ), - array(), - array( 'redirect' => 'no' ), - array( 'known', 'noclasses' ) - ); - - $newmessagesdifflink = $this->link( - $usertalktitle, - wfMsgHtml( 'newmessagesdifflink' ), - array(), - array( 'diff' => 'cur' ), - array( 'known', 'noclasses' ) - ); - - $ntl = wfMsg( - 'youhavenewmessages', - $newmessageslink, - $newmessagesdifflink - ); - # Disable Cache - $out->setSquidMaxage( 0 ); - } - } else if( count( $newtalks ) ) { - // _>" " for BC <= 1.16 - $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) ); - $msgs = array(); - foreach( $newtalks as $newtalk ) { - $msgs[] = Xml::element('a', - array( 'href' => $newtalk['link'] ), $newtalk['wiki'] ); - } - $parts = implode( $sep, $msgs ); - $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts ); - $out->setSquidMaxage( 0 ); - } else { - $ntl = ''; - } wfProfileOut( __METHOD__ . '-stuff2' ); wfProfileIn( __METHOD__ . '-stuff3' ); - $tpl->setRef( 'newtalk', $ntl ); + $tpl->setRef( 'newtalk', $newtalks ); $tpl->setRef( 'skin', $this ); $tpl->set( 'logo', $this->logoText() ); if ( $out->isArticle() and ( !isset( $oldid ) or isset( $diff ) ) and