Index: trunk/extensions/SemanticCompoundQueries/SCQ_QueryProcessor.php |
— | — | @@ -11,6 +11,16 @@ |
12 | 12 | class SCQQueryProcessor extends SMWQueryProcessor { |
13 | 13 | |
14 | 14 | /** |
| 15 | + * Comparison helper function, used in sorting results. |
| 16 | + */ |
| 17 | + public static function compareQueryResults( $a, $b ) { |
| 18 | + if ( $a->getDBKey() == $b->getDBKey() ) { |
| 19 | + return 0; |
| 20 | + } |
| 21 | + return ( $a->getDBKey() < $b->getDBKey() ) ? -1 : 1; |
| 22 | + } |
| 23 | + |
| 24 | + /** |
15 | 25 | * Handler for the #compound_query parser function. |
16 | 26 | * |
17 | 27 | * @param Parser $parser |
— | — | @@ -63,12 +73,15 @@ |
64 | 74 | $results = self::mergeSMWQueryResults( $results, $next_result->getResults() ); |
65 | 75 | } |
66 | 76 | |
| 77 | + // Sort results so that they'll show up by page name |
| 78 | + uasort( $results, 'self::compareQueryResults' ); |
| 79 | + |
67 | 80 | $query_result = new SCQQueryResult( $next_result->getPrintRequests(), new SMWQuery(), $results, smwfGetStore() ); |
68 | 81 | |
69 | 82 | if ( version_compare( SMW_VERSION, '1.6.1', '>' ) ) { |
70 | | - $printeouts = $next_result->getPrintRequests(); |
71 | | - SMWQueryProcessor::addThisPrintout( $printeouts, $other_params ); |
72 | | - $other_params = parent::getProcessedParams( $other_params, $printeouts ); |
| 83 | + $printouts = $next_result->getPrintRequests(); |
| 84 | + SMWQueryProcessor::addThisPrintout( $printouts, $other_params ); |
| 85 | + $other_params = parent::getProcessedParams( $other_params, $printouts ); |
73 | 86 | } |
74 | 87 | |
75 | 88 | return self::getResultFromQueryResult( |
— | — | @@ -185,7 +198,7 @@ |
186 | 199 | $params = self::getProcessedParams( $params, $extraprintouts, false ); |
187 | 200 | } |
188 | 201 | |
189 | | - $query = self::createQuery( $querystring, $params, $context, null, $extraprintouts ); |
| 202 | + $query = self::createQuery( $querystring, $params, $context, null, $extraprintouts ); |
190 | 203 | $query_result = smwfGetStore()->getQueryResult( $query ); |
191 | 204 | |
192 | 205 | foreach ( $query_result->getResults() as $wiki_page ) { |