http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90796
Revision: 90796 Author: ashley Date: 2011-06-25 19:48:45 +0000 (Sat, 25 Jun 2011) Log Message: ----------- SocialProfile: better URL building & swapped getVal() to getInt() where appropriate for SystemGifts Modified Paths: -------------- trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php Modified: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php =================================================================== --- trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php 2011-06-25 19:40:19 UTC (rev 90795) +++ trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php 2011-06-25 19:48:45 UTC (rev 90796) @@ -22,7 +22,7 @@ * @param $par Mixed: parameter passed to the page or null */ public function execute( $par ) { - global $wgUser, $wgOut, $wgRequest, $wgScriptPath, $wgSystemGiftsScripts; + global $wgUser, $wgOut, $wgRequest, $wgSystemGiftsScripts; $wgOut->setPageTitle( wfMsg( 'systemgiftmanager' ) ); @@ -56,20 +56,20 @@ $wgRequest->getVal( 'gift_name' ), $wgRequest->getVal( 'gift_description' ), $wgRequest->getVal( 'gift_category' ), - $wgRequest->getVal( 'gift_threshold' ) + $wgRequest->getInt( 'gift_threshold' ) ); $wgOut->addHTML( '<span class="view-status">' . wfMsg( 'ga-created' ) . '</span><br /><br />' ); } else { - $gift_id = $wgRequest->getVal( 'id' ); + $gift_id = $wgRequest->getInt( 'id' ); $g->updateGift( $gift_id, $wgRequest->getVal( 'gift_name' ), $wgRequest->getVal( 'gift_description' ), $wgRequest->getVal( 'gift_category' ), - $wgRequest->getVal( 'gift_threshold' ) + $wgRequest->getInt( 'gift_threshold' ) ); $wgOut->addHTML( '<span class="view-status">' . wfMsg( 'ga-saved' ) . @@ -79,13 +79,13 @@ $g->update_system_gifts(); $wgOut->addHTML( $this->displayForm( $gift_id ) ); } else { - $gift_id = $wgRequest->getVal( 'id' ); + $gift_id = $wgRequest->getInt( 'id' ); if ( $gift_id || $wgRequest->getVal( 'method' ) == 'edit' ) { $wgOut->addHTML( $this->displayForm( $gift_id ) ); } else { $wgOut->addHTML( - '<div><b><a href="' . $wgScriptPath . - '/index.php?title=Special:SystemGiftManager&method=edit">' . + '<div><b><a href="' . + $this->getTitle()->escapeFullURL( 'method=edit' ) . '">' . wfMsg( 'ga-addnew' ) . '</a></b></div>' ); $wgOut->addHTML( $this->displayGiftList() ); @@ -94,7 +94,6 @@ } function displayGiftList() { - global $wgScriptPath; $output = ''; // Prevent E_NOTICE $page = 0; $per_page = 50; @@ -102,7 +101,8 @@ if ( $gifts ) { foreach ( $gifts as $gift ) { $output .= '<div class="Item"> - <a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager&id=' . $gift['id'] . '">' . $gift['gift_name'] . '</a> + <a href="' . $this->getTitle()->escapeFullURL( 'id=' . $gift['id'] ) . '">' . + $gift['gift_name'] . '</a> </div>' . "\n"; } } @@ -110,9 +110,10 @@ } function displayForm( $gift_id ) { - global $wgUploadPath, $wgScriptPath; + global $wgUploadPath; - $form = '<div><b><a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager">' . wfMsg( 'ga-viewlist' ) . '</a></b></div>'; + $form = '<div><b><a href="' . $this->getTitle()->escapeFullURL() . + '">' . wfMsg( 'ga-viewlist' ) . '</a></b></div>'; if ( $gift_id ) { $gift = SystemGifts::getGift( $gift_id ); @@ -145,15 +146,20 @@ </tr> <tr> <td width="200" class="view-form">' . wfMsg( 'ga-threshold' ) . '</td> - <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="' . ( isset( $gift['gift_threshold'] ) ? $gift['gift_threshold'] : '' ) . '"/></td> + <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="' . + ( isset( $gift['gift_threshold'] ) ? $gift['gift_threshold'] : '' ) . '"/></td> </tr>'; if ( $gift_id ) { - $gift_image = '<img src="' . $wgUploadPath . '/awards/' . SystemGifts::getGiftImage( $gift_id, 'l' ) . '" border="0" alt="gift" />'; + $sgml = SpecialPage::getTitleFor( 'SystemGiftManagerLogo' ); + $gift_image = '<img src="' . $wgUploadPath . '/awards/' + SystemGifts::getGiftImage( $gift_id, 'l' ) . + '" border="0" alt="gift" />'; $form .= '<tr> <td width="200" class="view-form" valign="top">' . wfMsg( 'ga-giftimage' ) . '</td> <td width="695">' . $gift_image . - '<a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManagerLogo&gift_id=' . $gift_id . '">' . wfMsg( 'ga-img' ) . '</a> + '<a href="' . $sgml->escapeFullURL( 'gift_id=' . $gift_id ) . '">' . + wfMsg( 'ga-img' ) . '</a> </td> </tr>'; } @@ -163,6 +169,7 @@ } else { $button = wfMsg( 'ga-create-gift' ); } + $form .= '<tr> <td colspan="2"> <input type="hidden" name="id" value="' . ( isset( $gift['gift_id'] ) ? $gift['gift_id'] : '' ) . '" /> Modified: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php =================================================================== --- trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php 2011-06-25 19:40:19 UTC (rev 90795) +++ trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php 2011-06-25 19:48:45 UTC (rev 90796) @@ -51,7 +51,7 @@ return; } - $this->gift_id = $wgRequest->getVal( 'gift_id' ); + $this->gift_id = $wgRequest->getInt( 'gift_id' ); $this->initLogo( $wgRequest ); $this->executeLogo(); } @@ -63,7 +63,7 @@ # GET requests just give the main form; no data except wpDestfile. return; } - $this->gift_id = $request->getVal( 'gift_id' ); + $this->gift_id = $request->getInt( 'gift_id' ); $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ); $this->mReUpload = $request->getCheck( 'wpReUpload' ); $this->mUpload = $request->getCheck( 'wpUpload' ); @@ -426,7 +426,7 @@ * @access private */ function showSuccess( $status ) { - global $wgUser, $wgOut, $wgUploadPath, $wgScriptPath, $wgLang; + global $wgUser, $wgOut, $wgUploadPath, $wgLang; $ext = 'jpg'; $output = '<h2>' . wfMsg( 'ga-uploadsuccess' ) . '</h2>'; @@ -464,9 +464,12 @@ </td> </tr>'; + $systemGiftManager = SpecialPage::getTitleFor( 'SystemGiftManager' ); $output .= $wgLang->pipeList( array( - '<tr><td><a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager">' . wfMsg( 'ga-back-gift-list' ) . '</a> ', - ' <a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager&id=' . $this->gift_id . '">' . wfMsg( 'ga-back-edit-gift' ) . '</a></td></tr>' + '<tr><td><a href="' . $systemGiftManager->escapeFullURL() . '">' . + wfMsg( 'ga-back-gift-list' ) . '</a> ', + ' <a href="' . $systemGiftManager->escapeFullURL( 'id=' . $this->gift_id ) . '">' . + wfMsg( 'ga-back-edit-gift' ) . '</a></td></tr>' ) ); $output .= '</table>'; $wgOut->addHTML( $output ); @@ -563,7 +566,7 @@ $ew = ''; } - if ( '' != $msg ) { + if ( $msg != '' ) { $sub = wfMsg( 'uploaderror' ); $wgOut->addHTML( "<h2>{$sub}</h2>\n" . "<h4 class='error'>{$msg}</h4>\n" ); @@ -623,7 +626,8 @@ <table border="0"> <tr> - <td style="color:#666666;font-weight:800">' . wfMsg( 'ga-file-instructions' ) . wfMsg( 'ga-choosefile' ) . '<br /> + <td style="color:#666666;font-weight:800">' . + wfMsg( 'ga-file-instructions' ) . wfMsg( 'ga-choosefile' ) . '<br /> <input tabindex="1" type="file" name="wpUploadFile" id="wpUploadFile" style="width:100px" /> </td> </tr> Modified: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php =================================================================== --- trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php 2011-06-25 19:40:19 UTC (rev 90795) +++ trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php 2011-06-25 19:48:45 UTC (rev 90796) @@ -27,7 +27,7 @@ $output = ''; $user_name = $wgRequest->getVal( 'user' ); - $page = $wgRequest->getVal( 'page' ); + $page = $wgRequest->getInt( 'page', 1 ); /** * Redirect Non-logged in users to Login Page @@ -61,9 +61,6 @@ * Config for the page */ $per_page = 10; - if ( !$page || !is_numeric( $page ) ) { - $page = 1; - } $per_row = 2; /** _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs