From: Aaron Schulz Date: Sat, 29 Nov 2008 00:17:10 +0000 (+0000) Subject: * Use insertArticleLink() to remove duplication X-Git-Tag: 1.31.0-rc.0~44171 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=748e6b775106609f2048335683a334a0daa85039;p=lhc%2Fweb%2Fwiklou.git * Use insertArticleLink() to remove duplication * Break some long lines --- diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 34b22943a8..537d6b77c4 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -24,6 +24,7 @@ class RCCacheEntry extends RecentChange { */ class ChangesList { # Called by history lists and recent changes + public $skin; /** * Changeslist contructor @@ -45,7 +46,8 @@ class ChangesList { $sk = $user->getSkin(); $list = NULL; if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) { - return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk ); + return $user->getOption( 'usenewrc' ) ? + new EnhancedChangesList( $sk ) : new OldChangesList( $sk ); } else { return $list; } @@ -147,7 +149,6 @@ class ChangesList { protected function insertDateHeader( &$s, $rc_timestamp ) { global $wgLang; - # Make date header if necessary $date = $wgLang->date( $rc_timestamp, true, true ); if( $date != $this->lastdate ) { @@ -210,15 +211,14 @@ class ChangesList { # RTL/LTR marker $articlelink .= $wgContLang->getDirMark(); - wfRunHooks('ChangesListInsertArticleLink', - array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched)); + wfRunHooks( 'ChangesListInsertArticleLink', + array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) ); $s .= " $articlelink"; } protected function insertTimestamp( &$s, $rc ) { global $wgLang; - # Timestamp $s .= $this->message['semicolon-separator'] . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . '; } @@ -336,8 +336,7 @@ class OldChangesList extends ChangesList { public function recentChangesLine( &$rc, $watched = false ) { global $wgContLang, $wgRCShowChangedSize, $wgUser; - $fname = 'ChangesList::recentChangesLineOld'; - wfProfileIn( $fname ); + wfProfileIn( __METHOD__ ); # Extract DB fields into local scope // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. @@ -368,19 +367,12 @@ class OldChangesList extends ChangesList { } // Regular entries } else { - wfProfileIn($fname.'-page'); - $this->insertDiffHist($s, $rc, $unpatrolled); - # M, N, b and ! (minor, new, bot and unpatrolled) $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', $rc_bot ); $this->insertArticleLink($s, $rc, $unpatrolled, $watched); - - wfProfileOut($fname.'-page'); } - wfProfileIn( $fname.'-rest' ); - $this->insertTimestamp($s,$rc); if( $wgRCShowChangedSize ) { @@ -404,9 +396,7 @@ class OldChangesList extends ChangesList { $s = "
  • $s
  • \n"; - wfProfileOut( $fname.'-rest' ); - - wfProfileOut( $fname ); + wfProfileOut( __METHOD__ ); return $dateheader . $s; } } @@ -663,7 +653,7 @@ class EnhancedChangesList extends ChangesList { if( $namehidden ) { $r .= ' ' . wfMsgHtml('rev-deleted-event') . ''; } else { - $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched ); + $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched ); } $r .= $wgContLang->getDirMark(); @@ -728,7 +718,8 @@ class EnhancedChangesList extends ChangesList { $r .= "\n"; # Sub-entries - $r .= '
    '; + $r .= '
    '; + $r .= '
    '; foreach( $block as $rcObj ) { # Get rc_xxxx variables // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. @@ -751,9 +742,10 @@ class EnhancedChangesList extends ChangesList { } else if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) { $link = ''.$rcObj->timestamp.' '; } else { - $rcIdEq = ($rcObj->unpatrolled && $rc_type == RC_NEW) ? '&rcid='.$rcObj->mAttribs['rc_id'] : ''; - - $link = ''.$this->skin->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp, $curIdEq.'&'.$o.$rcIdEq ).''; + $rcIdEq = ($rcObj->unpatrolled && $rc_type == RC_NEW) ? + '&rcid='.$rcObj->mAttribs['rc_id'] : ''; + $link = ''.$this->skin->makeKnownLinkObj( $rcObj->getTitle(), + $rcObj->timestamp, $curIdEq.'&'.$o.$rcIdEq ).''; if( $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) $link = ''.$link.' '; } @@ -849,16 +841,13 @@ class EnhancedChangesList extends ChangesList { */ protected function recentChangesBlockLine( $rcObj ) { global $wgContLang, $wgRCShowChangedSize; - # Get rc_xxxx variables // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. extract( $rcObj->mAttribs ); - $curIdEq = 'curid='.$rc_cur_id; + $curIdEq = "curid={$rc_cur_id}"; $r = '
    '; - $r .= '
    ' . $this->spacerArrow() . ' '; - # Flag and Timestamp if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $r .= '    '; // 4 flags -> 4 spaces @@ -866,33 +855,26 @@ class EnhancedChangesList extends ChangesList { $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot ); } $r .= ' '.$rcObj->timestamp.' '; - # Article or log link if( $rc_log_type ) { $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL ); $logname = LogPage::logName( $rc_log_type ); $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname ) . ')'; - } else if( !$this->userCan($rcObj,Revision::DELETED_TEXT) ) { - $r .= '' . $rcObj->link . ''; } else { - $r .= $this->maybeWatchedLink( $rcObj->link, $rcObj->watched ); + $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched ); } - # Diff and hist links if ( $rc_type != RC_LOG ) { $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator']; $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')'; } $r .= ' . . '; - # Character diff if( $wgRCShowChangedSize ) { $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ; } - # User/talk $r .= ' '.$rcObj->userlink . $rcObj->usertalklink; - # Log action (if any) if( $rc_log_type ) { if( $this->isDeleted($rcObj,LogPage::DELETED_ACTION) ) { @@ -902,7 +884,6 @@ class EnhancedChangesList extends ChangesList { $this->skin, LogPage::extractParams($rc_params), true, true ); } } - # Edit or log comment if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) { // log comment @@ -912,7 +893,6 @@ class EnhancedChangesList extends ChangesList { $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() ); } } - # Show how many people are watching this if enabled $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers); @@ -936,7 +916,6 @@ class EnhancedChangesList extends ChangesList { $blockOut .= $this->recentChangesBlockGroup( $block ); } } - return '
    '.$blockOut.'
    '; }