Index: trunk/extensions/ContactPage/SpecialContact.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | SpecialPage::SpecialPage( 'Contact', '', true ); |
32 | 32 | |
33 | 33 | #inject messages |
34 | | - cpMsg(false); |
| 34 | + loadContactPageI18n(); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
— | — | @@ -101,11 +101,11 @@ |
102 | 102 | |
103 | 103 | #TODO: show captcha |
104 | 104 | |
105 | | - $wgOut->setPagetitle( cpMsg( "title" ) ); |
106 | | - $wgOut->addWikiText( cpMsg( "pagetext" ) ); |
| 105 | + $wgOut->setPagetitle( wfMsg( "contactpage-title" ) ); |
| 106 | + $wgOut->addWikiText( wfMsg( "contactpage-pagetext" ) ); |
107 | 107 | |
108 | 108 | if ( $this->subject === "" ) { |
109 | | - $this->subject = cpMsg( "defsubject" ); |
| 109 | + $this->subject = wfMsg( "contactpage-defsubject" ); |
110 | 110 | } |
111 | 111 | |
112 | 112 | #$emf = wfMsg( "emailfrom" ); |
— | — | @@ -116,8 +116,8 @@ |
117 | 117 | $emm = wfMsg( "emailmessage" ); |
118 | 118 | $ems = wfMsg( "emailsend" ); |
119 | 119 | $emc = wfMsg( "emailccme" ); |
120 | | - $emfn = cpMsg( "fromname" ); |
121 | | - $emfa = cpMsg( "fromaddress" ); |
| 120 | + $emfn = wfMsg( "contactpage-fromname" ); |
| 121 | + $emfa = wfMsg( "contactpage-fromaddress" ); |
122 | 122 | $encSubject = htmlspecialchars( $this->subject ); |
123 | 123 | $encFromName = htmlspecialchars( $this->fromname ); |
124 | 124 | $encFromAddress = htmlspecialchars( $this->fromaddress ); |
— | — | @@ -148,7 +148,7 @@ |
149 | 149 | <tr> |
150 | 150 | <td></td> |
151 | 151 | <td align='left'> |
152 | | -<small>".cpMsg( "formfootnotes" )."</small> |
| 152 | +<small>".wfMsg( "contactpage-formfootnotes" )."</small> |
153 | 153 | </td> |
154 | 154 | </tr> |
155 | 155 | </table> |
— | — | @@ -179,8 +179,15 @@ |
180 | 180 | if( wfRunHooks( 'ContactForm', array( &$to, &$replyto, &$subject, &$this->text ) ) ) { |
181 | 181 | |
182 | 182 | wfDebug( "$fname: sending mail from ".$from->toString()." to ".$to->toString()." replyto ".($replyto==null?'-/-':$replyto->toString())."\n" ); |
183 | | - $mailResult = userMailer( $to, $from, $subject, $this->text, $replyto ? $replyto->toString() : NULL ); #TODO: staring with MW 1.10, $replyto should be passed as an object |
184 | 183 | |
| 184 | + #HACK: in MW 1.9, replyto must be a string, in MW 1.0, it must be an object! |
| 185 | + $ver = preg_replace( '![^\d._+]!', '', $GLOBALS['wgVersion'] ); |
| 186 | + $replyaddr = $replyto == null |
| 187 | + ? NULL : version_compare( $ver, '1.10', '<' ) |
| 188 | + ? $replyto->toString() : $replyto; |
| 189 | + |
| 190 | + $mailResult = userMailer( $to, $from, $subject, $this->text, $replyaddr ); |
| 191 | + |
185 | 192 | if( WikiError::isError( $mailResult ) ) { |
186 | 193 | $wgOut->addHTML( wfMsg( "usermailererror" ) . $mailResult); |
187 | 194 | } else { |
Index: trunk/extensions/ContactPage/ContactPage.php |
— | — | @@ -30,11 +30,15 @@ |
31 | 31 | $wgContactSenderName = 'Contact Form on ' . $wgSitename; |
32 | 32 | |
33 | 33 | /** |
34 | | -* load the CategoryTree internationalization file |
| 34 | +* load the ContactPage internationalization file |
35 | 35 | */ |
36 | | -function cpLoadMessages() { |
37 | | - global $wgLang; |
38 | | - |
| 36 | +function loadContactPageI18n() { |
| 37 | + global $wgLang, $wgMessageCache; |
| 38 | + |
| 39 | + static $initialized = false; |
| 40 | + |
| 41 | + if ( $initialized ) return; |
| 42 | + |
39 | 43 | $messages= array(); |
40 | 44 | |
41 | 45 | $f= dirname( __FILE__ ) . '/ContactPage.i18n.php'; |
— | — | @@ -43,29 +47,8 @@ |
44 | 48 | $f= dirname( __FILE__ ) . '/ContactPage.i18n.' . $wgLang->getCode() . '.php'; |
45 | 49 | if ( file_exists( $f ) ) include( $f ); |
46 | 50 | |
47 | | - return $messages; |
| 51 | + $initialized = true; |
| 52 | + $wgMessageCache->addMessages( $messages ); |
48 | 53 | } |
49 | 54 | |
50 | | -/** |
51 | | -* Get a ContactPage message, "contactpage-" prefix added automatically |
52 | | -*/ |
53 | | -function cpMsg( $msg /*, ...*/ ) { |
54 | | - static $initialized = false; |
55 | | - global $wgMessageCache; |
56 | | - if ( !$initialized ) { |
57 | | - $wgMessageCache->addMessages( cpLoadMessages() ); |
58 | | - $initialized = true; |
59 | | - } |
60 | | - if ( $msg === false ) { |
61 | | - return null; |
62 | | - } |
63 | | - $args = func_get_args(); |
64 | | - $msg = array_shift( $args ); |
65 | | - if ( $msg == '' ) { |
66 | | - return wfMsgReal( $msg, $args ); |
67 | | - } else { |
68 | | - return wfMsgReal( "contactpage-$msg", $args ); |
69 | | - } |
70 | | -} |
71 | | - |
72 | 55 | ?> |
\ No newline at end of file |