Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryParser.php |
— | — | @@ -17,7 +17,6 @@ |
18 | 18 | protected $m_sepstack; // list of open blocks ("parentheses") that need closing at current step |
19 | 19 | protected $m_curstring; // remaining string to be parsed (parsing eats query string from the front) |
20 | 20 | protected $m_errors; // empty array if all went right, array of strings otherwise |
21 | | - protected $m_label; // label of the main query result |
22 | 21 | protected $m_defaultns; // description of the default namespace restriction, or NULL if not used |
23 | 22 | |
24 | 23 | protected $m_categoryprefix; // cache label of category namespace . ':' |
— | — | @@ -58,11 +57,10 @@ |
59 | 58 | wfProfileIn( 'SMWQueryParser::getQueryDescription (SMW)' ); |
60 | 59 | |
61 | 60 | $this->m_errors = array(); |
62 | | - $this->m_label = ''; |
63 | 61 | $this->m_curstring = $querystring; |
64 | 62 | $this->m_sepstack = array(); |
65 | 63 | $setNS = false; |
66 | | - $result = $this->getSubqueryDescription( $setNS, $this->m_label ); |
| 64 | + $result = $this->getSubqueryDescription( $setNS ); |
67 | 65 | |
68 | 66 | if ( !$setNS ) { // add default namespaces if applicable |
69 | 67 | $result = $this->addDescription( $this->m_defaultns, $result ); |
— | — | @@ -96,15 +94,6 @@ |
97 | 95 | } |
98 | 96 | |
99 | 97 | /** |
100 | | - * Return label for the results of this query (which |
101 | | - * might be empty if no such information was passed). |
102 | | - */ |
103 | | - public function getLabel() { |
104 | | - return $this->m_label; |
105 | | - } |
106 | | - |
107 | | - |
108 | | - /** |
109 | 98 | * Compute an SMWDescription for current part of a query, which should |
110 | 99 | * be a standalone query (the main query or a subquery enclosed within |
111 | 100 | * "\<q\>...\</q\>". Recursively calls similar methods and returns NULL upon error. |
— | — | @@ -124,12 +113,10 @@ |
125 | 114 | * Note that $setNS is no means to switch on or off default namespaces in general, |
126 | 115 | * but just controls query generation. For general effect, the default namespaces |
127 | 116 | * should be set to NULL. |
128 | | - * |
129 | | - * The call-by-ref parameter $label is used to append any label strings found. |
130 | 117 | * |
131 | 118 | * @return SMWDescription or null |
132 | 119 | */ |
133 | | - protected function getSubqueryDescription( &$setNS, &$label ) { |
| 120 | + protected function getSubqueryDescription( &$setNS ) { |
134 | 121 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
135 | 122 | |
136 | 123 | $conjunction = null; // used for the current inner conjunction |
— | — | @@ -144,14 +131,14 @@ |
145 | 132 | |
146 | 133 | switch ( $chunk ) { |
147 | 134 | case '[[': // start new link block |
148 | | - $ld = $this->getLinkDescription( $setsubNS, $label ); |
| 135 | + $ld = $this->getLinkDescription( $setsubNS ); |
149 | 136 | if ( $ld !== null ) { |
150 | 137 | $conjunction = $this->addDescription( $conjunction, $ld ); |
151 | 138 | } |
152 | 139 | break; |
153 | 140 | case '<q>': // enter new subquery, currently irrelevant but possible |
154 | 141 | $this->pushDelimiter( '</q>' ); |
155 | | - $conjunction = $this->addDescription( $conjunction, $this->getSubqueryDescription( $setsubNS, $label ) ); |
| 142 | + $conjunction = $this->addDescription( $conjunction, $this->getSubqueryDescription( $setsubNS ) ); |
156 | 143 | break; |
157 | 144 | case 'OR': case '||': case '': case '</q>': // finish disjunction and maybe subquery |
158 | 145 | if ( $this->m_defaultns !== null ) { // possibly add namespace restrictions |
— | — | @@ -231,29 +218,28 @@ |
232 | 219 | * Compute an SMWDescription for current part of a query, which should |
233 | 220 | * be the content of "[[ ... ]]". Returns NULL upon error. |
234 | 221 | * |
235 | | - * Parameters $setNS and $label have the same use as in getSubqueryDescription(). |
| 222 | + * Parameters $setNS has the same use as in getSubqueryDescription(). |
236 | 223 | */ |
237 | | - protected function getLinkDescription( &$setNS, &$label ) { |
| 224 | + protected function getLinkDescription( &$setNS ) { |
238 | 225 | // This method is called when we encountered an opening '[['. The following |
239 | 226 | // block could be a Category-statement, fixed object, or property statement. |
240 | 227 | $chunk = $this->readChunk( '', true, false ); // NOTE: untrimmed, initial " " escapes prop. chains |
241 | 228 | |
242 | 229 | if ( ( smwfNormalTitleText( $chunk ) == $this->m_categoryprefix ) || // category statement or |
243 | 230 | ( smwfNormalTitleText( $chunk ) == $this->m_conceptprefix ) ) { // concept statement |
244 | | - return $this->getClassDescription( $setNS, $label, |
245 | | - ( smwfNormalTitleText( $chunk ) == $this->m_categoryprefix ) ); |
| 231 | + return $this->getClassDescription( $setNS, ( smwfNormalTitleText( $chunk ) == $this->m_categoryprefix ) ); |
246 | 232 | } else { // fixed subject, namespace restriction, property query, or subquery |
247 | 233 | $sep = $this->readChunk( '', false ); // do not consume hit, "look ahead" |
248 | 234 | |
249 | 235 | if ( ( $sep == '::' ) || ( $sep == ':=' ) ) { |
250 | 236 | if ( $chunk { 0 } != ':' ) { // property statement |
251 | | - return $this->getPropertyDescription( $chunk, $setNS, $label ); |
| 237 | + return $this->getPropertyDescription( $chunk, $setNS ); |
252 | 238 | } else { // escaped article description, read part after :: to get full contents |
253 | 239 | $chunk .= $this->readChunk( '\[\[|\]\]|\|\||\|' ); |
254 | | - return $this->getArticleDescription( trim( $chunk ), $setNS, $label ); |
| 240 | + return $this->getArticleDescription( trim( $chunk ), $setNS ); |
255 | 241 | } |
256 | 242 | } else { // Fixed article/namespace restriction. $sep should be ]] or || |
257 | | - return $this->getArticleDescription( trim( $chunk ), $setNS, $label ); |
| 243 | + return $this->getArticleDescription( trim( $chunk ), $setNS ); |
258 | 244 | } |
259 | 245 | } |
260 | 246 | } |
— | — | @@ -263,7 +249,7 @@ |
264 | 250 | * is in between "[[Category:" and the closing "]]" and create a |
265 | 251 | * suitable description. |
266 | 252 | */ |
267 | | - protected function getClassDescription( &$setNS, &$label, $category = true ) { |
| 253 | + protected function getClassDescription( &$setNS, $category = true ) { |
268 | 254 | // note: no subqueries allowed here, inline disjunction allowed, wildcards allowed |
269 | 255 | $result = null; |
270 | 256 | $continue = true; |
— | — | @@ -286,7 +272,7 @@ |
287 | 273 | $continue = ( $chunk == '||' ) && $category; // disjunctions only for cateories |
288 | 274 | } |
289 | 275 | |
290 | | - return $this->finishLinkDescription( $chunk, false, $result, $setNS, $label ); |
| 276 | + return $this->finishLinkDescription( $chunk, false, $result, $setNS ); |
291 | 277 | } |
292 | 278 | |
293 | 279 | /** |
— | — | @@ -295,7 +281,7 @@ |
296 | 282 | * suitable description. The "::" is the first chunk on the current |
297 | 283 | * string. |
298 | 284 | */ |
299 | | - protected function getPropertyDescription( $propertyname, &$setNS, &$label ) { |
| 285 | + protected function getPropertyDescription( $propertyname, &$setNS ) { |
300 | 286 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
301 | 287 | $this->readChunk(); // consume separator ":=" or "::" |
302 | 288 | |
— | — | @@ -343,8 +329,7 @@ |
344 | 330 | if ( ( $typeid == '_wpg' ) || $inverse ) { |
345 | 331 | $this->pushDelimiter( '</q>' ); |
346 | 332 | $setsubNS = true; |
347 | | - $sublabel = ''; |
348 | | - $innerdesc = $this->addDescription( $innerdesc, $this->getSubqueryDescription( $setsubNS, $sublabel ), false ); |
| 333 | + $innerdesc = $this->addDescription( $innerdesc, $this->getSubqueryDescription( $setsubNS ), false ); |
349 | 334 | } else { // no subqueries allowed for non-pages |
350 | 335 | $this->m_errors[] = wfMsgForContent( 'smw_valuesubquery', end( $propertynames ) ); |
351 | 336 | $innerdesc = $this->addDescription( $innerdesc, new SMWThingDescription(), false ); |
— | — | @@ -403,7 +388,7 @@ |
404 | 389 | |
405 | 390 | $result = $innerdesc; |
406 | 391 | |
407 | | - return $this->finishLinkDescription( $chunk, false, $result, $setNS, $label ); |
| 392 | + return $this->finishLinkDescription( $chunk, false, $result, $setNS ); |
408 | 393 | } |
409 | 394 | |
410 | 395 | /** |
— | — | @@ -413,7 +398,7 @@ |
414 | 399 | * The first chunk behind the "[[" has already been read and is |
415 | 400 | * passed as a parameter. |
416 | 401 | */ |
417 | | - protected function getArticleDescription( $firstchunk, &$setNS, &$label ) { |
| 402 | + protected function getArticleDescription( $firstchunk, &$setNS ) { |
418 | 403 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
419 | 404 | |
420 | 405 | $chunk = $firstchunk; |
— | — | @@ -457,10 +442,10 @@ |
458 | 443 | } |
459 | 444 | } |
460 | 445 | |
461 | | - return $this->finishLinkDescription( $chunk, true, $result, $setNS, $label ); |
| 446 | + return $this->finishLinkDescription( $chunk, true, $result, $setNS ); |
462 | 447 | } |
463 | 448 | |
464 | | - protected function finishLinkDescription( $chunk, $hasNamespaces, $result, &$setNS, &$label ) { |
| 449 | + protected function finishLinkDescription( $chunk, $hasNamespaces, $result, &$setNS ) { |
465 | 450 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
466 | 451 | |
467 | 452 | if ( $result === null ) { // no useful information or concrete error found |
— | — | @@ -472,22 +457,21 @@ |
473 | 458 | |
474 | 459 | $setNS = $hasNamespaces; |
475 | 460 | |
476 | | - // terminate link (assuming that next chunk was read already) |
477 | | - if ( $chunk == '|' ) { |
| 461 | + if ( $chunk == '|' ) { // skip content after single |, but report a warning |
| 462 | + // Note: Using "|label" in query atoms used to be a way to set the mainlabel in SMW <1.0; no longer supported now |
478 | 463 | $chunk = $this->readChunk( '\]\]' ); |
479 | | - |
| 464 | + $labelpart = '|'; |
480 | 465 | if ( $chunk != ']]' ) { |
481 | | - $label .= $chunk; |
| 466 | + $labelpart .= $chunk; |
482 | 467 | $chunk = $this->readChunk( '\]\]' ); |
483 | | - } else { // empty label does not add to overall label |
484 | | - $chunk = ']]'; |
485 | 468 | } |
| 469 | + $this->m_errors[] = wfMsgForContent( 'smw_unexpectedpart', htmlspecialchars( $labelpart ) ); |
486 | 470 | } |
487 | 471 | |
488 | 472 | if ( $chunk != ']]' ) { |
489 | 473 | // What happended? We found some chunk that could not be processed as |
490 | | - // link content (as in [[Category:Test<q>]]) and there was no label to |
491 | | - // eat it. Or the closing ]] are just missing entirely. |
| 474 | + // link content (as in [[Category:Test<q>]]), or the closing ]] are |
| 475 | + // just missing entirely. |
492 | 476 | if ( $chunk != '' ) { |
493 | 477 | $this->m_errors[] = wfMsgForContent( 'smw_misplacedsymbol', htmlspecialchars( $chunk ) ); |
494 | 478 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -59,11 +59,7 @@ |
60 | 60 | $querymode = $printer->getQueryMode( $context ); |
61 | 61 | } |
62 | 62 | |
63 | | - if ( array_key_exists( 'mainlabel', $params ) ) { |
64 | | - $mainlabel = $params['mainlabel'] . $qp->getLabel(); |
65 | | - } else { |
66 | | - $mainlabel = $qp->getLabel(); |
67 | | - } |
| 63 | + $mainlabel = array_key_exists( 'mainlabel', $params ) ? $params['mainlabel'] : ''; |
68 | 64 | |
69 | 65 | if ( ( $querymode == SMWQuery::MODE_NONE ) || |
70 | 66 | ( ( !$desc->isSingleton() || |