r47690 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47689‎ | r47690 | r47691 >
Date:23:06, 22 February 2009
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: create images directory for extension's images and move stuff from UserWelcome/common/ there if we're gonna have UserWelcome as a part of the core SocialProfile package, which wasn't my original intention though. added title_line.gif into repo and changed UserProfile.css not to hotlink it from images.wikia.com but to get it locally. also did some cleanup to UserWelcome.php + made it fetch images from our new dir.
Modified paths:
  • /trunk/extensions/SocialProfile/UserProfile/UserProfile.css (modified) (history)
  • /trunk/extensions/SocialProfile/UserWelcome/UserWelcome.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserWelcome/common (deleted) (history)
  • /trunk/extensions/SocialProfile/images (added) (history)
  • /trunk/extensions/SocialProfile/images/addedFoeIcon.png (added) (history)
  • /trunk/extensions/SocialProfile/images/addedFriendIcon.png (added) (history)
  • /trunk/extensions/SocialProfile/images/awardIcon.png (added) (history)
  • /trunk/extensions/SocialProfile/images/challengeIcon.png (added) (history)
  • /trunk/extensions/SocialProfile/images/editIcon.gif (added) (history)
  • /trunk/extensions/SocialProfile/images/emailIcon.gif (added) (history)
  • /trunk/extensions/SocialProfile/images/icon_package_get.gif (added) (history)
  • /trunk/extensions/SocialProfile/images/title_line.gif (added) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserWelcome/UserWelcome.php
