r64078 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64077‎ | r64078 | r64079 >
Date:16:11, 23 March 2010
Author:ashley
Status:ok
Tags:
Comment:
move newtalk stuff from SkinTemplate to its own function in Skin
Modified paths:
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -311,8 +311,8 @@
312312 // Users can have their language set differently than the
313313 // content of the wiki. For these users, tell the web browser
314314 // that interface elements are in a different language.
315 - $tpl->set( 'userlangattributes', '');
316 - $tpl->set( 'specialpageattributes', '');
 315+ $tpl->set( 'userlangattributes', '' );
 316+ $tpl->set( 'specialpageattributes', '' );
317317
318318 $lang = $wgLang->getCode();
319319 $dir = $wgLang->getDir();
@@ -323,60 +323,17 @@
324324
325325 // The content of SpecialPages should be presented in the
326326 // user's language. Content of regular pages should not be touched.
327 - if($this->mTitle->isSpecialPage()) {
 327+ if( $this->mTitle->isSpecialPage() ) {
328328 $tpl->set( 'specialpageattributes', $attrs );
329329 }
330330 }
331331
332 - $newtalks = $wgUser->getNewMessageLinks();
 332+ $newtalks = $this->getNewtalks();
333333
334 - if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
335 - $usertitle = $this->mUser->getUserPage();
336 - $usertalktitle = $usertitle->getTalkPage();
337 -
338 - if( !$usertalktitle->equals( $this->mTitle ) ) {
339 - $newmessageslink = $this->link(
340 - $usertalktitle,
341 - wfMsgHtml( 'newmessageslink' ),
342 - array(),
343 - array( 'redirect' => 'no' ),
344 - array( 'known', 'noclasses' )
345 - );
346 -
347 - $newmessagesdifflink = $this->link(
348 - $usertalktitle,
349 - wfMsgHtml( 'newmessagesdifflink' ),
350 - array(),
351 - array( 'diff' => 'cur' ),
352 - array( 'known', 'noclasses' )
353 - );
354 -
355 - $ntl = wfMsg(
356 - 'youhavenewmessages',
357 - $newmessageslink,
358 - $newmessagesdifflink
359 - );
360 - # Disable Cache
361 - $out->setSquidMaxage( 0 );
362 - }
363 - } else if( count( $newtalks ) ) {
364 - // _>" " for BC <= 1.16
365 - $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
366 - $msgs = array();
367 - foreach( $newtalks as $newtalk ) {
368 - $msgs[] = Xml::element('a',
369 - array( 'href' => $newtalk['link'] ), $newtalk['wiki'] );
370 - }
371 - $parts = implode( $sep, $msgs );
372 - $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
373 - $out->setSquidMaxage( 0 );
374 - } else {
375 - $ntl = '';
376 - }
377334 wfProfileOut( __METHOD__ . '-stuff2' );
378335
379336 wfProfileIn( __METHOD__ . '-stuff3' );
380 - $tpl->setRef( 'newtalk', $ntl );
 337+ $tpl->setRef( 'newtalk', $newtalks );
381338 $tpl->setRef( 'skin', $this );
382339 $tpl->set( 'logo', $this->logoText() );
383340 if ( $out->isArticle() and ( !isset( $oldid ) or isset( $diff ) ) and
Index: trunk/phase3/includes/Skin.php
@@ -2181,4 +2181,61 @@
21822182 public function commonPrintStylesheet() {
21832183 return true;
21842184 }
 2185+
 2186+ /**
 2187+ * Gets new talk page messages for the current user.
 2188+ * @return MediaWiki message or if no new talk page messages, nothing
 2189+ */
 2190+ function getNewtalks() {
 2191+ global $wgUser, $wgOut;
 2192+ $newtalks = $wgUser->getNewMessageLinks();
 2193+
 2194+ if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
 2195+ $userTitle = $this->mUser->getUserPage();
 2196+ $userTalkTitle = $userTitle->getTalkPage();
 2197+
 2198+ if( !$userTalkTitle->equals( $this->mTitle ) ) {
 2199+ $newMessagesLink = $this->link(
 2200+ $userTalkTitle,
 2201+ wfMsgHtml( 'newmessageslink' ),
 2202+ array(),
 2203+ array( 'redirect' => 'no' ),
 2204+ array( 'known', 'noclasses' )
 2205+ );
 2206+
 2207+ $newMessagesDiffLink = $this->link(
 2208+ $userTalkTitle,
 2209+ wfMsgHtml( 'newmessagesdifflink' ),
 2210+ array(),
 2211+ array( 'diff' => 'cur' ),
 2212+ array( 'known', 'noclasses' )
 2213+ );
 2214+
 2215+ $ntl = wfMsg(
 2216+ 'youhavenewmessages',
 2217+ $newMessagesLink,
 2218+ $newMessagesDiffLink
 2219+ );
 2220+ # Disable Squid cache
 2221+ $wgOut->setSquidMaxage( 0 );
 2222+ }
 2223+ } elseif( count( $newtalks ) ) {
 2224+ // _>" " for BC <= 1.16
 2225+ $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
 2226+ $msgs = array();
 2227+ foreach( $newtalks as $newtalk ) {
 2228+ $msgs[] = Xml::element(
 2229+ 'a',
 2230+ array( 'href' => $newtalk['link'] ), $newtalk['wiki']
 2231+ );
 2232+ }
 2233+ $parts = implode( $sep, $msgs );
 2234+ $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
 2235+ $wgOut->setSquidMaxage( 0 );
 2236+ } else {
 2237+ $ntl = '';
 2238+ }
 2239+ return $ntl;
 2240+ }
 2241+
21852242 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r65293Follow-up r64078: Define $ntl at the beginning to avoid PHP Notice: Undefined...raymond08:14, 20 April 2010

Status & tagging log