http://www.mediawiki.org/wiki/Special:Code/MediaWiki/63062
Revision: 63062 Author: ashley Date: 2010-02-27 23:09:51 +0000 (Sat, 27 Feb 2010) Log Message: ----------- SocialProfile: cleanup to UserGifts stuff Modified Paths: -------------- trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php Modified: trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php =================================================================== --- trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php 2010-02-27 22:56:48 UTC (rev 63061) +++ trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php 2010-02-27 23:09:51 UTC (rev 63062) @@ -25,7 +25,7 @@ $usertitle = Title::newFromDBkey( $wgRequest->getVal( 'user' ) ); if ( !$usertitle ) { - $wgOut->addHTML( /*$wgOut->addHTML(*/ $this->displayFormNoUser() /*)*/ ); + $wgOut->addHTML( $this->displayFormNoUser() ); return false; } @@ -38,14 +38,14 @@ $wgOut->setPageTitle( wfMsg( 'g-error-title' ) ); $out .= wfMsg( 'g-error-message-to-yourself' ); $wgOut->addHTML( $out ); - } else if ( $wgUser->isBlocked() ) { + } elseif ( $wgUser->isBlocked() ) { $wgOut->setPageTitle( wfMsg( 'g-error-title' ) ); $out .= wfMsg( 'g-error-message-blocked' ); $wgOut->addHTML( $out ); - } else if ( $this->user_id_to == 0 ) { + } elseif ( $this->user_id_to == 0 ) { $wgOut->setPageTitle( wfMsg( 'g-error-title' ) ); $wgOut->addHTML( wfMsg( 'g-error-message-no-user' ) ); - } else if ( $wgUser->getID() == 0 ) { + } elseif ( $wgUser->getID() == 0 ) { $wgOut->setPageTitle( wfMsg( 'g-error-title' ) ); $out .= wfMsg( 'g-error-message-login' ); $wgOut->addHTML( $out ); @@ -57,7 +57,12 @@ $_SESSION['alreadysubmitted'] = true; - $ug_gift_id = $gift->sendGift( $this->user_name_to, $wgRequest->getVal( 'gift_id' ), 0, $wgRequest->getVal( 'message' ) ); + $ug_gift_id = $gift->sendGift( + $this->user_name_to, + $wgRequest->getVal( 'gift_id' ), + 0, + $wgRequest->getVal( 'message' ) + ); // clear the cache for the user profile gifts for this user $wgMemc->delete( wfMemcKey( 'user', 'profile', 'gifts', $this->user_id_to ) ); @@ -71,7 +76,9 @@ if ( is_array( $last_unique_gifts ) ) { foreach ( $last_unique_gifts as $last_unique_gift ) { - if ( $wgRequest->getVal( 'gift_id' ) == $last_unique_gift['gift_id'] ) $found = 0; + if ( $wgRequest->getVal( 'gift_id' ) == $last_unique_gift['gift_id'] ) { + $found = 0; + } } } @@ -83,7 +90,9 @@ ); // remove oldest value - if ( count( $last_unique_gifts ) > 4 ) array_shift( $last_unique_gifts ); + if ( count( $last_unique_gifts ) > 4 ) { + array_shift( $last_unique_gifts ); + } // reset the cache $wgMemc->set( $key, $last_unique_gifts ); @@ -97,12 +106,12 @@ $output .= '<div class="back-links"> <a href="' . $user_title->escapeFullURL() . '">' . wfMsg( 'g-back-link', $this->user_name_to ) . '</a> </div> - <div class="g-message"> - ' . wfMsg( 'g-sent-message', $this->user_name_to ) . ' - </div> - <div class="g-container"> - ' . $gift_image . ' - <div class="g-title">' . $sent_gift['name'] . '</div>'; + <div class="g-message">' + . wfMsg( 'g-sent-message', $this->user_name_to ) . + '</div> + <div class="g-container">' + . $gift_image . + '<div class="g-title">' . $sent_gift['name'] . '</div>'; if ( $sent_gift['message'] ) { $output .= '<div class="g-user-message">' . $sent_gift['message'] . '</div>'; } @@ -153,15 +162,15 @@ $wgOut->setPageTitle( wfMsg( 'g-give-to-user-title', $gift['gift_name'], $this->user_name_to ) ); - $gift_image = "<img id=\"gift_image_{$gift['gift_id']}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . "\" border=\"0\" alt=\"\"/>"; + $gift_image = "<img id=\"gift_image_{$gift['gift_id']}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />'; $output = '<form action="" method="post" enctype="multipart/form-data" name="gift"> - <div class="g-message"> - ' . wfMsg( 'g-give-to-user-message', $this->user_name_to, $give_gift_link->escapeFullURL( 'user=' . $this->user_name_to ) ) . " - </div> - <div id=\"give_gift_{$gift["gift_id"]}\" class=\"g-container\"> + <div class="g-message">' + . wfMsg( 'g-give-to-user-message', $this->user_name_to, $give_gift_link->escapeFullURL( 'user=' . $this->user_name_to ) ) . + "</div> + <div id=\"give_gift_{$gift['gift_id']}\" class=\"g-container\"> {$gift_image} - <div class=\"g-title\">{$gift["gift_name"]}</div>"; + <div class=\"g-title\">{$gift['gift_name']}</div>"; if ( $gift['gift_description'] ) { $output .= '<div class="g-describe">' . $gift['gift_description'] . '</div>'; } @@ -186,7 +195,7 @@ $output = $wgOut->setPageTitle( wfMsg( 'g-give-no-user-title' ) ); $output .= '<form action="" method="get" enctype="multipart/form-data" name="gift"> - <input type="hidden" name="title" value="' . $wgRequest->getVal( 'title' ) . '"> + <input type="hidden" name="title" value="' . $wgRequest->getVal( 'title' ) . '" /> <div class="g-message">' . wfMsg( 'g-give-no-user-message' ) . '</div> <div class="g-give-container">'; @@ -198,7 +207,7 @@ $output .= '<div class="g-give-title">' . wfMsg( 'g-give-list-friends-title' ) . '</div> <div class="g-gift-select"> <select onchange="javascript:chooseFriend(this.value)"> - <option value="#" selected>' . wfMsg( 'g-select-a-friend' ) . '</option>'; + <option value="#" selected="selected">' . wfMsg( 'g-select-a-friend' ) . '</option>'; foreach ( $friends as $friend ) { $output .= '<option value="' . urlencode( $friend['user_name'] ) . '">' . $friend['user_name'] . '</option>'; } @@ -210,8 +219,8 @@ $output .= '<div class="g-give-title">' . wfMsg( 'g-give-enter-friend-title' ) . '</div> <div class="g-give-textbox"> - <input type="text" width="85" name="user" value=""> - <input class="site-button" type="button" value="' . wfMsg( 'g-give-gift' ) . '" onclick="document.gift.submit()"> + <input type="text" width="85" name="user" value="" /> + <input class="site-button" type="button" value="' . wfMsg( 'g-give-gift' ) . '" onclick="document.gift.submit()" /> </div> </div> </form>'; @@ -224,18 +233,21 @@ $user = Title::makeTitle( NS_USER, $this->user_name_to ); $page = $wgRequest->getVal( 'page' ); - if ( !$page || !is_numeric( $page ) ) $page = 1; + if ( !$page || !is_numeric( $page ) ) { + $page = 1; + } $per_page = 24; $per_row = $wgGiveGiftPerRow; - if ( !$per_row ) $per_row = 3; + if ( !$per_row ) { + $per_row = 3; + } $total = Gifts::getGiftCount(); $gifts = Gifts::getGiftList( $per_page, $page, 'gift_name' ); $output = ''; if ( $gifts ) { - $wgOut->setPageTitle( wfMsg( 'g-give-all-title', $this->user_name_to ) ); $output .= '<div class="back-links"> @@ -249,16 +261,19 @@ $x = 1; foreach ( $gifts as $gift ) { + $gift_image = "<img id=\"gift_image_{$gift['id']}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['id'], 'l' ) . '" border="0" alt="" />'; - $gift_image = "<img id=\"gift_image_{$gift["id"]}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['id'], 'l' ) . "\" border=\"0\" alt=\"\" />"; - - $output .= "<div onclick=\"selectGift({$gift["id"]})\" onmouseover=\"highlightGift({$gift["id"]})\" onmouseout=\"unHighlightGift({$gift["id"]})\" id=\"give_gift_{$gift["id"]}\" class=\"g-give-all\"> + $output .= "<div onclick=\"selectGift({$gift['id']})\" onmouseover=\"highlightGift({$gift['id']})\" onmouseout=\"unHighlightGift({$gift['id']})\" id=\"give_gift_{$gift['id']}\" class=\"g-give-all\"> {$gift_image} - <div class=\"g-title g-blue\">{$gift["gift_name"]}</div>"; - if ( $gift['gift_description'] ) $output .= "<div class=\"g-describe\">{$gift["gift_description"]}</div>"; + <div class=\"g-title g-blue\">{$gift['gift_name']}</div>"; + if ( $gift['gift_description'] ) { + $output .= "<div class=\"g-describe\">{$gift['gift_description']}</div>"; + } $output .= '<div class="cleared"></div> </div>'; - if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) $output .= '<div class="cleared"></div>'; + if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) { + $output .= '<div class="cleared"></div>'; + } $x++; } @@ -275,13 +290,17 @@ $output .= '<a href="' . $give_gift_link->escapeFullURL( 'user=' . $user_safe . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'g-previous' ) . '</a> '; } - if ( ( $total % $per_page ) != 0 ) $numofpages++; - if ( $numofpages >= 9 ) $numofpages = 9 + $page; + if ( ( $total % $per_page ) != 0 ) { + $numofpages++; + } + if ( $numofpages >= 9 ) { + $numofpages = 9 + $page; + } for ( $i = 1; $i <= $numofpages; $i++ ) { if ( $i == $page ) { - $output .= ( $i . " " ); + $output .= ( $i . ' ' ); } else { - $output .= "<a href=\"" . $give_gift_link->escapeFullURL( 'user=' . $user_safe . '&page=' . $i ) . "\">$i</a> "; + $output .= '<a href="' . $give_gift_link->escapeFullURL( 'user=' . $user_safe . '&page=' . $i ) . "\">$i</a> "; } } Modified: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php =================================================================== --- trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php 2010-02-27 22:56:48 UTC (rev 63061) +++ trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php 2010-02-27 23:09:51 UTC (rev 63062) @@ -18,7 +18,7 @@ global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts; wfLoadExtensionMessages( 'UserGifts' ); - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); + $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' ); $this->gift_id = $wgRequest->getVal( 'gift_id' ); $rel = new UserGifts( $wgUser->getName() ); @@ -36,7 +36,6 @@ $gift = $rel->getUserGift( $this->gift_id ); if ( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) { - $_SESSION['alreadysubmitted'] = true; $user_page_link = Title::makeTitle( NS_USER, $wgUser->getName() ); @@ -53,9 +52,9 @@ $out = '<div class="back-links"> <a href="' . $wgUser->getUserPage()->escapeFullURL() . '">' . wfMsg( 'g-back-link', $gift['user_name_to'] ) . '</a> </div> - <div class="g-container"> - ' . $gift_image . wfMsg( 'g-remove-success-message', $gift['name'] ) . ' - <div class="cleared"></div> + <div class="g-container">' + . $gift_image . wfMsg( 'g-remove-success-message', $gift['name'] ) . + '<div class="cleared"></div> </div> <div class="g-buttons"> <input type="button" class="site-button" value="' . wfMsg( 'g-main-page' ) . '" size="20" onclick="window.location=\'index.php?title=' . wfMsgForContent( 'mainpage' ) . '\'" /> @@ -86,17 +85,17 @@ <a href="' . $wgUser->getUserPage()->escapeFullURL() . '">' . wfMsg( 'g-back-link', $gift['user_name_to'] ) . '</a> </div> <form action="" method="post" enctype="multipart/form-data" name="form1"> - <div class="g-remove-message"> - ' . wfMsg( 'g-remove-message', $gift['name'] ) . ' - </div> - <div class="g-container"> - ' . $gift_image . ' - <div class="g-name">' . $gift['name'] . '</div> + <div class="g-remove-message">' + . wfMsg( 'g-remove-message', $gift['name'] ) . + '</div> + <div class="g-container">' + . $gift_image . + '<div class="g-name">' . $gift['name'] . '</div> <div class="g-from">' . wfMsg( 'g-from', $user->escapeFullURL(), $gift['user_name_from'] ) . '</div>'; - if ( $gift['message'] ) { - $output .= '<div class="g-user-message">' . $gift['message'] . '</div>'; - } - $output .= '</div> + if ( $gift['message'] ) { + $output .= '<div class="g-user-message">' . $gift['message'] . '</div>'; + } + $output .= '</div> <div class="cleared"></div> <div class="g-buttons"> <input type="hidden" name="user" value="' . addslashes( $gift['user_name_from'] ) . '"> Modified: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php =================================================================== --- trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php 2010-02-27 22:56:48 UTC (rev 63061) +++ trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php 2010-02-27 23:09:51 UTC (rev 63062) @@ -16,7 +16,7 @@ */ function deleteImage( $id, $size ) { global $wgUploadDirectory; - $files = glob( $wgUploadDirectory . '/awards/' . $id . "_{$size}*" ); + $files = glob( $wgUploadDirectory . '/awards/' . $id . "_{$size}*" ); if ( $files && $files[0] ) { $img = basename( $files[0] ); unlink( $wgUploadDirectory . '/awards/' . $img ); @@ -48,11 +48,11 @@ * @param $par Mixed: parameter passed to the page or null */ public function execute( $par ) { - global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserGiftsScripts; + global $wgUser, $wgOut, $wgRequest, $wgUserGiftsScripts; wfLoadExtensionMessages( 'UserGifts' ); // Add CSS - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); + $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' ); // Check for permissions if ( $wgUser->isAnon() || !$this->canUserManage() ) { @@ -86,9 +86,9 @@ $out = '<div class="back-links"> <a href="' . SpecialPage::getTitleFor( 'GiftManager' )->escapeFullURL() . '">' . wfMsg( 'g-viewgiftlist' ) . '</a> </div> - <div class="g-container"> - ' . wfMsg( 'g-remove-success-message', $gift['gift_name'] ) . ' - <div class="cleared"></div> + <div class="g-container">' + . wfMsg( 'g-remove-success-message', $gift['gift_name'] ) . + '<div class="cleared"></div> </div>'; $wgOut->addHTML( $out ); @@ -103,7 +103,7 @@ * @return HTML output */ function displayForm() { - global $wgUser, $wgOut, $wgUploadPath; + global $wgOut, $wgUploadPath; $gift = Gifts::getGift( $this->gift_id ); @@ -114,13 +114,13 @@ <a href="' . SpecialPage::getTitleFor( 'GiftManager' )->escapeFullURL() . '">' . wfMsg( 'g-viewgiftlist' ) . '</a> </div> <form action="" method="post" enctype="multipart/form-data" name="form1"> - <div class="g-remove-message"> - ' . wfMsg( 'g-delete-message', $gift['gift_name'] ) . ' + <div class="g-remove-message">' + . wfMsg( 'g-delete-message', $gift['gift_name'] ) . + '</div> + <div class="g-container">' + . $gift_image . + '<div class="g-name">' . $gift['gift_name'] . '</div> </div> - <div class="g-container"> - ' . $gift_image . ' - <div class="g-name">' . $gift['gift_name'] . '</div> - </div> <div class="cleared"></div> <div class="g-buttons"> <input type="button" class="site-button" value="' . wfMsg( 'g-remove' ) . '" size="20" onclick="document.form1.submit()" /> Modified: trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php =================================================================== --- trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php 2010-02-27 22:56:48 UTC (rev 63061) +++ trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php 2010-02-27 23:09:51 UTC (rev 63062) @@ -18,7 +18,7 @@ global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserGiftsScripts; wfLoadExtensionMessages( 'UserGifts' ); - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); + $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' ); $user_name = ''; // Prevent E_NOTICE @@ -41,7 +41,6 @@ $dbr = wfGetDB( DB_SLAVE ); if ( $gift ) { - if ( $gift['status'] == 1 ) { if ( $gift['user_name_to'] == $wgUser->getName() ) { $g = new UserGifts( $gift['user_name_to'] ); @@ -50,11 +49,19 @@ } } - $res = $dbr->select( 'user_gift', + $res = $dbr->select( + 'user_gift', array( 'DISTINCT ug_user_name_to', 'ug_user_id_to', 'ug_date' ), - array( 'ug_gift_id' => $gift['gift_id'], "ug_user_name_to<>'" . addslashes( $gift['user_name_to'] ) . "'" ), + array( + 'ug_gift_id' => $gift['gift_id'], + "ug_user_name_to<>'" . addslashes( $gift['user_name_to'] ) . "'" + ), __METHOD__, - array( 'GROUP BY' => 'ug_user_name_to', 'ORDER BY' => 'ug_date DESC', 'LIMIT' => 6 ) + array( + 'GROUP BY' => 'ug_user_name_to', + 'ORDER BY' => 'ug_date DESC', + 'LIMIT' => 6 + ) ); $output = $wgOut->setPageTitle( wfMsgExt( 'g-description-title', 'parsemag', $gift['user_name_to'], $gift['name'] ) ); @@ -78,42 +85,41 @@ $gift_image = '<img src="' . $wgUploadPath . '/awards/' . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />'; - $output .= '<div class="g-description">' - . $gift_image . ' - <div class="g-name">' . $gift['name'] . '</div> + $output .= '<div class="g-description">' + . $gift_image . + '<div class="g-name">' . $gift['name'] . '</div> <div class="g-timestamp">(' . $gift['timestamp'] . ')</div> <div class="g-from">' . wfMsg( 'g-from', $user->escapeFullURL(), $gift['user_name_from'] ) . '</div>'; - if ( $message ) { - $output .= '<div class="g-user-message">' . $message . '</div>'; - } - $output .= '<div class="cleared"></div> + if ( $message ) { + $output .= '<div class="g-user-message">' . $message . '</div>'; + } + $output .= '<div class="cleared"></div> <div class="g-describe">' . $gift['description'] . '</div> <div class="g-actions"> <a href="' . $give_gift_link->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . wfMsg( 'g-to-another' ) . '</a>'; - if ( $gift['user_name_to'] == $wgUser->getName() ) { - $output .= ' '; - $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); - $output .= ' '; - $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>'; - } - $output .= '</div> + if ( $gift['user_name_to'] == $wgUser->getName() ) { + $output .= ' '; + $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); + $output .= ' '; + $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>'; + } + $output .= '</div> </div>'; - $output .= '<div class="g-recent"> + $output .= '<div class="g-recent"> <div class="g-recent-title">' . wfMsg( 'g-recent-recipients' ) . '</div> <div class="g-gift-count">' . wfMsgExt( 'g-given', 'parsemag', $gift['gift_count'] ) . '</div>'; - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { + $user_to_id = $row->ug_user_id_to; + $avatar = new wAvatar( $user_to_id, 'ml' ); + $user_name_link = Title::makeTitle( NS_USER, $row->ug_user_name_to ); - $user_to_id = $row->ug_user_id_to; - $avatar = new wAvatar( $user_to_id, 'ml' ); - $user_name_link = Title::makeTitle( NS_USER, $row->ug_user_name_to ); - - $output .= "<a href=\"" . $user_name_link->escapeFullURL() . "\"> - {$avatar->getAvatarURL()} - </a>"; - } - $output .= '<div class="cleared"></div> + $output .= '<a href="' . $user_name_link->escapeFullURL() . "\"> + {$avatar->getAvatarURL()} + </a>"; + } + $output .= '<div class="cleared"></div> </div> </div>'; Modified: trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php =================================================================== --- trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php 2010-02-27 22:56:48 UTC (rev 63061) +++ trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php 2010-02-27 23:09:51 UTC (rev 63062) @@ -18,7 +18,7 @@ global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts; wfLoadExtensionMessages( 'UserGifts' ); - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); + $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' ); $user_name = $wgRequest->getVal( 'user' ); $page = $wgRequest->getVal( 'page' ); @@ -28,7 +28,7 @@ * It will automatically return them to the ViewGifts page */ if ( $wgUser->getID() == 0 && $user_name == '' ) { - $login = SpecialPage::getTitleFor( 'UserLogin' ); + $login = SpecialPage::getTitleFor( 'Userlogin' ); $wgOut->redirect( $login->escapeFullURL( 'returnto=Special:ViewGifts' ) ); return false; } @@ -36,7 +36,9 @@ /** * If no user is set in the URL, we assume its the current user */ - if ( !$user_name ) $user_name = $wgUser->getName(); + if ( !$user_name ) { + $user_name = $wgUser->getName(); + } $user_id = User::idFromName( $user_name ); $user = Title::makeTitle( NS_USER, $user_name ); $user_safe = urlencode( $user_name ); @@ -54,16 +56,18 @@ * Config for the page */ $per_page = 10; - if ( !$page || !is_numeric( $page ) ) $page = 1; + if ( !$page || !is_numeric( $page ) ) { + $page = 1; + } $per_row = 2; /** - * Get all Gifts for this user into the array + * Get all gifts for this user into the array */ $rel = new UserGifts( $user_name ); $gifts = $rel->getUserGiftList( 0, $per_page, $page ); - $total = $rel->getGiftCountByUsername( $user_name ); // count($relationships); + $total = $rel->getGiftCountByUsername( $user_name ); $relationship = UserRelationship::getUserRelationshipByID( $user_id, $wgUser->getID() ); @@ -72,15 +76,16 @@ */ $output = $wgOut->setPageTitle( wfMsg( 'g-list-title', $rel->user_name ) ); - $output .= '<div class="back-links"><a href="' . $user->getFullURL() . '"> - ' . wfMsg( 'g-back-link', $rel->user_name ) . '</a> + $output .= '<div class="back-links"> + <a href="' . $user->getFullURL() . '">' + . wfMsg( 'g-back-link', $rel->user_name ) . + '</a> </div> - <div class="g-count"> - ' . wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ) . ' - </div>'; + <div class="g-count">' + . wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ) . + '</div>'; if ( $gifts ) { - $x = 1; // Safe links @@ -89,47 +94,48 @@ $remove_gift_link = SpecialPage::getTitleFor( 'RemoveGift' ); foreach ( $gifts as $gift ) { - $giftname_length = strlen( $gift['gift_name'] ); $giftname_space = stripos( $gift['gift_name'], ' ' ); if ( ( $giftname_space == false || $giftname_space >= "30" ) && $giftname_length > 30 ) { - $gift_name_display = substr( $gift['gift_name'], 0, 30 ) . " " . substr( $gift['gift_name'], 30, 50 ); + $gift_name_display = substr( $gift['gift_name'], 0, 30 ) . ' ' . substr( $gift['gift_name'], 30, 50 ); } else { $gift_name_display = $gift['gift_name']; - } ; + } $user_from = Title::makeTitle( NS_USER, $gift['user_name_from'] ); - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . "\" border=\"0\" alt=\"\"/>"; + $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />'; $output .= '<div class="g-item"> <a href="' . $view_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . $gift_image . '</a> <div class="g-title"> <a href="' . $view_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . $gift_name_display . '</a>'; - if ( $gift['status'] == 1 ) { - if ( $user_name == $wgUser->getName() ) { - $rel->clearUserGiftStatus( $gift['id'] ); - $rel->decNewGiftCount( $wgUser->getID() ); - } - $output .= '<span class="g-new">' . wfMsg( 'g-new' ) . '</span>'; - } - $output .= '</div>'; + if ( $gift['status'] == 1 ) { + if ( $user_name == $wgUser->getName() ) { + $rel->clearUserGiftStatus( $gift['id'] ); + $rel->decNewGiftCount( $wgUser->getID() ); + } + $output .= '<span class="g-new">' . wfMsg( 'g-new' ) . '</span>'; + } + $output .= '</div>'; - $output .= '<div class="g-from"> - ' . wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ) . ' - </div> + $output .= '<div class="g-from">' + . wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ) . + '</div> <div class="g-actions"> <a href="' . $give_gift_link->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . wfMsg( 'g-to-another' ) . '</a>'; - if ( $rel->user_name == $wgUser->getName() ) { - $output .= ' '; - $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); - $output .= ' '; - $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>'; - } + if ( $rel->user_name == $wgUser->getName() ) { + $output .= ' '; + $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); + $output .= ' '; + $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>'; + } $output .= '</div> <div class="cleared"></div>'; $output .= '</div>'; - if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) $output .= '<div class="cleared"></div>'; + if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) { + $output .= '<div class="cleared"></div>'; + } $x++; } @@ -148,15 +154,21 @@ $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'g-previous' ) . '</a> '; } - if ( ( $total % $per_page ) != 0 ) $numofpages++; - if ( $numofpages >= 9 && $page < $total ) $numofpages = 9 + $page; - if ( $numofpages >= ( $total / $per_page ) ) $numofpages = ( $total / $per_page ) + 1; + if ( ( $total % $per_page ) != 0 ) { + $numofpages++; + } + if ( $numofpages >= 9 && $page < $total ) { + $numofpages = 9 + $page; + } + if ( $numofpages >= ( $total / $per_page ) ) { + $numofpages = ( $total / $per_page ) + 1; + } for ( $i = 1; $i <= $numofpages; $i++ ) { if ( $i == $page ) { - $output .= ( $i . " " ); + $output .= ( $i . ' ' ); } else { - $output .= "<a href=\"" . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> "; + $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> "; } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs