Index: trunk/extensions/SemanticCompoundQueries/SCQ_QueryProcessor.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | for ( $i = 0; $i < strlen( $param ); $i++ ) { |
26 | 26 | $c = $param[$i]; |
27 | 27 | if ( ( $c == ';' ) && ( $uncompleted_square_brackets <= 0 ) ) { |
28 | | - $sub_params[] = $sub_param; |
| 28 | + $sub_params[] = trim($sub_param); |
29 | 29 | $sub_param = ""; |
30 | 30 | } else { |
31 | 31 | $sub_param .= $c; |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | $uncompleted_square_brackets--; |
36 | 36 | } |
37 | 37 | } |
38 | | - $sub_params[] = $sub_param; |
| 38 | + $sub_params[] = trim($sub_param); |
39 | 39 | return $sub_params; |
40 | 40 | } |
41 | 41 | |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | $sub_params = SCQQueryProcessor::getSubParams( $param ); |
59 | 59 | $next_result = SCQQueryProcessor::getQueryResultFromFunctionParams( $sub_params, SMW_OUTPUT_WIKI ); |
60 | 60 | if (method_exists($next_result, 'getResults')) { // SMW 1.5+ |
61 | | - $results = array_merge($results, $next_result->getResults()); |
| 61 | + $results = self::mergeSMWQueryResults($results, $next_result->getResults()); |
62 | 62 | } else { |
63 | 63 | if ( $query_result == null ) |
64 | 64 | $query_result = new SCQQueryResult( $next_result->getPrintRequests(), new SMWQuery() ); |
— | — | @@ -86,26 +86,22 @@ |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | | - * Combine the values from two SMWQueryResult objects into one |
| 90 | + * Combine two arrays of SMWWikiPageValue objects into one |
91 | 91 | */ |
92 | 92 | static function mergeSMWQueryResults( $result1, $result2 ) { |
93 | 93 | if ( $result1 == null ) { |
94 | | - $result1 = new SMWQueryResult( $result2->getPrintRequests(), new SMWQuery() ); |
| 94 | + return $result2; |
95 | 95 | } |
96 | 96 | $existing_page_names = array(); |
97 | | - while ( $row = $result1->getNext() ) { |
98 | | - if ( $row[0] instanceof SMWResultArray ) { |
99 | | - $content = $row[0]->getContent(); |
100 | | - $existing_page_names[] = $content[0]->getLongText( SMW_OUTPUT_WIKI ); |
| 97 | + foreach ($result1 as $r1) { |
| 98 | + $existing_page_names[] = $r1->getWikiValue(); |
| 99 | + } |
| 100 | + foreach ($result2 as $r2) { |
| 101 | + $page_name = $r2->getWikiValue(); |
| 102 | + if (! in_array($page_name, $existing_page_names)) { |
| 103 | + $result1[] = $r2; |
101 | 104 | } |
102 | 105 | } |
103 | | - while ( ( $row = $result2->getNext() ) !== false ) { |
104 | | - $row[0]->display_options = $result2->display_options; |
105 | | - $content = $row[0]->getContent(); |
106 | | - $page_name = $content[0]->getLongText( SMW_OUTPUT_WIKI ); |
107 | | - if ( ! in_array( $page_name, $existing_page_names ) ) |
108 | | - $result1->addRow( $row ); |
109 | | - } |
110 | 106 | return $result1; |
111 | 107 | } |
112 | 108 | |
— | — | @@ -168,4 +164,3 @@ |
169 | 165 | return $result; |
170 | 166 | } |
171 | 167 | } |
172 | | - |