Index: trunk/extensions/SemanticCompoundQueries/SCQ_QueryProcessor.php |
— | — | @@ -4,13 +4,12 @@ |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Class that holds static functions for handling compound queries. |
8 | | - * This class is heavily based on Semantic MediaWiki's SMWQueryProcessor, |
9 | | - * and calls that class's functions when possible. |
| 8 | + * This class inherits from Semantic MediaWiki's SMWQueryProcessor. |
10 | 9 | * |
11 | 10 | * @ingroup SemanticCompoundQueries |
12 | 11 | * @author Yaron Koren |
13 | 12 | */ |
14 | | -class SCQQueryProcessor { |
| 13 | +class SCQQueryProcessor extends SMWQueryProcessor { |
15 | 14 | |
16 | 15 | /** |
17 | 16 | * An alternative to explode() - that function won't work here, |
— | — | @@ -54,8 +53,8 @@ |
55 | 54 | // includes a square bracket, then it's a |
56 | 55 | // sub-query; otherwise it's a regular parameter |
57 | 56 | if ( strpos( $param, '[' ) !== false ) { |
58 | | - $sub_params = SCQQueryProcessor::getSubParams( $param ); |
59 | | - $next_result = SCQQueryProcessor::getQueryResultFromFunctionParams( $sub_params, SMW_OUTPUT_WIKI ); |
| 57 | + $sub_params = self::getSubParams( $param ); |
| 58 | + $next_result = self::getQueryResultFromFunctionParams( $sub_params, SMW_OUTPUT_WIKI ); |
60 | 59 | if ( method_exists( $next_result, 'getResults' ) ) { // SMW 1.5+ |
61 | 60 | $results = self::mergeSMWQueryResults( $results, $next_result->getResults() ); |
62 | 61 | } else { |
— | — | @@ -81,8 +80,8 @@ |
82 | 81 | } |
83 | 82 | |
84 | 83 | static function getQueryResultFromFunctionParams( $rawparams, $outputmode, $context = SMWQueryProcessor::INLINE_QUERY, $showmode = false ) { |
85 | | - SMWQueryProcessor::processFunctionParams( $rawparams, $querystring, $params, $printouts, $showmode ); |
86 | | - return SCQQueryProcessor::getQueryResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI, $context ); |
| 84 | + self::processFunctionParams( $rawparams, $querystring, $params, $printouts, $showmode ); |
| 85 | + return self::getQueryResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI, $context ); |
87 | 86 | } |
88 | 87 | |
89 | 88 | /** |
— | — | @@ -105,31 +104,9 @@ |
106 | 105 | return $result1; |
107 | 106 | } |
108 | 107 | |
109 | | - // this method is an exact copy of SMWQueryProcessor's function, |
110 | | - // but it needs to be duplicated because there it's protected |
111 | | - static function getResultFormat( $params ) { |
112 | | - $format = 'auto'; |
113 | | - if ( array_key_exists( 'format', $params ) ) { |
114 | | - $format = strtolower( trim( $params['format'] ) ); |
115 | | - global $smwgResultAliases, $smwgResultFormats; |
116 | | - if ( !array_key_exists( $format, $smwgResultFormats ) ) { |
117 | | - $is_alias = false; |
118 | | - foreach ( $smwgResultAliases as $main_format => $aliases ) { |
119 | | - if ( in_array( $format, $aliases ) ) { |
120 | | - $format = $main_format; |
121 | | - $is_alias = true; |
122 | | - break; |
123 | | - } |
124 | | - } |
125 | | - if ( !$is_alias ) $format = 'auto'; // If it is an unknown format, defaults to list/table again |
126 | | - } |
127 | | - } |
128 | | - return $format; |
129 | | - } |
130 | | - |
131 | 108 | static function getQueryResultFromQueryString( $querystring, $params, $extraprintouts, $outputmode, $context = SMWQueryProcessor::INLINE_QUERY ) { |
132 | 109 | wfProfileIn( 'SCQQueryProcessor::getQueryResultFromQueryString' ); |
133 | | - $query = SMWQueryProcessor::createQuery( $querystring, $params, $context, null, $extraprintouts ); |
| 110 | + $query = self::createQuery( $querystring, $params, $context, null, $extraprintouts ); |
134 | 111 | $query_result = smwfGetStore()->getQueryResult( $query ); |
135 | 112 | $display_options = array(); |
136 | 113 | foreach ( $params as $key => $value ) { |
— | — | @@ -165,8 +142,8 @@ |
166 | 143 | */ |
167 | 144 | static function getResultFromQueryResult( $res, $params, $extraprintouts, $outputmode, $context = SMWQueryProcessor::INLINE_QUERY, $format = '' ) { |
168 | 145 | wfProfileIn( 'SCQQueryProcessor::getResultFromQueryResult' ); |
169 | | - $format = SCQQueryProcessor::getResultFormat( $params ); |
170 | | - $printer = SMWQueryProcessor::getResultPrinter( $format, $context, $res ); |
| 146 | + $format = self::getResultFormat( $params ); |
| 147 | + $printer = self::getResultPrinter( $format, $context, $res ); |
171 | 148 | $result = $printer->getResult( $res, $params, $outputmode ); |
172 | 149 | wfProfileOut( 'SCQQueryProcessor::getResultFromQueryResult' ); |
173 | 150 | return $result; |