X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2FChangesList.php;h=70a5dcbbde80f2f3700e8a1153a72dc9f129a96f;hb=9e638dbef402377fb1c02f7228ec2fa611ee7aa0;hp=ac7ee9c89c13e63fd9a4cd1879499b6baf4cdc29;hpb=e53d3fe26e3dd47979b48337ad1393b3220b0a65;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ChangesList.php b/includes/ChangesList.php index ac7ee9c89c..70a5dcbbde 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -25,13 +25,14 @@ class RCCacheEntry extends RecentChange { class ChangesList { # Called by history lists and recent changes public $skin; + protected $watchlist = false; /** * Changeslist contructor * @param Skin $skin */ - public function __construct( &$skin ) { - $this->skin =& $skin; + public function __construct( $skin ) { + $this->skin = $skin; $this->preCacheMessages(); } @@ -52,6 +53,14 @@ class ChangesList { return $list; } } + + /** + * Sets the list to use a
  • tag + * @param bool $value + */ + public function setWatchlistDivs( $value = true ) { + $this->watchlist = $value; + } /** * As we use the same small set of messages in various methods and that @@ -59,8 +68,8 @@ class ChangesList { */ private function preCacheMessages() { if( !isset( $this->message ) ) { - foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '. - 'blocklink history boteditletter semicolon-separator' ) as $msg ) { + foreach ( explode( ' ', 'cur diff hist last blocklink history ' . + 'semicolon-separator pipe-separator' ) as $msg ) { $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) ); } } @@ -77,15 +86,84 @@ class ChangesList { * @return string */ protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) { - $f = $new ? - '' . $this->message['newpageletter'] . '' : $nothing; - $f .= $minor ? - '' . $this->message['minoreditletter'] . '' : $nothing; - $f .= $bot ? '' . $this->message['boteditletter'] . '' : $nothing; - $f .= $patrolled ? '!' : $nothing; + $f = $new ? self::flag( 'newpage' ) : $nothing; + $f .= $minor ? self::flag( 'minor' ) : $nothing; + $f .= $bot ? self::flag( 'bot' ) : $nothing; + $f .= $patrolled ? self::flag( 'unpatrolled' ) : $nothing; return $f; } + /** + * Provide the element appropriate to a given abbreviated flag, + * namely the flag indicating a new page, a minor edit, a bot edit, or an + * unpatrolled edit. By default in English it will contain "N", "m", "b", + * "!" respectively, plus it will have an appropriate title and class. + * + * @param $key string 'newpage', 'unpatrolled', 'minor', or 'bot' + * @return string Raw HTML + */ + public static function flag( $key ) { + static $messages = null; + if ( is_null( $messages ) ) { + foreach ( explode( ' ', 'minoreditletter boteditletter newpageletter ' . + 'unpatrolledletter recentchanges-label-minor recentchanges-label-bot ' . + 'recentchanges-label-newpage recentchanges-label-unpatrolled' ) as $msg ) { + $messages[$msg] = wfMsgExt( $msg, 'escapenoentities' ); + } + } + # Inconsistent naming, bleh + if ( $key == 'newpage' || $key == 'unpatrolled' ) { + $key2 = $key; + } else { + $key2 = $key . 'edit'; + } + return "" + . $messages["${key2}letter"] + . ''; + } + + /** + * Some explanatory wrapper text for the given flag, to be used in a legend + * explaining what the flags mean. For instance, "N - new page". See + * also flag(). + * + * @param $key string 'newpage', 'unpatrolled', 'minor', or 'bot' + * @return string Raw HTML + */ + private static function flagLine( $key ) { + return wfMsgExt( "recentchanges-legend-$key", array( 'escapenoentities', + 'replaceafter' ), self::flag( $key ) ); + } + + /** + * A handy legend to tell users what the little "m", "b", and so on mean. + * + * @return string Raw HTML + */ + public static function flagLegend() { + global $wgGroupPermissions, $wgLang; + + $flags = array( self::flagLine( 'newpage' ), + self::flagLine( 'minor' ) ); + + # Don't show info on bot edits unless there's a bot group of some kind + foreach ( $wgGroupPermissions as $rights ) { + if ( isset( $rights['bot'] ) && $rights['bot'] ) { + $flags[] = self::flagLine( 'bot' ); + break; + } + } + + if ( self::usePatrol() ) { + $flags[] = self::flagLine( 'unpatrolled' ); + } + + return '
    ' . + wfMsgExt( 'recentchanges-label-legend', 'parseinline', + $wgLang->commaList( $flags ) ) . '
    '; + } + /** * Returns text for the start of the tabular part of RC * @return string @@ -108,11 +186,18 @@ class ChangesList { public static function showCharacterDifference( $old, $new ) { global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode; $szdiff = $new - $old; + + $code = $wgLang->getCode(); + static $fastCharDiff = array(); + if ( !isset($fastCharDiff[$code]) ) { + $fastCharDiff[$code] = $wgMiserMode || wfMsgNoTrans( 'rc-change-size' ) === '$1'; + } - $formatedSize = ( $wgMiserMode? - $wgLang->formatNum($szdiff) : // avoid expensive calculations - wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $wgLang->formatNum( $szdiff ) ) - ); + $formatedSize = $wgLang->formatNum($szdiff); + + if ( !$fastCharDiff[$code] ) { + $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $formatedSize ); + } if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) { $tag = 'strong'; @@ -144,12 +229,32 @@ class ChangesList { # Diff $s .= '(' . $this->message['diff'] . ') ('; # Hist - $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], - 'action=history' ) . ') . . '; + $s .= $this->skin->link( + $rc->getMovedToTitle(), + $this->message['hist'], + array(), + array( 'action' => 'history' ), + array( 'known', 'noclasses' ) + ) . ') . . '; # "[[x]] moved to [[y]]" $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir'; - $s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ), - $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) ); + $s .= wfMsg( + $msg, + $this->skin->link( + $rc->getTitle(), + null, + array(), + array( 'redirect' => 'no' ), + array( 'known', 'noclasses' ) + ), + $this->skin->link( + $rc->getMovedToTitle(), + null, + array(), + array(), + array( 'known', 'noclasses' ) + ) + ); } protected function insertDateHeader( &$s, $rc_timestamp ) { @@ -160,7 +265,7 @@ class ChangesList { if( '' != $this->lastdate ) { $s .= "\n"; } - $s .= '

    '.$date."

    \n