Add ą, č, ę, ė, į, š, ų, ū, ž to linkTrail for lt language
[lhc/web/wiklou.git] / includes / Linker.php
index 0b80c08..0b2d3a7 100644 (file)
@@ -138,22 +138,30 @@ class Linker {
         * Return the CSS colour of a known link
         *
         * @since 1.16.3
-        * @param Title $t
+        * @param LinkTarget $t
         * @param int $threshold User defined threshold
         * @return string CSS class
         */
-       public static function getLinkColour( $t, $threshold ) {
-               $colour = '';
-               if ( $t->isRedirect() ) {
+       public static function getLinkColour( LinkTarget $t, $threshold ) {
+               $linkCache = MediaWikiServices::getInstance()->getLinkCache();
+               // Make sure the target is in the cache
+               $id = $linkCache->addLinkObj( $t );
+               if ( $id == 0 ) {
+                       // Doesn't exist
+                       return '';
+               }
+
+               if ( $linkCache->getGoodLinkFieldObj( $t, 'redirect' ) ) {
                        # Page is a redirect
-                       $colour = 'mw-redirect';
-               } elseif ( $threshold > 0 && $t->isContentPage() &&
-                       $t->exists() && $t->getLength() < $threshold
+                       return 'mw-redirect';
+               } elseif ( $threshold > 0 && MWNamespace::isContent( $t->getNamespace() )
+                       && $linkCache->getGoodLinkFieldObj( $t, 'length' ) < $threshold
                ) {
                        # Page is a stub
-                       $colour = 'stub';
+                       return 'stub';
                }
-               return $colour;
+
+               return '';
        }
 
        /**
@@ -235,6 +243,8 @@ class Linker {
                        return $linkRenderer->makeKnownLink( $target, $text, $customAttribs, $query );
                } elseif ( in_array( 'broken', $options, true ) ) {
                        return $linkRenderer->makeBrokenLink( $target, $text, $customAttribs, $query );
+               } elseif ( in_array( 'noclasses', $options, true ) ) {
+                       return $linkRenderer->makePreloadedLink( $target, $text, '', $customAttribs, $query );
                } else {
                        return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
                }
@@ -1746,8 +1756,6 @@ class Linker {
         *
         * If the option noBrackets is set the rollback link wont be enclosed in "[]".
         *
-        * See the "mediawiki.page.rollback" module for the client-side handling of this link.
-        *
         * @since 1.16.3. $context added in 1.20. $options added in 1.21
         *
         * @param Revision $rev
@@ -1776,8 +1784,6 @@ class Linker {
                        $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
                }
 
-               $context->getOutput()->addModules( 'mediawiki.page.rollback' );
-
                return '<span class="mw-rollback-link">' . $inner . '</span>';
        }
 
@@ -1872,6 +1878,7 @@ class Linker {
                $query = [
                        'action' => 'rollback',
                        'from' => $rev->getUserText(),
+                       'token' => $context->getUser()->getEditToken( 'rollback' ),
                ];
                $attrs = [
                        'data-mw' => 'interface',