http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88792
Revision: 88792
Author: jeroendedauw
Date: 2011-05-25 14:29:04 +0000 (Wed, 25 May 2011)
Log Message:
-----------
adding merge param
Modified Paths:
--------------
trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php
Modified: trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php
2011-05-25 14:21:26 UTC (rev 88791)
+++ trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php
2011-05-25 14:29:04 UTC (rev 88792)
@@ -35,7 +35,7 @@
$sets = $this->select( __METHOD__ );
$count = 0;
- $resultSets = array();
+ $resultSets = array();
foreach ( $sets as $set ) {
if ( ++$count > $params['limit'] ) {
@@ -45,17 +45,23 @@
break;
}
- $set = SWLChangeSet::newFromDBResult( $set )->toArray();
+ $resultSets[] = SWLChangeSet::newFromDBResult( $set );
+ }
+
+ if ( $params['merge'] ) {
+ $this->mergeSets( $resultSets );
+ }
+
+ $this->getResult()->setIndexedTagName( $resultSets, 'set' );
+
+ foreach ( $resultSets as &$set ) {
+ $set = $set->toArray();
foreach ( $set['changes'] as $propName => $changes ) {
$this->getResult()->setIndexedTagName(
$set['changes'][$propName], 'change' );
}
-
- $resultSets[] = $set;
}
- $this->getResult()->setIndexedTagName( $resultSets, 'set' );
-
$this->getResult()->addValue(
null,
'sets',
@@ -120,9 +126,20 @@
// TODO: error
}
}
- }
+ }
/**
+ * Merge change sets belonging to the same edit into one sinlge change
set.
+ *
+ * @since 0.1
+ *
+ * @param array $sets
+ */
+ protected function mergeSets( array &$sets ) {
+ // TODO
+ }
+
+ /**
* (non-PHPdoc)
* @see includes/api/ApiBase#getAllowedParams()
*/
@@ -158,6 +175,7 @@
return array (
'userid' => 'The ID of the user for which to return
semantic watchlist data.',
'groupids' => 'The IDs of the groups for which to
return semantic watchlist data.',
+ 'merge' => 'Merge sets of changes that belong to the
same edit?',
'continue' => 'Offset number from where to continue the
query',
'limit' => 'Max amount of words to return',
);
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs