Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -34,21 +34,15 @@ |
35 | 35 | */ |
36 | 36 | static public function createQuery( $querystring, array $params, $context = SMWQueryProcessor::INLINE_QUERY, $format = '', $extraprintouts = array() ) { |
37 | 37 | global $smwgQDefaultNamespaces, $smwgQFeatures, $smwgQConceptFeatures; |
| 38 | + if ( $format == '' ) { |
| 39 | + $format = SMWQueryProcessor::getResultFormat( $params ); |
| 40 | + } |
38 | 41 | |
39 | 42 | // parse query: |
40 | | - if ( $context == SMWQueryProcessor::CONCEPT_DESC ) { |
41 | | - $queryfeatures = $smwgQConceptFeatures; |
42 | | - } else { |
43 | | - $queryfeatures = $smwgQFeatures; |
44 | | - } |
45 | | - |
| 43 | + $queryfeatures = ( $context == SMWQueryProcessor::CONCEPT_DESC ) ? $smwgQConceptFeatures : $smwgQFeatures; |
46 | 44 | $qp = new SMWQueryParser( $queryfeatures ); |
47 | 45 | $qp->setDefaultNamespaces( $smwgQDefaultNamespaces ); |
48 | 46 | $desc = $qp->getQueryDescription( $querystring ); |
49 | | - |
50 | | - if ( $format == '' ) { |
51 | | - $format = SMWQueryProcessor::getResultFormat( $params ); |
52 | | - } |
53 | 47 | |
54 | 48 | if ( $format == 'count' ) { |
55 | 49 | $querymode = SMWQuery::MODE_COUNT; |
— | — | @@ -60,13 +54,9 @@ |
61 | 55 | } |
62 | 56 | |
63 | 57 | $mainlabel = array_key_exists( 'mainlabel', $params ) ? $params['mainlabel'] : ''; |
64 | | - |
65 | 58 | if ( ( $querymode == SMWQuery::MODE_NONE ) || |
66 | | - ( ( !$desc->isSingleton() || |
67 | | - ( count( $desc->getPrintRequests() ) + count( $extraprintouts ) == 0 ) |
68 | | - ) && ( $mainlabel != '-' ) |
69 | | - ) |
70 | | - ) { |
| 59 | + ( ( !$desc->isSingleton() || ( count( $desc->getPrintRequests() ) + count( $extraprintouts ) == 0 ) ) |
| 60 | + && ( $mainlabel != '-' ) ) ) { |
71 | 61 | $desc->prependPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $mainlabel ) ); |
72 | 62 | } |
73 | 63 | |
— | — | @@ -75,7 +65,7 @@ |
76 | 66 | $query->setExtraPrintouts( $extraprintouts ); |
77 | 67 | $query->addErrors( $qp->getErrors() ); // keep parsing errors for later output |
78 | 68 | |
79 | | - // set query parameters: |
| 69 | + // set mode, limit, and offset: |
80 | 70 | $query->querymode = $querymode; |
81 | 71 | if ( ( array_key_exists( 'offset', $params ) ) && ( is_int( $params['offset'] + 0 ) ) ) { |
82 | 72 | $query->setOffset( max( 0, trim( $params['offset'] ) + 0 ) ); |
— | — | @@ -83,7 +73,6 @@ |
84 | 74 | |
85 | 75 | if ( $query->querymode == SMWQuery::MODE_COUNT ) { // largest possible limit for "count", even inline |
86 | 76 | global $smwgQMaxLimit; |
87 | | - |
88 | 77 | $query->setOffset( 0 ); |
89 | 78 | $query->setLimit( $smwgQMaxLimit, false ); |
90 | 79 | } else { |
— | — | @@ -125,7 +114,6 @@ |
126 | 115 | foreach ( explode( ',', trim( $params['sort'] ) ) as $sort ) { |
127 | 116 | $sort = smwfNormalTitleDBKey( trim( $sort ) ); // slight normalisation |
128 | 117 | $order = current( $orders ); |
129 | | - |
130 | 118 | if ( $order === false ) { // default |
131 | 119 | $order = 'ASC'; |
132 | 120 | } |