r90832 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90831‎ | r90832 | r90833 >
Date:15:13, 26 June 2011
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: remove some unused variables from SpecialUploadAvatar.php + coding style tweaks
Modified paths:
  • /trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php
@@ -45,7 +45,7 @@
4646 * @param $params Mixed: parameter(s) passed to the page or null
4747 */
4848 public function execute( $params ) {
49 - global $wgRequest, $wgOut, $wgUser, $wgUserProfileScripts;
 49+ global $wgOut, $wgUser, $wgUserProfileScripts;
5050
5151 $wgOut->addExtensionStyle( $wgUserProfileScripts . '/UserProfile.css' );
5252 parent::execute( $params );
@@ -81,30 +81,39 @@
8282 $output = '<h1>' . wfMsg( 'uploadavatar' ) . '</h1>';
8383 $output .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-picture' ) );
8484 $output .= '<div class="profile-info">';
85 - $output .= '<p class="profile-update-title">' . wfMsg( 'user-profile-picture-yourpicture' ) . '</p>';
 85+ $output .= '<p class="profile-update-title">' .
 86+ wfMsg( 'user-profile-picture-yourpicture' ) . '</p>';
8687 $output .= '<p>' . wfMsg( 'user-profile-picture-yourpicturestext' ) . '</p>';
8788
8889 $output .= '<table cellspacing="0" cellpadding="0" style="margin-top:20px;">';
8990 $output .= '<tr>
90 - <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' . wfMsg( 'user-profile-picture-large' ) . '</td>
 91+ <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' .
 92+ wfMsg( 'user-profile-picture-large' ) .
 93+ '</td>
9194 <td style="padding-bottom:20px;">
9295 <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $wgUser->mId . '_l.' . $ext . '?ts=' . rand() . '" alt="" border="0" />
9396 </td>
9497 </tr>';
9598 $output .= '<tr>
96 - <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' . wfMsg( 'user-profile-picture-medlarge' ) . '</td>
 99+ <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' .
 100+ wfMsg( 'user-profile-picture-medlarge' ) .
 101+ '</td>
97102 <td style="padding-bottom:20px;">
98103 <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $wgUser->mId . '_ml.' . $ext . '?ts=' . rand() . '" alt="" border="0" />
99104 </td>
100105 </tr>';
101106 $output .= '<tr>
102 - <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' . wfMsg( 'user-profile-picture-medium' ) . '</td>
 107+ <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' .
 108+ wfMsg( 'user-profile-picture-medium' ) .
 109+ '</td>
103110 <td style="padding-bottom:20px;">
104111 <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $wgUser->mId . '_m.' . $ext . '?ts=' . rand() . '" alt="" border="0" />
105112 </td>
106113 </tr>';
107114 $output .= '<tr>
108 - <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' . wfMsg( 'user-profile-picture-small' ) . '</td>
 115+ <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' .
 116+ wfMsg( 'user-profile-picture-small' ) .
 117+ '</td>
109118 <td style="padding-bottom:20px;">
110119 <img src="' . $wgUploadPath . '/avatars/' . $wgDBname . '_' . $wgUser->mId . '_s.' . $ext . '?ts' . rand() . '" alt="" border="0" />
111120 </td>
@@ -130,35 +139,17 @@
131140 * @return HTML output
132141 */
133142 protected function getUploadForm( $message = '', $sessionKey = '', $hideIgnoreWarning = false ) {
134 - global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest, $wgUseCopyrightUpload;
 143+ global $wgOut, $wgUser, $wgUseCopyrightUpload;
135144
136 - $cols = intval( $wgUser->getOption( 'cols' ) );
137 - $ew = $wgUser->getOption( 'editwidth' );
138 - if ( $ew ) {
139 - $ew = ' style="width:100%"';
140 - } else {
141 - $ew = '';
142 - }
143 -
144 - if ( '' != $message ) {
 145+ if ( $message != '' ) {
145146 $sub = wfMsg( 'uploaderror' );
146147 $wgOut->addHTML( "<h2>{$sub}</h2>\n" .
147148 "<h4 class='error'>{$message}</h4>\n" );
148149 }
149150 $sk = $wgUser->getSkin();
150151
151 - $sourcefilename = wfMsg( 'sourcefilename' );
152 - $destfilename = wfMsg( 'destfilename' );
153 -
154 - $fd = wfMsg( 'filedesc' );
155152 $ulb = wfMsg( 'uploadbtn' );
156153
157 - $iw = wfMsg( 'ignorewarning' );
158 -
159 - $titleObj = SpecialPage::getTitleFor( 'Upload' );
160 - $action = $titleObj->escapeLocalURL();
161 -
162 - $encDestFile = htmlspecialchars( $this->mDesiredDestName );
163154 $source = null;
164155
165156 if ( $wgUseCopyrightUpload ) {
@@ -173,10 +164,6 @@
174165 ";
175166 }
176167
177 - $watchChecked = $wgUser->getOption( 'watchdefault' )
178 - ? 'checked="checked"'
179 - : '';
180 -
181168 $output = '<h1>' . wfMsg( 'uploadavatar' ) . '</h1>';
182169 $output .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-picture' ) );
183170 $output .= '<div class="profile-info">';
@@ -198,8 +185,12 @@
199186 <table border="0">
200187 <tr>
201188 <td>
202 - <p class="profile-update-title">' . wfMsg( 'user-profile-picture-choosepicture' ) . '</p>
203 - <p style="margin-bottom:10px;">' . wfMsg( 'user-profile-picture-picsize' ) . '</p>
 189+ <p class="profile-update-title">' .
 190+ wfMsg( 'user-profile-picture-choosepicture' ) .
 191+ '</p>
 192+ <p style="margin-bottom:10px;">' .
 193+ wfMsg( 'user-profile-picture-picsize' ) .
 194+ '</p>
204195 <input tabindex="1" type="file" name="wpUploadFile" id="wpUploadFile" size="36"/>
205196 </td>
206197 </tr>
@@ -226,9 +217,13 @@
227218 */
228219 function getAvatar( $size ) {
229220 global $wgUser, $wgDBname, $wgUploadDirectory, $wgUploadPath;
230 - $files = glob( $wgUploadDirectory . '/avatars/' . $wgDBname . '_' . $wgUser->getID() . '_' . $size . "*" );
 221+ $files = glob(
 222+ $wgUploadDirectory . '/avatars/' . $wgDBname . '_' .
 223+ $wgUser->getID() . '_' . $size . "*"
 224+ );
231225 if ( isset( $files[0] ) && $files[0] ) {
232 - return "<img src=\"{$wgUploadPath}/avatars/" . basename( $files[0] ) . '" alt="" border="0" />';
 226+ return "<img src=\"{$wgUploadPath}/avatars/" .
 227+ basename( $files[0] ) . '" alt="" border="0" />';
233228 }
234229 }
235230
@@ -280,7 +275,7 @@
281276 * Create the thumbnails and delete old files
282277 */
283278 public function performUpload( $comment, $pageText, $watch, $user ) {
284 - global $wgUploadDirectory, $wgOut, $wgUser, $wgDBname;
 279+ global $wgUploadDirectory, $wgUser, $wgDBname, $wgMemc;
285280
286281 $this->avatarUploadDirectory = $wgUploadDirectory . '/avatars';
287282
@@ -354,7 +349,7 @@
355350 unlink( $this->avatarUploadDirectory . '/' . $wgDBname . '_' . $wgUser->mId . '_ml.png' );
356351 }
357352 }
358 - global $wgMemc;
 353+
359354 $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), 's' );
360355 $data = $wgMemc->delete( $key );
361356

Status & tagging log