r85535 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85534‎ | r85535 | r85536 >
Date:13:45, 6 April 2011
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: remove some unused variables and rename some badly named variables in SpecialViewGifts.php
Modified paths:
  • /trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php
@@ -1,9 +1,16 @@
22 <?php
 3+/**
 4+ * Special:ViewGifts -- a special page for viewing the list of user-to-user
 5+ * gifts a given user has received
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ */
310
411 class ViewGifts extends SpecialPage {
512
613 /**
7 - * Constructor
 14+ * Constructor -- set up the new special page
815 */
916 public function __construct() {
1017 parent::__construct( 'ViewGifts' );
@@ -15,12 +22,12 @@
1623 * @param $par Mixed: parameter passed to the page or null
1724 */
1825 public function execute( $par ) {
19 - global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
 26+ global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserGiftsScripts;
2027
2128 $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' );
2229
2330 $user_name = $wgRequest->getVal( 'user' );
24 - $page = $wgRequest->getVal( 'page' );
 31+ $page = $wgRequest->getVal( 'page' );
2532
2633 /**
2734 * Redirect Non-logged in users to Login Page
@@ -33,14 +40,13 @@
3441 }
3542
3643 /**
37 - * If no user is set in the URL, we assume its the current user
 44+ * If no user is set in the URL, we assume it's the current user
3845 */
3946 if ( !$user_name ) {
4047 $user_name = $wgUser->getName();
4148 }
4249 $user_id = User::idFromName( $user_name );
4350 $user = Title::makeTitle( NS_USER, $user_name );
44 - $user_safe = urlencode( $user_name );
4551
4652 /**
4753 * Error message for username that does not exist (from URL)
@@ -68,66 +74,76 @@
6975 $gifts = $rel->getUserGiftList( 0, $per_page, $page );
7076 $total = $rel->getGiftCountByUsername( $user_name );
7177
72 - $relationship = UserRelationship::getUserRelationshipByID( $user_id, $wgUser->getID() );
73 -
7478 /**
7579 * Show gift count for user
7680 */
77 - $output = $wgOut->setPageTitle( wfMsg( 'g-list-title', $rel->user_name ) );
 81+ $wgOut->setPageTitle( wfMsg( 'g-list-title', $rel->user_name ) );
7882
79 - $output .= '<div class="back-links">
80 - <a href="' . $user->getFullURL() . '">'
81 - . wfMsg( 'g-back-link', $rel->user_name ) .
 83+ $output = '<div class="back-links">
 84+ <a href="' . $user->getFullURL() . '">' .
 85+ wfMsg( 'g-back-link', $rel->user_name ) .
8286 '</a>
8387 </div>
84 - <div class="g-count">'
85 - . wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ) .
 88+ <div class="g-count">' .
 89+ wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ) .
8690 '</div>';
8791
8892 if ( $gifts ) {
8993 $x = 1;
9094
9195 // Safe links
92 - $view_gift_link = SpecialPage::getTitleFor( 'ViewGift' );
93 - $give_gift_link = SpecialPage::getTitleFor( 'GiveGift' );
94 - $remove_gift_link = SpecialPage::getTitleFor( 'RemoveGift' );
 96+ $viewGiftLink = SpecialPage::getTitleFor( 'ViewGift' );
 97+ $giveGiftLink = SpecialPage::getTitleFor( 'GiveGift' );
 98+ $removeGiftLink = SpecialPage::getTitleFor( 'RemoveGift' );
9599
96100 foreach ( $gifts as $gift ) {
97101 $giftname_length = strlen( $gift['gift_name'] );
98102 $giftname_space = stripos( $gift['gift_name'], ' ' );
99103
100104 if ( ( $giftname_space == false || $giftname_space >= "30" ) && $giftname_length > 30 ) {
101 - $gift_name_display = substr( $gift['gift_name'], 0, 30 ) . ' ' . substr( $gift['gift_name'], 30, 50 );
 105+ $gift_name_display = substr( $gift['gift_name'], 0, 30 ) .
 106+ ' ' . substr( $gift['gift_name'], 30, 50 );
102107 } else {
103108 $gift_name_display = $gift['gift_name'];
104109 }
105110
106111 $user_from = Title::makeTitle( NS_USER, $gift['user_name_from'] );
107 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />';
 112+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" .
 113+ Gifts::getGiftImage( $gift['gift_id'], 'l' ) .
 114+ '" border="0" alt="" />';
108115
109116 $output .= '<div class="g-item">
110 - <a href="' . $view_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . $gift_image . '</a>
 117+ <a href="' . $viewGiftLink->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' .
 118+ $gift_image .
 119+ '</a>
111120 <div class="g-title">
112 - <a href="' . $view_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . $gift_name_display . '</a>';
 121+ <a href="' . $viewGiftLink->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' .
 122+ $gift_name_display .
 123+ '</a>';
113124 if ( $gift['status'] == 1 ) {
114125 if ( $user_name == $wgUser->getName() ) {
115126 $rel->clearUserGiftStatus( $gift['id'] );
116127 $rel->decNewGiftCount( $wgUser->getID() );
117128 }
118 - $output .= '<span class="g-new">' . wfMsg( 'g-new' ) . '</span>';
 129+ $output .= '<span class="g-new">' .
 130+ wfMsg( 'g-new' ) .
 131+ '</span>';
119132 }
120133 $output .= '</div>';
121134
122 - $output .= '<div class="g-from">'
123 - . wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ) .
 135+ $output .= '<div class="g-from">' .
 136+ wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ) .
124137 '</div>
125138 <div class="g-actions">
126 - <a href="' . $give_gift_link->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . wfMsg( 'g-to-another' ) . '</a>';
 139+ <a href="' . $giveGiftLink->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' .
 140+ wfMsg( 'g-to-another' ) .
 141+ '</a>';
127142 if ( $rel->user_name == $wgUser->getName() ) {
128143 $output .= '&#160;';
129 - $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
 144+ $output .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
130145 $output .= '&#160;';
131 - $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>';
 146+ $output .= '<a href="' . $removeGiftLink->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' .
 147+ wfMsg( 'g-remove-gift' ) . '</a>';
132148 }
133149 $output .= '</div>
134150 <div class="cleared"></div>';
@@ -145,12 +161,13 @@
146162 */
147163 $numofpages = $total / $per_page;
148164
149 - $page_link = SpecialPage::getTitleFor( 'ViewGifts' );
 165+ $pageLink = SpecialPage::getTitleFor( 'ViewGifts' );
150166
151167 if ( $numofpages > 1 ) {
152168 $output .= '<div class="page-nav">';
153169 if ( $page > 1 ) {
154 - $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'g-previous' ) . '</a> ';
 170+ $output .= '<a href="' . $pageLink->escapeFullURL( 'user=' . $user_name . '&page=' . ( $page - 1 ) ) . '">' .
 171+ wfMsg( 'g-previous' ) . '</a> ';
155172 }
156173
157174 if ( ( $total % $per_page ) != 0 ) {
@@ -167,19 +184,17 @@
168185 if ( $i == $page ) {
169186 $output .= ( $i . ' ' );
170187 } else {
171 - $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> ";
 188+ $output .= '<a href="' . $pageLink->escapeFullURL( 'user=' . $user_name . '&page=' . $i ) . "\">$i</a> ";
172189 }
173190 }
174191
175192 if ( ( $total - ( $per_page * $page ) ) > 0 ) {
176 - $output .= ' <a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page + 1 ) ) . '">' . wfMsg( 'g-next' ) . '</a>';
 193+ $output .= ' <a href="' . $pageLink->escapeFullURL( 'user=' . $user_name . '&page=' . ( $page + 1 ) ) . '">' .
 194+ wfMsg( 'g-next' ) . '</a>';
177195 }
178196 $output .= '</div>';
179197 }
180198
181 - /**
182 - * Build next/prev nav
183 - */
184199 $wgOut->addHTML( $output );
185200 }
186201 }

Status & tagging log