r76660 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76659‎ | r76660 | r76661 >
Date:17:08, 14 November 2010
Author:raymond
Status:ok (Comments)
Tags:
Comment:
Add possibility to use customized contage pages via [[Special:Contact/typename]]
It calls the contact page with a customized pagetext and prefilled form fields (details see README, section Costumization)
Modified paths:
  • /trunk/extensions/ContactPage/README (modified) (history)
  • /trunk/extensions/ContactPage/SpecialContact.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContactPage/SpecialContact.php
@@ -70,7 +70,7 @@
7171 return;
7272 }
7373
74 - $f = new EmailContactForm( $nu );
 74+ $f = new EmailContactForm( $nu, $par);
7575
7676 if ( 'success' == $action ) {
7777 wfDebug( __METHOD__ . ": success.\n" );
@@ -118,12 +118,43 @@
119119 /**
120120 * @param User $target
121121 */
122 - function __construct( $target ) {
 122+ function __construct( $target, $par ) {
123123 global $wgRequest, $wgUser;
124124
 125+ $formType = $wgRequest->getText( 'type', $par );
 126+
 127+ # Check for type in [[Special:Contact/type]]: change pagetext and prefill form fields
 128+ if ( $formType != '' ) {
 129+ $message = 'contactpage-pagetext-' . $formType;
 130+ $text = wfMsgExt( $message, 'parse' );
 131+ if ( !wfEmptyMsg( $message, $text ) ) {
 132+ $this->formularText = $text;
 133+ } else {
 134+ $this->formularText = wfMsgExt( 'contactpage-pagetext', 'parse' );
 135+ }
 136+
 137+ $message = 'contactpage-subject-' . $formType;
 138+ $text = wfMsgForContentNoTrans( $message );
 139+ if ( !wfEmptyMsg( $message, $text ) ) {
 140+ $this->subject = $wgRequest->getText( 'wpSubject', $text );
 141+ } else {
 142+ $this->subject = $wgRequest->getText( 'wpSubject' );
 143+ }
 144+
 145+ $message = 'contactpage-text-' . $formType;
 146+ $text = wfMsgForContentNoTrans( $message );
 147+ if ( !wfEmptyMsg( $message, $text ) ) {
 148+ $this->text = $wgRequest->getText( 'wpText', $text );
 149+ } else {
 150+ $this->text = $wgRequest->getText( 'wpText' );
 151+ }
 152+ } else {
 153+ $this->formularText = wfMsgExt( 'contactpage-pagetext', 'parse' );
 154+ $this->text = $wgRequest->getText( 'wpText' );
 155+ $this->subject = $wgRequest->getText( 'wpSubject' );
 156+ }
 157+
125158 $this->target = $target;
126 - $this->text = $wgRequest->getText( 'wpText' );
127 - $this->subject = $wgRequest->getText( 'wpSubject' );
128159 $this->cc_me = $wgRequest->getBool( 'wpCCMe' );
129160 $this->includeIP = $wgRequest->getBool( 'wpIncludeIP' );
130161
@@ -188,7 +219,7 @@
189220 #TODO: show captcha
190221
191222 $wgOut->setPageTitle( wfMsg( 'contactpage-title' ) );
192 - $wgOut->addWikiMsg( 'contactpage-pagetext' );
 223+ $wgOut->addHTML( $this->formularText );
193224
194225 if ( $this->subject === '' ) {
195226 $this->subject = wfMsgForContent( 'contactpage-defsubject' );
Index: trunk/extensions/ContactPage/README
@@ -51,3 +51,18 @@
5252
5353 $wgCaptchaTriggers['contactpage'] = true;
5454
 55+== Costumization ==
 56+
 57+[[Special:Contact]] calls the default formular.
 58+Pagetext: [[MediaWiki:contactpage-pagetext]]
 59+Subject: prefilled with text from [[MediaWiki:Contactpage-defsubject]]
 60+E-mail body: empty.
 61+
 62+[[Special:Contact/typename]] calls the contact page with a customized pagetext and
 63+prefilled form fields:
 64+Pagetext: [[MediaWiki:contactpage-pagetext-typename]]
 65+Subject: prefilled with text from [[MediaWiki:Contactpage-subject-typename]]
 66+E-mail body: prefilled with text from [[MediaWiki:Contactpage-text-typename]]
 67+
 68+If a customized message does not exist the default message is shown.
 69+

Follow-up revisions

RevisionCommit summaryAuthorDate
r76671Follow-up r76660: typos per CRraymond20:09, 14 November 2010
r76694Follow-up r76660: Add formType to the object which is passed to 'ContactFormB...raymond18:48, 15 November 2010

Comments

#Comment by Nikerabbit (talk | contribs)   19:06, 14 November 2010

+ $f = new EmailContactForm( $nu, $par);

+== Costumization ==

Whitespace. Typo.

+			$text = wfMsgExt( $message, 'parse' );
+			if ( !wfEmptyMsg( $message, $text ) ) {

Are you sure that works?

#Comment by Raymond (talk | contribs)   20:15, 14 November 2010

Whitespace. Typo. Fixed with r76671, r76672

Are you sure that works? 

Yes. Tested twice now.

Status & tagging log