Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php |
— | — | @@ -1,9 +1,16 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Special:ViewGifts -- a special page for viewing the list of user-to-user |
| 5 | + * gifts a given user has received |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
| 9 | + */ |
3 | 10 | |
4 | 11 | class ViewGifts extends SpecialPage { |
5 | 12 | |
6 | 13 | /** |
7 | | - * Constructor |
| 14 | + * Constructor -- set up the new special page |
8 | 15 | */ |
9 | 16 | public function __construct() { |
10 | 17 | parent::__construct( 'ViewGifts' ); |
— | — | @@ -15,12 +22,12 @@ |
16 | 23 | * @param $par Mixed: parameter passed to the page or null |
17 | 24 | */ |
18 | 25 | public function execute( $par ) { |
19 | | - global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts; |
| 26 | + global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserGiftsScripts; |
20 | 27 | |
21 | 28 | $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' ); |
22 | 29 | |
23 | 30 | $user_name = $wgRequest->getVal( 'user' ); |
24 | | - $page = $wgRequest->getVal( 'page' ); |
| 31 | + $page = $wgRequest->getVal( 'page' ); |
25 | 32 | |
26 | 33 | /** |
27 | 34 | * Redirect Non-logged in users to Login Page |
— | — | @@ -33,14 +40,13 @@ |
34 | 41 | } |
35 | 42 | |
36 | 43 | /** |
37 | | - * If no user is set in the URL, we assume its the current user |
| 44 | + * If no user is set in the URL, we assume it's the current user |
38 | 45 | */ |
39 | 46 | if ( !$user_name ) { |
40 | 47 | $user_name = $wgUser->getName(); |
41 | 48 | } |
42 | 49 | $user_id = User::idFromName( $user_name ); |
43 | 50 | $user = Title::makeTitle( NS_USER, $user_name ); |
44 | | - $user_safe = urlencode( $user_name ); |
45 | 51 | |
46 | 52 | /** |
47 | 53 | * Error message for username that does not exist (from URL) |
— | — | @@ -68,66 +74,76 @@ |
69 | 75 | $gifts = $rel->getUserGiftList( 0, $per_page, $page ); |
70 | 76 | $total = $rel->getGiftCountByUsername( $user_name ); |
71 | 77 | |
72 | | - $relationship = UserRelationship::getUserRelationshipByID( $user_id, $wgUser->getID() ); |
73 | | - |
74 | 78 | /** |
75 | 79 | * Show gift count for user |
76 | 80 | */ |
77 | | - $output = $wgOut->setPageTitle( wfMsg( 'g-list-title', $rel->user_name ) ); |
| 81 | + $wgOut->setPageTitle( wfMsg( 'g-list-title', $rel->user_name ) ); |
78 | 82 | |
79 | | - $output .= '<div class="back-links"> |
80 | | - <a href="' . $user->getFullURL() . '">' |
81 | | - . wfMsg( 'g-back-link', $rel->user_name ) . |
| 83 | + $output = '<div class="back-links"> |
| 84 | + <a href="' . $user->getFullURL() . '">' . |
| 85 | + wfMsg( 'g-back-link', $rel->user_name ) . |
82 | 86 | '</a> |
83 | 87 | </div> |
84 | | - <div class="g-count">' |
85 | | - . wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ) . |
| 88 | + <div class="g-count">' . |
| 89 | + wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ) . |
86 | 90 | '</div>'; |
87 | 91 | |
88 | 92 | if ( $gifts ) { |
89 | 93 | $x = 1; |
90 | 94 | |
91 | 95 | // Safe links |
92 | | - $view_gift_link = SpecialPage::getTitleFor( 'ViewGift' ); |
93 | | - $give_gift_link = SpecialPage::getTitleFor( 'GiveGift' ); |
94 | | - $remove_gift_link = SpecialPage::getTitleFor( 'RemoveGift' ); |
| 96 | + $viewGiftLink = SpecialPage::getTitleFor( 'ViewGift' ); |
| 97 | + $giveGiftLink = SpecialPage::getTitleFor( 'GiveGift' ); |
| 98 | + $removeGiftLink = SpecialPage::getTitleFor( 'RemoveGift' ); |
95 | 99 | |
96 | 100 | foreach ( $gifts as $gift ) { |
97 | 101 | $giftname_length = strlen( $gift['gift_name'] ); |
98 | 102 | $giftname_space = stripos( $gift['gift_name'], ' ' ); |
99 | 103 | |
100 | 104 | if ( ( $giftname_space == false || $giftname_space >= "30" ) && $giftname_length > 30 ) { |
101 | | - $gift_name_display = substr( $gift['gift_name'], 0, 30 ) . ' ' . substr( $gift['gift_name'], 30, 50 ); |
| 105 | + $gift_name_display = substr( $gift['gift_name'], 0, 30 ) . |
| 106 | + ' ' . substr( $gift['gift_name'], 30, 50 ); |
102 | 107 | } else { |
103 | 108 | $gift_name_display = $gift['gift_name']; |
104 | 109 | } |
105 | 110 | |
106 | 111 | $user_from = Title::makeTitle( NS_USER, $gift['user_name_from'] ); |
107 | | - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />'; |
| 112 | + $gift_image = "<img src=\"{$wgUploadPath}/awards/" . |
| 113 | + Gifts::getGiftImage( $gift['gift_id'], 'l' ) . |
| 114 | + '" border="0" alt="" />'; |
108 | 115 | |
109 | 116 | $output .= '<div class="g-item"> |
110 | | - <a href="' . $view_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . $gift_image . '</a> |
| 117 | + <a href="' . $viewGiftLink->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . |
| 118 | + $gift_image . |
| 119 | + '</a> |
111 | 120 | <div class="g-title"> |
112 | | - <a href="' . $view_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . $gift_name_display . '</a>'; |
| 121 | + <a href="' . $viewGiftLink->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . |
| 122 | + $gift_name_display . |
| 123 | + '</a>'; |
113 | 124 | if ( $gift['status'] == 1 ) { |
114 | 125 | if ( $user_name == $wgUser->getName() ) { |
115 | 126 | $rel->clearUserGiftStatus( $gift['id'] ); |
116 | 127 | $rel->decNewGiftCount( $wgUser->getID() ); |
117 | 128 | } |
118 | | - $output .= '<span class="g-new">' . wfMsg( 'g-new' ) . '</span>'; |
| 129 | + $output .= '<span class="g-new">' . |
| 130 | + wfMsg( 'g-new' ) . |
| 131 | + '</span>'; |
119 | 132 | } |
120 | 133 | $output .= '</div>'; |
121 | 134 | |
122 | | - $output .= '<div class="g-from">' |
123 | | - . wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ) . |
| 135 | + $output .= '<div class="g-from">' . |
| 136 | + wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ) . |
124 | 137 | '</div> |
125 | 138 | <div class="g-actions"> |
126 | | - <a href="' . $give_gift_link->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . wfMsg( 'g-to-another' ) . '</a>'; |
| 139 | + <a href="' . $giveGiftLink->escapeFullURL( 'gift_id=' . $gift['gift_id'] ) . '">' . |
| 140 | + wfMsg( 'g-to-another' ) . |
| 141 | + '</a>'; |
127 | 142 | if ( $rel->user_name == $wgUser->getName() ) { |
128 | 143 | $output .= ' '; |
129 | | - $output .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); |
| 144 | + $output .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); |
130 | 145 | $output .= ' '; |
131 | | - $output .= '<a href="' . $remove_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . wfMsg( 'g-remove-gift' ) . '</a>'; |
| 146 | + $output .= '<a href="' . $removeGiftLink->escapeFullURL( 'gift_id=' . $gift['id'] ) . '">' . |
| 147 | + wfMsg( 'g-remove-gift' ) . '</a>'; |
132 | 148 | } |
133 | 149 | $output .= '</div> |
134 | 150 | <div class="cleared"></div>'; |
— | — | @@ -145,12 +161,13 @@ |
146 | 162 | */ |
147 | 163 | $numofpages = $total / $per_page; |
148 | 164 | |
149 | | - $page_link = SpecialPage::getTitleFor( 'ViewGifts' ); |
| 165 | + $pageLink = SpecialPage::getTitleFor( 'ViewGifts' ); |
150 | 166 | |
151 | 167 | if ( $numofpages > 1 ) { |
152 | 168 | $output .= '<div class="page-nav">'; |
153 | 169 | if ( $page > 1 ) { |
154 | | - $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'g-previous' ) . '</a> '; |
| 170 | + $output .= '<a href="' . $pageLink->escapeFullURL( 'user=' . $user_name . '&page=' . ( $page - 1 ) ) . '">' . |
| 171 | + wfMsg( 'g-previous' ) . '</a> '; |
155 | 172 | } |
156 | 173 | |
157 | 174 | if ( ( $total % $per_page ) != 0 ) { |
— | — | @@ -167,19 +184,17 @@ |
168 | 185 | if ( $i == $page ) { |
169 | 186 | $output .= ( $i . ' ' ); |
170 | 187 | } else { |
171 | | - $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> "; |
| 188 | + $output .= '<a href="' . $pageLink->escapeFullURL( 'user=' . $user_name . '&page=' . $i ) . "\">$i</a> "; |
172 | 189 | } |
173 | 190 | } |
174 | 191 | |
175 | 192 | if ( ( $total - ( $per_page * $page ) ) > 0 ) { |
176 | | - $output .= ' <a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page + 1 ) ) . '">' . wfMsg( 'g-next' ) . '</a>'; |
| 193 | + $output .= ' <a href="' . $pageLink->escapeFullURL( 'user=' . $user_name . '&page=' . ( $page + 1 ) ) . '">' . |
| 194 | + wfMsg( 'g-next' ) . '</a>'; |
177 | 195 | } |
178 | 196 | $output .= '</div>'; |
179 | 197 | } |
180 | 198 | |
181 | | - /** |
182 | | - * Build next/prev nav |
183 | | - */ |
184 | 199 | $wgOut->addHTML( $output ); |
185 | 200 | } |
186 | 201 | } |