r107403 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107402‎ | r107403 | r107404 >
Date:18:25, 27 December 2011
Author:bsitu
Status:ok
Tags:
Comment:
follow up to -r107081 - Add comment to class methods and display only the first user in mark as helpful template
Modified paths:
  • /trunk/extensions/MarkAsHelpful/includes/MarkAsHelpfulUtil.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MarkAsHelpful/includes/MarkAsHelpfulUtil.php
@@ -5,6 +5,15 @@
66 */
77 class MarkAsHelpfulUtil {
88
 9+ /**
 10+ * Generate 'mark as helpful' template for current user
 11+ * @param $user Object - The current user
 12+ * @param $isAbleToMark bool - flag to check if the user is able to mark the item as helpful
 13+ * @param $helpfulUserList array - list of users who have marked this item as helpful
 14+ * @param $type string - the object type
 15+ * @param $item int - the object id
 16+ * @return html | empty text
 17+ */
918 public static function getMarkAsHelpfulTemplate( $user, $isAbleToMark, $helpfulUserList, $type, $item ) {
1019
1120 if ( $user->isAnon() ) {
@@ -29,23 +38,31 @@
3039
3140 }
3241
 42+ /**
 43+ * The template to display in this format: {{user name or ip}} thinks this is helpful
 44+ * @param $helpfulUserList array - List of users that mark the item as helpful
 45+ * @return string html | empty text
 46+ */
3347 private static function otherMarkedTemplate( $helpfulUserList ) {
 48+
3449 if ( count( $helpfulUserList ) == 0 ) {
3550 return '';
3651 }
3752
38 - $userList = '';
39 -
40 - foreach ( $helpfulUserList as $val ) {
41 - $userList .= $val['user_name'] . ' ';
 53+ reset( $helpfulUserList );
 54+
 55+ $user = current( $helpfulUserList );
 56+
 57+ // show the first user 'in mark as helpful' template
 58+ if ( $user['user_name'] ) {
 59+ $data = wfMessage( 'mah-someone-marked-text' )->params( $user['user_name'] )->escaped();
4260 }
43 -
44 - $data = '';
45 -
46 - if ( $userList ) {
47 - $data = wfMessage( 'mah-someone-marked-text' )->params( $userList )->escaped();
 61+ else {
 62+ $data = wfMessage( 'mah-someone-marked-text' )->params( $user['user_ip'] )->escaped();
4863 }
49 -
 64+
 65+ // Add other user in user list to a hidden div, this is for future enhancement
 66+
5067 return <<<HTML
5168 <div class='mw-mah-wrapper'>
5269 <span class='mah-helpful-marked-state'>
@@ -55,6 +72,12 @@
5673 HTML;
5774 }
5875
 76+ /**
 77+ * The template to display in this format: You think this is helpful
 78+ * @Todo future enhancement: We may pass the list of other users as well
 79+ * so we can put them in hidden div
 80+ * @return string html
 81+ */
5982 private static function ownerMarkedTemplate() {
6083 $mahMarkedText = wfMessage( 'mah-you-marked-text' )->escaped();
6184 $undoLinkText = wfMessage( 'mah-undo-mark-text' )->escaped();
@@ -69,6 +92,10 @@
7093 HTML;
7194 }
7295
 96+ /**
 97+ * The template to request a user to mark an item as helpful
 98+ * @return string html
 99+ */
73100 private static function requestToMarkTemplate() {
74101 $mahLinkText = wfMessage( 'mah-mark-text' )->escaped();
75102 return <<<HTML

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107081added gender support for x thinks this helpful. follow up r106743rmoen18:10, 22 December 2011

Status & tagging log