r90796 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90795‎ | r90796 | r90797 >
Date:19:48, 25 June 2011
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: better URL building & swapped getVal() to getInt() where appropriate for SystemGifts
Modified paths:
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php
@@ -22,7 +22,7 @@
2323 * @param $par Mixed: parameter passed to the page or null
2424 */
2525 public function execute( $par ) {
26 - global $wgUser, $wgOut, $wgRequest, $wgScriptPath, $wgSystemGiftsScripts;
 26+ global $wgUser, $wgOut, $wgRequest, $wgSystemGiftsScripts;
2727
2828 $wgOut->setPageTitle( wfMsg( 'systemgiftmanager' ) );
2929
@@ -56,20 +56,20 @@
5757 $wgRequest->getVal( 'gift_name' ),
5858 $wgRequest->getVal( 'gift_description' ),
5959 $wgRequest->getVal( 'gift_category' ),
60 - $wgRequest->getVal( 'gift_threshold' )
 60+ $wgRequest->getInt( 'gift_threshold' )
6161 );
6262 $wgOut->addHTML(
6363 '<span class="view-status">' . wfMsg( 'ga-created' ) .
6464 '</span><br /><br />'
6565 );
6666 } else {
67 - $gift_id = $wgRequest->getVal( 'id' );
 67+ $gift_id = $wgRequest->getInt( 'id' );
6868 $g->updateGift(
6969 $gift_id,
7070 $wgRequest->getVal( 'gift_name' ),
7171 $wgRequest->getVal( 'gift_description' ),
7272 $wgRequest->getVal( 'gift_category' ),
73 - $wgRequest->getVal( 'gift_threshold' )
 73+ $wgRequest->getInt( 'gift_threshold' )
7474 );
7575 $wgOut->addHTML(
7676 '<span class="view-status">' . wfMsg( 'ga-saved' ) .
@@ -79,13 +79,13 @@
8080 $g->update_system_gifts();
8181 $wgOut->addHTML( $this->displayForm( $gift_id ) );
8282 } else {
83 - $gift_id = $wgRequest->getVal( 'id' );
 83+ $gift_id = $wgRequest->getInt( 'id' );
8484 if ( $gift_id || $wgRequest->getVal( 'method' ) == 'edit' ) {
8585 $wgOut->addHTML( $this->displayForm( $gift_id ) );
8686 } else {
8787 $wgOut->addHTML(
88 - '<div><b><a href="' . $wgScriptPath .
89 - '/index.php?title=Special:SystemGiftManager&amp;method=edit">' .
 88+ '<div><b><a href="' .
 89+ $this->getTitle()->escapeFullURL( 'method=edit' ) . '">' .
9090 wfMsg( 'ga-addnew' ) . '</a></b></div>'
9191 );
9292 $wgOut->addHTML( $this->displayGiftList() );
@@ -94,7 +94,6 @@
9595 }
9696
9797 function displayGiftList() {
98 - global $wgScriptPath;
9998 $output = ''; // Prevent E_NOTICE
10099 $page = 0;
101100 $per_page = 50;
@@ -102,7 +101,8 @@
103102 if ( $gifts ) {
104103 foreach ( $gifts as $gift ) {
105104 $output .= '<div class="Item">
106 - <a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager&amp;id=' . $gift['id'] . '">' . $gift['gift_name'] . '</a>
 105+ <a href="' . $this->getTitle()->escapeFullURL( 'id=' . $gift['id'] ) . '">' .
 106+ $gift['gift_name'] . '</a>
107107 </div>' . "\n";
108108 }
109109 }
@@ -110,9 +110,10 @@
111111 }
112112
113113 function displayForm( $gift_id ) {
114 - global $wgUploadPath, $wgScriptPath;
 114+ global $wgUploadPath;
115115
116 - $form = '<div><b><a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager">' . wfMsg( 'ga-viewlist' ) . '</a></b></div>';
 116+ $form = '<div><b><a href="' . $this->getTitle()->escapeFullURL() .
 117+ '">' . wfMsg( 'ga-viewlist' ) . '</a></b></div>';
117118
118119 if ( $gift_id ) {
119120 $gift = SystemGifts::getGift( $gift_id );
@@ -145,15 +146,20 @@
146147 </tr>
147148 <tr>
148149 <td width="200" class="view-form">' . wfMsg( 'ga-threshold' ) . '</td>
149 - <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="' . ( isset( $gift['gift_threshold'] ) ? $gift['gift_threshold'] : '' ) . '"/></td>
 150+ <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="' .
 151+ ( isset( $gift['gift_threshold'] ) ? $gift['gift_threshold'] : '' ) . '"/></td>
150152 </tr>';
151153
152154 if ( $gift_id ) {
153 - $gift_image = '<img src="' . $wgUploadPath . '/awards/' . SystemGifts::getGiftImage( $gift_id, 'l' ) . '" border="0" alt="gift" />';
 155+ $sgml = SpecialPage::getTitleFor( 'SystemGiftManagerLogo' );
 156+ $gift_image = '<img src="' . $wgUploadPath . '/awards/'
 157+ SystemGifts::getGiftImage( $gift_id, 'l' ) .
 158+ '" border="0" alt="gift" />';
154159 $form .= '<tr>
155160 <td width="200" class="view-form" valign="top">' . wfMsg( 'ga-giftimage' ) . '</td>
156161 <td width="695">' . $gift_image .
157 - '<a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManagerLogo&gift_id=' . $gift_id . '">' . wfMsg( 'ga-img' ) . '</a>
 162+ '<a href="' . $sgml->escapeFullURL( 'gift_id=' . $gift_id ) . '">' .
 163+ wfMsg( 'ga-img' ) . '</a>
158164 </td>
159165 </tr>';
160166 }
@@ -163,6 +169,7 @@
164170 } else {
165171 $button = wfMsg( 'ga-create-gift' );
166172 }
 173+
167174 $form .= '<tr>
168175 <td colspan="2">
169176 <input type="hidden" name="id" value="' . ( isset( $gift['gift_id'] ) ? $gift['gift_id'] : '' ) . '" />
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php
@@ -51,7 +51,7 @@
5252 return;
5353 }
5454
55 - $this->gift_id = $wgRequest->getVal( 'gift_id' );
 55+ $this->gift_id = $wgRequest->getInt( 'gift_id' );
5656 $this->initLogo( $wgRequest );
5757 $this->executeLogo();
5858 }
@@ -63,7 +63,7 @@
6464 # GET requests just give the main form; no data except wpDestfile.
6565 return;
6666 }
67 - $this->gift_id = $request->getVal( 'gift_id' );
 67+ $this->gift_id = $request->getInt( 'gift_id' );
