Index: trunk/extensions/Contest/specials/SpecialContestant.php |
— | — | @@ -53,8 +53,8 @@ |
54 | 54 | $this->displayNavigation(); |
55 | 55 | |
56 | 56 | $this->showGeneralInfo( $contestant ); |
57 | | - $this->showRating(); |
58 | | - $this->showComments(); |
| 57 | + $this->showRating( $contestant ); |
| 58 | + $this->showComments( $contestant ); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
Index: trunk/extensions/Contest/Contest.php |
— | — | @@ -53,6 +53,7 @@ |
54 | 54 | $wgAutoloadClasses['ApiDeleteContest'] = dirname( __FILE__ ) . '/api/ApiDeleteContest.php'; |
55 | 55 | $wgAutoloadClasses['ApiQueryChallenges'] = dirname( __FILE__ ) . '/api/ApiQueryChallenges.php'; |
56 | 56 | $wgAutoloadClasses['ApiQueryContestants'] = dirname( __FILE__ ) . '/api/ApiQueryContestants.php'; |
| 57 | +$wgAutoloadClasses['ApiQueryContestComments'] = dirname( __FILE__ ) . '/api/ApiQueryContestComments.php'; |
57 | 58 | $wgAutoloadClasses['ApiQueryContests'] = dirname( __FILE__ ) . '/api/ApiQueryContests.php'; |
58 | 59 | |
59 | 60 | $wgAutoloadClasses['Contest'] = dirname( __FILE__ ) . '/includes/Contest.class.php'; |
— | — | @@ -93,6 +94,7 @@ |
94 | 95 | $wgAPIModules['deletecontest'] = 'ApiDeleteContest'; |
95 | 96 | $wgAPIListModules['challenges'] = 'ApiQueryChallenges'; |
96 | 97 | $wgAPIListModules['contestants'] = 'ApiQueryContestants'; |
| 98 | +$wgAPIListModules['contestcomments'] = 'ApiQueryContestComments'; |
97 | 99 | $wgAPIListModules['contests'] = 'ApiQueryContests'; |
98 | 100 | |
99 | 101 | // Hooks |
Index: trunk/extensions/Contest/api/ApiContestQuery.php |
— | — | @@ -16,14 +16,16 @@ |
17 | 17 | abstract class ApiContestQuery extends ApiQueryBase { |
18 | 18 | |
19 | 19 | /** |
20 | | - * Returns the class name of the ContestDBClass deriving class to be used |
21 | | - * to query for results. |
| 20 | + * Returns the class specific info. |
| 21 | + * * class: name of the ContestDBClass deriving class (ie Contest) |
| 22 | + * * item: item name (ie contest) |
| 23 | + * * set: item set name (ie contests) |
22 | 24 | * |
23 | 25 | * @since 0.1 |
24 | 26 | * |
25 | | - * @return string |
| 27 | + * @return array of string |
26 | 28 | */ |
27 | | - protected abstract function getClassName(); |
| 29 | + protected abstract function getClassInfo(); |
28 | 30 | |
29 | 31 | /** |
30 | 32 | * Returns an instance of the ContestDBClass deriving class. |
— | — | @@ -36,7 +38,8 @@ |
37 | 39 | * @return ContestDBClass |
38 | 40 | */ |
39 | 41 | protected function getClass() { |
40 | | - $className = $this->getClassName(); |
| 42 | + $className = $this->getClassInfo(); |
| 43 | + $className = $className['class']; |
41 | 44 | return $className::s(); |
42 | 45 | } |
43 | 46 | |
— | — | @@ -141,11 +144,20 @@ |
142 | 145 | $serializedResults[] = $result->toArray(); |
143 | 146 | } |
144 | 147 | |
145 | | - $this->getResult()->setIndexedTagName( $serializedResults, 'contest' ); |
146 | | - |
| 148 | + $this->addIndexedTagNames( $serializedResults ); |
| 149 | + $this->addSerializedResults( $serializedResults ); |
| 150 | + } |
| 151 | + |
| 152 | + protected function addIndexedTagNames( array $serializedResults ) { |
| 153 | + $classInfo = $this->getClassInfo(); |
| 154 | + $this->getResult()->setIndexedTagName( $serializedResults, $classInfo['item'] ); |
| 155 | + } |
| 156 | + |
| 157 | + protected function addSerializedResults( array $serializedResults ) { |
| 158 | + $classInfo = $this->getClassInfo(); |
147 | 159 | $this->getResult()->addValue( |
148 | 160 | null, |
149 | | - 'contests', |
| 161 | + $classInfo['set'], |
150 | 162 | $serializedResults |
151 | 163 | ); |
152 | 164 | } |
Index: trunk/extensions/Contest/api/ApiQueryContests.php |
— | — | @@ -14,8 +14,16 @@ |
15 | 15 | */ |
16 | 16 | class ApiQueryContests extends ApiContestQuery { |
17 | 17 | |
18 | | - protected function getClassName() { |
19 | | - return 'Contest'; |
| 18 | + /** |
| 19 | + * (non-PHPdoc) |
| 20 | + * @see ApiContestQuery::getClassInfo() |
| 21 | + */ |
| 22 | + protected function getClassInfo() { |
| 23 | + return array( |
| 24 | + 'class' => 'Contest', |
| 25 | + 'item' => 'contest', |
| 26 | + 'set' => 'contests', |
| 27 | + ); |
20 | 28 | } |
21 | 29 | |
22 | 30 | public function __construct( $main, $action ) { |
Index: trunk/extensions/Contest/api/ApiQueryChallenges.php |
— | — | @@ -14,8 +14,16 @@ |
15 | 15 | */ |
16 | 16 | class ApiQueryChallenges extends ApiContestQuery { |
17 | 17 | |
18 | | - protected function getClassName() { |
19 | | - return 'ContestChallenge'; |
| 18 | + /** |
| 19 | + * (non-PHPdoc) |
| 20 | + * @see ApiContestQuery::getClassInfo() |
| 21 | + */ |
| 22 | + protected function getClassInfo() { |
| 23 | + return array( |
| 24 | + 'class' => 'ContestChallenge', |
| 25 | + 'item' => 'challenge', |
| 26 | + 'set' => 'challenges', |
| 27 | + ); |
20 | 28 | } |
21 | 29 | |
22 | 30 | public function __construct( $main, $action ) { |
Index: trunk/extensions/Contest/api/ApiQueryContestComments.php |
— | — | @@ -0,0 +1,74 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * API module to get a list of commets. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file ApiQueryContestComments.php |
| 10 | + * @ingroup Contest |
| 11 | + * @ingroup API |
| 12 | + * |
| 13 | + * @licence GNU GPL v3+ |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class ApiQueryContestComments extends ApiContestQuery { |
| 17 | + |
| 18 | + /** |
| 19 | + * (non-PHPdoc) |
| 20 | + * @see ApiContestQuery::getClassInfo() |
| 21 | + */ |
| 22 | + protected function getClassInfo() { |
| 23 | + return array( |
| 24 | + 'class' => 'ContestComment', |
| 25 | + 'item' => 'comment', |
| 26 | + 'set' => 'comments', |
| 27 | + ); |
| 28 | + } |
| 29 | + |
| 30 | + public function __construct( $main, $action ) { |
| 31 | + parent::__construct( $main, $action, 'coco' ); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Handle the API request. |
| 36 | + * Checks for access rights and then let's the parent method do the actual work. |
| 37 | + */ |
| 38 | + public function execute() { |
| 39 | + global $wgUser; |
| 40 | + |
| 41 | + if ( !$wgUser->isAllowed( 'contestjudge' ) || $wgUser->isBlocked() ) { |
| 42 | + $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
| 43 | + } |
| 44 | + |
| 45 | + parent::execute(); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * (non-PHPdoc) |
| 50 | + * @see includes/api/ApiBase#getDescription() |
| 51 | + */ |
| 52 | + public function getDescription() { |
| 53 | + return 'API module for querying contest comments'; |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * (non-PHPdoc) |
| 58 | + * @see includes/api/ApiBase#getExamples() |
| 59 | + */ |
| 60 | + protected function getExamples() { |
| 61 | + return array ( |
| 62 | + 'api.php?action=query&list=contestcomments&cocoprops=id|user_id|contestant_id|text', |
| 63 | + 'api.php?action=query&list=contestcomments&cocoprops=id|text&cocouser_id=42', |
| 64 | + ); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * (non-PHPdoc) |
| 69 | + * @see includes/api/ApiBase#getVersion() |
| 70 | + */ |
| 71 | + public function getVersion() { |
| 72 | + return __CLASS__ . ': $Id$'; |
| 73 | + } |
| 74 | + |
| 75 | +} |
Property changes on: trunk/extensions/Contest/api/ApiQueryContestComments.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 76 | + Id |
Index: trunk/extensions/Contest/api/ApiQueryContestants.php |
— | — | @@ -14,8 +14,16 @@ |
15 | 15 | */ |
16 | 16 | class ApiQueryContestants extends ApiContestQuery { |
17 | 17 | |
18 | | - protected function getClassName() { |
19 | | - return 'ContestContestant'; |
| 18 | + /** |
| 19 | + * (non-PHPdoc) |
| 20 | + * @see ApiContestQuery::getClassInfo() |
| 21 | + */ |
| 22 | + protected function getClassInfo() { |
| 23 | + return array( |
| 24 | + 'class' => 'ContestContestant', |
| 25 | + 'item' => 'contestant', |
| 26 | + 'set' => 'contestants', |
| 27 | + ); |
20 | 28 | } |
21 | 29 | |
22 | 30 | public function __construct( $main, $action ) { |
— | — | @@ -51,7 +59,7 @@ |
52 | 60 | protected function getExamples() { |
53 | 61 | return array ( |
54 | 62 | 'api.php?action=query&list=contestants&ctprops=id|user_id|contest_id|rating', |
55 | | - 'api.php?action=query&list=contestants&ctprops=id|rating&ctcontestid=42', |
| 63 | + 'api.php?action=query&list=contestants&ctprops=id|rating&ctcontest_id=42', |
56 | 64 | ); |
57 | 65 | } |
58 | 66 | |