+ /**
+ * Provide the <abbr> 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 "<abbr class=\"$key\" title=\""
+ . $messages["recentchanges-label-$key"] . "\">"
+ . $messages["${key2}letter"]
+ . '</abbr>';
+ }
+
+ /**
+ * 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 '<div class="mw-rc-label-legend">' .
+ wfMsgExt( 'recentchanges-label-legend', 'parseinline',
+ $wgLang->commaList( $flags ) ) . '</div>';
+ }
+