@@ -2,9 +2,9 @@
33 /**
44 * UserWelcome extension
55 * Adds <welcomeUser/> tag to display user-specific social information
6 - * Intended to use with SocialProfile extension version 1.3 or later, will fail without it
7 - * or if you have an older version of SocialProfile than 1.3.
86 *
 7+ * @file
 8+ * @ingroup Extensions
99 * @author Wikia, Inc.
1010 * @version 1.0
1111 * @link http://www.mediawiki.org/wiki/Extension:UserWelcome Documentation
@@ -20,17 +20,17 @@
2121
2222 // Extension credits that show up on Special:Version
2323 $wgExtensionCredits['parserhook'][] = array(
24 - 'name' => 'UserWelcome',
25 - 'version' => '1.0.1',
26 - 'description' => 'Adds <tt>&lt;welcomeUser&gt;</tt> tag to display user-specific social info to logged-in users',
 24+ 'name' => 'UserWelcome',
 25+ 'version' => '1.1',
 26+ 'author' => 'Wikia New York Team',
 27+ 'description' => 'Adds <tt>&lt;welcomeUser&gt;</tt> tag to display user-specific social info to logged-in users',
2728 'description-msg' => 'userwelcome-desc',
28 - 'author' => 'Wikia New York Team',
29 - 'url' => 'http://www.mediawiki.org/wiki/Extension:UserWelcome',
 29+ 'url' => 'http://www.mediawiki.org/wiki/Extension:UserWelcome',
3030 );
3131
3232 function wfWelcomeUser() {
33 - global $wgParser;
34 - $wgParser->setHook( 'welcomeUser', 'getWelcomeUser' );
 33+ global $wgParser;
 34+ $wgParser->setHook( 'welcomeUser', 'getWelcomeUser' );
3535 return true;
3636 }
3737
@@ -40,159 +40,154 @@
4141 function getWelcomeUser( $input, $args, $parser ){
4242
4343 $parser->disableCache();
44 - $output = "";
45 - $output .= getWelcome();
 44+ $output = getWelcome();
4645
4746 return $output;
4847 }
4948
5049 function getWelcome(){
51 - global $wgUser, $IP, $wgUploadPath;
52 - wfLoadExtensionMessages('UserWelcome');
 50+ global $wgUser, $wgUploadPath;
 51+ wfLoadExtensionMessages( 'UserWelcome' );
5352
5453 // Get stats and user level
55 - $stats = new UserStats($wgUser->getID(), $wgUser->getName());
 54+ $stats = new UserStats( $wgUser->getID(), $wgUser->getName() );
5655 $stats_data = $stats->getUserStats();
57 - $user_level = new UserLevel($stats_data["points"]);
 56+ $user_level = new UserLevel( $stats_data['points'] );
5857
5958 // Safe links
60 - $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('mp-userlevels-link'));
61 - $avatar_link = Title::makeTitle(NS_SPECIAL, 'UploadAvatar');
62 - $invite_link = Title::makeTitle(NS_SPECIAL, 'InviteContacts');
 59+ $level_link = Title::makeTitle( NS_HELP, wfMsgHtml( 'mp-userlevels-link' ) );
 60+ $avatar_link = Title::makeTitle( NS_SPECIAL, 'UploadAvatar' );
 61+ $invite_link = Title::makeTitle( NS_SPECIAL, 'InviteContacts' );
6362
6463 // Make an avatar
65 - $avatar = new wAvatar($wgUser->getID(), "l");
 64+ $avatar = new wAvatar( $wgUser->getID(), 'l' );
6665
67 - $output = "";
68 -
6966 // Profile top images/points
70 - $output .= "<div class=\"mp-welcome-logged-in\">
71 - <h2>".wfMsg('mp-welcome-logged-in', $wgUser->getName())."</h2>
72 - <div class=\"mp-welcome-image\">
73 - <a href=\"". $wgUser->getUserPage()->escapeFullURL(). "\" rel=\"nofollow\"><img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/></a>";
74 - if( strpos($avatar->getAvatarImage(), 'default_') !== false ) {
75 - $output .= "<div><a href=\"".$avatar_link->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('mp-welcome-upload')."</a></div>";
 67+ $output = '<div class="mp-welcome-logged-in">
 68+ <h2>'.wfMsg( 'mp-welcome-logged-in', $wgUser->getName() ).'</h2>
 69+ <div class="mp-welcome-image">
 70+ <a href="'. $wgUser->getUserPage()->escapeFullURL(). '" rel="nofollow"><img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0"/></a>';
 71+ if( strpos( $avatar->getAvatarImage(), 'default_' ) !== false ) {
 72+ $output .= '<div><a href="'.$avatar_link->escapeFullURL().'" rel="nofollow">'.wfMsg( 'mp-welcome-upload' ).'</a></div>';
7673 } else {
77 - $output .= "<div><a href=\"".$avatar_link->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('mp-welcome-edit')."</a></div>";
 74+ $output .= '<div><a href="'.$avatar_link->escapeFullURL().'" rel="nofollow">'.wfMsg( 'mp-welcome-edit' ).'</a></div>';
7875 }
79 - $output .= "</div>";
 76+ $output .= '</div>';
8077
8178 global $wgUserLevels;
8279 if( $wgUserLevels ){
83 - $output .= "<div class=\"mp-welcome-points\">
84 - <div class=\"points-and-level\">
85 - <div class=\"total-points\">".wfMsgExt( 'mp-welcome-points', array( 'parsemag' ), $stats_data["points"] )."</div>
86 - <div class=\"honorific-level\"><a href=\"".$level_link->escapeFullURL()."\">({$user_level->getLevelName()})</a></div>
 80+ $output .= '<div class="mp-welcome-points">
 81+ <div class="points-and-level">
 82+ <div class="total-points">'.wfMsgExt( 'mp-welcome-points', array( 'parsemag' ), $stats_data['points'] ).'</div>
 83+ <div class="honorific-level"><a href="'.$level_link->escapeFullURL().'">('.$user_level->getLevelName().')</a></div>
8784 </div>
88 - <div class=\"cleared\"></div>
89 - <div class=\"needed-points\">
90 - " . wfMsgExt( 'mp-welcome-needed-points', array( 'parsemag' ), $level_link->escapeFullURL(),
91 - $user_level->getNextLevelName(), $user_level->getPointsNeededToAdvance() ) . "
 85+ <div class="cleared"></div>
 86+ <div class="needed-points">
 87+ ' . wfMsgExt( 'mp-welcome-needed-points', array( 'parsemag' ), $level_link->escapeFullURL(),
 88+ $user_level->getNextLevelName(), $user_level->getPointsNeededToAdvance() ) . '
9289 </div>
93 - </div>";
 90+ </div>';
9491 }
9592
96 - $output .= "<div class=\"cleared\"></div>";
 93+ $output .= '<div class="cleared"></div>';
9794 $output .= getRequests();
98 - $output .= "</div>";
 95+ $output .= '</div>';
9996
10097 return $output;
10198 }
10299
103100 function getRequests(){
104 - wfLoadExtensionMessages('UserWelcome');
 101+ wfLoadExtensionMessages( 'UserWelcome' );
105102
106 - //get requests
 103+ // Get requests
107104 $requests = getNewMessagesLink() . getRelationshipRequestLink() . getNewGiftLink() . getNewSystemGiftLink();
108105
109106 $output = '';
110107 if( $requests ){
111 -
112 - $output .= "<div class=\"mp-requests\">
113 - <h3>".wfMsg('mp-requests-title')."</h3>
114 - <div class=\"mp-requests-message\">
115 - ".wfMsg('mp-requests-message')."
 108+ $output .= '<div class="mp-requests">
 109+ <h3>'.wfMsg( 'mp-requests-title' ).'</h3>
 110+ <div class="mp-requests-message">
 111+ '.wfMsg( 'mp-requests-message' )."
116112 </div>
117113 $requests
118114 </div>";
119 -
120115 }
121116
122117 return $output;
123118 }
124119
125120 function getRelationshipRequestLink(){
126 - global $wgUser, $IP, $wgUploadPath;
127 - wfLoadExtensionMessages('UserWelcome');
128 - require_once("$IP/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php");
129 - $friend_request_count = UserRelationship::getOpenRequestCount($wgUser->getID(), 1);
130 - $foe_request_count = UserRelationship::getOpenRequestCount($wgUser->getID(), 2);
131 - $relationship_request_link = Title::makeTitle(NS_SPECIAL, 'ViewRelationshipRequests');
 121+ global $wgUser, $wgScriptPath;
 122+ wfLoadExtensionMessages( 'UserWelcome' );
 123+ $friend_request_count = UserRelationship::getOpenRequestCount( $wgUser->getID(), 1 );
 124+ $foe_request_count = UserRelationship::getOpenRequestCount( $wgUser->getID(), 2 );
 125+ $relationship_request_link = SpecialPage::getTitleFor( 'ViewRelationshipRequests' );
132126
133 - $rel_title = Title::makeTitle(NS_SPECIAL, 'ViewRelationshipRequests');
134 - $output = "";
 127+ $rel_title = SpecialPage::getTitleFor( 'ViewRelationshipRequests' );
 128+ $output = '';
135129
136130 if( $friend_request_count ){
137 - $output .= "<p>
138 - <img src=\"{$wgUploadPath}/common/addedFriendIcon.png\" alt=\"\" border=\"0\"/>
139 - <a href=\"".$relationship_request_link->escapeFullURL()."\" rel=\"nofollow\">".wfMsgExt('mp-request-new-friend', 'parsemag', $friend_request_count)."</a>
140 - </p>";
 131+ $output .= '<p>
 132+ <img src="'.$wgScriptPath.'/extensions/SocialProfile/images/addedFriendIcon.png" alt="" border="0" />
 133+ <a href="'.$relationship_request_link->escapeFullURL().'" rel="nofollow">'
 134+ .wfMsgExt( 'mp-request-new-friend', 'parsemag', $friend_request_count ).'</a>
 135+ </p>';
141136 }
142137
143138 if( $foe_request_count ){
144 - $output .= "<p>
145 - <img src=\"{$wgUploadPath}/common/addedFoeIcon.png\" alt=\"\" border=\"0\"/>
146 - <a href=\"".$relationship_request_link->escapeFullURL()."\" rel=\"nofollow\">".wfMsgExt('mp-request-new-foe', 'parsemag', $foe_request_count)."</a>
147 - </p>";
148 - }
 139+ $output .= '<p>
 140+ <img src="'.$wgScriptPath.'/extensions/SocialProfile/images/addedFoeIcon.png" alt="" border="0" />
 141+ <a href="'.$relationship_request_link->escapeFullURL().'" rel="nofollow">'
 142+ .wfMsgExt( 'mp-request-new-foe', 'parsemag', $foe_request_count ).'</a>
 143+ </p>';
 144+ }
 145+
149146 return $output;
150147 }
151148
152149 function getNewGiftLink(){
153 - global $wgUser, $IP, $wgUploadPath;
154 - wfLoadExtensionMessages('UserWelcome');
155 - require_once("$IP/extensions/SocialProfile/UserGifts/UserGiftsClass.php");
156 - $gift_count = UserGifts::getNewGiftCount($wgUser->getID());
157 - $gifts_title = Title::makeTitle(NS_SPECIAL, 'ViewGifts');
158 - $output = "";
 150+ global $wgUser, $wgScriptPath;
 151+ wfLoadExtensionMessages( 'UserWelcome' );
 152+ $gift_count = UserGifts::getNewGiftCount( $wgUser->getID() );
 153+ $gifts_title = SpecialPage::getTitleFor( 'ViewGifts' );
 154+ $output = '';
159155 if( $gift_count ){
160 - $output .= "<p>
161 - <img src=\"{$wgUploadPath}/common/icon_package_get.gif\" alt=\"\" border=\"0\"/>
162 - <a href=\"".$gifts_title->escapeFullURL()."\" rel=\"nofollow\">".wfMsgExt('mp-request-new-gift', 'parsemag', $gift_count)."</a>
163 - </p>";
 156+ $output .= '<p>
 157+ <img src="'.$wgScriptPath.'/extensions/SocialProfile/images/icon_package_get.gif" alt="" border="0" />
 158+ <a href="'.$gifts_title->escapeFullURL().'" rel="nofollow">'.wfMsgExt( 'mp-request-new-gift', 'parsemag', $gift_count ).'</a>
 159+ </p>';
164160 }
165161 return $output;
166162 }
167163
168164 function getNewSystemGiftLink(){
169 - global $wgUser, $IP, $wgUploadPath;
170 - wfLoadExtensionMessages('UserWelcome');
171 - require_once("$IP/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php");
172 - $gift_count = UserSystemGifts::getNewSystemGiftCount($wgUser->getID());
173 - $gifts_title = Title::makeTitle(NS_SPECIAL, 'ViewSystemGifts');
174 - $output = "";
 165+ global $wgUser, $wgScriptPath;
 166+ wfLoadExtensionMessages( 'UserWelcome' );
 167+ $gift_count = UserSystemGifts::getNewSystemGiftCount( $wgUser->getID() );
 168+ $gifts_title = SpecialPage::getTitleFor( 'ViewSystemGifts' );
 169+ $output = '';
175170
176171 if( $gift_count ){
177 - $output .= "<p>
178 - <img src=\"{$wgUploadPath}/common/awardIcon.png\" alt=\"\" border=\"0\"/>
179 - <a href=\"".$gifts_title->escapeFullURL()."\" rel=\"nofollow\">".wfMsgExt('mp-request-new-award', 'parsemag', $gift_count)."</a>
180 - </p>";
 172+ $output .= '<p>
 173+ <img src="'.$wgScriptPath.'/extensions/SocialProfile/images/awardIcon.png" alt="" border="0" />
 174+ <a href="'.$gifts_title->escapeFullURL().'" rel="nofollow">'.wfMsgExt( 'mp-request-new-award', 'parsemag', $gift_count ).'</a>
 175+ </p>';
181176 }
182177
183178 return $output;
184179 }
185180
186181 function getNewMessagesLink(){
187 - global $wgUser, $wgUploadPath;
188 - wfLoadExtensionMessages('UserWelcome');
189 - $new_messages = UserBoard::getNewMessageCount($wgUser->getID());
 182+ global $wgUser, $wgScriptPath;
 183+ wfLoadExtensionMessages( 'UserWelcome' );
 184+ $new_messages = UserBoard::getNewMessageCount( $wgUser->getID() );
190185 $output = '';
191186 if( $new_messages ){
192 - $board_link = Title::makeTitle(NS_SPECIAL, 'UserBoard');
193 - $output .= "<p>
194 - <img src=\"{$wgUploadPath}/common/emailIcon.gif\" alt=\"email icon\" border=\"\"/>
195 - <a href=\"".$board_link->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('mp-request-new-message')."</a>
196 - </p>";
 187+ $board_link = SpecialPage::getTitleFor( 'UserBoard' );
 188+ $output .= '<p>
 189+ <img src="'.$wgScriptPath.'/extensions/SocialProfile/images/emailIcon.gif" alt="email icon" border="" />
 190+ <a href="'.$board_link->escapeFullURL().'" rel="nofollow">'.wfMsg( 'mp-request-new-message' ).'</a>
 191+ </p>';
197192 }
198193 return $output;
199194 }
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.css
@@ -10,10 +10,10 @@
1111 visibility: hidden;
1212 }
1313
14 -.clearfix {display: inline-block;}
 14+.clearfix { display: inline-block; }
1515
1616 /* Hides from IE-mac \*/
17 -* html .clearfix {height: 1%;}
 17+* html .clearfix { height: 1%; }
1818 /* End hide from IE-mac */
1919
2020 .firstHeading {
@@ -64,7 +64,7 @@
6565 }
6666
6767 .user-section-heading {
68 - background:url('http://images.wikia.com/common/wikiany/images/title_line.gif?1') repeat-x scroll 0px 80%;
 68+ background:url('../images/title_line.gif') repeat-x scroll 0px 80%;
6969 width:100%;
7070 line-height:22px;
7171 margin:0px 0px 8px 0px;
Index: trunk/extensions/SocialProfile/images/editIcon.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/SocialProfile/images/editIcon.gif
___________________________________________________________________
Name: svn:mime-type
7272 + application/octet-stream
Index: trunk/extensions/SocialProfile/images/emailIcon.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/SocialProfile/images/emailIcon.gif
___________________________________________________________________
Name: svn:mime-type
7373 + application/octet-stream
Index: trunk/extensions/SocialProfile/images/addedFriendIcon.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/SocialProfile/images/addedFriendIcon.png
___________________________________________________________________
Name: svn:mime-type
7474 + image/png
Index: trunk/extensions/SocialProfile/images/icon_package_get.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/SocialProfile/images/icon_package_get.gif
___________________________________________________________________
Name: svn:mime-type
7575 + application/octet-stream
Index: trunk/extensions/SocialProfile/images/addedFoeIcon.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/SocialProfile/images/addedFoeIcon.png
___________________________________________________________________
Name: svn:mime-type
7676 + image/png
Index: trunk/extensions/SocialProfile/images/awardIcon.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/SocialProfile/images/awardIcon.png
___________________________________________________________________
Name: svn:mime-type
7777 + image/png
Index: trunk/extensions/SocialProfile/images/title_line.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/SocialProfile/images/title_line.gif
___________________________________________________________________
Name: svn:mime-type
7878 + application/octet-stream
Index: trunk/extensions/SocialProfile/images/challengeIcon.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/SocialProfile/images/challengeIcon.png
___________________________________________________________________
Name: svn:mime-type
7979 + image/png

Status & tagging log