r84467 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84466‎ | r84467 | r84468 >
Date:17:47, 21 March 2011
Author:nimishg
Status:ok
Tags:
Comment:
mft: r84203
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/UserDailyContribs/UserDailyContribs.hooks.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UserDailyContribs/UserDailyContribs.i18n.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UserDailyContribs/UserDailyContribs.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/UserDailyContribs/api (added) (history)
  • /branches/wmf/1.17wmf1/extensions/UserDailyContribs/api/ApiUserDailyContribs.php (added) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/UserDailyContribs/UserDailyContribs.i18n.php
@@ -59,7 +59,7 @@
6060 'userdailycontribs-desc' => 'مساهمات المستخدمين اليويمه لامتداد تتبع الضغطات',
6161 );
6262
63 -/** Bashkir (Башҡорт)
 63+/** Bashkir (Башҡортса)
6464 * @author Assele
6565 */
6666 $messages['ba'] = array(
@@ -73,7 +73,7 @@
7474 'userdailycontribs-desc' => 'Штодзённы ўклад удзельніка для гаджэта сачэння за націскамі мышшу',
7575 );
7676
77 -/** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца))
 77+/** Belarusian (Taraškievica orthography) (‪Беларуская (тарашкевіца)‬)
7878 * @author Jim-by
7979 */
8080 $messages['be-tarask'] = array(
@@ -344,7 +344,7 @@
345345 * @author Bjankuloski06
346346 */
347347 $messages['mk'] = array(
348 - 'userdailycontribs-desc' => 'Дневни придонеси од корисници за проширувањето „Следење на кликови“',
 348+ 'userdailycontribs-desc' => 'Дневни придонеси од корисници за додатокот „Следење на стискања“',
349349 );
350350
351351 /** Malayalam (മലയാളം)
@@ -561,8 +561,9 @@
562562
563563 /** Traditional Chinese (‪中文(繁體)‬)
564564 * @author Liangent
 565+ * @author Mark85296341
565566 */
566567 $messages['zh-hant'] = array(
567 - 'userdailycontribs-desc' => '點擊跟蹤擴展的用戶每日貢獻',
 568+ 'userdailycontribs-desc' => '點擊追蹤擴展的用戶每日貢獻',
568569 );
569570
Index: branches/wmf/1.17wmf1/extensions/UserDailyContribs/api/ApiUserDailyContribs.php
@@ -0,0 +1,59 @@
 2+<?php
 3+
 4+class ApiUserDailyContribs extends ApiBase {
 5+
 6+ public function execute() {
 7+ $params = $this->extractRequestParams();
 8+ $result = $this->getResult();
 9+
 10+ $userName = $params['user'];
 11+ $days = $params['daysago'];
 12+ $user = User::newFromName($userName);
 13+ if ( !$user ) {
 14+ $this->dieUsage( 'Specified user does not exist', 'bad_user' );
 15+ }
 16+
 17+ $now = time();
 18+ $result->addValue( $this->getModuleName() ,
 19+ 'totalEdits',
 20+ ($user->getEditCount() == NULL)?0:$user->getEditCount() );
 21+ //returns YYYY-MM-DD-HH-MM-SS format
 22+ $result->addValue( $this->getModuleName() ,
 23+ 'registration', $user->getRegistration() );
 24+ $result->addValue( $this->getModuleName() ,
 25+ 'timeFrameEdits', getUserEditCountSince( $now - ($days * 60 *60 *24) ));
 26+ }
 27+
 28+ public function getAllowedParams() {
 29+ return array(
 30+ 'user' => array(
 31+ ApiBase::PARAM_TYPE => 'user',
 32+ ),
 33+ 'daysago' => array(
 34+ ApiBase::PARAM_TYPE => 'integer',
 35+ ApiBase::PARAM_MIN => 0,
 36+ ),
 37+
 38+ );
 39+ }
 40+
 41+ public function getParamDescription() {
 42+ return array(
 43+ 'user' => 'Username to query',
 44+ 'daysago' => 'Number of edits since this many days ago',
 45+ );
 46+ }
 47+
 48+ public function getDescription() {
 49+ return 'Get the total number of user edits, time of registration, and edits in a given timeframe';
 50+ }
 51+
 52+ protected function getExamples() {
 53+ return 'api.php?action=userdailycontribs&user=WikiSysop&daysago=5';
 54+ }
 55+
 56+ public function getVersion() {
 57+ return __CLASS__ . ': $Id: ApiUserDailyContribs.php 84203 2011-03-17 21:09:27Z nimishg $';
 58+ }
 59+
 60+}
\ No newline at end of file
Property changes on: branches/wmf/1.17wmf1/extensions/UserDailyContribs/api/ApiUserDailyContribs.php
___________________________________________________________________
Added: svn:eol-style
161 + native
Index: branches/wmf/1.17wmf1/extensions/UserDailyContribs/UserDailyContribs.php
@@ -24,10 +24,12 @@
2525 'descriptionmsg' => 'userdailycontribs-desc',
2626 );
2727 $wgAutoloadClasses['UserDailyContribsHooks'] = dirname( __FILE__ ) . '/UserDailyContribs.hooks.php';
 28+$wgAutoloadClasses['ApiUserDailyContribs'] = dirname( __FILE__ ) . '/api/ApiUserDailyContribs.php';
2829 $wgExtensionMessagesFiles['UserDailyContribs'] = dirname( __FILE__ ) . '/UserDailyContribs.i18n.php';
2930 $wgHooks['LoadExtensionSchemaUpdates'][] = 'UserDailyContribsHooks::loadExtensionSchemaUpdates';
3031 $wgHooks['ArticleSaveComplete'][] = 'UserDailyContribsHooks::articleSaveComplete';
3132 $wgHooks['ParserTestTables'][] = 'UserDailyContribsHooks::parserTestTables';
 33+$wgAPIModules['userdailycontribs'] = 'ApiUserDailyContribs';
3234
3335 /**
3436 * Get the number of revisions a user has made since a given time
Index: branches/wmf/1.17wmf1/extensions/UserDailyContribs/UserDailyContribs.hooks.php
@@ -13,10 +13,14 @@
1414 /**
1515 * LoadExtensionSchemaUpdates hook
1616 */
17 - public static function loadExtensionSchemaUpdates() {
18 - global $wgExtNewTables;
19 -
20 - $wgExtNewTables[] = array( 'user_daily_contribs', dirname( __FILE__ ) . '/patches/UserDailyContribs.sql' );
 17+ public static function loadExtensionSchemaUpdates( $updater = null ) {
 18+ if ( $updater === null ) {
 19+ global $wgExtNewTables;
 20+ $wgExtNewTables[] = array( 'user_daily_contribs', dirname( __FILE__ ) . '/patches/UserDailyContribs.sql' );
 21+ } else {
 22+ $updater->addExtensionUpdate( array( 'addTable', 'user_daily_contribs',
 23+ dirname( __FILE__ ) . '/patches/UserDailyContribs.sql', true ) );
 24+ }
2125 return true;
2226 }
2327
@@ -58,4 +62,4 @@
5963 }
6064 return true;
6165 }
62 -}
\ No newline at end of file
 66+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r84484Followup r84467, fix svn props on API (it's useful)reedy20:49, 21 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84203Stylistic changes and some validationnimishg21:09, 17 March 2011

Status & tagging log