Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | $wgOut->addScriptFile( $wgUserProfileScripts . '/UpdateProfile.js' ); |
88 | 88 | } |
89 | 89 | |
90 | | - if ( $wgRequest->wasPosted() ) { |
| 90 | + if ( $wgRequest->wasPosted() ) { |
91 | 91 | if ( !$section ) { |
92 | 92 | $section = 'basic'; |
93 | 93 | } |
— | — | @@ -194,6 +194,7 @@ |
195 | 195 | $notify_challenge = $wgRequest->getVal( 'notify_challenge' ); |
196 | 196 | $notify_honorifics = $wgRequest->getVal( 'notify_honorifics' ); |
197 | 197 | $notify_message = $wgRequest->getVal( 'notify_message' ); |
| 198 | + $show_year_of_birth = $wgRequest->getVal( 'show_year_of_birth', 0 ); |
198 | 199 | if ( $notify_friend == '' ) { |
199 | 200 | $notify_friend = 0; |
200 | 201 | } |
— | — | @@ -214,6 +215,7 @@ |
215 | 216 | $wgUser->setOption( 'notifychallenge', $notify_challenge ); |
216 | 217 | $wgUser->setOption( 'notifyhonorifics', $notify_honorifics ); |
217 | 218 | $wgUser->setOption( 'notifymessage', $notify_message ); |
| 219 | + $wgUser->setOption( 'showyearofbirth', $show_year_of_birth ); |
218 | 220 | $wgUser->saveSettings(); |
219 | 221 | |
220 | 222 | // Allow extensions like UserMailingList do their magic here |
— | — | @@ -222,8 +224,8 @@ |
223 | 225 | |
224 | 226 | function formatBirthdayDB( $birthday ) { |
225 | 227 | $dob = explode( '/', $birthday ); |
226 | | - if ( count( $dob ) == 2 ) { |
227 | | - $year = 2007; |
| 228 | + if ( count( $dob ) == 2 || count( $dob ) == 3 ) { |
| 229 | + $year = isset( $dob[2] ) ? $dob[2] : 2007; |
228 | 230 | $month = $dob[0]; |
229 | 231 | $day = $dob[1]; |
230 | 232 | $birthday_date = $year . '-' . $month . '-' . $day; |
— | — | @@ -233,13 +235,16 @@ |
234 | 236 | return ( $birthday_date ); |
235 | 237 | } |
236 | 238 | |
237 | | - function formatBirthday( $birthday ) { |
| 239 | + function formatBirthday( $birthday, $showYOB = false ) { |
238 | 240 | $dob = explode( '-', $birthday ); |
239 | 241 | if ( count( $dob ) == 3 ) { |
240 | | - $year = 0000; |
241 | 242 | $month = $dob[1]; |
242 | 243 | $day = $dob[2]; |
243 | | - $birthday_date = $month . '/' . $day; // . '/' . $year; |
| 244 | + $birthday_date = $month . '/' . $day; |
| 245 | + if ( $showYOB ) { |
| 246 | + $year = $dob[0]; |
| 247 | + $birthday_date .= '/' . $year; |
| 248 | + } |
244 | 249 | } else { |
245 | 250 | $birthday_date = ''; |
246 | 251 | } |
— | — | @@ -382,6 +387,7 @@ |
383 | 388 | __METHOD__ |
384 | 389 | ); |
385 | 390 | |
| 391 | + $showYOB = true; |
386 | 392 | if ( $s !== false ) { |
387 | 393 | $location_city = $s->up_location_city; |
388 | 394 | $location_state = $s->up_location_state; |
— | — | @@ -391,7 +397,8 @@ |
392 | 398 | $hometown_city = $s->up_hometown_city; |
393 | 399 | $hometown_state = $s->up_hometown_state; |
394 | 400 | $hometown_country = $s->up_hometown_country; |
395 | | - $birthday = $this->formatBirthday( $s->up_birthday ); |
| 401 | + $showYOB = $wgUser->getIntOption( 'showyearofbirth', !isset( $s->up_birthday ) ) == 1; |
| 402 | + $birthday = $this->formatBirthday( $s->up_birthday, $showYOB ); |
396 | 403 | $schools = $s->up_schools; |
397 | 404 | $places = $s->up_places_lived; |
398 | 405 | $websites = $s->up_websites; |
— | — | @@ -498,8 +505,13 @@ |
499 | 506 | |
500 | 507 | $form .= '<div class="profile-update"> |
501 | 508 | <p class="profile-update-title">' . wfMsg( 'user-profile-personal-birthday' ) . '</p> |
502 | | - <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-birthdate' ) . '</p> |
503 | | - <p class="profile-update-unit"><input type="text" size="25" name="birthday" id="birthday" value="' . ( isset( $birthday ) ? $birthday : '' ) . '" /></p> |
| 509 | + <p class="profile-update-unit-left" id="birthday-format">' . |
| 510 | + wfMsg( $showYOB ? 'user-profile-personal-birthdate-with-year' : 'user-profile-personal-birthdate' ) . |
| 511 | + '</p> |
| 512 | + <p class="profile-update-unit"><input type="text"' . |
| 513 | + ( $showYOB ? ' class="long-birthday"' : null ) . |
| 514 | + ' size="25" name="birthday" id="birthday" value="' . |
| 515 | + ( isset( $birthday ) ? $birthday : '' ) . '" /></p> |
504 | 516 | <div class="cleared"></div> |
505 | 517 | </div><div class="cleared"></div>'; |
506 | 518 | |
— | — | @@ -662,8 +674,18 @@ |
663 | 675 | * @return HTML |
664 | 676 | */ |
665 | 677 | function displayPreferencesForm() { |
666 | | - global $wgUser, $wgOut; |
| 678 | + global $wgRequest, $wgUser, $wgOut; |
667 | 679 | |
| 680 | + $dbr = wfGetDB( DB_MASTER ); |
| 681 | + $s = $dbr->selectRow( |
| 682 | + 'user_profile', |
| 683 | + array( 'up_birthday' ), |
| 684 | + array( 'up_user_id' => $wgUser->getID() ), |
| 685 | + __METHOD__ |
| 686 | + ); |
| 687 | + |
| 688 | + $showYOB = isset( $s, $s->up_birthday ) ? false : true; |
| 689 | + |
668 | 690 | // @todo If the checkboxes are in front of the option, this would look more like Special:Preferences |
669 | 691 | $wgOut->setPageTitle( wfMsg( 'user-profile-section-preferences' ) ); |
670 | 692 | $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-preferences' ) ); |
— | — | @@ -689,6 +711,14 @@ |
690 | 712 | ' <input type="checkbox" size="25" name="notify_honorifics" id="notify_honorifics" value="1"' . ( ( $wgUser->getIntOption( 'notifyhonorifics', 1 ) == 1 ) ? 'checked' : '' ) . '/> |
691 | 713 | </p>'; |
692 | 714 | |
| 715 | + $form .= '<p class="profile-update-title">' . |
| 716 | + wfMsg( 'user-profile-preferences-miscellaneous' ) . |
| 717 | + '</p> |
| 718 | + <p class="profile-update-row">' . |
| 719 | + wfMsg( 'user-profile-preferences-miscellaneous-show-year-of-birth' ) . |
| 720 | + ' <input type="checkbox" size="25" name="show_year_of_birth" id="show_year_of_birth" value="1"' . ( ( $wgUser->getIntOption( 'showyearofbirth', $showYOB ) == 1 ) ? 'checked' : '' ) . '/> |
| 721 | + </p>'; |
| 722 | + |
693 | 723 | // Allow extensions (like UserMailingList) to add new checkboxes |
694 | 724 | wfRunHooks( 'SpecialUpdateProfile::displayPreferencesForm', array( $this, &$form ) ); |
695 | 725 | |
— | — | @@ -735,7 +765,7 @@ |
736 | 766 | $form = '<h1>' . wfMsg( 'user-profile-tidbits-title' ) . '</h1>'; |
737 | 767 | $form .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-custom' ) ); |
738 | 768 | $form .= '<form action="" method="post" enctype="multipart/form-data" name="profile"> |
739 | | - <div class="profile-info clearfix"> |
| 769 | + <div class="profile-info clearfix"> |
740 | 770 | <div class="profile-update"> |
741 | 771 | <p class="profile-update-title">' . wfMsgForContent( 'user-profile-tidbits-title' ) . '</p> |
742 | 772 | <div id="profile-update-custom1"> |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialEditProfile.php |
— | — | @@ -179,7 +179,7 @@ |
180 | 180 | $hometown_city = $s->up_hometown_city; |
181 | 181 | $hometown_state = $s->up_hometown_state; |
182 | 182 | $hometown_country = $s->up_hometown_country; |
183 | | - $birthday = $this->formatBirthday( $s->up_birthday ); |
| 183 | + $birthday = $this->formatBirthday( $s->up_birthday, true ); |
184 | 184 | $schools = $s->up_schools; |
185 | 185 | $places = $s->up_places_lived; |
186 | 186 | $websites = $s->up_websites; |
— | — | @@ -286,8 +286,8 @@ |
287 | 287 | |
288 | 288 | $form .= '<div class="profile-update"> |
289 | 289 | <p class="profile-update-title">' . wfMsg( 'user-profile-personal-birthday' ) . '</p> |
290 | | - <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-birthdate' ) . '</p> |
291 | | - <p class="profile-update-unit"><input type="text" size="25" name="birthday" id="birthday" value="' . ( isset( $birthday ) ? $birthday : '' ) . '" /></p> |
| 290 | + <p class="profile-update-unit-left">' . wfMsg( 'user-profile-personal-birthdate-with-year' ) . '</p> |
| 291 | + <p class="profile-update-unit"><input type="text" class="long-birthday" size="25" name="birthday" id="birthday" value="' . ( isset( $birthday ) ? $birthday : '' ) . '" /></p> |
292 | 292 | <div class="cleared"></div> |
293 | 293 | </div><div class="cleared"></div>'; |
294 | 294 | |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php |
— | — | @@ -117,6 +117,7 @@ |
118 | 118 | 'user-profile-personal-hometown' => 'Hometown', |
119 | 119 | 'user-profile-personal-birthday' => 'Birthday', |
120 | 120 | 'user-profile-personal-birthdate' => 'Date (MM/DD)', |
| 121 | + 'user-profile-personal-birthdate-with-year' => 'Date (MM/DD/YYYY)', |
121 | 122 | 'user-profile-personal-aboutme' => 'About me', |
122 | 123 | 'user-profile-personal-work' => 'Work', |
123 | 124 | 'user-profile-personal-occupation' => 'Occupation', |
— | — | @@ -142,6 +143,8 @@ |
143 | 144 | 'user-profile-preferences-emails-gift' => 'When you receive a gift', |
144 | 145 | 'user-profile-preferences-emails-level' => 'When advancing a level', |
145 | 146 | 'user-profile-preferences-emails-weekly' => 'Receive weekly email updates', |
| 147 | + 'user-profile-preferences-miscellaneous' => 'Miscellaneous', |
| 148 | + 'user-profile-preferences-miscellaneous-show-year-of-birth' => 'Show year of birth', |
146 | 149 | 'user-profile-update-button' => 'Update', |
147 | 150 | 'user-profile-tidbits-title' => 'Tidbits', |
148 | 151 | 'user-profile-tidbits-favmoment' => 'Favorite sports moment', |
— | — | @@ -9284,6 +9287,7 @@ |
9285 | 9288 | 'user-profile-personal-hometown' => 'Родной город', |
9286 | 9289 | 'user-profile-personal-birthday' => 'День рождения', |
9287 | 9290 | 'user-profile-personal-birthdate' => 'Дата (ММ/ДД)', |
| 9291 | + 'user-profile-personal-birthdate-with-year' => 'Дата (ММ/ДД/ГГГГ)', |
9288 | 9292 | 'user-profile-personal-aboutme' => 'Обо мне', |
9289 | 9293 | 'user-profile-personal-work' => 'Работа', |
9290 | 9294 | 'user-profile-personal-occupation' => 'Занятие', |
— | — | @@ -9309,6 +9313,8 @@ |
9310 | 9314 | 'user-profile-preferences-emails-gift' => 'Когда вы получаете подарок', |
9311 | 9315 | 'user-profile-preferences-emails-level' => 'Когда повышается уровень', |
9312 | 9316 | 'user-profile-preferences-emails-weekly' => 'Получать еженедельные обновления по почте', |
| 9317 | + 'user-profile-preferences-miscellaneous' => 'Разное', |
| 9318 | + 'user-profile-preferences-miscellaneous-show-year-of-birth' => 'Показывать год рождения', |
9313 | 9319 | 'user-profile-update-button' => 'Обновить', |
9314 | 9320 | 'user-profile-tidbits-title' => 'Интересные подробности', |
9315 | 9321 | 'user-profile-tidbits-favmoment' => 'Любимые спортивный момент', |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php |
— | — | @@ -84,6 +84,9 @@ |
85 | 85 | public function getProfile() { |
86 | 86 | global $wgMemc; |
87 | 87 | |
| 88 | + $user = User::newFromId( $this->user_id ); |
| 89 | + $user->loadFromId(); |
| 90 | + |
88 | 91 | // Try cache first |
89 | 92 | $key = wfMemcKey( 'user', 'profile', 'info', $this->user_id ); |
90 | 93 | $data = $wgMemc->get( $key ); |
— | — | @@ -107,13 +110,15 @@ |
108 | 111 | $profile['user_page_type'] = 1; |
109 | 112 | $profile['user_id'] = 0; |
110 | 113 | } |
| 114 | + $showYOB = $user->getIntOption( 'showyearofbirth', !isset( $row->up_birthday ) ) == 1; |
| 115 | + $issetUpBirthday = isset( $row->up_birthday ) ? $row->up_birthday : ''; |
111 | 116 | $profile['location_city'] = isset( $row->up_location_city ) ? $row->up_location_city : ''; |
112 | 117 | $profile['location_state'] = isset( $row->up_location_state ) ? $row->up_location_state : ''; |
113 | 118 | $profile['location_country'] = isset( $row->up_location_country ) ? $row->up_location_country : ''; |
114 | 119 | $profile['hometown_city'] = isset( $row->up_hometown_city ) ? $row->up_hometown_city : ''; |
115 | 120 | $profile['hometown_state'] = isset( $row->up_hometown_state ) ? $row->up_hometown_state : ''; |
116 | 121 | $profile['hometown_country'] = isset( $row->up_hometown_country ) ? $row->up_hometown_country : ''; |
117 | | - $profile['birthday'] = $this->formatBirthday( isset( $row->up_birthday ) ? $row->up_birthday : '' ); |
| 122 | + $profile['birthday'] = $this->formatBirthday( $issetUpBirthday, $showYOB); |
118 | 123 | |
119 | 124 | $profile['about'] = isset( $row->up_about ) ? $row->up_about : ''; |
120 | 125 | $profile['places_lived'] = isset( $row->up_places_lived ) ? $row->up_places_lived : ''; |
— | — | @@ -138,8 +143,6 @@ |
139 | 144 | $wgMemc->set( $key, $profile ); |
140 | 145 | } |
141 | 146 | |
142 | | - $user = User::newFromId( $this->user_id ); |
143 | | - $user->loadFromId(); |
144 | 147 | $profile['real_name'] = $user->getRealName(); |
145 | 148 | $profile['email'] = $user->getEmail(); |
146 | 149 | |
— | — | @@ -152,12 +155,16 @@ |
153 | 156 | * @param $birthday String: birthday in YYYY-MM-DD format |
154 | 157 | * @return String: formatted birthday |
155 | 158 | */ |
156 | | - function formatBirthday( $birthday ) { |
| 159 | + function formatBirthday( $birthday, $showYear = true ) { |
157 | 160 | $dob = explode( '-', $birthday ); |
158 | 161 | if ( count( $dob ) == 3 ) { |
159 | 162 | $month = $dob[1]; |
160 | 163 | $day = $dob[2]; |
161 | | - return date( 'F jS', mktime( 0, 0, 0, $month, $day ) ); |
| 164 | + if ( !$showYear ) { |
| 165 | + return date( 'F jS', mktime( 0, 0, 0, $month, $day ) ); |
| 166 | + } |
| 167 | + $year = $dob[0]; |
| 168 | + return date( 'F jS, Y', mktime( 0, 0, 0, $month, $day, $year ) ); |
162 | 169 | //return $day . ' ' . $wgLang->getMonthNameGen( $month ); |
163 | 170 | } |
164 | 171 | return $birthday; |
Index: trunk/extensions/SocialProfile/UserProfile/UpdateProfile.js |
— | — | @@ -40,4 +40,14 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | document.getElementById( id + '_form' ).innerHTML = section_select; |
44 | | -} |
\ No newline at end of file |
| 44 | +} |
| 45 | + |
| 46 | +mw.loader.using( 'jquery.ui.datepicker', function() { |
| 47 | + jQuery( function( jQuery ) { |
| 48 | + jQuery( '#birthday' ).datepicker({ |
| 49 | + changeYear: true, |
| 50 | + yearRange: '1930:c', |
| 51 | + dateFormat: jQuery( '#birthday' ).hasClass( 'long-birthday' ) ? 'mm/dd/yy' : 'mm/dd' |
| 52 | + }); |
| 53 | + }); |
| 54 | +}); |
\ No newline at end of file |