Add support for Number grouping(commafy) based on CLDR number grouping patterns like...
[lhc/web/wiklou.git] / includes / Message.php
index 3ddbdcb..803f091 100644 (file)
@@ -11,7 +11,7 @@
  *    $button = Xml::button( wfMessage( 'submit' )->text() );
  * </pre>
  * Messages can have parameters:
- *    wfMessage( 'welcome-to' )->params( $wgSitename )->text(); 
+ *    wfMessage( 'welcome-to' )->params( $wgSitename )->text();
  *        {{GRAMMAR}} and friends work correctly
  *    wfMessage( 'are-friends', $user, $friend );
  *    wfMessage( 'bad-message' )->rawParams( '<script>...</script>' )->escaped();
@@ -48,9 +48,8 @@
  * $escaped = wfMessage( 'key' )->rawParams( 'apple' )->escaped();
  * </pre>
  *
- * TODO:
+ * @todo
  * - test, can we have tests?
- * - sort out the details marked with fixme
  *
  * @since 1.17
  * @author Niklas Laxström
@@ -61,7 +60,7 @@ class Message {
         * means the current interface language, false content language.
         */
        protected $interface = true;
-       
+
        /**
         * In which language to get this message. Overrides the $interface
         * variable.
@@ -69,7 +68,7 @@ class Message {
         * @var Language
         */
        protected $language = null;
-       
+
        /**
         * The message key.
         */
@@ -101,6 +100,11 @@ class Message {
         */
        protected $title = null;
 
+       /**
+        * @var string
+        */
+       protected $message;
+
        /**
         * Constructor.
         * @param $key: message key, or array of message keys to try and use the first non-empty message for
@@ -182,7 +186,7 @@ class Message {
                }
                return $this;
        }
-       
+
        /**
         * Add parameters that are numeric and will be passed through
         * Language::formatNum before substitution
@@ -199,7 +203,7 @@ class Message {
                }
                return $this;
        }
-       
+
        /**
         * Request the message in any language that is supported.
         * As a side effect interface message status is unconditionally
@@ -217,7 +221,7 @@ class Message {
                } else {
                        $type = gettype( $lang );
                        throw new MWException( __METHOD__ . " must be "
-                               . "passed a String or Language object; $type given" 
+                               . "passed a String or Language object; $type given"
                        );
                }
                $this->interface = false;
@@ -225,10 +229,17 @@ class Message {
        }
 
        /**
-        * Request the message in the wiki's content language.
+        * Request the message in the wiki's content language,
+        * unless it is disabled for this message.
+        * @see $wgForceUIMsgAsContentMsg
         * @return Message: $this
         */
        public function inContentLanguage() {
+               global $wgForceUIMsgAsContentMsg;
+               if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
+                       return $this;
+               }
+
                global $wgContLang;
                $this->interface = false;
                $this->language = $wgContLang;
@@ -262,10 +273,10 @@ class Message {
         */
        public function toString() {
                $string = $this->getMessageText();
-               
+
                # Replace parameters before text parsing
                $string = $this->replaceParameters( $string, 'before' );
-               
+
                # Maybe transform using the full parser
                if( $this->format === 'parse' ) {
                        $string = $this->parseText( $string );
@@ -281,10 +292,10 @@ class Message {
                        $string = $this->transformText( $string );
                        $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
                }
-               
+
                # Raw parameter replacement
                $string = $this->replaceParameters( $string, 'after' );
-               
+
                return $string;
        }
 
@@ -297,7 +308,7 @@ class Message {
        public function __toString() {
                return $this->toString();
        }
-       
+
        /**
         * Fully parse the text from wikitext to HTML
         * @return String parsed HTML
@@ -355,7 +366,7 @@ class Message {
        /**
         * Check whether a message does not exist, or is an empty string
         * @return Bool: true if is is and false if not
-        * @todo Merge with isDisabled()?
+        * @todo FIXME: Merge with isDisabled()?
         */
        public function isBlank() {
                $message = $this->fetchMessage();