Index: trunk/extensions/WikiLove/WikiLove.hooks.php |
— | — | @@ -93,6 +93,9 @@ |
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Adds a tab the old way (before MW 1.18) |
| 97 | + * @param $skin |
| 98 | + * @param $contentActions |
| 99 | + * @return bool |
97 | 100 | */ |
98 | 101 | public static function skinTemplateTabs( $skin, &$contentActions ) { |
99 | 102 | self::skinConfigViewsLinks( $skin, $contentActions ); |
— | — | @@ -101,6 +104,9 @@ |
102 | 105 | |
103 | 106 | /** |
104 | 107 | * Adds a tab or an icon the new way (MW >1.18) |
| 108 | + * @param $skin Skin |
| 109 | + * @param $links array |
| 110 | + * @return bool |
105 | 111 | */ |
106 | 112 | public static function skinTemplateNavigation( &$skin, &$links ) { |
107 | 113 | if ( self::showIcon( $skin ) ) { |
— | — | @@ -118,10 +124,11 @@ |
119 | 125 | * |
120 | 126 | * @param $skin Skin |
121 | 127 | * @param $views array |
| 128 | + * @return bool |
122 | 129 | */ |
123 | 130 | private static function skinConfigViewsLinks( $skin, &$views ) { |
124 | 131 | global $wgWikiLoveGlobal, $wgUser; |
125 | | - |
| 132 | + |
126 | 133 | // If WikiLove is turned off for this user, don't display tab. |
127 | 134 | if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) { |
128 | 135 | return true; |
— | — | @@ -137,6 +144,7 @@ |
138 | 145 | $views['wikilove']['primary'] = true; |
139 | 146 | } |
140 | 147 | } |
| 148 | + return true; |
141 | 149 | } |
142 | 150 | |
143 | 151 | /** |
— | — | @@ -161,7 +169,7 @@ |
162 | 170 | */ |
163 | 171 | public static function getUserTalkPage( $title ) { |
164 | 172 | global $wgUser; |
165 | | - |
| 173 | + |
166 | 174 | // Exit early if the sending user isn't logged in |
167 | 175 | if ( !$wgUser->isLoggedIn() ) { |
168 | 176 | return null; |
— | — | @@ -178,7 +186,7 @@ |
179 | 187 | if ( $baseTitle === null ) { |
180 | 188 | return null; |
181 | 189 | } |
182 | | - |
| 190 | + |
183 | 191 | // Get the user talk page |
184 | 192 | if ( $ns == NS_USER_TALK ) { |
185 | 193 | // We're already on the user talk page |
— | — | @@ -187,15 +195,15 @@ |
188 | 196 | // We're on the user page, so retrieve the user talk page instead |
189 | 197 | $talkTitle = $baseTitle->getTalkPage(); |
190 | 198 | } |
191 | | - |
192 | | - // If it's a redirect, exit. We don't follow redirects since it might confuse the user or |
193 | | - // lead to an endless loop (like if the talk page redirects to the user page or a subpage). |
194 | | - // This means that the WikiLove tab will not appear on user pages or user talk pages if |
| 199 | + |
| 200 | + // If it's a redirect, exit. We don't follow redirects since it might confuse the user or |
| 201 | + // lead to an endless loop (like if the talk page redirects to the user page or a subpage). |
| 202 | + // This means that the WikiLove tab will not appear on user pages or user talk pages if |
195 | 203 | // the user talk page is a redirect. |
196 | 204 | if ( $talkTitle->isRedirect() ) { |
197 | 205 | return null; |
198 | 206 | } |
199 | | - |
| 207 | + |
200 | 208 | // Make sure we can edit the page |
201 | 209 | if ( $talkTitle->quickUserCan( 'edit' ) ) { |
202 | 210 | return $talkTitle; |
Index: trunk/extensions/WikiLove/WikiLove.local.php |
— | — | @@ -3,12 +3,20 @@ |
4 | 4 | * Custom ResourceLoader module that loads a custom WikiLove.js per-wiki. |
5 | 5 | */ |
6 | 6 | class WikiLoveLocal extends ResourceLoaderWikiModule { |
| 7 | + |
| 8 | + /** |
| 9 | + * @param $context ResourceLoaderContext |
| 10 | + * @return array |
| 11 | + */ |
7 | 12 | protected function getPages( ResourceLoaderContext $context ) { |
8 | 13 | return array( |
9 | 14 | 'MediaWiki:WikiLove.js' => array( 'type' => 'script' ), |
10 | 15 | ); |
11 | 16 | } |
12 | 17 | |
| 18 | + /** |
| 19 | + * @return array |
| 20 | + */ |
13 | 21 | public function getMessages() { |
14 | 22 | global $wgWikiLoveOptionMessages; |
15 | 23 | return $wgWikiLoveOptionMessages; |
Index: trunk/extensions/WikiLove/ApiWikiLove.php |
— | — | @@ -2,23 +2,23 @@ |
3 | 3 | class ApiWikiLove extends ApiBase { |
4 | 4 | public function execute() { |
5 | 5 | global $wgRequest, $wgWikiLoveLogging, $wgParser; |
6 | | - |
| 6 | + |
7 | 7 | $params = $this->extractRequestParams(); |
8 | | - |
| 8 | + |
9 | 9 | $title = Title::newFromText( $params['title'] ); |
10 | 10 | if ( is_null( $title ) ) { |
11 | 11 | $this->dieUsageMsg( array( 'invaliduser', $params['title'] ) ); |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | $talk = WikiLoveHooks::getUserTalkPage( $title ); |
15 | 15 | if ( is_null( $talk ) ) { |
16 | 16 | $this->dieUsageMsg( array( 'invaliduser', $params['title'] ) ); |
17 | 17 | } |
18 | | - |
| 18 | + |
19 | 19 | if ( $wgWikiLoveLogging ) { |
20 | 20 | $this->saveInDb( $talk, $params['subject'], $params['message'], $params['type'], isset( $params['email'] ) ? 1 : 0 ); |
21 | 21 | } |
22 | | - |
| 22 | + |
23 | 23 | // not using section => 'new' here, as we like to give our own edit summary |
24 | 24 | $api = new ApiMain( new FauxRequest( array( |
25 | 25 | 'action' => 'edit', |
— | — | @@ -30,9 +30,9 @@ |
31 | 31 | 'summary' => wfMsgForContent( 'wikilove-summary', $wgParser->stripSectionName( $params['subject'] ) ), |
32 | 32 | 'notminor' => true, |
33 | 33 | ), false, array( 'wsEditToken' => $wgRequest->getSessionData( 'wsEditToken' ) ) ), true ); |
34 | | - |
| 34 | + |
35 | 35 | $api->execute(); |
36 | | - |
| 36 | + |
37 | 37 | if ( isset( $params['email'] ) ) { |
38 | 38 | $this->emailUser( $talk, $params['subject'], $params['email'], $params['token'] ); |
39 | 39 | } |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | $this->setWarning( 'Not logging unregistered recipients' ); |
60 | 60 | return; |
61 | 61 | } |
62 | | - |
| 62 | + |
63 | 63 | $values = array( |
64 | 64 | 'wll_timestamp' => $dbw->timestamp(), |
65 | 65 | 'wll_sender' => $wgUser->getId(), |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | 'wll_message' => $message, |
74 | 74 | 'wll_email' => $email, |
75 | 75 | ); |
76 | | - |
| 76 | + |
77 | 77 | try{ |
78 | 78 | $dbw->insert( 'wikilove_log', $values, __METHOD__ ); |
79 | 79 | } catch( DBQueryError $dbqe ) { |
Index: trunk/extensions/WikiLove/ApiWikiLoveImageLog.php |
— | — | @@ -2,36 +2,35 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * This API is for logging each time a user attempts to use a custom image via the Make your own |
6 | | - * feature. This is basically just to see if users can grok the concept. Once usage analysis is |
| 6 | + * feature. This is basically just to see if users can grok the concept. Once usage analysis is |
7 | 7 | * complete, this API can be deleted. |
8 | 8 | */ |
9 | 9 | class ApiWikiLoveImageLog extends ApiBase { |
10 | 10 | public function execute() { |
11 | | - global $wgRequest, $wgWikiLoveLogging, $wgParser; |
12 | | - |
| 11 | + global $wgWikiLoveLogging; |
| 12 | + |
13 | 13 | $params = $this->extractRequestParams(); |
14 | | - |
| 14 | + |
15 | 15 | if ( $wgWikiLoveLogging ) { |
16 | 16 | $this->saveInDb( $params['image'], $params['success'] ); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | | - * @param $user User ID |
22 | 21 | * @param $image string |
23 | 22 | * @param $success integer |
24 | 23 | */ |
25 | 24 | private function saveInDb( $image, $success ) { |
26 | 25 | global $wgUser; |
27 | 26 | $dbw = wfGetDB( DB_MASTER ); |
28 | | - |
| 27 | + |
29 | 28 | $values = array( |
30 | 29 | 'wlil_timestamp' => $dbw->timestamp(), |
31 | 30 | 'wlil_user_id' => $wgUser->getId(), |
32 | 31 | 'wlil_image' => $image, |
33 | 32 | 'wlil_success' => $success, |
34 | 33 | ); |
35 | | - |
| 34 | + |
36 | 35 | try{ |
37 | 36 | $dbw->insert( 'wikilove_image_log', $values, __METHOD__ ); |
38 | 37 | } catch( DBQueryError $dbqe ) { |
— | — | @@ -44,7 +43,7 @@ |
45 | 44 | 'This API is for logging each time a user attempts to use a custom image via WikiLove.', |
46 | 45 | ); |
47 | 46 | } |
48 | | - |
| 47 | + |
49 | 48 | public function getAllowedParams() { |
50 | 49 | return array( |
51 | 50 | 'image' => array( |
— | — | @@ -57,7 +56,7 @@ |
58 | 57 | ) |
59 | 58 | ); |
60 | 59 | } |
61 | | - |
| 60 | + |
62 | 61 | public function getVersion() { |
63 | 62 | return __CLASS__ . ': $Id$'; |
64 | 63 | } |