Merge "Fix undo edit summary when the user who made the old revision is hidden"
[lhc/web/wiklou.git] / languages / LanguageConverter.php
index d9227d7..a02fc8a 100644 (file)
@@ -364,11 +364,11 @@ class LanguageConverter {
                // this one is needed when the text is inside an HTML markup
                $htmlfix = '|<[^>]+$|^[^<>]*>';
 
-               // disable convert to variants between <code></code> tags
+               // disable convert to variants between <code> tags
                $codefix = '<code>.+?<\/code>|';
-               // disable convertsion of <script type="text/javascript"> ... </script>
+               // disable conversion of <script> tags
                $scriptfix = '<script.*?>.*?<\/script>|';
-               // disable conversion of <pre xxxx> ... </pre>
+               // disable conversion of <pre> tags
                $prefix = '<pre.*?>.*?<\/pre>|';
 
                $reg = '/' . $codefix . $scriptfix . $prefix .
@@ -952,7 +952,7 @@ class LanguageConverter {
                                                $txt = $revision->getContent( Revision::RAW )->getNativeData();
                                        }
 
-                                       //@todo: in the future, use a specialized content model, perhaps based on json!
+                                       // @todo in the future, use a specialized content model, perhaps based on json!
                                }
                        }
                }
@@ -1357,6 +1357,37 @@ class ConverterRule {
                }
        }
 
+       /**
+        * Similar to getRuleConvertedStr(), but this prefers to use original
+        * page title if $variant === $this->mConverter->mMainLanguageCode
+        * and may return false in this case (so this title conversion rule
+        * will be ignored and the original title is shown).
+        *
+        * @since 1.22
+        * @param $variant The variant code to display page title in
+        * @return String|false The converted title or false if just page name
+        */
+       function getRuleConvertedTitle( $variant ) {
+               if ( $variant === $this->mConverter->mMainLanguageCode ) {
+                       // If a string targeting exactly this variant is set,
+                       // use it. Otherwise, just return false, so the real
+                       // page name can be shown (and because variant === main,
+                       // there'll be no further automatic conversion).
+                       $disp = $this->getTextInBidtable( $variant );
+                       if ( $disp ) {
+                               return $disp;
+                       }
+                       if ( array_key_exists( $variant, $this->mUnidtable ) ) {
+                               $disp = array_values( $this->mUnidtable[$variant] );
+                               $disp = $disp[0];
+                       }
+                       // Assigned above or still false.
+                       return $disp;
+               } else {
+                       return $this->getRuleConvertedStr( $variant );
+               }
+       }
+
        /**
         * Generate conversion table for all text.
         * @private
@@ -1509,7 +1540,7 @@ class ConverterRule {
                                        $this->mRuleDisplay = $this->getRuleConvertedStr( $variant );
                                        break;
                                case 'T':
-                                       $this->mRuleTitle = $this->getRuleConvertedStr( $variant );
+                                       $this->mRuleTitle = $this->getRuleConvertedTitle( $variant );
                                        $this->mRuleDisplay = '';
                                        break;
                                default: