r85267 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85266‎ | r85267 | r85268 >
Date:18:00, 3 April 2011
Author:ashley
Status:deferred (Comments)
Tags:
Comment:
SocialProfile: converted one raw HTML usage to the [[wiki link syntax]] in UserBoard + general cleanup to SpecialSendBoardBlast.php
Modified paths:
  • /trunk/extensions/SocialProfile/UserBoard/SpecialSendBoardBlast.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoard.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserBoard/UserBoard.i18n.php
@@ -9,13 +9,13 @@
1010 $messages = array();
1111
1212 /** English
13 - * @author Wikia, Inc.
 13+ * @author Aaron Wright
 14+ * @author David Pean
1415 * @author Purodha
1516 */
1617 $messages['en'] = array(
1718 'boardblastlogintitle' => 'You must be logged in to send board blasts',
18 - 'boardblastlogintext' => 'In order to send board blasts,
19 -you must be <a href="index.php?title=Special:UserLogin">logged in</a>.',
 19+ 'boardblastlogintext' => 'In order to send board blasts, you must be [[Special:UserLogin|logged in]].',
2020 'messagesenttitle' => 'Messages sent',
2121 'boardblasttitle' => 'Send board blast',
2222 'boardblaststep1' => 'Step 1 - Write your message',
Index: trunk/extensions/SocialProfile/UserBoard/SpecialSendBoardBlast.php
@@ -1,6 +1,7 @@
22 <?php
33 /**
4 - * A special page to allow users to send a mass board message by selecting from a list of their friends and foes
 4+ * A special page to allow users to send a mass board message by selecting from
 5+ * a list of their friends and foes
56 *
67 * @file
78 * @ingroup Extensions
@@ -35,7 +36,7 @@
3637 // This feature is available only to logged-in users.
3738 if ( !$wgUser->isLoggedIn() ) {
3839 $wgOut->setPageTitle( wfMsg( 'boardblastlogintitle' ) );
39 - $output = wfMsg( 'boardblastlogintext' );
 40+ $output = wfMsgExt( 'boardblastlogintext', 'parse' );
4041 $wgOut->addHTML( $output );
4142 return '';
4243 }
@@ -50,7 +51,14 @@
5152 $user = User::newFromId( $user_id );
5253 $user->loadFromId();
5354 $user_name = $user->getName();
54 - $b->sendBoardMessage( $wgUser->getID(), $wgUser->getName(), $user_id, $user_name, $wgRequest->getVal( 'message' ), 1 );
 55+ $b->sendBoardMessage(
 56+ $wgUser->getID(),
 57+ $wgUser->getName(),
 58+ $user_id,
 59+ $user_name,
 60+ $wgRequest->getVal( 'message' ),
 61+ 1
 62+ );
5563 $count++;
5664 }
5765 $output .= wfMsg( 'messagesentsuccess' );
@@ -70,9 +78,9 @@
7179
7280 $stats = new UserStats( $wgUser->getID(), $wgUser->getName() );
7381 $stats_data = $stats->getUserStats();
 82+ $friendCount = $stats_data['friend_count'];
 83+ $foeCount = $stats_data['foe_count'];
7484
75 -
76 -
7785 $output = '<div class="board-blast-message-form">
7886 <h2>' . wfMsg( 'boardblaststep1' ) . '</h2>
7987 <form method="post" name="blast" action="">
@@ -89,16 +97,16 @@
9098 <a href="javascript:void(0);" onclick="javascript:select_all()">' . wfMsg( 'boardlinkselectall' ) . '</a> -
9199 <a href="javascript:void(0);" onclick="javascript:unselect_all()">' . wfMsg( 'boardlinkunselectall' ) . '</a> ';
92100
93 - if ( $stats_data['friend_count'] > 0 && $stats_data['foe_count'] > 0 ) {
94 - $output .= '- <a href="javascript:void(0);" onclick="javascript:toggle_friends(1)">' . wfMsg( 'boardlinkselectfriends' ) . '</a> -';
95 - $output .= '<a href="javascript:void(0);" onclick="javascript:toggle_friends(0)">' . wfMsg( 'boardlinkunselectfriends' ) . '</a>';
96 - }
 101+ if ( $friendCount > 0 && $foeCount > 0 ) {
 102+ $output .= '- <a href="javascript:void(0);" onclick="javascript:toggle_friends(1)">' . wfMsg( 'boardlinkselectfriends' ) . '</a> -';
 103+ $output .= '<a href="javascript:void(0);" onclick="javascript:toggle_friends(0)">' . wfMsg( 'boardlinkunselectfriends' ) . '</a>';
 104+ }
97105
98 - if ( $stats_data['foe_count'] > 0 && $stats_data['friend_count'] > 0 ) {
99 - $output .= '- <a href="javascript:void(0);" onclick="javascript:toggle_foes(1)">' . wfMsg( 'boardlinkselectfoes' ) . '</a> -';
100 - $output .= '<a href="javascript:void(0);" onclick="javascript:toggle_foes(0)">' . wfMsg( 'boardlinkunselectfoes' ) . '</a>';
101 - }
102 - $output .= '</div>
 106+ if ( $foeCount > 0 && $friendCount > 0 ) {
 107+ $output .= '- <a href="javascript:void(0);" onclick="javascript:toggle_foes(1)">' . wfMsg( 'boardlinkselectfoes' ) . '</a> -';
 108+ $output .= '<a href="javascript:void(0);" onclick="javascript:toggle_foes(0)">' . wfMsg( 'boardlinkunselectfoes' ) . '</a>';
 109+ }
 110+ $output .= '</div>
103111 </div>';
104112
105113 $rel = new UserRelationship( $wgUser->getName() );
@@ -110,7 +118,13 @@
111119 $per_row = 3;
112120 if ( count( $relationships ) > 0 ) {
113121 foreach ( $relationships as $relationship ) {
114 - $output .= '<div class="blast-' . ( ( $relationship['type'] == 1 ) ? 'friend' : 'foe' ) . "-unselected\" id=\"user-{$relationship['user_id']}\" onclick=\"javascript:toggle_user({$relationship['user_id']})\">
 122+ if ( $relationship['type'] == 1 ) {
 123+ $class = 'friend';
 124+ } else {
 125+ $class = 'foe';
 126+ }
 127+ $id = $relationship['user_id'];
 128+ $output .= '<div class="blast-' . $class . "-unselected\" id=\"user-{$id}\" onclick=\"javascript:toggle_user({$id})\">
115129 {$relationship['user_name']}
116130 </div>";
117131 if ( $x == count( $relationships ) || $x != 1 && $x % $per_row == 0 ) {
@@ -129,6 +143,7 @@
130144 $output .= '<div class="blast-message-box-button">
131145 <input type="button" value="' . wfMsg( 'boardsendbutton' ) . '" class="site-button" onclick="javascript:send_messages();" />
132146 </div>';
 147+
133148 return $output;
134149 }
135150 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r85274SocialProfile: per CR on r85267, use addWikiMsg() hereashley20:04, 3 April 2011

Comments

#Comment by Nikerabbit (talk | contribs)   19:12, 3 April 2011
$output = wfMsgExt( 'boardblastlogintext', 'parse' );
$wgOut->addHTML( $output );

->

$wgOut->addWikiMsg( 'boardblastlogintext' );
#Comment by Jack Phoenix (talk | contribs)   20:05, 3 April 2011

Thanks! Fixed in r85274; I thought that there was a better way of doing this than with wfMsgExt() but I just couldn't remember it...

Status & tagging log