Index: trunk/extensions/ContactPage/SpecialContact.php |
— | — | @@ -3,7 +3,8 @@ |
4 | 4 | * Speclial:Contact, a contact form for visitors. |
5 | 5 | * Based on SpecialEmailUser.php |
6 | 6 | * |
7 | | - * @addtogroup SpecialPage |
| 7 | + * @file |
| 8 | + * @ingroup SpecialPage |
8 | 9 | * @author Daniel Kinzler, brightbyte.de |
9 | 10 | * @copyright © 2007 Daniel Kinzler |
10 | 11 | * @license GNU General Public Licence 2.0 or later |
— | — | @@ -18,30 +19,30 @@ |
19 | 20 | require_once("$IP/includes/UserMailer.php"); |
20 | 21 | |
21 | 22 | /** |
22 | | - * |
| 23 | + * Provides the contact form |
| 24 | + * @ingroup SpecialPage |
23 | 25 | */ |
24 | 26 | class SpecialContact extends SpecialPage { |
25 | 27 | |
26 | 28 | /** |
27 | 29 | * Constructor |
28 | 30 | */ |
29 | | - function __construct() { |
30 | | - global $wgOut; |
31 | | - SpecialPage::SpecialPage( 'Contact', '', true ); |
| 31 | + public function __construct() { |
| 32 | + parent::__construct( 'Contact' ); |
32 | 33 | } |
33 | 34 | |
34 | 35 | /** |
35 | 36 | * Main execution function |
36 | | - * @param $par Parameters passed to the page |
| 37 | + * |
| 38 | + * @param $par Mixed: Parameters passed to the page |
37 | 39 | */ |
38 | | - function execute( $par ) { |
| 40 | + public function execute( $par ) { |
39 | 41 | global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, $wgContactUser; |
40 | 42 | |
41 | 43 | wfLoadExtensionMessages( 'ContactPage' ); |
42 | | - $fname = "SpecialContact::execute"; |
43 | 44 | |
44 | 45 | if( !$wgEnableEmail || !$wgContactUser ) { |
45 | | - $wgOut->showErrorPage( "nosuchspecialpage", "nospecialpagetext" ); |
| 46 | + $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' ); |
46 | 47 | return; |
47 | 48 | } |
48 | 49 | |
— | — | @@ -50,16 +51,16 @@ |
51 | 52 | $nu = User::newFromName( $wgContactUser ); |
52 | 53 | if( is_null( $nu ) || !$nu->canReceiveEmail() ) { |
53 | 54 | wfDebug( "Target is invalid user or can't receive.\n" ); |
54 | | - $wgOut->showErrorPage( "noemailtitle", "noemailtext" ); |
| 55 | + $wgOut->showErrorPage( 'noemailtitle', 'noemailtext' ); |
55 | 56 | return; |
56 | 57 | } |
57 | 58 | |
58 | 59 | $f = new EmailContactForm( $nu ); |
59 | 60 | |
60 | | - if ( "success" == $action ) { |
61 | | - wfDebug( "$fname: success.\n" ); |
62 | | - $f->showSuccess( ); |
63 | | - } else if ( "submit" == $action && $wgRequest->wasPosted() && $f->hasAllInfo() ) { |
| 61 | + if ( 'success' == $action ) { |
| 62 | + wfDebug( __METHOD__ . ": success.\n" ); |
| 63 | + $f->showSuccess(); |
| 64 | + } else if ( 'submit' == $action && $wgRequest->wasPosted() && $f->hasAllInfo() ) { |
64 | 65 | $token = $wgRequest->getVal( 'wpEditToken' ); |
65 | 66 | |
66 | 67 | if( $wgUser->isAnon() ) { |
— | — | @@ -71,19 +72,19 @@ |
72 | 73 | } |
73 | 74 | |
74 | 75 | if ( !$tokenOk ) { |
75 | | - wfDebug( "$fname: bad token (".($wgUser->isAnon()?'anon':'user')."): $token\n" ); |
76 | | - $wgOut->addWikiText( wfMsg( 'sessionfailure' ) ); |
| 76 | + wfDebug( __METHOD__ . ": bad token (".( $wgUser->isAnon() ? 'anon' : 'user' )."): $token\n" ); |
| 77 | + $wgOut->addWikiMsg( 'sessionfailure' ); |
77 | 78 | $f->showForm(); |
78 | 79 | } else if ( !$f->passCaptcha() ) { |
79 | | - wfDebug( "$fname: captcha failed" ); |
80 | | - $wgOut->addWikiText( wfMsg( 'contactpage-captcha-failed' ) ); //TODO: provide a message for this! |
| 80 | + wfDebug( __METHOD__ . ": captcha failed" ); |
| 81 | + $wgOut->addWikiMsg( 'contactpage-captcha-failed' ); |
81 | 82 | $f->showForm(); |
82 | 83 | } else { |
83 | | - wfDebug( "$fname: submit\n" ); |
| 84 | + wfDebug( __METHOD__ . ": submit\n" ); |
84 | 85 | $f->doSubmit(); |
85 | 86 | } |
86 | 87 | } else { |
87 | | - wfDebug( "$fname: form\n" ); |
| 88 | + wfDebug( __METHOD__ . ": form\n" ); |
88 | 89 | $f->showForm(); |
89 | 90 | } |
90 | 91 | } |
— | — | @@ -91,13 +92,13 @@ |
92 | 93 | |
93 | 94 | /** |
94 | 95 | * @todo document |
95 | | - * @addtogroup SpecialPage |
| 96 | + * @ingroup SpecialPage |
96 | 97 | */ |
97 | 98 | class EmailContactForm { |
98 | 99 | |
99 | 100 | var $target; |
100 | 101 | var $text, $subject; |
101 | | - var $cc_me; // Whether user requested to be sent a separate copy of their email. |
| 102 | + var $cc_me; // Whether user requested to be sent a separate copy of their email. |
102 | 103 | |
103 | 104 | /** |
104 | 105 | * @param User $target |
— | — | @@ -114,12 +115,12 @@ |
115 | 116 | $this->fromname = $wgRequest->getText( 'wpFromName' ); |
116 | 117 | $this->fromaddress = $wgRequest->getText( 'wpFromAddress' ); |
117 | 118 | |
118 | | - if ($wgUser->isLoggedIn()) { |
119 | | - if (!$this->fromname) $this->fromname = $wgUser->getName(); |
120 | | - if (!$this->fromaddress) $this->fromaddress = $wgUser->getEmail(); |
| 119 | + if( $wgUser->isLoggedIn() ) { |
| 120 | + if( !$this->fromname ) $this->fromname = $wgUser->getName(); |
| 121 | + if( !$this->fromaddress ) $this->fromaddress = $wgUser->getEmail(); |
121 | 122 | } |
122 | 123 | |
123 | | - //prepare captcha if applicable |
| 124 | + // prepare captcha if applicable |
124 | 125 | if ( $this->useCaptcha() ) { |
125 | 126 | $captcha = ConfirmEditHooks::getInstance(); |
126 | 127 | $captcha->trigger = 'contactpage'; |
— | — | @@ -152,11 +153,11 @@ |
153 | 154 | |
154 | 155 | #TODO: show captcha |
155 | 156 | |
156 | | - $wgOut->setPagetitle( wfMsg( "contactpage-title" ) ); |
157 | | - $wgOut->addWikiText( wfMsg( "contactpage-pagetext" ) ); |
| 157 | + $wgOut->setPageTitle( wfMsg( 'contactpage-title' ) ); |
| 158 | + $wgOut->addWikiMsg( 'contactpage-pagetext' ); |
158 | 159 | |
159 | | - if ( $this->subject === "" ) { |
160 | | - $this->subject = wfMsgForContent( "contactpage-defsubject" ); |
| 160 | + if ( $this->subject === '' ) { |
| 161 | + $this->subject = wfMsgForContent( 'contactpage-defsubject' ); |
161 | 162 | } |
162 | 163 | |
163 | 164 | $msgSuffix = $wgContactRequireAll ? '-required' : ''; |
— | — | @@ -230,8 +231,8 @@ |
231 | 232 | |
232 | 233 | function useCaptcha() { |
233 | 234 | global $wgCaptchaClass, $wgCaptchaTriggers, $wgUser; |
234 | | - if ( !$wgCaptchaClass ) return false; //no captcha installed |
235 | | - if ( !@$wgCaptchaTriggers['contactpage'] ) return false; //don't trigger on contact form |
| 235 | + if ( !$wgCaptchaClass ) return false; // no captcha installed |
| 236 | + if ( !@$wgCaptchaTriggers['contactpage'] ) return false; // don't trigger on contact form |
236 | 237 | |
237 | 238 | if( $wgUser->isAllowed( 'skipcaptcha' ) ) { |
238 | 239 | wfDebug( "EmailContactForm::useCaptcha: user group allows skipping captcha\n" ); |
— | — | @@ -243,7 +244,7 @@ |
244 | 245 | |
245 | 246 | function getCaptcha() { |
246 | 247 | global $wgCaptcha; |
247 | | - if ( !$this->useCaptcha() ) return ""; |
| 248 | + if ( !$this->useCaptcha() ) return ''; |
248 | 249 | |
249 | 250 | wfSetupSession(); #NOTE: make sure we have a session. May be required for captchas to work. |
250 | 251 | |
— | — | @@ -260,7 +261,7 @@ |
261 | 262 | return $wgCaptcha->passCaptcha(); |
262 | 263 | } |
263 | 264 | |
264 | | - function doSubmit( ) { |
| 265 | + function doSubmit() { |
265 | 266 | global $wgOut; |
266 | 267 | global $wgEnableEmail, $wgUserEmailUseReplyTo, $wgEmergencyContact; |
267 | 268 | global $wgContactUser, $wgContactSender, $wgContactSenderName; |
— | — | @@ -268,40 +269,35 @@ |
269 | 270 | $csender = $wgContactSender ? $wgContactSender : $wgEmergencyContact; |
270 | 271 | $cname = $wgContactSenderName; |
271 | 272 | |
272 | | - $fname = 'EmailContactForm::doSubmit'; |
| 273 | + wfDebug( __METHOD__ . ": start\n" ); |
273 | 274 | |
274 | | - wfDebug( "$fname: start\n" ); |
275 | | - |
276 | 275 | $to = new MailAddress( $this->target ); |
277 | 276 | $replyto = NULL; |
278 | 277 | |
279 | 278 | if ( !$this->fromaddress ) { |
280 | 279 | $from = new MailAddress( $csender, $cname ); |
281 | | - } |
282 | | - else if ( $wgUserEmailUseReplyTo ) { |
| 280 | + } else if ( $wgUserEmailUseReplyTo ) { |
283 | 281 | $from = new MailAddress( $csender, $cname ); |
284 | 282 | $replyto = new MailAddress( $this->fromaddress, $this->fromname ); |
285 | | - } |
286 | | - else { |
| 283 | + } else { |
287 | 284 | $from = new MailAddress( $this->fromaddress, $this->fromname ); |
288 | 285 | } |
289 | 286 | |
290 | 287 | $subject = trim( $this->subject ); |
291 | 288 | |
292 | | - if ( $subject === "" ) { |
293 | | - $subject = wfMsgForContent( "contactpage-defsubject" ); |
| 289 | + if ( $subject === '' ) { |
| 290 | + $subject = wfMsgForContent( 'contactpage-defsubject' ); |
294 | 291 | } |
295 | 292 | |
296 | | - if ( $this->fromname !== "" ) { |
297 | | - $subject = wfMsgForContent( "contactpage-subject-and-sender", $subject, $this->fromname ); |
| 293 | + if ( $this->fromname !== '' ) { |
| 294 | + $subject = wfMsgForContent( 'contactpage-subject-and-sender', $subject, $this->fromname ); |
| 295 | + } else if ( $this->fromaddress !== '' ) { |
| 296 | + $subject = wfMsgForContent( 'contactpage-subject-and-sender', $subject, $this->fromaddress ); |
298 | 297 | } |
299 | | - else if ( $this->fromaddress !== "" ) { |
300 | | - $subject = wfMsgForContent( "contactpage-subject-and-sender", $subject, $this->fromaddress ); |
301 | | - } |
302 | 298 | |
303 | 299 | if( wfRunHooks( 'ContactForm', array( &$to, &$replyto, &$subject, &$this->text ) ) ) { |
304 | 300 | |
305 | | - wfDebug( "$fname: sending mail from ".$from->toString()." to ".$to->toString()." replyto ".($replyto==null?'-/-':$replyto->toString())."\n" ); |
| 301 | + wfDebug( __METHOD__ . ": sending mail from ".$from->toString()." to ".$to->toString()." replyto ".( $replyto == null ? '-/-' : $replyto->toString() )."\n" ); |
306 | 302 | |
307 | 303 | #HACK: in MW 1.9, replyto must be a string, in MW 1.10 it must be an object! |
308 | 304 | $ver = preg_replace( '![^\d._+]!', '', $GLOBALS['wgVersion'] ); |
— | — | @@ -312,15 +308,14 @@ |
313 | 309 | $mailResult = userMailer( $to, $from, $subject, $this->text, $replyaddr ); |
314 | 310 | |
315 | 311 | if( WikiError::isError( $mailResult ) ) { |
316 | | - $wgOut->addWikiText( wfMsg( "usermailererror" ) . $mailResult->getMessage()); |
| 312 | + $wgOut->addWikiMsg( 'usermailererror' ) . $mailResult->getMessage(); |
317 | 313 | } else { |
318 | | - |
319 | 314 | // if the user requested a copy of this mail, do this now, |
320 | 315 | // unless they are emailing themselves, in which case one copy of the message is sufficient. |
321 | | - if ($this->cc_me && $replyto) { |
| 316 | + if( $this->cc_me && $replyto ) { |
322 | 317 | $cc_subject = wfMsg('emailccsubject', $this->target->getName(), $subject); |
323 | 318 | if( wfRunHooks( 'ContactForm', array( &$from, &$replyto, &$cc_subject, &$this->text ) ) ) { |
324 | | - wfDebug( "$fname: sending cc mail from ".$from->toString()." to ".$replyto->toString()."\n" ); |
| 319 | + wfDebug( __METHOD__ . ": sending cc mail from ".$from->toString()." to ".$replyto->toString()."\n" ); |
325 | 320 | $ccResult = userMailer( $replyto, $from, $cc_subject, $this->text ); |
326 | 321 | if( WikiError::isError( $ccResult ) ) { |
327 | 322 | // At this stage, the user's CC mail has failed, but their |
— | — | @@ -328,29 +323,29 @@ |
329 | 324 | // We can either show them an error, or we can say everything was fine, |
330 | 325 | // or we can say we sort of failed AND sort of succeeded. Of these options, |
331 | 326 | // simply saying there was an error is probably best. |
332 | | - $wgOut->addWikiText( wfMsg( "usermailererror" ) . $ccResult); |
| 327 | + $wgOut->addWikiText( wfMsg( 'usermailererror' ) . $ccResult ); |
333 | 328 | return; |
334 | 329 | } |
335 | 330 | } |
336 | 331 | } |
337 | 332 | |
338 | | - wfDebug( "$fname: success\n" ); |
| 333 | + wfDebug( __METHOD__ . ": success\n" ); |
339 | 334 | |
340 | | - $titleObj = SpecialPage::getTitleFor( "Contact" ); |
| 335 | + $titleObj = SpecialPage::getTitleFor( 'Contact' ); |
341 | 336 | $wgOut->redirect( $titleObj->getFullURL( "action=success" ) ); |
342 | 337 | wfRunHooks( 'ContactFromComplete', array( $to, $replyto, $subject, $this->text ) ); |
343 | 338 | } |
344 | 339 | } |
345 | 340 | |
346 | | - wfDebug( "$fname: end\n" ); |
| 341 | + wfDebug( __METHOD__ . ": end\n" ); |
347 | 342 | } |
348 | 343 | |
349 | | - function showSuccess( ) { |
| 344 | + function showSuccess() { |
350 | 345 | global $wgOut; |
351 | 346 | |
352 | | - $wgOut->setPagetitle( wfMsg( "emailsent" ) ); |
353 | | - $wgOut->addWikiText( wfMsg( "emailsenttext" ) ); |
| 347 | + $wgOut->setPageTitle( wfMsg( 'emailsent' ) ); |
| 348 | + $wgOut->addWikiMsg( 'emailsenttext' ); |
354 | 349 | |
355 | 350 | $wgOut->returnToMain( false ); |
356 | 351 | } |
357 | | -} |
| 352 | +} |
\ No newline at end of file |
Index: trunk/extensions/ContactPage/ContactPage.alias.php |
— | — | @@ -2,7 +2,8 @@ |
3 | 3 | /** |
4 | 4 | * Aliases for Special:Contact |
5 | 5 | * |
6 | | - * @addtogroup Extensions |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
9 | 10 | $aliases = array(); |
— | — | @@ -55,7 +56,7 @@ |
56 | 57 | |
57 | 58 | /** Finnish (Suomi) */ |
58 | 59 | $aliases['fi'] = array( |
59 | | - 'Contact' => array( 'Yhteystiedot' ), |
| 60 | + 'Contact' => array( 'Ota yhteyttä' ), |
60 | 61 | ); |
61 | 62 | |
62 | 63 | /** Galician (Galego) */ |
Index: trunk/extensions/ContactPage/ContactPage.i18n.php |
— | — | @@ -1,8 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Internationalisation file for extension ContactPage. |
| 4 | + * Internationalisation file for ContactPage extension. |
5 | 5 | * |
6 | | - * @addtogroup Extensions |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
7 | 8 | * @author Daniel Kinzler, brightbyte.de |
8 | 9 | * @copyright © 2007 Daniel Kinzler |
9 | 10 | * @license GNU General Public Licence 2.0 or later |
— | — | @@ -10,6 +11,9 @@ |
11 | 12 | |
12 | 13 | $messages = array(); |
13 | 14 | |
| 15 | +/** English |
| 16 | + * @author Daniel Kinzler |
| 17 | + */ |
14 | 18 | $messages['en'] = array( |
15 | 19 | 'contact' => 'Contact page', |
16 | 20 | 'contactpage' => 'Contact page', |
Index: trunk/extensions/ContactPage/ContactPage.php |
— | — | @@ -3,8 +3,8 @@ |
4 | 4 | * Setup for ContactPage extension, a special page that implements a contact form |
5 | 5 | * for use by anonymous visitors. |
6 | 6 | * |
7 | | - * @package MediaWiki |
8 | | - * @subpackage Extensions |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
9 | 9 | * @author Daniel Kinzler, brightbyte.de |
10 | 10 | * @copyright © 2007 Daniel Kinzler |
11 | 11 | * @licence GNU General Public Licence 2.0 or later |