X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FChangesList.php;h=8732e6f636aab1414fdc5f1be117d8143cc99422;hb=2c9cfd7cce6ba9de336cff9f9917385e5901b0c4;hp=91bf212bb6edc7bf52393b6fcf319835a84aa4e6;hpb=b9f44792f4961670501542bb885786be676bd2a8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 91bf212bb6..8732e6f636 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -1,4 +1,12 @@ mAttribs = $rc->mAttribs; @@ -17,19 +30,19 @@ class RCCacheEntry extends RecentChange { } /** - * Class to show various lists of changes: - * - what links here - * - related changes - * - recent changes + * Base class for all changes lists */ class ChangesList { - # Called by history lists and recent changes + + /** + * @var Skin + */ public $skin; protected $watchlist = false; - + /** * Changeslist contructor - * @param Skin $skin + * @param $skin Skin */ public function __construct( $skin ) { $this->skin = $skin; @@ -43,12 +56,14 @@ class ChangesList { * @param $user User to fetch the list class for * @return ChangesList derivative */ - public static function newFromUser( &$user ) { + public static function newFromUser( $user ) { + global $wgRequest; + $sk = $user->getSkin(); - $list = NULL; - if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) { - return $user->getOption( 'usenewrc' ) ? - new EnhancedChangesList( $sk ) : new OldChangesList( $sk ); + $list = null; + if( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) { + $new = $wgRequest->getBool( 'enhanced', $user->getOption( 'usenewrc' ) ); + return $new ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk ); } else { return $list; } @@ -56,7 +71,7 @@ class ChangesList { /** * Sets the list to use a
  • tag - * @param bool $value + * @param $value Boolean */ public function setWatchlistDivs( $value = true ) { $this->watchlist = $value; @@ -75,21 +90,19 @@ class ChangesList { } } - /** * Returns the appropriate flags for new page, minor change and patrolling - * @param bool $new - * @param bool $minor - * @param bool $patrolled - * @param string $nothing, string to use for empty space - * @param bool $bot - * @return string + * @param $flags Array Associative array of 'flag' => Bool + * @param $nothing String to use for empty space + * @return String */ - protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) { - $f = $new ? self::flag( 'newpage' ) : $nothing; - $f .= $minor ? self::flag( 'minor' ) : $nothing; - $f .= $bot ? self::flag( 'bot' ) : $nothing; - $f .= $patrolled ? self::flag( 'unpatrolled' ) : $nothing; + protected function recentChangesFlags( $flags, $nothing = ' ' ) { + $f = ''; + foreach( array( 'newpage', 'minor', 'bot', 'unpatrolled' ) as $flag ){ + $f .= isset( $flags[$flag] ) && $flags[$flag] + ? self::flag( $flag ) + : $nothing; + } return $f; } @@ -99,74 +112,41 @@ class ChangesList { * 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 + * @param $key String: 'newpage', 'unpatrolled', 'minor', or 'bot' + * @return String: Raw HTML */ - public static function flag( $key ) { + public static function flag( $flag ) { 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; + $messages = array( + 'newpage' => array( 'newpageletter', 'recentchanges-label-newpage' ), + 'minoredit' => array( 'minoreditletter', 'recentchanges-label-minor' ), + 'botedit' => array( 'boteditletter', 'recentchanges-label-bot' ), + 'unpatrolled' => array( 'unpatrolledletter', 'recentchanges-label-unpatrolled' ), + ); + foreach( $messages as &$value ) { + $value[0] = wfMsgExt( $value[0], 'escapenoentities' ); + $value[1] = wfMsgExt( $value[1], 'escapenoentities' ); } } - if ( self::usePatrol() ) { - $flags[] = self::flagLine( 'unpatrolled' ); - } + # Inconsistent naming, bleh + $map = array( + 'newpage' => 'newpage', + 'minor' => 'minoredit', + 'bot' => 'botedit', + 'unpatrolled' => 'unpatrolled', + 'minoredit' => 'minoredit', + 'botedit' => 'botedit', + ); + $flag = $map[$flag]; - return '
    ' . - wfMsgExt( 'recentchanges-label-legend', 'parseinline', - $wgLang->commaList( $flags ) ) . '
    '; + return "" . $messages[$flag][0] . ''; } /** * Returns text for the start of the tabular part of RC - * @return string + * @return String */ public function beginRecentChangesList() { $this->rc_cache = array(); @@ -179,9 +159,9 @@ class ChangesList { /** * Show formatted char difference - * @param int $old bytes - * @param int $new bytes - * @returns string + * @param $old Integer: bytes + * @param $new Integer: bytes + * @returns String */ public static function showCharacterDifference( $old, $new ) { global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode; @@ -215,7 +195,7 @@ class ChangesList { /** * Returns text for the end of RC - * @return string + * @return String */ public function endRecentChangesList() { if( $this->rclistOpen ) { @@ -225,7 +205,12 @@ class ChangesList { } } - protected function insertMove( &$s, $rc ) { + /** + * @param $s + * @param $rc RecentChange + * @return void + */ + public function insertMove( &$s, $rc ) { # Diff $s .= '(' . $this->message['diff'] . ') ('; # Hist @@ -257,12 +242,12 @@ class ChangesList { ); } - protected function insertDateHeader( &$s, $rc_timestamp ) { + public function insertDateHeader( &$s, $rc_timestamp ) { global $wgLang; # Make date header if necessary $date = $wgLang->date( $rc_timestamp, true, true ); if( $date != $this->lastdate ) { - if( '' != $this->lastdate ) { + if( $this->lastdate != '' ) { $s .= "\n"; } $s .= Xml::element( 'h4', null, $date ) . "\n