From: umherirrender Date: Thu, 20 Jun 2013 19:34:07 +0000 (+0200) Subject: Allow modification of flags on Recent Changes X-Git-Tag: 1.31.0-rc.0~19376 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=bb0ab45ee876adc3046e70d21d693963cc329619;p=lhc%2Fweb%2Fwiklou.git Allow modification of flags on Recent Changes Moved the message map in ChangesList::flag to a new setting named $wgRecentChangesFlags and used it keys to iterate over the flags Also allow setting the class to deal with minor vs. minoredit Also make ChangesList::recentChangesFlags public to be used from extensions, when they will build its own line Changed one list of placeholders to use recentChangesFlags to have the correct number of spaces there Change-Id: If69de05c4edec4e84c3e059090b9cb89845e3269 --- diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 33c6351240..71f44d461d 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -111,6 +111,8 @@ production. * Add new hook AbortTalkPageEmailNotification, this will be used to determine whether to send the regular talk page email notification * (bug 46513) Vector: Add the collapsibleTabs script from the Vector extension. +* Added $wgRecentChangesFlags for defining new flags for RecentChanges and + watchlists. === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 02c02e0d28..d54e7f0459 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -136,9 +136,10 @@ class ChangesList extends ContextSource { * @param string $nothing to use for empty space * @return String */ - protected function recentChangesFlags( $flags, $nothing = ' ' ) { + public function recentChangesFlags( $flags, $nothing = ' ' ) { + global $wgRecentChangesFlags; $f = ''; - foreach ( array( 'newpage', 'minor', 'bot', 'unpatrolled' ) as $flag ) { + foreach ( array_keys( $wgRecentChangesFlags ) as $flag ) { $f .= isset( $flags[$flag] ) && $flags[$flag] ? self::flag( $flag ) : $nothing; @@ -152,36 +153,35 @@ class ChangesList extends ContextSource { * unpatrolled edit. By default in English it will contain "N", "m", "b", * "!" respectively, plus it will have an appropriate title and class. * - * @param string $flag 'newpage', 'unpatrolled', 'minor', or 'bot' + * @param string $flag One key of $wgRecentChangesFlags * @return String: Raw HTML */ public static function flag( $flag ) { - static $messages = null; - if ( is_null( $messages ) ) { - $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] = wfMessage( $value[0] )->escaped(); - $value[1] = wfMessage( $value[1] )->escaped(); + static $flagInfos = null; + if ( is_null( $flagInfos ) ) { + global $wgRecentChangesFlags; + $flagInfos = array(); + foreach ( $wgRecentChangesFlags as $key => $value ) { + $flagInfos[$key]['letter'] = wfMessage( $value['letter'] )->escaped(); + $flagInfos[$key]['title'] = wfMessage( $value['title'] )->escaped(); + // Allow customized class name, fall back to flag name + $flagInfos[$key]['class'] = Sanitizer::escapeClass( + isset( $value['class'] ) ? $value['class'] : $key ); } } - # Inconsistent naming, bleh + // Inconsistent naming, bleh, kepted for b/c $map = array( - 'newpage' => 'newpage', - 'minor' => 'minoredit', - 'bot' => 'botedit', - 'unpatrolled' => 'unpatrolled', - 'minoredit' => 'minoredit', - 'botedit' => 'botedit', + 'minoredit' => 'minor', + 'botedit' => 'bot', ); - $flag = $map[$flag]; + if ( isset( $map[$flag] ) ) { + $flag = $map[$flag]; + } - return "" . $messages[$flag][0] . ''; + return "" . + $flagInfos[$flag]['letter'] . + ''; } /** @@ -1198,7 +1198,7 @@ class EnhancedChangesList extends ChangesList { $r .= ''; # Flag and Timestamp if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) { - $r .= '    '; // 4 flags -> 4 spaces + $r .= $this->recentChangesFlags( array() ); // no flags, but need the placeholders } else { $r .= $this->recentChangesFlags( array( 'newpage' => $type == RC_NEW, diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ecb2664920..65f2477685 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -5218,6 +5218,26 @@ $wgUseTagFilter = true; */ $wgUnwatchedPageThreshold = false; +/** + * Recent changes flag, shown in Recentchanges and watchlist + * + * Adding a new one: + * $wgRecentChangesFlags['flag'] => array( 'letter-msg', 'tooltip-msg' ); + * 'class' allows to set a css class different than the flag name + * + * @since 1.22 + */ +$wgRecentChangesFlags = array( + 'newpage' => array( 'letter' => 'newpageletter', + 'title' => 'recentchanges-label-newpage' ), + 'minor' => array( 'letter' => 'minoreditletter', + 'title' => 'recentchanges-label-minor', 'class' => 'minoredit' ), + 'bot' => array( 'letter' => 'boteditletter', + 'title' => 'recentchanges-label-bot', 'class' => 'botedit' ), + 'unpatrolled' => array( 'letter' => 'unpatrolledletter', + 'title' => 'recentchanges-label-unpatrolled' ), +); + /** @} */ # end RC/watchlist } /************************************************************************//**