6868 $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' );
6969 $this->mReUpload = $request->getCheck( 'wpReUpload' );
7070 $this->mUpload = $request->getCheck( 'wpUpload' );
@@ -426,7 +426,7 @@
427427 * @access private
428428 */
429429 function showSuccess( $status ) {
430 - global $wgUser, $wgOut, $wgUploadPath, $wgScriptPath, $wgLang;
 430+ global $wgUser, $wgOut, $wgUploadPath, $wgLang;
431431 $ext = 'jpg';
432432
433433 $output = '<h2>' . wfMsg( 'ga-uploadsuccess' ) . '</h2>';
@@ -464,9 +464,12 @@
465465 </td>
466466 </tr>';
467467
 468+ $systemGiftManager = SpecialPage::getTitleFor( 'SystemGiftManager' );
468469 $output .= $wgLang->pipeList( array(
469 - '<tr><td><a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager">' . wfMsg( 'ga-back-gift-list' ) . '</a>&#160;',
470 - '&#160;<a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager&amp;id=' . $this->gift_id . '">' . wfMsg( 'ga-back-edit-gift' ) . '</a></td></tr>'
 470+ '<tr><td><a href="' . $systemGiftManager->escapeFullURL() . '">' .
 471+ wfMsg( 'ga-back-gift-list' ) . '</a>&#160;',
 472+ '&#160;<a href="' . $systemGiftManager->escapeFullURL( 'id=' . $this->gift_id ) . '">' .
 473+ wfMsg( 'ga-back-edit-gift' ) . '</a></td></tr>'
471474 ) );
472475 $output .= '</table>';
473476 $wgOut->addHTML( $output );
@@ -563,7 +566,7 @@
564567 $ew = '';
565568 }
566569
567 - if ( '' != $msg ) {
 570+ if ( $msg != '' ) {
568571 $sub = wfMsg( 'uploaderror' );
569572 $wgOut->addHTML( "<h2>{$sub}</h2>\n" .
570573 "<h4 class='error'>{$msg}</h4>\n" );
@@ -623,7 +626,8 @@
624627 <table border="0">
625628 <tr>
626629
627 - <td style="color:#666666;font-weight:800">' . wfMsg( 'ga-file-instructions' ) . wfMsg( 'ga-choosefile' ) . '<br />
 630+ <td style="color:#666666;font-weight:800">' .
 631+ wfMsg( 'ga-file-instructions' ) . wfMsg( 'ga-choosefile' ) . '<br />
628632 <input tabindex="1" type="file" name="wpUploadFile" id="wpUploadFile" style="width:100px" />
629633 </td>
630634 </tr>
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php
@@ -27,7 +27,7 @@
2828
2929 $output = '';
3030 $user_name = $wgRequest->getVal( 'user' );
31 - $page = $wgRequest->getVal( 'page' );
 31+ $page = $wgRequest->getInt( 'page', 1 );
3232
3333 /**
3434 * Redirect Non-logged in users to Login Page
@@ -61,9 +61,6 @@
6262 * Config for the page
6363 */
6464 $per_page = 10;
65 - if ( !$page || !is_numeric( $page ) ) {
66 - $page = 1;
67 - }
6865 $per_row = 2;
6966
7067 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r91210SocialProfile: fix E_PARSE in SystemGifts/SpecialSystemGiftManager.php caused...ashley19:45, 30 June 2011

Status & tagging log