r62745 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62744‎ | r62745 | r62746 >
Date:18:31, 20 February 2010
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: fix some E_NOTICEs
Modified paths:
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/TopAwards.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php
@@ -79,6 +79,7 @@
8080 function displayGiftList() {
8181 global $wgScriptPath;
8282 $output = ''; // Prevent E_NOTICE
 83+ $page = 0;
8384 $per_page = 10;
8485 $gifts = SystemGifts::getGiftList( $per_page, $page );
8586 if ( $gifts ) {
@@ -104,11 +105,11 @@
105106 <table border="0" cellpadding="5" cellspacing="0" width="500">
106107 <tr>
107108 <td width="200" class="view-form">' . wfMsg( 'ga-giftname' ) . '</td>
108 - <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="' . $gift['gift_name'] . '"/></td>
 109+ <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="' . ( isset( $gift['gift_name'] ) ? $gift['gift_name'] : '' ) . '"/></td>
109110 </tr>
110111 <tr>
111112 <td width="200" class="view-form" valign="top">' . wfMsg( 'ga-giftdesc' ) . '</td>
112 - <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">' . $gift['gift_description'] . '</textarea></td>
 113+ <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">' . ( isset( $gift['gift_description'] ) ? $gift['gift_description'] : '' ) . '</textarea></td>
113114 </tr>
114115 <tr>
115116 <td width="200" class="view-form">' . wfMsg( 'ga-gifttype' ) . '</td>
@@ -116,30 +117,39 @@
117118 <select name="gift_category">';
118119 $g = new SystemGifts();
119120 foreach ( $g->categories as $category => $id ) {
120 - $form .= '<option' . ( ( $gift['gift_category'] == $id ) ? ' selected="selected"' : '' ) . " value=\"{$id}\">{$category}</option>";
 121+ $sel = '';
 122+ if ( isset( $gift['gift_category'] ) && $gift['gift_category'] == $id ) {
 123+ $sel = ' selected="selected"';
 124+ }
 125+ $form .= '<option' . $sel . " value=\"{$id}\">{$category}</option>";
121126 }
122127 $form .= '</select>
123128 </td>
124129 </tr>
125130 <tr>
126131 <td width="200" class="view-form">' . wfMsg( 'ga-threshold' ) . '</td>
127 - <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="' . $gift['gift_threshold'] . '"/></td>
 132+ <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="' . ( isset( $gift['gift_threshold'] ) ? $gift['gift_threshold'] : '' ) . '"/></td>
128133 </tr>';
129134
130135 if ( $gift_id ) {
131136 $gift_image = '<img src="' . $wgUploadPath . '/awards/' . SystemGifts::getGiftImage( $gift_id, 'l' ) . '" border="0" alt="gift" />';
132137 $form .= '<tr>
133138 <td width="200" class="view-form" valign="top">' . wfMsg( 'ga-giftimage' ) . '</td>
134 - <td width="695">' . $gift_image . '
135 - <a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManagerLogo&gift_id=' . $gift_id . '">' . wfMsg( 'ga-img' ) . '</a>
 139+ <td width="695">' . $gift_image .
 140+ '<a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManagerLogo&gift_id=' . $gift_id . '">' . wfMsg( 'ga-img' ) . '</a>
136141 </td>
137142 </tr>';
138143 }
139144
 145+ if ( isset( $gift['gift_id'] ) ) {
 146+ $button = wfMsg( 'edit' );
 147+ } else {
 148+ $button = wfMsg( 'ga-create-gift' );
 149+ }
140150 $form .= '<tr>
141151 <td colspan="2">
142 - <input type="hidden" name="id" value="' . $gift['gift_id'] . '" />
143 - <input type="button" class="createbox" value="' . ( ( $gift['gift_id'] ) ? wfMsg( 'edit' ) : wfMsg( 'ga-create-gift' ) ) . '" size="20" onclick="document.gift.submit()" />
 152+ <input type="hidden" name="id" value="' . ( isset( $gift['gift_id'] ) ? $gift['gift_id'] : '' ) . '" />
 153+ <input type="button" class="createbox" value="' . $button . '" size="20" onclick="document.gift.submit()" />
144154 <input type="button" class="createbox" value="' . wfMsg( 'cancel' ) . '" size="20" onclick="history.go(-1)" />
145155 </td>
146156 </tr>
Index: trunk/extensions/SocialProfile/SystemGifts/TopAwards.php
@@ -77,31 +77,29 @@
7878 $output .= '</div>';
7979 $output .= '<div class="top-awards">';
8080
81 - while ( $row = $dbr->fetchObject( $res ) ) {
82 -
 81+ foreach ( $res as $row ) {
8382 $user_name = $row->sg_user_name;
8483 $user_id = $row->sg_user_id;
8584 $avatar = new wAvatar( $user_id, 'm' );
8685 $top_gift = $row->top_gift;
8786 $gift_name = number_format( $top_gift ) . " {$categories[$category_number][category_name]}" . ( ( $top_gift > 1 ) ? 's' : '' ) . " Milestone";
8887
89 - if ( $gift_name !== $gift_name_check ) {
90 - $x = 1;
91 - $output .= "<div class=\"top-award-title\">
92 - {$gift_name}
93 - </div>";
94 - } else {
95 - $x++;
96 - }
 88+ if ( $gift_name !== $gift_name_check ) {
 89+ $x = 1;
 90+ $output .= "<div class=\"top-award-title\">
 91+ {$gift_name}
 92+ </div>";
 93+ } else {
 94+ $x++;
 95+ }
9796
98 - $output .= "<div class=\"top-award\">
 97+ $output .= "<div class=\"top-award\">
9998 <span class=\"top-award-number\">{$x}.</span>
10099 {$avatar->getAvatarURL()}
101100 <a href=\"" . $wgScriptPath . "/index.php?title=User:{$row->sg_user_name}\">{$user_name}</a>
102101 </div>";
103102
104 - $gift_name_check = $gift_name;
105 -
 103+ $gift_name_check = $gift_name;
106104 }
107105
108106 $output .= '</div>
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php
@@ -118,7 +118,7 @@
119119 global $wgScriptPath;
120120 wfLoadExtensionMessages( 'UserGifts' );
121121 $output = ''; // Prevent E_NOTICE
122 - // FIXME: undefined variable page
 122+ $page = 0;
123123 $per_page = 10;
124124 $gifts = Gifts::getManagedGiftList( $per_page, $page );
125125 if ( $gifts ) {
@@ -150,14 +150,13 @@
151151
152152 $form .= '<form action="" method="post" enctype="multipart/form-data" name="gift">';
153153 $form .= '<table border="0" cellpadding="5" cellspacing="0" width="500">';
154 - // FIXME: undefined variable gift (twice)
155154 $form .= '<tr>
156155 <td width="200" class="view-form">' . wfMsg( 'g-gift-name' ) . '</td>
157 - <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="' . $gift['gift_name'] . '"/></td>
 156+ <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="' . ( isset( $gift['gift_name'] ) ? $gift['gift_name'] : '' ) . '"/></td>
158157 </tr>
159158 <tr>
160159 <td width="200" class="view-form" valign="top">' . wfMsg( 'giftmanager-description' ) . '</td>
161 - <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">' . $gift['gift_description'] . '</textarea></td>
 160+ <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">' . ( isset( $gift['gift_description'] ) ? $gift['gift_description'] : '' ) . '</textarea></td>
162161 </tr>';
163162 if ( $gift_id ) {
164163 $creator = Title::makeTitle( NS_USER, $gift['creator_user_name'] );
@@ -186,21 +185,25 @@
187186 $gift_image = '<img src="' . $wgUploadPath . '/awards/' . Gifts::getGiftImage( $gift_id, 'l' ) . '" border="0" alt="' . wfMsg( 'g-gift' ) . '" />';
188187 $form .= '<tr>
189188 <td width="200" class="view-form" valign="top">' . wfMsg( 'giftmanager-giftimage' ) . '</td>
190 - <td width="695">' . $gift_image . '
191 - <p>
 189+ <td width="695">' . $gift_image .
 190+ '<p>
192191 <a href="' . $wgScriptPath . '/index.php?title=Special:GiftManagerLogo&gift_id=' . $gift_id . '">' . wfMsg( 'giftmanager-image' ) . '</a>
193192 </td>
194193 </tr>';
195194 }
196195
197 - // FIXME: undefined variable gift (twice)
198 - $form .= '
199 - <tr>
200 - <td colspan="2">
201 - <input type="hidden" name="id" value="' . $gift['gift_id'] . '" />
202 - <input type="button" class="createbox" value="' . ( ( $gift['gift_id'] ) ? wfMsg( 'edit' ) : wfMsg( 'g-create-gift' ) ) . '" size="20" onclick="document.gift.submit()" />
203 - <input type="button" class="createbox" value="' . wfMsg( 'cancel' ) . '" size="20" onclick="history.go(-1)" />
204 - </td>
 196+ if ( isset( $gift['gift_id'] ) ) {
 197+ $button = wfMsg( 'edit' );
 198+ } else {
 199+ $button = wfMsg( 'g-create-gift' );
 200+ }
 201+
 202+ $form .= '<tr>
 203+ <td colspan="2">
 204+ <input type="hidden" name="id" value="' . ( isset( $gift['gift_id'] ) ? $gift['gift_id'] : '' ) . '" />
 205+ <input type="button" class="createbox" value="' . $button . '" size="20" onclick="document.gift.submit()" />
 206+ <input type="button" class="createbox" value="' . wfMsg( 'cancel' ) . '" size="20" onclick="history.go(-1)" />
 207+ </td>
205208 </tr>
206209 </table>
207210

Status & tagging log