r100473 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100472‎ | r100473 | r100474 >
Date:23:07, 21 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Trim trailing whitespace

Documentation, returns
Modified paths:
  • /trunk/extensions/WikiLove/ApiWikiLove.php (modified) (history)
  • /trunk/extensions/WikiLove/ApiWikiLoveImageLog.php (modified) (history)
  • /trunk/extensions/WikiLove/WikiLove.hooks.php (modified) (history)
  • /trunk/extensions/WikiLove/WikiLove.local.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/WikiLove.hooks.php
@@ -93,6 +93,9 @@
9494
9595 /**
9696 * Adds a tab the old way (before MW 1.18)
 97+ * @param $skin
 98+ * @param $contentActions
 99+ * @return bool
97100 */
98101 public static function skinTemplateTabs( $skin, &$contentActions ) {
99102 self::skinConfigViewsLinks( $skin, $contentActions );
@@ -101,6 +104,9 @@
102105
103106 /**
104107 * Adds a tab or an icon the new way (MW >1.18)
 108+ * @param $skin Skin
 109+ * @param $links array
 110+ * @return bool
105111 */
106112 public static function skinTemplateNavigation( &$skin, &$links ) {
107113 if ( self::showIcon( $skin ) ) {
@@ -118,10 +124,11 @@
119125 *
120126 * @param $skin Skin
121127 * @param $views array
 128+ * @return bool
122129 */
123130 private static function skinConfigViewsLinks( $skin, &$views ) {
124131 global $wgWikiLoveGlobal, $wgUser;
125 -
 132+
126133 // If WikiLove is turned off for this user, don't display tab.
127134 if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) {
128135 return true;
@@ -137,6 +144,7 @@
138145 $views['wikilove']['primary'] = true;
139146 }
140147 }
 148+ return true;
141149 }
142150
143151 /**
@@ -161,7 +169,7 @@
162170 */
163171 public static function getUserTalkPage( $title ) {
164172 global $wgUser;
165 -
 173+
166174 // Exit early if the sending user isn't logged in
167175 if ( !$wgUser->isLoggedIn() ) {
168176 return null;
@@ -178,7 +186,7 @@
179187 if ( $baseTitle === null ) {
180188 return null;
181189 }
182 -
 190+
183191 // Get the user talk page
184192 if ( $ns == NS_USER_TALK ) {
185193 // We're already on the user talk page
@@ -187,15 +195,15 @@
188196 // We're on the user page, so retrieve the user talk page instead
189197 $talkTitle = $baseTitle->getTalkPage();
190198 }
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
195203 // the user talk page is a redirect.
196204 if ( $talkTitle->isRedirect() ) {
197205 return null;
198206 }
199 -
 207+
200208 // Make sure we can edit the page
201209 if ( $talkTitle->quickUserCan( 'edit' ) ) {
202210 return $talkTitle;
Index: trunk/extensions/WikiLove/WikiLove.local.php
@@ -3,12 +3,20 @@
44 * Custom ResourceLoader module that loads a custom WikiLove.js per-wiki.
55 */
66 class WikiLoveLocal extends ResourceLoaderWikiModule {
 7+
 8+ /**
 9+ * @param $context ResourceLoaderContext
 10+ * @return array
 11+ */
712 protected function getPages( ResourceLoaderContext $context ) {
813 return array(
914 'MediaWiki:WikiLove.js' => array( 'type' => 'script' ),
1015 );
1116 }
1217
 18+ /**
 19+ * @return array
 20+ */
1321 public function getMessages() {
1422 global $wgWikiLoveOptionMessages;
1523 return $wgWikiLoveOptionMessages;
Index: trunk/extensions/WikiLove/ApiWikiLove.php
@@ -2,23 +2,23 @@
33 class ApiWikiLove extends ApiBase {
44 public function execute() {
55 global $wgRequest, $wgWikiLoveLogging, $wgParser;
6 -
 6+
77 $params = $this->extractRequestParams();
8 -
 8+
99 $title = Title::newFromText( $params['title'] );
1010 if ( is_null( $title ) ) {
1111 $this->dieUsageMsg( array( 'invaliduser', $params['title'] ) );
1212 }
13 -
 13+
1414 $talk = WikiLoveHooks::getUserTalkPage( $title );
1515 if ( is_null( $talk ) ) {
1616 $this->dieUsageMsg( array( 'invaliduser', $params['title'] ) );
1717 }
18 -
 18+
1919 if ( $wgWikiLoveLogging ) {
2020 $this->saveInDb( $talk, $params['subject'], $params['message'], $params['type'], isset( $params['email'] ) ? 1 : 0 );
2121 }
22 -
 22+
2323 // not using section => 'new' here, as we like to give our own edit summary
2424 $api = new ApiMain( new FauxRequest( array(
2525 'action' => 'edit',
@@ -30,9 +30,9 @@
3131 'summary' => wfMsgForContent( 'wikilove-summary', $wgParser->stripSectionName( $params['subject'] ) ),
3232 'notminor' => true,
3333 ), false, array( 'wsEditToken' => $wgRequest->getSessionData( 'wsEditToken' ) ) ), true );
34 -
 34+
3535 $api->execute();
36 -
 36+
3737 if ( isset( $params['email'] ) ) {
3838 $this->emailUser( $talk, $params['subject'], $params['email'], $params['token'] );
3939 }
@@ -58,7 +58,7 @@
5959 $this->setWarning( 'Not logging unregistered recipients' );
6060 return;
6161 }
62 -
 62+
6363 $values = array(
6464 'wll_timestamp' => $dbw->timestamp(),
6565 'wll_sender' => $wgUser->getId(),
@@ -72,7 +72,7 @@
7373 'wll_message' => $message,
7474 'wll_email' => $email,
7575 );
76 -
 76+
7777 try{
7878 $dbw->insert( 'wikilove_log', $values, __METHOD__ );
7979 } catch( DBQueryError $dbqe ) {
Index: trunk/extensions/WikiLove/ApiWikiLoveImageLog.php
@@ -2,36 +2,35 @@
33
44 /**
55 * 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
77 * complete, this API can be deleted.
88 */
99 class ApiWikiLoveImageLog extends ApiBase {
1010 public function execute() {
11 - global $wgRequest, $wgWikiLoveLogging, $wgParser;
12 -
 11+ global $wgWikiLoveLogging;
 12+
1313 $params = $this->extractRequestParams();
14 -
 14+
1515 if ( $wgWikiLoveLogging ) {
1616 $this->saveInDb( $params['image'], $params['success'] );
1717 }
1818 }
1919
2020 /**
21 - * @param $user User ID
2221 * @param $image string
2322 * @param $success integer
2423 */
2524 private function saveInDb( $image, $success ) {
2625 global $wgUser;
2726 $dbw = wfGetDB( DB_MASTER );
28 -
 27+
2928 $values = array(
3029 'wlil_timestamp' => $dbw->timestamp(),
3130 'wlil_user_id' => $wgUser->getId(),
3231 'wlil_image' => $image,
3332 'wlil_success' => $success,
3433 );
35 -
 34+
3635 try{
3736 $dbw->insert( 'wikilove_image_log', $values, __METHOD__ );
3837 } catch( DBQueryError $dbqe ) {
@@ -44,7 +43,7 @@
4544 'This API is for logging each time a user attempts to use a custom image via WikiLove.',
4645 );
4746 }
48 -
 47+
4948 public function getAllowedParams() {
5049 return array(
5150 'image' => array(
@@ -57,7 +56,7 @@
5857 )
5958 );
6059 }
61 -
 60+
6261 public function getVersion() {
6362 return __CLASS__ . ': $Id$';
6463 }

Status & tagging log