Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetterCA.php |
— | — | @@ -186,4 +186,38 @@ |
187 | 187 | |
188 | 188 | return $state_menu; |
189 | 189 | } |
| 190 | + |
| 191 | + public function generateCountryDropdown( $defaultCountry = 124 ) { |
| 192 | + $country_options = ''; |
| 193 | + |
| 194 | + // create a new array of countries with potentially translated country names for alphabetizing later |
| 195 | + foreach ( $this->getCountries() as $iso_value => $full_name ) { |
| 196 | + $countries[ $iso_value ] = wfMsg( 'payflowpro_gateway-country-dropdown-' . $iso_value ); |
| 197 | + } |
| 198 | + |
| 199 | + // alphabetically sort the country names |
| 200 | + asort( $countries, SORT_STRING ); |
| 201 | + |
| 202 | + // generate a dropdown option for each country |
| 203 | + foreach ( $countries as $iso_value => $full_name ) { |
| 204 | + if ( $this->form_data[ 'country' ] ) { |
| 205 | + $selected = ( $iso_value == $this->form_data[ 'country' ] ) ? true : false; |
| 206 | + } else { |
| 207 | + $selected = ( $iso_value == $defaultCountry ) ? true : false; // Select default |
| 208 | + } |
| 209 | + $country_options .= Xml::option( $full_name, $iso_value, $selected ); |
| 210 | + } |
| 211 | + |
| 212 | + // build the actual select |
| 213 | + $country_menu = Xml::openElement( |
| 214 | + 'select', |
| 215 | + array( |
| 216 | + 'name' => 'country', |
| 217 | + 'id' => 'country' |
| 218 | + ) ); |
| 219 | + $country_menu .= $country_options; |
| 220 | + $country_menu .= Xml::closeElement( 'select' ); |
| 221 | + |
| 222 | + return $country_menu; |
| 223 | + } |
190 | 224 | } |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | if ( $this->form_data[ 'country' ] ) { |
155 | 155 | $selected = ( $iso_value == $this->form_data[ 'country' ] ) ? true : false; |
156 | 156 | } else { |
157 | | - $selected = ( $iso_value == $defaultCountry ) ? true : false; // Default to United States |
| 157 | + $selected = ( $iso_value == $defaultCountry ) ? true : false; // Select default |
158 | 158 | } |
159 | 159 | $country_options .= Xml::option( $full_name, $iso_value, $selected ); |
160 | 160 | } |