Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -202,7 +202,7 @@ |
203 | 203 | public function setFormClass( $class_name=NULL ) { |
204 | 204 | if ( !$class_name ) { |
205 | 205 | global $wgRequest, $wgPayflowGatewayDefaultForm; |
206 | | - $form_class = ( strlen( $wgRequest->getText( 'form_name' ))) ? $wgRequest->getText( 'form_name' ) : $wgPayflowGatewayDefaultForm; |
| 206 | + $form_class = $wgRequest->getText( 'form_name', $wgPayflowGatewayDefaultForm ); |
207 | 207 | |
208 | 208 | // make sure our form class exists before going on, if not try loading default form class |
209 | 209 | $class_name = "PayflowProGateway_Form_" . $form_class; |
— | — | @@ -909,7 +909,8 @@ |
910 | 910 | 'utm_source' => $this->getUtmSource(), |
911 | 911 | 'utm_medium' => $wgRequest->getText( 'utm_medium' ), |
912 | 912 | 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ), |
913 | | - 'language' => $wgRequest->getText( 'language' ), |
| 913 | + // try to honr the user-set language (uselang), otherwise the language set in the URL (language) |
| 914 | + 'language' => $wgRequest->getText( 'uselang', $wgRequest->getText( 'language' )), |
914 | 915 | 'comment' => $wgRequest->getText( 'comment' ), |
915 | 916 | 'comment-option' => $wgRequest->getText( 'comment-option' ), |
916 | 917 | 'email-opt' => $wgRequest->getText( 'email-opt' ), |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/SingleColumn.php |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class PayflowProGateway_Form_SingleColumn extends PayflowProGateway_Form_TwoColumnLetter { |
| 5 | + |
| 6 | + public function __construct( &$form_data, &$form_errors ) { |
| 7 | + global $wgOut, $wgScriptPath; |
| 8 | + |
| 9 | + // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this |
| 10 | + if ( !strlen( $this->getStylePath())) { |
| 11 | + $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/SingleColumn.css' ); |
| 12 | + } |
| 13 | + |
| 14 | + parent::__construct( $form_data, $form_errors ); |
| 15 | + } |
| 16 | + |
| 17 | + public function generateFormEnd() { |
| 18 | + return $this->generateFormClose(); |
| 19 | + } |
| 20 | +} |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/SingleColumn.css |
— | — | @@ -0,0 +1,3 @@ |
| 2 | +.payflow-cc-form-section { |
| 3 | + float: none; |
| 4 | +} |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/Form.css |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php |
— | — | @@ -26,19 +26,59 @@ |
27 | 27 | */ |
28 | 28 | public $form_errors; |
29 | 29 | |
| 30 | + /** |
| 31 | + * The full path to CSS for the current form |
| 32 | + * @var string |
| 33 | + */ |
| 34 | + protected $style_path; |
| 35 | + |
30 | 36 | abstract public function generateFormStart(); |
31 | 37 | abstract public function generateFormSubmit(); |
32 | 38 | abstract public function generateFormEnd(); |
33 | 39 | |
34 | 40 | public function __construct( &$data, &$error ) { |
35 | | - global $wgPayflowGatewayTest; |
| 41 | + global $wgPayflowGatewayTest, $wgOut; |
36 | 42 | |
37 | 43 | $this->test = $wgPayflowGatewayTest; |
38 | 44 | $this->form_data =& $data; |
39 | 45 | $this->form_errors =& $error; |
| 46 | + |
| 47 | + /** |
| 48 | + * add form-specific css - the path can be set using $this->setStylePath, |
| 49 | + * which should be called before loading this constructor |
| 50 | + */ |
| 51 | + if ( !strlen( $this->getStylePath())) { |
| 52 | + $this->setStylePath(); |
| 53 | + } |
| 54 | + $wgOut->addExtensionStyle( $this->getStylePath() ); |
40 | 55 | } |
41 | 56 | |
42 | 57 | /** |
| 58 | + * Set the path to the CSS file for the form |
| 59 | + * |
| 60 | + * This should be a full path, perhaps taking advantage of $wgScriptPath. |
| 61 | + * If you do not pass the path to the method, the style path will default |
| 62 | + * to the default css in css/Form.css |
| 63 | + * @param string $style_path |
| 64 | + */ |
| 65 | + public function setStylePath( $style_path=null ) { |
| 66 | + global $wgScriptPath; |
| 67 | + if ( !$style_path ) { |
| 68 | + // load the default form CSS if the style path not explicitly set |
| 69 | + $style_path = $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/Form.css'; |
| 70 | + } |
| 71 | + $this->style_path = $style_path; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * Get the path to CSS |
| 76 | + * @return String |
| 77 | + */ |
| 78 | + public function getStylePath() { |
| 79 | + return $this->style_path; |
| 80 | + } |
| 81 | + |
| 82 | + /** |
43 | 83 | * Generates the donation footer ("There are other ways to give...") |
44 | 84 | * @returns string of HTML |
45 | 85 | */ |
— | — | @@ -287,6 +327,4 @@ |
288 | 328 | } |
289 | 329 | return $this->hidden_fields; |
290 | 330 | } |
291 | | - |
292 | | - |
293 | | -} |
| 331 | +} |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php |
— | — | @@ -82,8 +82,13 @@ |
83 | 83 | global $wgPayflowGatewayHeader, $wgOut; |
84 | 84 | // intro text |
85 | 85 | if ( $wgPayflowGatewayHeader ) { |
86 | | - $header = str_replace( '@language', $this->form_data['language'], $wgPayflowGatewayHeader ); |
87 | | - $wgOut->addHtml( $wgOut->parse( $header )); |
| 86 | + $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowGatewayHeader ); |
| 87 | + $template = $wgOut->parse( $header ); |
| 88 | + |
| 89 | + // make sure that we actually have a matching template to display so we don't display the 'redlink' |
| 90 | + if ( !preg_match( '/redlink\=1/', $template )) { |
| 91 | + $wgOut->addHtml( $template ); |
| 92 | + } |
88 | 93 | } |
89 | 94 | } |
90 | 95 | |
— | — | @@ -224,4 +229,4 @@ |
225 | 230 | |
226 | 231 | return $form; |
227 | 232 | } |
228 | | -} |
| 233 | +} |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php |
— | — | @@ -4,11 +4,14 @@ |
5 | 5 | |
6 | 6 | public function __construct( &$form_data, &$form_errors ) { |
7 | 7 | global $wgOut, $wgScriptPath; |
| 8 | + |
| 9 | + // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this |
| 10 | + if ( !strlen( $this->getStylePath())) { |
| 11 | + $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' ); |
| 12 | + } |
| 13 | + |
8 | 14 | parent::__construct( $form_data, $form_errors ); |
9 | | - |
10 | | - // add form-specific css |
11 | | - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css'); |
12 | | - |
| 15 | + |
13 | 16 | // update the list of hidden fields we need to use in this form. |
14 | 17 | $this->updateHiddenFields(); |
15 | 18 | } |
— | — | @@ -34,7 +37,7 @@ |
35 | 38 | } else { |
36 | 39 | $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
37 | 40 | } |
38 | | - $form .= Xml::closeElement( 'div' ); |
| 41 | + $form .= Xml::closeElement( 'div' ); // close div#mw-payflow-general-error |
39 | 42 | } |
40 | 43 | |
41 | 44 | // open form |
— | — | @@ -53,28 +56,23 @@ |
54 | 57 | public function generateFormEnd() { |
55 | 58 | global $wgRequest, $wgOut; |
56 | 59 | $form = ''; |
57 | | - // add hidden fields |
58 | | - $hidden_fields = $this->getHiddenFields(); |
59 | | - foreach ( $hidden_fields as $field => $value ) { |
60 | | - $form .= Xml::hidden( $field, $value ); |
61 | | - } |
62 | | - |
63 | | - $form .= Xml::closeElement( 'form' ); |
| 60 | + |
| 61 | + $form .= $this->generateFormClose(); |
64 | 62 | |
65 | | - $form .= $this->generateDonationFooter(); |
66 | | - |
67 | | - $form .= Xml::closeElement( 'div' ); |
68 | | - $form .= Xml::closeElement( 'div' ); |
69 | | - $form .= Xml::closeElement( 'div' ); |
70 | | - |
71 | 63 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter', 'class' => 'payflowpro_gateway-cc_form_column')); |
72 | 64 | $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter_inside' )); |
| 65 | + |
73 | 66 | $text_template = $wgRequest->getText( 'text_template' ); |
74 | | - if ( $wgRequest->getText( 'language' )) $text_template .= '/' . $wgRequest->getText( 'language' ); |
| 67 | + // if the user has uselang set, honor that, otherwise default to the language set for the form defined by 'language' in the query string |
| 68 | + if ( $wgRequest->getText( 'language' )) $text_template .= '/' . $this->form_data[ 'language' ]; |
75 | 69 | |
76 | | - $form .= ( strlen( $text_template )) ? $wgOut->parse( '{{'.$text_template.'}}' ) : ''; |
77 | | - $form .= Xml::closeElement( 'div' ); |
78 | | - $form .= Xml::closeElement( 'div' ); |
| 70 | + $template = ( strlen( $text_template )) ? $wgOut->parse( '{{'.$text_template.'}}' ) : ''; |
| 71 | + // if the template doesn't exist, prevent the display of the red link |
| 72 | + if ( preg_match( '/redlink\=1/', $template )) $template = NULL; |
| 73 | + $form .= $template; |
| 74 | + |
| 75 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-cc_form_letter |
| 76 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-cc_form_letter_inside |
79 | 77 | return $form; |
80 | 78 | } |
81 | 79 | |
— | — | @@ -103,7 +101,12 @@ |
104 | 102 | $email_opt_value = ( $this->form_data[ 'numAttempt' ]) ? $this->form_data[ 'email-opt' ] : true; |
105 | 103 | $form .= '<tr>'; |
106 | 104 | $form .= '<td>' . Xml::check( 'email-opt', $email_opt_value ) . '</td>'; |
107 | | - $form .= '<td>' . Xml::label( wfMsg( 'donate_interface-email-agreement' ), 'email-opt' ) . '</td>'; |
| 105 | + $form .= '<td>'; |
| 106 | + // put the label inside Xml::openElement so any HTML in the msg might get rendered (right, Germany?) |
| 107 | + $form .= Xml::openElement( 'label', array( 'for' => 'email-opt' )); |
| 108 | + $form .= wfMsg( 'donate_interface-email-agreement' ); |
| 109 | + $form .= Xml::closeElement( 'label' ); |
| 110 | + $form .= '</td>'; |
108 | 111 | $form .= '</tr>'; |
109 | 112 | |
110 | 113 | $form .= Xml::closeElement( 'table' ); |
— | — | @@ -126,4 +129,25 @@ |
127 | 130 | |
128 | 131 | $this->setHiddenFields( $hidden_fields ); |
129 | 132 | } |
| 133 | + |
| 134 | + /** |
| 135 | + * Generate form closing elements |
| 136 | + */ |
| 137 | + public function generateFormClose() { |
| 138 | + $form = ''; |
| 139 | + // add hidden fields |
| 140 | + $hidden_fields = $this->getHiddenFields(); |
| 141 | + foreach ( $hidden_fields as $field => $value ) { |
| 142 | + $form .= Xml::hidden( $field, $value ); |
| 143 | + } |
| 144 | + |
| 145 | + $form .= Xml::closeElement( 'form' ); // close form 'payment' |
| 146 | + |
| 147 | + $form .= $this->generateDonationFooter(); |
| 148 | + |
| 149 | + $form .= Xml::closeElement( 'div' ); //close div#mw-creditcard |
| 150 | + $form .= Xml::closeElement( 'div' ); //close div#payflowpro_gateway-cc_form_form |
| 151 | + $form .= Xml::closeElement( 'div' ); //close div#payflowpro_gateway-cc_form_container |
| 152 | + return $form; |
| 153 | + } |
130 | 154 | } |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | $wgAutoloadClasses[ 'PayflowProGateway_Form' ] = $dir . 'forms/Form.php'; |
26 | 26 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumn' ] = $dir . 'forms/TwoColumn.php'; |
27 | 27 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumnLetter' ] = $dir . 'forms/TwoColumnLetter.php'; |
| 28 | +$wgAutoloadClasses[ 'PayflowProGateway_Form_SingleColumn' ] = $dir . 'forms/SingleColumn.php'; |
28 | 29 | $wgExtensionMessagesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.i18n.php'; |
29 | 30 | $wgExtensionAliasesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.alias.php'; |
30 | 31 | $wgSpecialPages['PayflowProGateway'] = 'PayflowProGateway'; |