Index: trunk/extensions/ArticleAssessmentPilot/ApiArticleAssessmentPilot.php |
— | — | @@ -1,83 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Extend the API for ArticleAssessment |
5 | | - * |
6 | | - * @file |
7 | | - * @ingroup API |
8 | | - */ |
9 | | - |
10 | | -class ApiArticleAssessment extends ApiBase { |
11 | | - |
12 | | - /** |
13 | | - * runs when the API is called with "articleasessment" |
14 | | - * @see includes/api/ApiBase#execute() |
15 | | - */ |
16 | | - public function execute() { |
17 | | - $params = $this->extractRequestParams(); |
18 | | - $this->validateParams( $params ); |
19 | | - |
20 | | - if( isset( $params['getCumulativeResults'] ) ){ |
21 | | - //get cumulative results |
22 | | - |
23 | | - //query to add 'n' reviews together |
24 | | - |
25 | | - } |
26 | | - else if ( isset( $params['setUserVals'] ) ){ |
27 | | - //set user values |
28 | | - |
29 | | - //validate authid |
30 | | - |
31 | | - //insert |
32 | | - } |
33 | | - |
34 | | - } |
35 | | - |
36 | | - /** |
37 | | - * Required parameter check |
38 | | - * @param $params params extracted from the POST |
39 | | - */ |
40 | | - protected function validateParams( $params ) { |
41 | | - |
42 | | - if( isset( $params['getCumulativeResults'] ) ){ |
43 | | - //get cumulative results |
44 | | - $required = array('pageId', 'revId'); |
45 | | - foreach ( $required as $arg ) { |
46 | | - if ( !isset( $params[$arg] ) ) { |
47 | | - $this->dieUsageMsg( array( 'missingparam', $arg ) ); |
48 | | - } |
49 | | - } |
50 | | - } |
51 | | - else if ( isset( $params['setUserVals'] ) ){ |
52 | | - //set user values |
53 | | - $required = array('userId', 'authId', 'pageId', 'revId', 'review'); |
54 | | - foreach ( $required as $arg ) { |
55 | | - if ( !isset( $params[$arg] ) ) { |
56 | | - $this->dieUsageMsg( array( 'missingparam', $arg ) ); |
57 | | - } |
58 | | - } |
59 | | - } |
60 | | - else{ |
61 | | - //FIXME: better usage message |
62 | | - $this->dieUsageMsg( array('missingparam', "mode") ); |
63 | | - } |
64 | | - } |
65 | | - |
66 | | - /* |
67 | | - public function getParamDescription() { |
68 | | - return array( |
69 | | - 'getResults' => 'set if you want to get results', |
70 | | - ); |
71 | | - }*/ |
72 | | - |
73 | | - public function getDescription() { |
74 | | - return array( |
75 | | - 'get and set article assessment data' |
76 | | - ); |
77 | | - } |
78 | | - |
79 | | - |
80 | | - public function getVersion() { |
81 | | - return __CLASS__ . ':0'; |
82 | | - } |
83 | | - |
84 | | -} |
\ No newline at end of file |
Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | |
10 | 10 | //Auto-load files |
11 | 11 | $dir = dirname( __FILE__ ) . '/'; |
12 | | -$wgAutoloadClasses['ApiArticleAssessment'] = $dir . 'ApiArticleAssessment.php'; |
| 12 | +$wgAutoloadClasses['ApiArticleAssessment'] = $dir . 'api/ApiArticleAssessment.php'; |
13 | 13 | $wgAutoloadClasses['ArticleAssessmentPilotHooks'] = $dir . 'ArticleAssessmentPilot.hooks.php'; |
14 | 14 | |
15 | 15 | |
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessmentPilot.php |
— | — | @@ -0,0 +1,83 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Extend the API for ArticleAssessment |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup API |
| 8 | + */ |
| 9 | + |
| 10 | +class ApiArticleAssessment extends ApiBase { |
| 11 | + |
| 12 | + /** |
| 13 | + * runs when the API is called with "articleasessment" |
| 14 | + * @see includes/api/ApiBase#execute() |
| 15 | + */ |
| 16 | + public function execute() { |
| 17 | + $params = $this->extractRequestParams(); |
| 18 | + $this->validateParams( $params ); |
| 19 | + |
| 20 | + if( isset( $params['getCumulativeResults'] ) ){ |
| 21 | + //get cumulative results |
| 22 | + |
| 23 | + //query to add 'n' reviews together |
| 24 | + |
| 25 | + } |
| 26 | + else if ( isset( $params['setUserVals'] ) ){ |
| 27 | + //set user values |
| 28 | + |
| 29 | + //validate authid |
| 30 | + |
| 31 | + //insert |
| 32 | + } |
| 33 | + |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Required parameter check |
| 38 | + * @param $params params extracted from the POST |
| 39 | + */ |
| 40 | + protected function validateParams( $params ) { |
| 41 | + |
| 42 | + if( isset( $params['getCumulativeResults'] ) ){ |
| 43 | + //get cumulative results |
| 44 | + $required = array('pageId', 'revId'); |
| 45 | + foreach ( $required as $arg ) { |
| 46 | + if ( !isset( $params[$arg] ) ) { |
| 47 | + $this->dieUsageMsg( array( 'missingparam', $arg ) ); |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + else if ( isset( $params['setUserVals'] ) ){ |
| 52 | + //set user values |
| 53 | + $required = array('userId', 'authId', 'pageId', 'revId', 'review'); |
| 54 | + foreach ( $required as $arg ) { |
| 55 | + if ( !isset( $params[$arg] ) ) { |
| 56 | + $this->dieUsageMsg( array( 'missingparam', $arg ) ); |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + else{ |
| 61 | + //FIXME: better usage message |
| 62 | + $this->dieUsageMsg( array('missingparam', "mode") ); |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + /* |
| 67 | + public function getParamDescription() { |
| 68 | + return array( |
| 69 | + 'getResults' => 'set if you want to get results', |
| 70 | + ); |
| 71 | + }*/ |
| 72 | + |
| 73 | + public function getDescription() { |
| 74 | + return array( |
| 75 | + 'get and set article assessment data' |
| 76 | + ); |
| 77 | + } |
| 78 | + |
| 79 | + |
| 80 | + public function getVersion() { |
| 81 | + return __CLASS__ . ':0'; |
| 82 | + } |
| 83 | + |
| 84 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessmentPilot.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 85 | + native |