Add extension DeletedContributions to core
[lhc/web/wiklou.git] / languages / Language.php
index 5d228e6..fa485d1 100644 (file)
@@ -39,7 +39,7 @@ class FakeConverter {
        function parserConvert($t, $p) {return $t;}
        function getVariants() { return array( $this->mLang->getCode() ); }
        function getPreferredVariant() {return $this->mLang->getCode(); }
-       function findVariantLink(&$l, &$n) {}
+       function findVariantLink(&$l, &$n, $forTemplate = false) {}
        function getExtraHashOptions() {return '';}
        function getParsedTitle() {return '';}
        function markNoConversion($text, $noParse=false) {return $text;}
@@ -176,6 +176,15 @@ class Language {
                }
        }
 
+       /**
+        * Reduce memory usage
+        */
+       function __destruct() {
+               foreach ( $this as $name => $value ) {
+                       unset( $this->$name );
+               }
+       }
+
        /**
         * Hook which will be called if this is the content language.
         * Descendants can use this to register hook functions or modify globals
@@ -1689,7 +1698,9 @@ class Language {
                        } else {
                                # Fall back to English if local list is incomplete
                                $magicWords =& Language::getMagicWords();
-                               if ( !isset($magicWords[$mw->mId]) ) { throw new MWException("Magic word not found" ); }
+                               if ( !isset($magicWords[$mw->mId]) ) {
+                                       throw new MWException("Magic word '{$mw->mId}' not found" ); 
+                               }
                                $rawEntry = $magicWords[$mw->mId];
                        }
                }
@@ -1741,14 +1752,14 @@ class Language {
 
                                // Fail fast
                                if ( !file_exists($file) )
-                                       throw new MWException( 'Aliases file does not exist' );
+                                       throw new MWException( "Aliases file does not exist: $file" );
 
                                $aliases = array();
                                require($file);
 
                                // Check the availability of aliases
                                if ( !isset($aliases['en']) )
-                                       throw new MWException( 'Malformed aliases file' );
+                                       throw new MWException( "Malformed aliases file: $file" );
 
                                // Merge all aliases in fallback chain
                                $code = $this->getCode();
@@ -1813,7 +1824,7 @@ class Language {
          * LanguageIs.php for the , => . and . => , implementation.
          *
          * @todo check if it's viable to use localeconv() for the decimal
-         *       seperator thing.
+         *       separator thing.
          * @param $number Mixed: the string to be formatted, should be an integer
          *        or a floating point number.
          * @param $nocommafy Bool: set to true for special numbers like dates
@@ -1887,6 +1898,17 @@ class Language {
                }
                return $s;
        }
+       
+       /**
+        * Take a list of strings and build a locale-friendly comma-separated
+        * list, using the local comma-separator message.
+        * @fixme Fix this so it can work for $wgContLang too
+        */
+       function commaList( $list ) {
+               return implode(
+                       $list,
+                       wfMsgExt( 'comma-separator', 'escapenoentities' ) );
+       }
 
        /**
         * Truncate a string to a specified length in bytes, appending an optional
@@ -1970,7 +1992,7 @@ class Language {
                if ( !count($forms) ) { return ''; }
                $forms = $this->preConvertPlural( $forms, 2 );
 
-               return ( abs($count) == 1 ) ? $forms[0] : $forms[1];
+               return ( $count == 1 ) ? $forms[0] : $forms[1];
        }
 
        /**
@@ -2096,8 +2118,8 @@ class Language {
         * @param $nt Mixed: the title object of the link
         * @return null the input parameters may be modified upon return
         */
-       function findVariantLink( &$link, &$nt ) {
-               $this->mConverter->findVariantLink($link, $nt);
+       function findVariantLink( &$link, &$nt, $forTemplate = false ) {
+               $this->mConverter->findVariantLink($link, $nt, $forTemplate );
        }
 
        /**