r92621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92620‎ | r92621 | r92622 >
Date:10:49, 20 July 2011
Author:ashley
Status:ok
Tags:
Comment:
SocialProfile: since we already have a wAvatar object available, use its getAvatarURL() method to build the <img> tag instead of hacky DIY solutions
Modified paths:
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php
@@ -27,7 +27,7 @@
2828 * @param $params Mixed: parameter(s) passed to the page or null
2929 */
3030 public function execute( $params ) {
31 - global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserRelationshipScripts;
 31+ global $wgUser, $wgOut, $wgRequest, $wgUserRelationshipScripts;
3232
3333 // Can't use $this->setHeaders(); here because then it'll set the page
3434 // title to <removerelationship> and we don't want that, we'll be
@@ -105,14 +105,12 @@
106106 }
107107
108108 $avatar = new wAvatar( $this->user_id_to, 'l' );
109 - $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' .
110 - $avatar->getAvatarImage() . '" alt="" border="0" />';
111109
112110 $out = '';
113111 $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
114112
115113 $out .= "<div class=\"relationship-action\">
116 - {$avatar_img}
 114+ {$avatar->getAvatarURL()}
117115 " . $error . "
118116 <div class=\"relationship-buttons\">
119117 <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-main-page' ) . "\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
@@ -132,13 +130,11 @@
133131 }
134132
135133 $avatar = new wAvatar( $this->user_id_to, 'l' );
136 - $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' .
137 - $avatar->getAvatarImage() . '" alt="" border="0" />';
138134
139135 $out = '';
140136 $wgOut->setPageTitle( wfMsg( 'ur-add-error-message-pending-request-title' ) );
141137 $out .= "<div class=\"relationship-action\">
142 - {$avatar_img}
 138+ {$avatar->getAvatarURL()}
143139 " . $error . "
144140 <div class=\"relationship-buttons\">
145141 <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-main-page' ) . "\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
@@ -179,8 +175,6 @@
180176 $rel = $rel->addRelationshipRequest( $this->user_name_to, $this->relationship_type, $wgRequest->getVal( 'message' ) );
181177
182178 $avatar = new wAvatar( $this->user_id_to, 'l' );
183 - $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' .
184 - $avatar->getAvatarImage() . '" alt="" border="0" />';
185179
186180 $out = '';
187181
@@ -193,7 +187,7 @@
194188 }
195189
196190 $out .= "<div class=\"relationship-action\">
197 - {$avatar_img}
 191+ {$avatar->getAvatarURL()}
198192 " . $sent . "
199193 <div class=\"relationship-buttons\">
200194 <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-main-page' ) . "\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
@@ -215,7 +209,7 @@
216210 * @return $form Mixed: HTML code for the form
217211 */
218212 function displayForm() {
219 - global $wgOut, $wgUploadPath;
 213+ global $wgOut;
220214
221215 if ( $this->relationship_type == 1 ) {
222216 $wgOut->setPageTitle( wfMsg( 'ur-add-title-friend', $this->user_name_to ) );
@@ -228,12 +222,10 @@
229223 }
230224
231225 $avatar = new wAvatar( $this->user_id_to, 'l' );
232 - $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' .
233 - $avatar->getAvatarImage() . '" alt="" border="0" />';
234226
235227 $form = "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
236228 <div class=\"relationship-action\">
237 - {$avatar_img}
 229+ {$avatar->getAvatarURL()}
238230 " . $add .
239231 '<div class="cleared"></div>
240232 </div>
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php
@@ -26,7 +26,7 @@
2727 * @param $params Mixed: parameter(s) passed to the page or null
2828 */
2929 public function execute( $params ) {
30 - global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserRelationshipScripts;
 30+ global $wgUser, $wgOut, $wgRequest, $wgUserRelationshipScripts;
3131
3232 // Can't use $this->setHeaders(); here because then it'll set the page
3333 // title to <removerelationship> and we don't want that, we'll be
@@ -65,8 +65,8 @@
6666 $out = '';
6767 if ( $wgUser->getID() == $this->user_id_to ) {
6868 $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
69 - $out .= '<div class="relationship-error-message">'
70 - . wfMsg( 'ur-remove-error-message-remove-yourself' ) .
 69+ $out .= '<div class="relationship-error-message">' .
 70+ wfMsg( 'ur-remove-error-message-remove-yourself' ) .
7171 '</div>
7272 <div>
7373 <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
@@ -129,12 +129,11 @@
130130 $this->relationship_type
131131 );
132132 $avatar = new wAvatar( $this->user_id_to, 'l' );
133 - $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' .
134 - $avatar->getAvatarImage() . '" alt="" border="" />';
135133
136134 $wgOut->setPageTitle( $confirmTitle );
 135+
137136 $out .= "<div class=\"relationship-action\">
138 - {$avatar_img}" .
 137+ {$avatar->getAvatarURL()}" .
139138 $confirmMsg .
140139 "<div class=\"relationship-buttons\">
141140 <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-main-page' ) . "\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
@@ -157,11 +156,9 @@
158157 * @return $form Mixed: HTML code for the form
159158 */
160159 function displayForm() {
161 - global $wgOut, $wgUploadPath;
 160+ global $wgOut;
162161
163162 $avatar = new wAvatar( $this->user_id_to, 'l' );
164 - $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' .
165 - $avatar->getAvatarImage() . '" alt="avatar" />';
166163
167164 if ( $this->relationship_type == 1 ) {
168165 $title = wfMsg( 'ur-remove-relationship-title-friend', $this->user_name_to );
@@ -174,7 +171,7 @@
175172
176173 $form = "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
177174 <div class=\"relationship-action\">
178 - {$avatar_img}" .
 175+ {$avatar->getAvatarURL()}" .
179176 $remove .
180177 '<div class="relationship-buttons">
181178 <input type="hidden" name="user" value="' . addslashes( $this->user_name_to ) . '" />

Follow-up revisions

RevisionCommit summaryAuthorDate
r92622SocialProfile: follow-up to r92621: do the same for UserStatsashley11:07, 20 July 2011
r92623SocialProfile: follow-up to r92621: do the same for UserProfile. Also changed...ashley11:17, 20 July 2011
r92624SocialProfile: follow-up to r92621, r92617: remove DIY avatar code from UserW...ashley11:25, 20 July 2011
r92625SocialPrSocialProfile: follow-up to r92621: remove DIY avatar code from UserG...ashley11:30, 20 July 2011

Status & tagging log