Index: trunk/phase3/includes/Message.php |
— | — | @@ -15,8 +15,8 @@ |
16 | 16 | * Messages can have parameters: |
17 | 17 | * Message::key( 'welcome-to' )->params( $wgSitename )->text(); |
18 | 18 | * {{GRAMMAR}} and friends work correctly |
19 | | - * Message::key( 'are-friends' )->params( $user, $friend ); |
20 | | - * Message::key( 'bad-message' )->rawParams( '<script>...</script>' )->escaped() |
| 19 | + * Message::key( 'are-friends', $user, $friend ); |
| 20 | + * Message::key( 'bad-message' )->rawParams( '<script>...</script>' )->escaped(); |
21 | 21 | * </pre> |
22 | 22 | * Sometimes the message text ends up in the database, so content language is needed. |
23 | 23 | * Message::key( 'file-log' )->params( $user, $filename )->inContentLanguage()->text() |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | * Message::key( 'mysterious-message' )->exists() |
27 | 27 | * </pre> |
28 | 28 | * If you want to use a different language: |
29 | | - * Message::key( 'email-header' )->language( $user->getOption( 'language' ) )->plain() |
| 29 | + * Message::key( 'email-header' )->inLanguage( $user->getOption( 'language' ) )->plain() |
30 | 30 | * Note that you cannot parse the text except in the content or interface |
31 | 31 | * languages |
32 | 32 | * </pre> |
— | — | @@ -111,12 +111,12 @@ |
112 | 112 | * Factory function that is just wrapper for the real constructor. It is |
113 | 113 | * intented to be used instead of the real constructor, because it allows |
114 | 114 | * chaining method calls, while new objects don't. |
115 | | - * //FIXME: key or get or something else? |
116 | 115 | * @param $key String: message key |
| 116 | + * @param Varargs: parameters as Strings |
117 | 117 | * @return Message: $this |
118 | 118 | */ |
119 | | - public static function key( $key ) { |
120 | | - return new self( $key ); |
| 119 | + public static function key( $key, /*...*/ ) { |
| 120 | + return new self( $key, array_shift( func_get_args() ); |
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
— | — | @@ -140,7 +140,7 @@ |
141 | 141 | public function rawParams( /*...*/ ) { |
142 | 142 | $params = func_get_args(); |
143 | 143 | foreach( $params as $param ) { |
144 | | - $this->parameters[] = array( 'raw' => $param ); |
| 144 | + $this->parameters[] = self::rawParam( $param ); |
145 | 145 | } |
146 | 146 | return $this; |
147 | 147 | } |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | * @param $lang Mixed: language code or Language object. |
154 | 154 | * @return Message: $this |
155 | 155 | */ |
156 | | - public function language( $lang ) { |
| 156 | + public function inLanguage( $lang ) { |
157 | 157 | if( $lang instanceof Language ){ |
158 | 158 | $this->language = $lang; |
159 | 159 | } elseif ( is_string( $lang ) ) { |
— | — | @@ -280,6 +280,10 @@ |
281 | 281 | return $this->fetchMessage() === false; |
282 | 282 | } |
283 | 283 | |
| 284 | + public static function rawParam( $value ) { |
| 285 | + return array( 'raw' => $value ); |
| 286 | + } |
| 287 | + |
284 | 288 | /** |
285 | 289 | * Substitutes any paramaters into the message text. |
286 | 290 | * @param $message String, the message text |