Merge "Only try to show character difference if it isn't empty"
[lhc/web/wiklou.git] / includes / changes / ChangesList.php
index 65eb320..5b8559e 100644 (file)
@@ -41,6 +41,9 @@ class ChangesList extends ContextSource {
        protected $rclistOpen;
        protected $rcMoveIndex;
 
+       /** @var callable */
+       protected $changeLinePrefixer;
+
        /** @var BagOStuff */
        protected $watchMsgCache;
 
@@ -169,17 +172,19 @@ class ChangesList extends ContextSource {
         * @return array of classes
         */
        protected function getHTMLClasses( $rc, $watched ) {
-               $classes = [];
+               $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
                $logType = $rc->mAttribs['rc_log_type'];
 
                if ( $logType ) {
+                       $classes[] = self::CSS_CLASS_PREFIX . 'log';
                        $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
                } else {
+                       $classes[] = self::CSS_CLASS_PREFIX . 'edit';
                        $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
                                $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
-                       $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
-                               $rc->mAttribs['rc_namespace'] );
                }
+               $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
+                       $rc->mAttribs['rc_namespace'] );
 
                // Indicate watched status on the line to allow for more
                // comprehensive styling.
@@ -571,7 +576,9 @@ class ChangesList extends ContextSource {
                        return '';
                }
                $cache = $this->watchMsgCache;
-               return $cache->getWithSetCallback( $count, $cache::TTL_INDEFINITE,
+               return $cache->getWithSetCallback(
+                       $cache->makeKey( 'watching-users-msg', $count ),
+                       $cache::TTL_INDEFINITE,
                        function () use ( $count ) {
                                return $this->msg( 'number_of_watching_users_RCview' )
                                        ->numParams( $count )->escaped();
@@ -766,4 +773,15 @@ class ChangesList extends ContextSource {
 
                return $attrs;
        }
+
+       /**
+        * Sets the callable that generates a change line prefix added to the beginning of each line.
+        *
+        * @param callable $prefixer Callable to run that generates the change line prefix.
+        *     Takes three parameters: a RecentChange object, a ChangesList object,
+        *     and whether the current entry is a grouped entry.
+        */
+       public function setChangeLinePrefixer( callable $prefixer ) {
+               $this->changeLinePrefixer = $prefixer;
+       }
 }