r63062 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63061‎ | r63062 | r63063 >
Date:23:09, 27 February 2010
Author:ashley
Status:resolved (Comments)
Tags:
Comment:
SocialProfile: cleanup to UserGifts stuff
Modified paths:
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php
@@ -16,7 +16,7 @@
1717 */
1818 function deleteImage( $id, $size ) {
1919 global $wgUploadDirectory;
20 - $files = glob( $wgUploadDirectory . '/awards/' . $id . "_{$size}*" );
 20+ $files = glob( $wgUploadDirectory . '/awards/' . $id . "_{$size}*" );
2121 if ( $files && $files[0] ) {
2222 $img = basename( $files[0] );
2323 unlink( $wgUploadDirectory . '/awards/' . $img );
@@ -48,11 +48,11 @@
4949 * @param $par Mixed: parameter passed to the page or null
5050 */
5151 public function execute( $par ) {
52 - global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserGiftsScripts;
 52+ global $wgUser, $wgOut, $wgRequest, $wgUserGiftsScripts;
5353 wfLoadExtensionMessages( 'UserGifts' );
5454
5555 // Add CSS
56 - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
 56+ $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' );
5757
5858 // Check for permissions
5959 if ( $wgUser->isAnon() || !$this->canUserManage() ) {
@@ -86,9 +86,9 @@
8787 $out = '<div class="back-links">
8888 <a href="' . SpecialPage::getTitleFor( 'GiftManager' )->escapeFullURL() . '">' . wfMsg( 'g-viewgiftlist' ) . '</a>
8989 </div>
90 - <div class="g-container">
91 - ' . wfMsg( 'g-remove-success-message', $gift['gift_name'] ) . '
92 - <div class="cleared"></div>
 90+ <div class="g-container">'
 91+ . wfMsg( 'g-remove-success-message', $gift['gift_name'] ) .
 92+ '<div class="cleared"></div>
9393 </div>';
9494
9595 $wgOut->addHTML( $out );
@@ -103,7 +103,7 @@
104104 * @return HTML output
105105 */
106106 function displayForm() {
107 - global $wgUser, $wgOut, $wgUploadPath;
 107+ global $wgOut, $wgUploadPath;
108108
109109 $gift = Gifts::getGift( $this->gift_id );
110110
@@ -114,13 +114,13 @@
115115 <a href="' . SpecialPage::getTitleFor( 'GiftManager' )->escapeFullURL() . '">' . wfMsg( 'g-viewgiftlist' ) . '</a>
116116 </div>
117117 <form action="" method="post" enctype="multipart/form-data" name="form1">
118 - <div class="g-remove-message">
119 - ' . wfMsg( 'g-delete-message', $gift['gift_name'] ) . '
 118+ <div class="g-remove-message">'
 119+ . wfMsg( 'g-delete-message', $gift['gift_name'] ) .
 120+ '</div>
 121+ <div class="g-container">'
 122+ . $gift_image .
 123+ '<div class="g-name">' . $gift['gift_name'] . '</div>
120124 </div>
121 - <div class="g-container">
122 - ' . $gift_image . '
123 - <div class="g-name">' . $gift['gift_name'] . '</div>
124 - </div>
125125 <div class="cleared"></div>
126126 <div class="g-buttons">
127127 <input type="button" class="site-button" value="' . wfMsg( 'g-remove' ) . '" size="20" onclick="document.form1.submit()" />
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php
@@ -25,7 +25,7 @@
2626
2727 $usertitle = Title::newFromDBkey( $wgRequest->getVal( 'user' ) );
2828 if ( !$usertitle ) {
29 - $wgOut->addHTML( /*$wgOut->addHTML(*/ $this->displayFormNoUser() /*)*/ );
 29+ $wgOut->addHTML( $this->displayFormNoUser() );
3030 return false;
3131 }
3232
@@ -38,14 +38,14 @@
3939 $wgOut->setPageTitle( wfMsg( 'g-error-title' ) );
4040 $out .= wfMsg( 'g-error-message-to-yourself' );
4141 $wgOut->addHTML( $out );
42 - } else if ( $wgUser->isBlocked() ) {
 42+ } elseif ( $wgUser->isBlocked() ) {
4343 $wgOut->setPageTitle( wfMsg( 'g-error-title' ) );
4444 $out .= wfMsg( 'g-error-message-blocked' );
4545 $wgOut->addHTML( $out );
46 - } else if ( $this->user_id_to == 0 ) {
 46+ } elseif ( $this->user_id_to == 0 ) {
4747 $wgOut->setPageTitle( wfMsg( 'g-error-title' ) );
4848 $wgOut->addHTML( wfMsg( 'g-error-message-no-user' ) );
49 - } else if ( $wgUser->getID() == 0 ) {
 49+ } elseif ( $wgUser->getID() == 0 ) {
5050 $wgOut->setPageTitle( wfMsg( 'g-error-title' ) );
5151 $out .= wfMsg( 'g-error-message-login' );
5252 $wgOut->addHTML( $out );
@@ -57,7 +57,12 @@
5858
5959 $_SESSION['alreadysubmitted'] = true;
6060
61 - $ug_gift_id = $gift->sendGift( $this->user_name_to, $wgRequest->getVal( 'gift_id' ), 0, $wgRequest->getVal( 'message' ) );
 61+ $ug_gift_id = $gift->sendGift(
 62+ $this->user_name_to,
 63+ $wgRequest->getVal( 'gift_id' ),
 64+ 0,
 65+ $wgRequest->getVal( 'message' )
 66+ );
6267
6368 // clear the cache for the user profile gifts for this user
6469 $wgMemc->delete( wfMemcKey( 'user', 'profile', 'gifts', $this->user_id_to ) );
@@ -71,7 +76,9 @@
7277
7378 if ( is_array( $last_unique_gifts ) ) {
7479 foreach ( $last_unique_gifts as $last_unique_gift ) {
75 - if ( $wgRequest->getVal( 'gift_id' ) == $last_unique_gift['gift_id'] ) $found = 0;
 80+ if ( $wgRequest->getVal( 'gift_id' ) == $last_unique_gift['gift_id'] ) {
 81+ $found = 0;
 82+ }
7683 }
7784 }
7885
@@ -83,7 +90,9 @@
8491 );
8592
8693 // remove oldest value
87 - if ( count( $last_unique_gifts ) > 4 ) array_shift( $last_unique_gifts );
 94+ if ( count( $last_unique_gifts ) > 4 ) {
 95+ array_shift( $last_unique_gifts );
 96+ }
8897
8998 // reset the cache
9099 $wgMemc->set( $key, $last_unique_gifts );
@@ -97,12 +106,12 @@
98107 $output .= '<div class="back-links">
99108 <a href="' . $user_title->escapeFullURL() . '">' . wfMsg( 'g-back-link', $this->user_name_to ) . '</a>
100109 </div>
101 - <div class="g-message">
102 - ' . wfMsg( 'g-sent-message', $this->user_name_to ) . '
103 - </div>
104 - <div class="g-container">
105 - ' . $gift_image . '
106 - <div class="g-title">' . $sent_gift['name'] . '</div>';
 110+ <div class="g-message">'
 111+ . wfMsg( 'g-sent-message', $this->user_name_to ) .
 112+ '</div>
 113+ <div class="g-container">'
 114+ . $gift_image .
 115+ '<div class="g-title">' . $sent_gift['name'] . '</div>';
107116 if ( $sent_gift['message'] ) {
108117 $output .= '<div class="g-user-message">' . $sent_gift['message'] . '</div>';
109118 }
@@ -153,15 +162,15 @@
154163
155164 $wgOut->setPageTitle( wfMsg( 'g-give-to-user-title', $gift['gift_name'], $this->user_name_to ) );
156165
157 - $gift_image = "<img id=\"gift_image_{$gift['gift_id']}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . "\" border=\"0\" alt=\"\"/>";
 166+ $gift_image = "<img id=\"gift_image_{$gift['gift_id']}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />';
158167
159168 $output = '<form action="" method="post" enctype="multipart/form-data" name="gift">
160 - <div class="g-message">
161 - ' . wfMsg( 'g-give-to-user-message', $this->user_name_to, $give_gift_link->escapeFullURL( 'user=' . $this->user_name_to ) ) . "
162 - </div>
163 - <div id=\"give_gift_{$gift["gift_id"]}\" class=\"g-container\">
 169+ <div class="g-message">'
 170+ . wfMsg( 'g-give-to-user-message', $this->user_name_to, $give_gift_link->escapeFullURL( 'user=' . $this->user_name_to ) ) .
 171+ "</div>
 172+ <div id=\"give_gift_{$gift['gift_id']}\" class=\"g-container\">
164173 {$gift_image}
165 - <div class=\"g-title\">{$gift["gift_name"]}</div>";
 174+ <div class=\"g-title\">{$gift['gift_name']}</div>";
166175 if ( $gift['gift_description'] ) {
167176 $output .= '<div class="g-describe">' . $gift['gift_description'] . '</div>';
168177 }
@@ -186,7 +195,7 @@
187196 $output = $wgOut->setPageTitle( wfMsg( 'g-give-no-user-title' ) );
188197
189198 $output .= '<form action="" method="get" enctype="multipart/form-data" name="gift">
190 - <input type="hidden" name="title" value="' . $wgRequest->getVal( 'title' ) . '">
 199+ <input type="hidden" name="title" value="' . $wgRequest->getVal( 'title' ) . '" />
191200 <div class="g-message">' . wfMsg( 'g-give-no-user-message' ) . '</div>
192201 <div class="g-give-container">';
193202
@@ -198,7 +207,7 @@
199208 $output .= '<div class="g-give-title">' . wfMsg( 'g-give-list-friends-title' ) . '</div>
200209 <div class="g-gift-select">
201210 <select onchange="javascript:chooseFriend(this.value)">
202 - <option value="#" selected>' . wfMsg( 'g-select-a-friend' ) . '</option>';
 211+ <option value="#" selected="selected">' . wfMsg( 'g-select-a-friend' ) . '</option>';
203212 foreach ( $friends as $friend ) {
204213 $output .= '<option value="' . urlencode( $friend['user_name'] ) . '">' . $friend['user_name'] . '</option>';
205214 }
@@ -210,8 +219,8 @@
211220
212221 $output .= '<div class="g-give-title">' . wfMsg( 'g-give-enter-friend-title' ) . '</div>
213222 <div class="g-give-textbox">
214 - <input type="text" width="85" name="user" value="">
215 - <input class="site-button" type="button" value="' . wfMsg( 'g-give-gift' ) . '" onclick="document.gift.submit()">
 223+ <input type="text" width="85" name="user" value="" />
 224+ <input class="site-button" type="button" value="' . wfMsg( 'g-give-gift' ) . '" onclick="document.gift.submit()" />
216225 </div>
217226 </div>
218227 </form>';
@@ -224,18 +233,21 @@
225234 $user = Title::makeTitle( NS_USER, $this->user_name_to );
226235
227236 $page = $wgRequest->getVal( 'page' );
228 - if ( !$page || !is_numeric( $page ) ) $page = 1;
 237+ if ( !$page || !is_numeric( $page ) ) {
 238+ $page = 1;
 239+ }
229240
230241 $per_page = 24;
231242 $per_row = $wgGiveGiftPerRow;
232 - if ( !$per_row ) $per_row = 3;
 243+ if ( !$per_row ) {
 244+ $per_row = 3;
 245+ }
233246
234247 $total = Gifts::getGiftCount();
235248 $gifts = Gifts::getGiftList( $per_page, $page, 'gift_name' );
236249 $output = '';
237250
238251 if ( $gifts ) {
239 -
240252 $wgOut->setPageTitle( wfMsg( 'g-give-all-title', $this->user_name_to ) );
241253
242254 $output .= '<div class="back-links">
@@ -249,16 +261,19 @@
250262 $x = 1;
251263
252264 foreach ( $gifts as $gift ) {
 265+ $gift_image = "<img id=\"gift_image_{$gift['id']}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['id'], 'l' ) . '" border="0" alt="" />';
253266
254 - $gift_image = "<img id=\"gift_image_{$gift["id"]}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['id'], 'l' ) . "\" border=\"0\" alt=\"\" />";
255 -
256 - $output .= "<div onclick=\"selectGift({$gift["id"]})\" onmouseover=\"highlightGift({$gift["id"]})\" onmouseout=\"unHighlightGift({$gift["id"]})\" id=\"give_gift_{$gift["id"]}\" class=\"g-give-all\">
 267+ $output .= "<div onclick=\"selectGift({$gift['id']})\" onmouseover=\"highlightGift({$gift['id']})\" onmouseout=\"unHighlightGift({$gift['id']})\" id=\"give_gift_{$gift['id']}\" class=\"g-give-all\">
257268 {$gift_image}
258 - <div class=\"g-title g-blue\">{$gift["gift_name"]}</div>";
259 - if ( $gift['gift_description'] ) $output .= "<div class=\"g-describe\">{$gift["gift_description"]}</div>";
 269+ <div class=\"g-title g-blue\">{$gift['gift_name']}</div>";
 270+ if ( $gift['gift_description'] ) {
 271+ $output .= "<div class=\"g-describe\">{$gift['gift_description']}</div>";
 272+ }
260273 $output .= '<div class="cleared"></div>
261274 </div>';
262 - if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) $output .= '<div class="cleared"></div>';
 275+ if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) {
 276+ $output .= '<div class="cleared"></div>';
 277+ }
263278 $x++;
264279 }
265280
@@ -275,13 +290,17 @@
276291 $output .= '<a href="' . $give_gift_link->escapeFullURL( 'user=' . $user_safe . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'g-previous' ) . '</a> ';
277292 }
278293
279 - if ( ( $total % $per_page ) != 0 ) $numofpages++;
280 - if ( $numofpages >= 9 ) $numofpages = 9 + $page;
 294+ if ( ( $total % $per_page ) != 0 ) {
 295+ $numofpages++;
 296+ }
 297+ if ( $numofpages >= 9 ) {
 298+ $numofpages = 9 + $page;
 299+ }
281300 for ( $i = 1; $i <= $numofpages; $i++ ) {
282301 if ( $i == $page ) {
283 - $output .= ( $i . " " );
 302+ $output .= ( $i . ' ' );
284303 } else {
285 - $output .= "<a href=\"" . $give_gift_link->escapeFullURL( 'user=' . $user_safe . '&page=' . $i ) . "\">$i</a> ";
 304+ $output .= '<a href="' . $give_gift_link->escapeFullURL( 'user=' . $user_safe . '&page=' . $i ) . "\">$i</a> ";
286305 }
287306 }
288307
Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php
@@ -18,7 +18,7 @@
1919 global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserGiftsScripts;
2020 wfLoadExtensionMessages( 'UserGifts' );
2121
22 - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
 22+ $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' );
2323
2424 $user_name = ''; // Prevent E_NOTICE
2525
@@ -41,7 +41,6 @@
4242 $dbr = wfGetDB( DB_SLAVE );
4343
4444 if ( $gift ) {
45 -
4645 if ( $gift['status'] == 1 ) {
4746 if ( $gift['user_name_to'] == $wgUser->getName() ) {
4847 $g = new UserGifts( $gift['user_name_to'] );
@@ -50,11 +49,19 @@
5150 }
5251 }
5352
54 - $res = $dbr->select( 'user_gift',
 53+ $res = $dbr->select(
 54+ 'user_gift',
5555 array( 'DISTINCT ug_user_name_to', 'ug_user_id_to', 'ug_date' ),
56 - array( 'ug_gift_id' => $gift['gift_id'], "ug_user_name_to<>'" . addslashes( $gift['user_name_to'] ) . "'" ),
 56+ array(
 57+ 'ug_gift_id' => $gift['gift_id'],
 58+ "ug_user_name_to<>'" . addslashes( $gift['user_name_to'] ) . "'"
 59+ ),
5760 __METHOD__,
58 - array( 'GROUP BY' => 'ug_user_name_to', 'ORDER BY' => 'ug_date DESC', 'LIMIT' => 6 )
 61+ array(
 62+ 'GROUP BY' => 'ug_user_name_to',
 63+ 'ORDER BY' => 'ug_date DESC',
 64+ 'LIMIT' => 6
 65+ )
5966 );
6067
6168 $output = $wgOut->setPageTitle( wfMsgExt( 'g-description-title', 'parsemag', $gift['user_name_to'], $gift['name'] ) );
@@ -78,42 +85,41 @@
7986
8087 $gift_image = '<img src="' . $wgUploadPath . '/awards/' . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />';
8188
82 - $output .= '<div class="g-description">'
83 - . $gift_image . '
84 - <div class="g-name">' . $gift['name'] . '</div>
 89+ $output .= '<div class="g-description">'
 90+ . $gift_image .
 91+ '<div class="g-name">' . $gift['name'] . '</div>
8592 <div class="g-timestamp">(' . $gift['timestamp'] . ')</div>
8693 <div class="g-from">' . wfMsg( 'g-from', $user->escapeFullURL(), $gift['user_name_from'] ) . '</div>';
87 - if ( $message ) {
88 - $output .= '<div class="g-user-message">' . $message . '</div>';
89 - }
90 - $output .= '<div class="cleared"></div>
 94+ if ( $message ) {
 95+ $output .= '<div class="g-user-message">' . $message . '</div>';
 96+ }
 97+ $output .= '<div class="cleared"></div>
9198 <div class="g-describe">' . $gift['description'] . '</div>
9299 <div class="g-actions">
93100 <a href="' . $give_gift_link->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . wfMsg( 'g-to-another' ) . '</a>';
94 - if ( $gift['user_name_to'] == $wgUser->getName() ) {
95 - $output .= '&nbsp';
96 - $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
97 - $output .= '&nbsp;';
98 - $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>';
99 - }
100 - $output .= '</div>
 101+ if ( $gift['user_name_to'] == $wgUser->getName() ) {
 102+ $output .= '&nbsp';
 103+ $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
 104+ $output .= '&nbsp;';
 105+ $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>';
 106+ }
 107+ $output .= '</div>
101108 </div>';
102109
103 - $output .= '<div class="g-recent">
 110+ $output .= '<div class="g-recent">
104111 <div class="g-recent-title">' . wfMsg( 'g-recent-recipients' ) . '</div>
105112 <div class="g-gift-count">' . wfMsgExt( 'g-given', 'parsemag', $gift['gift_count'] ) . '</div>';
106113
107 - while ( $row = $dbr->fetchObject( $res ) ) {
 114+ foreach ( $res as $row ) {
 115+ $user_to_id = $row->ug_user_id_to;
 116+ $avatar = new wAvatar( $user_to_id, 'ml' );
 117+ $user_name_link = Title::makeTitle( NS_USER, $row->ug_user_name_to );
108118
109 - $user_to_id = $row->ug_user_id_to;
110 - $avatar = new wAvatar( $user_to_id, 'ml' );
111 - $user_name_link = Title::makeTitle( NS_USER, $row->ug_user_name_to );
112 -
113 - $output .= "<a href=\"" . $user_name_link->escapeFullURL() . "\">
114 - {$avatar->getAvatarURL()}
115 - </a>";
116 - }
117 - $output .= '<div class="cleared"></div>
 119+ $output .= '<a href="' . $user_name_link->escapeFullURL() . "\">
 120+ {$avatar->getAvatarURL()}
 121+ </a>";
 122+ }
 123+ $output .= '<div class="cleared"></div>
118124 </div>
119125 </div>';
120126
Index: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php
@@ -18,7 +18,7 @@
1919 global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
2020 wfLoadExtensionMessages( 'UserGifts' );
2121
22 - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
 22+ $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' );
2323
2424 $this->gift_id = $wgRequest->getVal( 'gift_id' );
2525 $rel = new UserGifts( $wgUser->getName() );
@@ -36,7 +36,6 @@
3737
3838 $gift = $rel->getUserGift( $this->gift_id );
3939 if ( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) {
40 -
4140 $_SESSION['alreadysubmitted'] = true;
4241
4342 $user_page_link = Title::makeTitle( NS_USER, $wgUser->getName() );
@@ -53,9 +52,9 @@
5453 $out = '<div class="back-links">
5554 <a href="' . $wgUser->getUserPage()->escapeFullURL() . '">' . wfMsg( 'g-back-link', $gift['user_name_to'] ) . '</a>
5655 </div>
57 - <div class="g-container">
58 - ' . $gift_image . wfMsg( 'g-remove-success-message', $gift['name'] ) . '
59 - <div class="cleared"></div>
 56+ <div class="g-container">'
 57+ . $gift_image . wfMsg( 'g-remove-success-message', $gift['name'] ) .
 58+ '<div class="cleared"></div>
6059 </div>
6160 <div class="g-buttons">
6261 <input type="button" class="site-button" value="' . wfMsg( 'g-main-page' ) . '" size="20" onclick="window.location=\'index.php?title=' . wfMsgForContent( 'mainpage' ) . '\'" />
@@ -86,17 +85,17 @@
8786 <a href="' . $wgUser->getUserPage()->escapeFullURL() . '">' . wfMsg( 'g-back-link', $gift['user_name_to'] ) . '</a>
8887 </div>
8988 <form action="" method="post" enctype="multipart/form-data" name="form1">
90 - <div class="g-remove-message">
91 - ' . wfMsg( 'g-remove-message', $gift['name'] ) . '
92 - </div>
93 - <div class="g-container">
94 - ' . $gift_image . '
95 - <div class="g-name">' . $gift['name'] . '</div>
 89+ <div class="g-remove-message">'
 90+ . wfMsg( 'g-remove-message', $gift['name'] ) .
 91+ '</div>
 92+ <div class="g-container">'
 93+ . $gift_image .
 94+ '<div class="g-name">' . $gift['name'] . '</div>
9695 <div class="g-from">' . wfMsg( 'g-from', $user->escapeFullURL(), $gift['user_name_from'] ) . '</div>';
97 - if ( $gift['message'] ) {
98 - $output .= '<div class="g-user-message">' . $gift['message'] . '</div>';
99 - }
100 - $output .= '</div>
 96+ if ( $gift['message'] ) {
 97+ $output .= '<div class="g-user-message">' . $gift['message'] . '</div>';
 98+ }
 99+ $output .= '</div>
101100 <div class="cleared"></div>
102101 <div class="g-buttons">
103102 <input type="hidden" name="user" value="' . addslashes( $gift['user_name_from'] ) . '">
Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php
@@ -18,7 +18,7 @@
1919 global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
2020 wfLoadExtensionMessages( 'UserGifts' );
2121
22 - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
 22+ $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' );
2323
2424 $user_name = $wgRequest->getVal( 'user' );
2525 $page = $wgRequest->getVal( 'page' );
@@ -28,7 +28,7 @@
2929 * It will automatically return them to the ViewGifts page
3030 */
3131 if ( $wgUser->getID() == 0 && $user_name == '' ) {
32 - $login = SpecialPage::getTitleFor( 'UserLogin' );
 32+ $login = SpecialPage::getTitleFor( 'Userlogin' );
3333 $wgOut->redirect( $login->escapeFullURL( 'returnto=Special:ViewGifts' ) );
3434 return false;
3535 }
@@ -36,7 +36,9 @@
3737 /**
3838 * If no user is set in the URL, we assume its the current user
3939 */
40 - if ( !$user_name ) $user_name = $wgUser->getName();
 40+ if ( !$user_name ) {
 41+ $user_name = $wgUser->getName();
 42+ }
4143 $user_id = User::idFromName( $user_name );
4244 $user = Title::makeTitle( NS_USER, $user_name );
4345 $user_safe = urlencode( $user_name );
@@ -54,16 +56,18 @@
5557 * Config for the page
5658 */
5759 $per_page = 10;
58 - if ( !$page || !is_numeric( $page ) ) $page = 1;
 60+ if ( !$page || !is_numeric( $page ) ) {
 61+ $page = 1;
 62+ }
5963 $per_row = 2;
6064
6165 /**
62 - * Get all Gifts for this user into the array
 66+ * Get all gifts for this user into the array
6367 */
6468 $rel = new UserGifts( $user_name );
6569
6670 $gifts = $rel->getUserGiftList( 0, $per_page, $page );
67 - $total = $rel->getGiftCountByUsername( $user_name ); // count($relationships);
 71+ $total = $rel->getGiftCountByUsername( $user_name );
6872
6973 $relationship = UserRelationship::getUserRelationshipByID( $user_id, $wgUser->getID() );
7074
@@ -72,15 +76,16 @@
7377 */
7478 $output = $wgOut->setPageTitle( wfMsg( 'g-list-title', $rel->user_name ) );
7579
76 - $output .= '<div class="back-links"><a href="' . $user->getFullURL() . '">
77 - ' . wfMsg( 'g-back-link', $rel->user_name ) . '</a>
 80+ $output .= '<div class="back-links">
 81+ <a href="' . $user->getFullURL() . '">'
 82+ . wfMsg( 'g-back-link', $rel->user_name ) .
 83+ '</a>
7884 </div>
79 - <div class="g-count">
80 - ' . wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ) . '
81 - </div>';
 85+ <div class="g-count">'
 86+ . wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ) .
 87+ '</div>';
8288
8389 if ( $gifts ) {
84 -
8590 $x = 1;
8691
8792 // Safe links
@@ -89,47 +94,48 @@
9095 $remove_gift_link = SpecialPage::getTitleFor( 'RemoveGift' );
9196
9297 foreach ( $gifts as $gift ) {
93 -
9498 $giftname_length = strlen( $gift['gift_name'] );
9599 $giftname_space = stripos( $gift['gift_name'], ' ' );
96100
97101 if ( ( $giftname_space == false || $giftname_space >= "30" ) && $giftname_length > 30 ) {
98 - $gift_name_display = substr( $gift['gift_name'], 0, 30 ) . " " . substr( $gift['gift_name'], 30, 50 );
 102+ $gift_name_display = substr( $gift['gift_name'], 0, 30 ) . ' ' . substr( $gift['gift_name'], 30, 50 );
99103 } else {
100104 $gift_name_display = $gift['gift_name'];
101 - } ;
 105+ }
102106
103107 $user_from = Title::makeTitle( NS_USER, $gift['user_name_from'] );
104 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . "\" border=\"0\" alt=\"\"/>";
 108+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />';
105109
106110 $output .= '<div class="g-item">
107111 <a href="' . $view_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . $gift_image . '</a>
108112 <div class="g-title">
109113 <a href="' . $view_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . $gift_name_display . '</a>';
110 - if ( $gift['status'] == 1 ) {
111 - if ( $user_name == $wgUser->getName() ) {
112 - $rel->clearUserGiftStatus( $gift['id'] );
113 - $rel->decNewGiftCount( $wgUser->getID() );
114 - }
115 - $output .= '<span class="g-new">' . wfMsg( 'g-new' ) . '</span>';
116 - }
117 - $output .= '</div>';
 114+ if ( $gift['status'] == 1 ) {
 115+ if ( $user_name == $wgUser->getName() ) {
 116+ $rel->clearUserGiftStatus( $gift['id'] );
 117+ $rel->decNewGiftCount( $wgUser->getID() );
 118+ }
 119+ $output .= '<span class="g-new">' . wfMsg( 'g-new' ) . '</span>';
 120+ }
 121+ $output .= '</div>';
118122
119 - $output .= '<div class="g-from">
120 - ' . wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ) . '
121 - </div>
 123+ $output .= '<div class="g-from">'
 124+ . wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ) .
 125+ '</div>
122126 <div class="g-actions">
123127 <a href="' . $give_gift_link->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . wfMsg( 'g-to-another' ) . '</a>';
124 - if ( $rel->user_name == $wgUser->getName() ) {
125 - $output .= '&nbsp;';
126 - $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
127 - $output .= '&nbsp;';
128 - $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>';
129 - }
 128+ if ( $rel->user_name == $wgUser->getName() ) {
 129+ $output .= '&nbsp;';
 130+ $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
 131+ $output .= '&nbsp;';
 132+ $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>';
 133+ }
130134 $output .= '</div>
131135 <div class="cleared"></div>';
132136 $output .= '</div>';
133 - if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) $output .= '<div class="cleared"></div>';
 137+ if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) {
 138+ $output .= '<div class="cleared"></div>';
 139+ }
134140
135141 $x++;
136142 }
@@ -148,15 +154,21 @@
149155 $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'g-previous' ) . '</a> ';
150156 }
151157
152 - if ( ( $total % $per_page ) != 0 ) $numofpages++;
153 - if ( $numofpages >= 9 && $page < $total ) $numofpages = 9 + $page;
154 - if ( $numofpages >= ( $total / $per_page ) ) $numofpages = ( $total / $per_page ) + 1;
 158+ if ( ( $total % $per_page ) != 0 ) {
 159+ $numofpages++;
 160+ }
 161+ if ( $numofpages >= 9 && $page < $total ) {
 162+ $numofpages = 9 + $page;
 163+ }
 164+ if ( $numofpages >= ( $total / $per_page ) ) {
 165+ $numofpages = ( $total / $per_page ) + 1;
 166+ }
155167
156168 for ( $i = 1; $i <= $numofpages; $i++ ) {
157169 if ( $i == $page ) {
158 - $output .= ( $i . " " );
 170+ $output .= ( $i . ' ' );
159171 } else {
160 - $output .= "<a href=\"" . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> ";
 172+ $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> ";
161173 }
162174 }
163175

Follow-up revisions

RevisionCommit summaryAuthorDate
r77028SocialProfile: follow-up to r63062 - define $out as per code review (thanks M...ashley20:06, 19 November 2010

Comments

#Comment by MarkAHershberger (talk | contribs)   01:49, 19 November 2010

In SpecialGiveGift.php there are several:

$out .= wfMsg( ... )

but $out is never given an initial value so this results in "Undefined variable: out" when running under E_STRICT. I even went looking for an earlier revision where $out would have a value (so I could see where this changed) but it looks like it haa been there forever.

#Comment by Jack Phoenix (talk | contribs)   20:06, 19 November 2010

Good catch, thanks for spotting that! I've fixed it in r77028.

Status & tagging log