Index: trunk/extensions/SemanticMediaWiki/includes/api/ApiAskArgs.php |
— | — | @@ -69,7 +69,8 @@ |
70 | 70 | |
71 | 71 | public function getDescription() { |
72 | 72 | return array( |
73 | | - 'API module to query SMW by providing a query specified as a list of conditions, printeouts and parameters.' |
| 73 | + 'API module to query SMW by providing a query specified as a list of conditions, printeouts and parameters. |
| 74 | + This API module is in alpha stage, and likely to see changes in upcomming versions of SMW.' |
74 | 75 | ); |
75 | 76 | } |
76 | 77 | |
Index: trunk/extensions/SemanticMediaWiki/includes/api/ApiSMWQuery.php |
— | — | @@ -55,8 +55,20 @@ |
56 | 56 | } |
57 | 57 | |
58 | 58 | protected function addQueryResult( SMWQueryResult $queryResult ) { |
59 | | - // TODO: create general SMWQueryResult serialization method that can then also be used for JSON printer |
60 | | - $this->getResult()->addValue( 'query', null, $queryResult->serializeToArray() ); |
| 59 | + $serialized = $queryResult->serializeToArray(); |
| 60 | + $result = $this->getResult(); |
| 61 | + |
| 62 | + $result->setIndexedTagName( $serialized['results'], 'result' ); |
| 63 | + $result->setIndexedTagName( $serialized['printrequests'], 'printrequest' ); |
| 64 | + |
| 65 | + $result->addValue( 'query', null, $serialized ); |
| 66 | + |
| 67 | + if ( $queryResult->hasFurtherResults() ) { |
| 68 | + // TODO: obtain continuation data from store |
| 69 | + $result->disableSizeCheck(); |
| 70 | + $result->addValue( 'query-continue', null, 0 ); |
| 71 | + $result->enableSizeCheck(); |
| 72 | + } |
61 | 73 | } |
62 | 74 | |
63 | 75 | public function getPossibleErrors() { |
Index: trunk/extensions/SemanticMediaWiki/includes/api/ApiAsk.php |
— | — | @@ -18,9 +18,17 @@ |
19 | 19 | $params = $this->extractRequestParams(); |
20 | 20 | $this->requireParameters( $params, array( 'query' ) ); |
21 | 21 | |
22 | | - // SMWQueryProcessor::processFunctionParams( $rawparams, $queryString, $m_params, $m_printouts); |
| 22 | + $rawParams = explode( '|', $params['query'] ); |
| 23 | + $queryString = ''; |
| 24 | + $printeouts = array(); |
23 | 25 | |
24 | | - $queryResult = $this->getQueryResult( $this->getQuery( $params['query'] ) ); |
| 26 | + SMWQueryProcessor::processFunctionParams( $rawParams, $queryString, $this->parameters, $printeouts ); |
| 27 | + |
| 28 | + $queryResult = $this->getQueryResult( $this->getQuery( |
| 29 | + $queryString, |
| 30 | + $printeouts |
| 31 | + ) ); |
| 32 | + |
25 | 33 | $this->addQueryResult( $queryResult ); |
26 | 34 | } |
27 | 35 | |
— | — | @@ -40,7 +48,8 @@ |
41 | 49 | |
42 | 50 | public function getDescription() { |
43 | 51 | return array( |
44 | | - 'API module to query SMW by providing a query in the ask language.' |
| 52 | + 'API module to query SMW by providing a query in the ask language. |
| 53 | + This API module is in alpha stage, and likely to see changes in upcomming versions of SMW.' |
45 | 54 | ); |
46 | 55 | } |
47 | 56 | |