Index: trunk/extensions/NewUserMessage/NewUserMessage.i18n.php |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | $messages['en'] = array( |
17 | 17 | 'newusermessage-desc' => "Adds a message to newly created user's talk pages", |
18 | 18 | 'newuseredit-summary' => 'Adding [[{{int:newusermessage-template}}|welcome message]] to new user\'s talk page', |
| 19 | + 'newusermessage-template' => 'Template:Welcome', # The title of the message template |
19 | 20 | 'newusermessage-template-subject' => 'Template:Welcome-subject', # Always substituted. Used if LiquidThreads is enabled in the User_talk namespace. Do not translate or duplicate this message to other languages |
20 | 21 | 'newusermessage-template-body' => 'Template:Welcome-body', # Used if LiquidThreads is enabled in the User_talk namespace. Do not translate or duplicate this message to other languages |
21 | 22 | 'newusermessage-editor' => 'New user message', # The username used for the edit |
Index: trunk/extensions/NewUserMessage/NewUserMessage.class.php |
— | — | @@ -84,7 +84,12 @@ |
85 | 85 | * @returns String |
86 | 86 | */ |
87 | 87 | static function fetchText() { |
88 | | - return self::fetchTemplateIfExists( wfMsg( 'newusermessage-template-body' ) ); |
| 88 | + $text = self::fetchTemplateIfExists( wfMsg( 'newusermessage-template-body' ) ); |
| 89 | + // Fall back if necessary to the old template |
| 90 | + if ( !$text ) { |
| 91 | + $text = self::fetchTemplateIfExists( wfMsg( 'newusermessage-template' ) ); |
| 92 | + } |
| 93 | + return $text; |
89 | 94 | } |
90 | 95 | |
91 | 96 | /** |
— | — | @@ -149,8 +154,12 @@ |
150 | 155 | $editor = self::fetchEditor(); |
151 | 156 | $flags = self::fetchFlags(); |
152 | 157 | |
153 | | - $subject = self::substString( $subject, $user, $editor, $talk, "preparse" ); |
154 | | - $text = self::substString( $text, $user, $editor, $talk ); |
| 158 | + if ( $subject ) { |
| 159 | + $subject = self::substString( $subject, $user, $editor, $talk, "preparse" ); |
| 160 | + } |
| 161 | + if ( $text ) { |
| 162 | + $text = self::substString( $text, $user, $editor, $talk ); |
| 163 | + } |
155 | 164 | |
156 | 165 | return self::leaveUserMessage( $user, $article, $subject, $text, |
157 | 166 | $signature, $editSummary, $editor, $flags ); |
— | — | @@ -233,9 +242,14 @@ |
234 | 243 | * @param $signature String the signature, if provided. |
235 | 244 | */ |
236 | 245 | static protected function formatUserMessage( $subject, $text, $signature ) { |
237 | | - $signature = empty($signature) ? "~~~~~" : "{$signature} ~~~~~"; |
238 | | - $text = "\n== $subject ==\n\n$text\n\n-- $signature"; |
| 246 | + $contents = "\n"; |
| 247 | + $signature = empty( $signature ) ? "~~~~~" : "{$signature} ~~~~~"; |
| 248 | + |
| 249 | + if ( $subject ) { |
| 250 | + $contents .= "== $subject ==\n"; |
| 251 | + } |
| 252 | + $contents .= "\n$text\n\n-- $signature\n"; |
239 | 253 | |
240 | | - return $text; |
| 254 | + return $contents; |
241 | 255 | } |
242 | 256 | } |