+
+ /**
+ * Convert a comma-delimited list of block log flags
+ * into a more readable (and translated) form
+ *
+ * @param $flags Flags to format
+ * @param $forContent Whether to localize the message depending of the user
+ * language
+ * @return string
+ */
+ public static function formatBlockFlags( $flags, $forContent = false ) {
+ $flags = explode( ',', trim( $flags ) );
+ if( count( $flags ) > 0 ) {
+ for( $i = 0; $i < count( $flags ); $i++ )
+ $flags[$i] = self::formatBlockFlag( $flags[$i], $forContent );
+ return '(' . implode( ', ', $flags ) . ')';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Translate a block log flag if possible
+ *
+ * @param $flag Flag to translate
+ * @param $forContent Whether to localize the message depending of the user
+ * language
+ * @return string
+ */
+ public static function formatBlockFlag( $flag, $forContent = false ) {
+ static $messages = array();
+ if( !isset( $messages[$flag] ) ) {
+ $k = 'block-log-flags-' . $flag;
+ if( $forContent )
+ $msg = wfMsgForContent( $k );
+ else
+ $msg = wfMsg( $k );
+ $messages[$flag] = htmlspecialchars( wfEmptyMsg( $k, $msg ) ? $flag : $msg );
+ }
+ return $messages[$flag];
+ }