@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @param string $param |
| 134 | 134 | * |
| 135 | - * @return array |
|
| 135 | + * @return string[] |
|
| 136 | 136 | */ |
| 137 | 137 | protected static function getSubParams( $param ) { |
| 138 | 138 | $sub_params = []; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param $context |
| 169 | 169 | * @param $showmode |
| 170 | 170 | * |
| 171 | - * @return SMWQueryResult |
|
| 171 | + * @return \SMWQueryResult |
|
| 172 | 172 | */ |
| 173 | 173 | protected static function getQueryResultFromFunctionParams( $rawParams, $context = QueryProcessor::INLINE_QUERY, $showMode = false ) { |
| 174 | 174 | list( $querystring, $params, $printouts ) = self::getComponentsFromFunctionParams( $rawParams, $showMode ); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * Combine two arrays of SMWWikiPageValue objects into one |
| 181 | 181 | * |
| 182 | 182 | * @param array $result1 |
| 183 | - * @param array $result2 |
|
| 183 | + * @param \SMWDIWikiPage[] $result2 |
|
| 184 | 184 | * |
| 185 | 185 | * @return array |
| 186 | 186 | */ |
@@ -204,6 +204,9 @@ discard block |
||
| 204 | 204 | return $result1; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | + /** |
|
| 208 | + * @param \SMW\Query\PrintRequest[] $printRequests2 |
|
| 209 | + */ |
|
| 207 | 210 | protected static function mergeSMWPrintRequests( $printRequests1, $printRequests2 ) { |
| 208 | 211 | $existingPrintoutLabels = []; |
| 209 | 212 | foreach ( $printRequests1 as $p1 ) { |
@@ -226,7 +229,7 @@ discard block |
||
| 226 | 229 | * @param $outputMode |
| 227 | 230 | * @param $context |
| 228 | 231 | * |
| 229 | - * @return SMWQueryResult |
|
| 232 | + * @return \SMWQueryResult |
|
| 230 | 233 | */ |
| 231 | 234 | protected static function getQueryResultFromQueryString( $querystring, array $params, $extraPrintouts, $context = QueryProcessor::INLINE_QUERY ) { |
| 232 | 235 | |
@@ -262,7 +265,7 @@ discard block |
||
| 262 | 265 | * |
| 263 | 266 | * @param CompoundQueryResult $res |
| 264 | 267 | * @param array $params These need to be the result of a list fed to getProcessedParams as of SMW 1.6.2 |
| 265 | - * @param $outputmode |
|
| 268 | + * @param integer $outputmode |
|
| 266 | 269 | * @param $context |
| 267 | 270 | * @param string $format |
| 268 | 271 | * |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Comparison helper function, used in sorting results. |
| 23 | 23 | */ |
| 24 | - public static function compareQueryResults( $a, $b ) { |
|
| 24 | + public static function compareQueryResults($a, $b) { |
|
| 25 | 25 | |
| 26 | - if ( $a->getSerialization() == $b->getSerialization() ) { |
|
| 26 | + if ($a->getSerialization() == $b->getSerialization()) { |
|
| 27 | 27 | return 0; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - return ( $a->getSerialization() < $b->getSerialization() ) ? -1 : 1; |
|
| 30 | + return ($a->getSerialization() < $b->getSerialization()) ? -1 : 1; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -37,20 +37,20 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - public static function doCompoundQuery( Parser &$parser ) { |
|
| 40 | + public static function doCompoundQuery(Parser &$parser) { |
|
| 41 | 41 | global $smwgQEnabled, $smwgIQRunningNumber; |
| 42 | 42 | |
| 43 | - if ( !$smwgQEnabled ) { |
|
| 44 | - return smwfEncodeMessages( [ wfMessage( 'smw_iq_disabled' )->inContentLanguage()->text() ] ); |
|
| 43 | + if (!$smwgQEnabled) { |
|
| 44 | + return smwfEncodeMessages([wfMessage('smw_iq_disabled')->inContentLanguage()->text()]); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $smwgIQRunningNumber++; |
| 48 | 48 | |
| 49 | 49 | $params = func_get_args(); |
| 50 | - array_shift( $params ); // We already know the $parser. |
|
| 50 | + array_shift($params); // We already know the $parser. |
|
| 51 | 51 | |
| 52 | - list( $queryParams, $otherParams ) = self::separateParams( $params ); |
|
| 53 | - list( $queryResult, $otherParams ) = self::queryAndMergeResults( $queryParams, $otherParams ); |
|
| 52 | + list($queryParams, $otherParams) = self::separateParams($params); |
|
| 53 | + list($queryResult, $otherParams) = self::queryAndMergeResults($queryParams, $otherParams); |
|
| 54 | 54 | |
| 55 | 55 | return self::getResultFromQueryResult( |
| 56 | 56 | $queryResult, |
@@ -65,25 +65,25 @@ discard block |
||
| 65 | 65 | * @param $params |
| 66 | 66 | * @return array |
| 67 | 67 | */ |
| 68 | - public static function separateParams( $params ) { |
|
| 68 | + public static function separateParams($params) { |
|
| 69 | 69 | $queryParams = []; |
| 70 | 70 | $otherParams = []; |
| 71 | 71 | |
| 72 | - foreach ( $params as $param ) { |
|
| 72 | + foreach ($params as $param) { |
|
| 73 | 73 | // Very primitive heuristic - if the parameter |
| 74 | 74 | // includes a square bracket, then it's a |
| 75 | 75 | // sub-query; otherwise it's a regular parameter. |
| 76 | - if ( strpos( $param, '[' ) !== false ) { |
|
| 76 | + if (strpos($param, '[') !== false) { |
|
| 77 | 77 | $queryParams[] = $param; |
| 78 | 78 | } else { |
| 79 | - $parts = explode( '=', $param, 2 ); |
|
| 79 | + $parts = explode('=', $param, 2); |
|
| 80 | 80 | |
| 81 | - if ( count( $parts ) >= 2 ) { |
|
| 82 | - $otherParams[strtolower( trim( $parts[0] ) )] = $parts[1]; // don't trim here, some params care for " " |
|
| 81 | + if (count($parts) >= 2) { |
|
| 82 | + $otherParams[strtolower(trim($parts[0]))] = $parts[1]; // don't trim here, some params care for " " |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | - return [ $queryParams, $otherParams ]; |
|
| 86 | + return [$queryParams, $otherParams]; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -93,36 +93,36 @@ discard block |
||
| 93 | 93 | * @param $otherParams |
| 94 | 94 | * @return array |
| 95 | 95 | */ |
| 96 | - public static function queryAndMergeResults( $queryParams, $otherParams ) { |
|
| 96 | + public static function queryAndMergeResults($queryParams, $otherParams) { |
|
| 97 | 97 | $results = []; |
| 98 | 98 | $printRequests = []; |
| 99 | 99 | |
| 100 | - foreach ( $queryParams as $param ) { |
|
| 101 | - $subQueryParams = self::getSubParams( $param ); |
|
| 100 | + foreach ($queryParams as $param) { |
|
| 101 | + $subQueryParams = self::getSubParams($param); |
|
| 102 | 102 | |
| 103 | - if ( array_key_exists( 'format', $otherParams ) && !array_key_exists( 'format', $subQueryParams ) ) { |
|
| 103 | + if (array_key_exists('format', $otherParams) && !array_key_exists('format', $subQueryParams)) { |
|
| 104 | 104 | $subQueryParams['format'] = $otherParams['format']; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $nextResult = self::getQueryResultFromFunctionParams($subQueryParams); |
| 108 | 108 | |
| 109 | - $results = self::mergeSMWQueryResults( $results, $nextResult->getResults() ); |
|
| 110 | - $printRequests = self::mergeSMWPrintRequests( $printRequests, $nextResult->getPrintRequests() ); |
|
| 109 | + $results = self::mergeSMWQueryResults($results, $nextResult->getResults()); |
|
| 110 | + $printRequests = self::mergeSMWPrintRequests($printRequests, $nextResult->getPrintRequests()); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Sort results so that they'll show up by page name |
| 114 | - if( !isset($otherParams['unsorted']) || !strcmp( $otherParams['unsorted'], 'on' ) ) { |
|
| 115 | - uasort( $results, [ '\SCQ\CompoundQueryProcessor', 'compareQueryResults' ] ); |
|
| 114 | + if (!isset($otherParams['unsorted']) || !strcmp($otherParams['unsorted'], 'on')) { |
|
| 115 | + uasort($results, ['\SCQ\CompoundQueryProcessor', 'compareQueryResults']); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - $queryResult = new CompoundQueryResult( $printRequests, new Query(), $results, smwfGetStore() ); |
|
| 118 | + $queryResult = new CompoundQueryResult($printRequests, new Query(), $results, smwfGetStore()); |
|
| 119 | 119 | |
| 120 | - if ( version_compare( SMW_VERSION, '1.6.1', '>' ) ) { |
|
| 121 | - self::addThisPrintout( $printRequests, $otherParams ); |
|
| 122 | - $otherParams = self::getProcessedParams( $otherParams, $printRequests ); |
|
| 120 | + if (version_compare(SMW_VERSION, '1.6.1', '>')) { |
|
| 121 | + self::addThisPrintout($printRequests, $otherParams); |
|
| 122 | + $otherParams = self::getProcessedParams($otherParams, $printRequests); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return [ $queryResult, $otherParams ]; |
|
| 125 | + return [$queryResult, $otherParams]; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -134,31 +134,31 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return array |
| 136 | 136 | */ |
| 137 | - protected static function getSubParams( $param ) { |
|
| 137 | + protected static function getSubParams($param) { |
|
| 138 | 138 | $sub_params = []; |
| 139 | 139 | $sub_param = ''; |
| 140 | 140 | $uncompleted_square_brackets = 0; |
| 141 | 141 | |
| 142 | - for ( $i = 0; $i < strlen( $param ); $i++ ) { |
|
| 142 | + for ($i = 0; $i < strlen($param); $i++) { |
|
| 143 | 143 | $c = $param[$i]; |
| 144 | 144 | |
| 145 | - if ( ( $c == ';' ) && ( $uncompleted_square_brackets <= 0 ) ) { |
|
| 146 | - $sub_params[] = trim( $sub_param ); |
|
| 145 | + if (($c == ';') && ($uncompleted_square_brackets <= 0)) { |
|
| 146 | + $sub_params[] = trim($sub_param); |
|
| 147 | 147 | $sub_param = ''; |
| 148 | 148 | } else { |
| 149 | 149 | $sub_param .= $c; |
| 150 | 150 | |
| 151 | - if ( $c == '[' ) { |
|
| 151 | + if ($c == '[') { |
|
| 152 | 152 | $uncompleted_square_brackets++; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - elseif ( $c == ']' ) { |
|
| 155 | + elseif ($c == ']') { |
|
| 156 | 156 | $uncompleted_square_brackets--; |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $sub_params[] = trim( $sub_param ); |
|
| 161 | + $sub_params[] = trim($sub_param); |
|
| 162 | 162 | |
| 163 | 163 | return $sub_params; |
| 164 | 164 | } |
@@ -170,10 +170,10 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @return SMWQueryResult |
| 172 | 172 | */ |
| 173 | - protected static function getQueryResultFromFunctionParams( $rawParams, $context = QueryProcessor::INLINE_QUERY, $showMode = false ) { |
|
| 174 | - list( $querystring, $params, $printouts ) = self::getComponentsFromFunctionParams( $rawParams, $showMode ); |
|
| 173 | + protected static function getQueryResultFromFunctionParams($rawParams, $context = QueryProcessor::INLINE_QUERY, $showMode = false) { |
|
| 174 | + list($querystring, $params, $printouts) = self::getComponentsFromFunctionParams($rawParams, $showMode); |
|
| 175 | 175 | |
| 176 | - return self::getQueryResultFromQueryString( $querystring, $params, $printouts, $context ); |
|
| 176 | + return self::getQueryResultFromQueryString($querystring, $params, $printouts, $context); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -184,19 +184,19 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @return array |
| 186 | 186 | */ |
| 187 | - protected static function mergeSMWQueryResults( $result1, $result2 ) { |
|
| 188 | - if ( $result1 == null ) { |
|
| 187 | + protected static function mergeSMWQueryResults($result1, $result2) { |
|
| 188 | + if ($result1 == null) { |
|
| 189 | 189 | return $result2; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $existing_page_names = []; |
| 193 | - foreach ( $result1 as $r1 ) { |
|
| 193 | + foreach ($result1 as $r1) { |
|
| 194 | 194 | $existing_page_names[] = $r1->getSerialization(); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - foreach ( $result2 as $r2 ) { |
|
| 197 | + foreach ($result2 as $r2) { |
|
| 198 | 198 | $page_name = $r2->getSerialization(); |
| 199 | - if ( ! in_array( $page_name, $existing_page_names ) ) { |
|
| 199 | + if (!in_array($page_name, $existing_page_names)) { |
|
| 200 | 200 | $result1[] = $r2; |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -204,15 +204,15 @@ discard block |
||
| 204 | 204 | return $result1; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - protected static function mergeSMWPrintRequests( $printRequests1, $printRequests2 ) { |
|
| 207 | + protected static function mergeSMWPrintRequests($printRequests1, $printRequests2) { |
|
| 208 | 208 | $existingPrintoutLabels = []; |
| 209 | - foreach ( $printRequests1 as $p1 ) { |
|
| 209 | + foreach ($printRequests1 as $p1) { |
|
| 210 | 210 | $existingPrintoutLabels[] = $p1->getLabel(); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - foreach ( $printRequests2 as $p2 ) { |
|
| 213 | + foreach ($printRequests2 as $p2) { |
|
| 214 | 214 | $label = $p2->getLabel(); |
| 215 | - if ( ! in_array( $label, $existingPrintoutLabels ) ) { |
|
| 215 | + if (!in_array($label, $existingPrintoutLabels)) { |
|
| 216 | 216 | $printRequests1[] = $p2; |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -228,20 +228,20 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return SMWQueryResult |
| 230 | 230 | */ |
| 231 | - protected static function getQueryResultFromQueryString( $querystring, array $params, $extraPrintouts, $context = QueryProcessor::INLINE_QUERY ) { |
|
| 231 | + protected static function getQueryResultFromQueryString($querystring, array $params, $extraPrintouts, $context = QueryProcessor::INLINE_QUERY) { |
|
| 232 | 232 | |
| 233 | - if ( version_compare( SMW_VERSION, '1.6.1', '>' ) ) { |
|
| 234 | - QueryProcessor::addThisPrintout( $extraPrintouts, $params ); |
|
| 235 | - $params = self::getProcessedParams( $params, $extraPrintouts, false ); |
|
| 233 | + if (version_compare(SMW_VERSION, '1.6.1', '>')) { |
|
| 234 | + QueryProcessor::addThisPrintout($extraPrintouts, $params); |
|
| 235 | + $params = self::getProcessedParams($params, $extraPrintouts, false); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $query = self::createQuery( $querystring, $params, $context, null, $extraPrintouts ); |
|
| 239 | - $queryResult = smwfGetStore()->getQueryResult( $query ); |
|
| 238 | + $query = self::createQuery($querystring, $params, $context, null, $extraPrintouts); |
|
| 239 | + $queryResult = smwfGetStore()->getQueryResult($query); |
|
| 240 | 240 | |
| 241 | 241 | $parameters = []; |
| 242 | 242 | |
| 243 | - if ( version_compare( SMW_VERSION, '1.7.2', '>' ) ) { |
|
| 244 | - foreach ( $params as $param ) { |
|
| 243 | + if (version_compare(SMW_VERSION, '1.7.2', '>')) { |
|
| 244 | + foreach ($params as $param) { |
|
| 245 | 245 | $parameters[$param->getName()] = $param->getValue(); |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $parameters = $params; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - foreach ( $queryResult->getResults() as $wikiPage ) { |
|
| 252 | + foreach ($queryResult->getResults() as $wikiPage) { |
|
| 253 | 253 | $wikiPage->display_options = $parameters; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -268,20 +268,20 @@ discard block |
||
| 268 | 268 | * |
| 269 | 269 | * @return string |
| 270 | 270 | */ |
| 271 | - protected static function getResultFromQueryResult( CompoundQueryResult $res, array $params, $outputmode, $context = QueryProcessor::INLINE_QUERY, $format = '' ) { |
|
| 271 | + protected static function getResultFromQueryResult(CompoundQueryResult $res, array $params, $outputmode, $context = QueryProcessor::INLINE_QUERY, $format = '') { |
|
| 272 | 272 | |
| 273 | - if ( version_compare( SMW_VERSION, '1.6.1', '>' ) ) { |
|
| 273 | + if (version_compare(SMW_VERSION, '1.6.1', '>')) { |
|
| 274 | 274 | $format = $params['format']; |
| 275 | 275 | |
| 276 | - if ( version_compare( SMW_VERSION, '1.7.2', '>' ) ) { |
|
| 276 | + if (version_compare(SMW_VERSION, '1.7.2', '>')) { |
|
| 277 | 277 | $format = $format->getValue(); |
| 278 | 278 | } |
| 279 | 279 | } else { |
| 280 | - $format = self::getResultFormat( $params ); |
|
| 280 | + $format = self::getResultFormat($params); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - $printer = self::getResultPrinter( $format, $context ); |
|
| 284 | - $result = $printer->getResult( $res, $params, $outputmode ); |
|
| 283 | + $printer = self::getResultPrinter($format, $context); |
|
| 284 | + $result = $printer->getResult($res, $params, $outputmode); |
|
| 285 | 285 | |
| 286 | 286 | return $result; |
| 287 | 287 | } |