r97359 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97358‎ | r97359 | r97360 >
Date:02:27, 17 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r97358;
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/api/ApiSMWQuery.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php
@@ -229,6 +229,13 @@
230230
231231 public function getDataItemSerialization( SMWDataItem $dataItem ) {
232232 switch ( $dataItem->getDIType() ) {
 233+ case SMWDataItem::TYPE_WIKIPAGE:
 234+ $title = $dataItem->getTitle();
 235+ $result = array(
 236+ 'fulltext' => $title->getFullText(),
 237+ 'fullurl' => $title->getFullUrl(),
 238+ );
 239+ break;
233240 case SMWDataItem::TYPE_NUMBER:
234241 $result = $dataItem->getNumber();
235242 break;
@@ -248,7 +255,16 @@
249256
250257 public function serializeToArray() {
251258 $results = array();
 259+ $printRequests = array();
252260
 261+ foreach ( $this->mPrintRequests as /* SMWPrintRequest */ $printRequest ) {
 262+ $printRequests[] = array(
 263+ 'label' => $printRequest->getLabel(),
 264+ 'typeid' => $printRequest->getTypeID(),
 265+ 'mode' => $printRequest->getMode(),
 266+ );
 267+ }
 268+
253269 foreach ( $this->mResults as /* SMWDIWikiPage */ $diWikiPage ) {
254270 $result = array();
255271
@@ -264,7 +280,7 @@
265281 $results[$diWikiPage->getTitle()->getFullText()] = $result;
266282 }
267283
268 - return $results;
 284+ return array( 'results' => $results, 'printrequests' => $printRequests );
269285 }
270286
271287 }
Index: trunk/extensions/SemanticMediaWiki/includes/api/ApiSMWQuery.php
@@ -56,7 +56,7 @@
5757
5858 protected function addQueryResult( SMWQueryResult $queryResult ) {
5959 // TODO: create general SMWQueryResult serialization method that can then also be used for JSON printer
60 - $this->getResult()->addValue( 'result', null, $queryResult->serializeToArray() );
 60+ $this->getResult()->addValue( 'query', null, $queryResult->serializeToArray() );
6161 }
6262
6363 public function getPossibleErrors() {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97358Follow up to r97324; fixed serializationjeroendedauw02:17, 17 September 2011