http://www.mediawiki.org/wiki/Special:Code/MediaWiki/64078
Revision: 64078 Author: ashley Date: 2010-03-23 16:11:37 +0000 (Tue, 23 Mar 2010) Log Message: ----------- move newtalk stuff from SkinTemplate to its own function in Skin Modified Paths: -------------- trunk/phase3/includes/Skin.php trunk/phase3/includes/SkinTemplate.php Modified: trunk/phase3/includes/Skin.php =================================================================== --- trunk/phase3/includes/Skin.php 2010-03-23 15:43:57 UTC (rev 64077) +++ trunk/phase3/includes/Skin.php 2010-03-23 16:11:37 UTC (rev 64078) @@ -2181,4 +2181,61 @@ 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; + } + } Modified: trunk/phase3/includes/SkinTemplate.php =================================================================== --- trunk/phase3/includes/SkinTemplate.php 2010-03-23 15:43:57 UTC (rev 64077) +++ trunk/phase3/includes/SkinTemplate.php 2010-03-23 16:11:37 UTC (rev 64078) @@ -311,8 +311,8 @@ // 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 @@ // 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 _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs