Merge "Localisation updates from https://translatewiki.net."
[lhc/web/wiklou.git] / includes / skins / BaseTemplate.php
index f0b336a..156df67 100644 (file)
@@ -18,6 +18,9 @@
  * @file
  */
 
+use Wikimedia\WrappedString;
+use Wikimedia\WrappedStringList;
+
 /**
  * New base template for a skin's template extended from QuickTemplate
  * this class features helper methods that provide common ways of interacting
@@ -98,14 +101,7 @@ abstract class BaseTemplate extends QuickTemplate {
                }
                if ( isset( $this->data['nav_urls']['permalink'] ) && $this->data['nav_urls']['permalink'] ) {
                        $toolbox['permalink'] = $this->data['nav_urls']['permalink'];
-                       if ( $toolbox['permalink']['href'] === '' ) {
-                               unset( $toolbox['permalink']['href'] );
-                               $toolbox['ispermalink']['tooltiponly'] = true;
-                               $toolbox['ispermalink']['id'] = 't-ispermalink';
-                               $toolbox['ispermalink']['msg'] = 'permalink';
-                       } else {
-                               $toolbox['permalink']['id'] = 't-permalink';
-                       }
+                       $toolbox['permalink']['id'] = 't-permalink';
                }
                if ( isset( $this->data['nav_urls']['info'] ) && $this->data['nav_urls']['info'] ) {
                        $toolbox['info'] = $this->data['nav_urls']['info'];
@@ -143,7 +139,7 @@ abstract class BaseTemplate extends QuickTemplate {
                        if ( isset( $plink['active'] ) ) {
                                $ptool['active'] = $plink['active'];
                        }
-                       foreach ( [ 'href', 'class', 'text', 'dir', 'data' ] as $k ) {
+                       foreach ( [ 'href', 'class', 'text', 'dir', 'data', 'exists' ] as $k ) {
                                if ( isset( $plink[$k] ) ) {
                                        $ptool['links'][0][$k] = $plink[$k];
                                }
@@ -370,7 +366,7 @@ abstract class BaseTemplate extends QuickTemplate {
                if ( isset( $item['text'] ) ) {
                        $text = $item['text'];
                } else {
-                       $text = $this->translator->translate( isset( $item['msg'] ) ? $item['msg'] : $key );
+                       $text = wfMessage( isset( $item['msg'] ) ? $item['msg'] : $key )->text();
                }
 
                $html = htmlspecialchars( $text );
@@ -391,7 +387,7 @@ abstract class BaseTemplate extends QuickTemplate {
                if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) {
                        $attrs = $item;
                        foreach ( [ 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary',
-                               'tooltip-params' ] as $k ) {
+                               'tooltip-params', 'exists' ] as $k ) {
                                unset( $attrs[$k] );
                        }
 
@@ -412,13 +408,19 @@ abstract class BaseTemplate extends QuickTemplate {
                        }
 
                        if ( isset( $item['single-id'] ) ) {
+                               $tooltipOption = isset( $item['exists'] ) && $item['exists'] === false ? 'nonexisting' : null;
+
                                if ( isset( $item['tooltiponly'] ) && $item['tooltiponly'] ) {
-                                       $title = Linker::titleAttrib( $item['single-id'], null, $tooltipParams );
+                                       $title = Linker::titleAttrib( $item['single-id'], $tooltipOption, $tooltipParams );
                                        if ( $title !== false ) {
                                                $attrs['title'] = $title;
                                        }
                                } else {
-                                       $tip = Linker::tooltipAndAccesskeyAttribs( $item['single-id'], $tooltipParams );
+                                       $tip = Linker::tooltipAndAccesskeyAttribs(
+                                               $item['single-id'],
+                                               $tooltipParams,
+                                               $tooltipOption
+                                       );
                                        if ( isset( $tip['title'] ) && $tip['title'] !== false ) {
                                                $attrs['title'] = $tip['title'];
                                        }
@@ -535,8 +537,7 @@ abstract class BaseTemplate extends QuickTemplate {
                                $realAttrs = [
                                        'type' => 'submit',
                                        'name' => $mode,
-                                       'value' => $this->translator->translate(
-                                               $mode == 'go' ? 'searcharticle' : 'searchbutton' ),
+                                       'value' => wfMessage( $mode == 'go' ? 'searcharticle' : 'searchbutton' )->text(),
                                ];
                                $realAttrs = array_merge(
                                        $realAttrs,
@@ -562,7 +563,7 @@ abstract class BaseTemplate extends QuickTemplate {
                                        'src' => $attrs['src'],
                                        'alt' => isset( $attrs['alt'] )
                                                ? $attrs['alt']
-                                               : $this->translator->translate( 'searchbutton' ),
+                                               : wfMessage( 'searchbutton' )->text(),
                                        'width' => isset( $attrs['width'] ) ? $attrs['width'] : null,
                                        'height' => isset( $attrs['height'] ) ? $attrs['height'] : null,
                                ];
@@ -756,14 +757,14 @@ abstract class BaseTemplate extends QuickTemplate {
         * debug stuff. This should be called right before outputting the closing
         * body and html tags.
         *
-        * @return string
+        * @return string|WrappedStringList HTML
         * @since 1.29
         */
-       function getTrail() {
-               $html = MWDebug::getDebugHTML( $this->getSkin()->getContext() );
-               $html .= $this->get( 'bottomscripts' );
-               $html .= $this->get( 'reporttime' );
-
-               return $html;
+       public function getTrail() {
+               return WrappedString::join( "\n", [
+                       MWDebug::getDebugHTML( $this->getSkin()->getContext() ),
+                       $this->get( 'bottomscripts' ),
+                       $this->get( 'reporttime' )
+               ] );
        }
 }