r61088 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61087‎ | r61088 | r61089 >
Date:17:23, 15 January 2010
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: display city for non-default countries in user profile
Modified paths:
  • /trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php
@@ -218,10 +218,22 @@
219219 }
220220 $profile_data = $this->profile_data;
221221
 222+ $defaultCountry = wfMsgForContent( 'user-profile-default-country' );
 223+
222224 $location = $profile_data['location_city'] . ', ' . $profile_data['location_state'];
223 - if ( $profile_data['location_country'] != 'United States' ) {
224 - $location = '';
225 - $location .= $profile_data['location_country'];
 225+ if ( $profile_data['location_country'] != $defaultCountry ) {
 226+ if ( $profile_data['location_city'] && $profile_data['location_state'] ) { // city AND state
 227+ $location = $profile_data['location_city'] . ', ' .
 228+ $profile_data['location_state'] . ', ' .
 229+ $profile_data['location_country'];
 230+ } elseif ( $profile_data['location_city'] && !$profile_data['location_state'] ) { // city, but no state
 231+ $location = $profile_data['location_city'] . ', ' . $profile_data['location_country'];
 232+ } elseif ( $profile_data['location_state'] && !$profile_data['location_city'] ) { // state, but no city
 233+ $location = $profile_data['location_state'] . ', ' . $profile_data['location_country'];
 234+ } else {
 235+ $location = '';
 236+ $location .= $profile_data['location_country'];
 237+ }
226238 }
227239
228240 if ( $location == ', ' ) {
@@ -229,10 +241,21 @@
230242 }
231243
232244 $hometown = $profile_data['hometown_city'] . ', ' . $profile_data['hometown_state'];
233 - if ( $profile_data['hometown_country'] != 'United States' ) {
234 - $hometown = '';
235 - $hometown .= $profile_data['hometown_country'];
 245+ if ( $profile_data['hometown_country'] != $defaultCountry ) {
 246+ if ( $profile_data['hometown_city'] && $profile_data['hometown_state'] ) { // city AND state
 247+ $hometown = $profile_data['hometown_city'] . ', ' .
 248+ $profile_data['hometown_state'] . ', ' .
 249+ $profile_data['hometown_country'];
 250+ } elseif ( $profile_data['hometown_city'] && !$profile_data['hometown_state'] ) { // city, but no state
 251+ $hometown = $profile_data['hometown_city'] . ', ' . $profile_data['hometown_country'];
 252+ } elseif ( $profile_data['hometown_state'] && !$profile_data['hometown_city'] ) { // state, but no city
 253+ $hometown = $profile_data['hometown_state'] . ', ' . $profile_data['hometown_country'];
 254+ } else {
 255+ $hometown = '';
 256+ $hometown .= $profile_data['hometown_country'];
 257+ }
236258 }
 259+
237260 if ( $hometown == ', ' ) {
238261 $hometown = '';
239262 }

Status & tagging log