Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryParser.php |
— | — | @@ -115,11 +115,9 @@ |
116 | 116 | * The call-by-ref parameter $label is used to append any label strings found. |
117 | 117 | */ |
118 | 118 | protected function getSubqueryDescription(&$setNS, &$label) { |
119 | | - global $smwgQPrintoutLimit; |
120 | 119 | wfLoadExtensionMessages('SemanticMediaWiki'); |
121 | 120 | $conjunction = NULL; // used for the current inner conjunction |
122 | 121 | $disjuncts = array(); // (disjunctive) array of subquery conjunctions |
123 | | - $printrequests = array(); // the printrequests found for this query level |
124 | 122 | $hasNamespaces = false; // does the current $conjnuction have its own namespace restrictions? |
125 | 123 | $mustSetNS = $setNS; // must ns restrictions be set? (may become true even if $setNS is false) |
126 | 124 | |
— | — | @@ -129,9 +127,7 @@ |
130 | 128 | switch ($chunk) { |
131 | 129 | case '[[': // start new link block |
132 | 130 | $ld = $this->getLinkDescription($setsubNS, $label); |
133 | | - if ($ld instanceof SMWPrintRequest) { |
134 | | - $printrequests[] = $ld; |
135 | | - } elseif ($ld instanceof SMWDescription) { |
| 131 | + if ($ld !== NULL) { |
136 | 132 | $conjunction = $this->addDescription($conjunction,$ld); |
137 | 133 | } |
138 | 134 | break; |
— | — | @@ -202,31 +198,18 @@ |
203 | 199 | } |
204 | 200 | $setNS = $mustSetNS; // NOTE: also false if namespaces were given but no default NS descs are available |
205 | 201 | |
206 | | - $prcount = 0; |
207 | | - foreach ($printrequests as $pr) { // add printrequests |
208 | | - if ($prcount < $smwgQPrintoutLimit) { |
209 | | - $result->addPrintRequest($pr); |
210 | | - $prcount++; |
211 | | - } else { |
212 | | - $this->m_errors[] = wfMsgForContent('smw_overprintoutlimit'); |
213 | | - break; |
214 | | - } |
215 | | - } |
216 | 202 | return $result; |
217 | 203 | } |
218 | 204 | |
219 | 205 | /** |
220 | 206 | * Compute an SMWDescription for current part of a query, which should |
221 | | - * be the content of "[[ ... ]]". Alternatively, if the current syntax |
222 | | - * specifies a print request, return the print request object. |
223 | | - * Returns NULL upon error. |
| 207 | + * be the content of "[[ ... ]]". Returns NULL upon error. |
224 | 208 | * |
225 | 209 | * Parameters $setNS and $label have the same use as in getSubqueryDescription(). |
226 | 210 | */ |
227 | 211 | protected function getLinkDescription(&$setNS, &$label) { |
228 | 212 | // This method is called when we encountered an opening '[['. The following |
229 | | - // block could be a Category-statement, fixed object, property statements, |
230 | | - // or according print statements. |
| 213 | + // block could be a Category-statement, fixed object, or property statement. |
231 | 214 | $chunk = $this->readChunk('',true,false); // NOTE: untrimmed, initial " " escapes prop. chains |
232 | 215 | if ( (smwfNormalTitleText($chunk) == $this->m_categoryprefix) || // category statement or |
233 | 216 | (smwfNormalTitleText($chunk) == $this->m_conceptprefix) ) { // concept statement |
— | — | @@ -284,12 +267,8 @@ |
285 | 268 | protected function getPropertyDescription($propertyname, &$setNS, &$label) { |
286 | 269 | wfLoadExtensionMessages('SemanticMediaWiki'); |
287 | 270 | $this->readChunk(); // consume separator ":=" or "::" |
288 | | - // first process property chain syntax (e.g. "property1.property2::value"): |
289 | | - if ($propertyname{0} == ' ') { // escape |
290 | | - $propertynames = array($propertyname); |
291 | | - } else { |
292 | | - $propertynames = explode('.', $propertyname); |
293 | | - } |
| 271 | + // first process property chain syntax (e.g. "property1.property2::value"), escaped by initial " ": |
| 272 | + $propertynames = ($propertyname{0} == ' ')?array($propertyname):explode('.', $propertyname); |
294 | 273 | $properties = array(); |
295 | 274 | $typeid = '_wpg'; |
296 | 275 | foreach ($propertynames as $name) { |
— | — | @@ -332,7 +311,7 @@ |
333 | 312 | } |
334 | 313 | $chunk = $this->readChunk(); |
335 | 314 | break; |
336 | | - default: //normal object value or print statement |
| 315 | + default: //normal object value |
337 | 316 | // read value(s), possibly with inner [[...]] |
338 | 317 | $open = 1; |
339 | 318 | $value = $chunk; |
— | — | @@ -366,32 +345,12 @@ |
367 | 346 | $dv->acceptQuerySyntax(); |
368 | 347 | $dv->setUserValue($value); |
369 | 348 | $vl = $dv->getValueList(); |
370 | | - $pm = $dv->getPrintModifier(); |
371 | | - if ($vl !== NULL) { // prefer conditions over print statements (only one possible right now) |
| 349 | + if ($vl !== NULL) { |
372 | 350 | $innerdesc = $this->addDescription($innerdesc, $vl, false); |
373 | | - } elseif ($pm !== false) { |
374 | | - if ($chunk == '|') { |
375 | | - $printlabel = $this->readChunk('\]\]'); |
376 | | - if ($printlabel != ']]') { |
377 | | - $chunk = $this->readChunk('\]\]'); |
378 | | - } else { |
379 | | - $printlabel = ''; |
380 | | - $chunk = ']]'; |
381 | | - } |
382 | | - } else { |
383 | | - $printlabel = $property->getWikiValue(); |
384 | | - } |
385 | | - if ($chunk == ']]') { |
386 | | - return new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, $printlabel, $property, $pm); |
387 | | - } else { |
388 | | - $this->m_errors[] = wfMsgForContent('smw_badprintout'); |
389 | | - return NULL; |
390 | | - } |
391 | 351 | } |
392 | 352 | } else { // unary value |
393 | 353 | $comparator = SMW_CMP_EQ; |
394 | | - $printmodifier = ''; |
395 | | - SMWQueryParser::prepareValue($value, $comparator, $printmodifier); |
| 354 | + SMWQueryParser::prepareValue($value, $comparator); |
396 | 355 | $dv = SMWDataValueFactory::newPropertyObjectValue($property, $value); |
397 | 356 | if (!$dv->isValid()) { |
398 | 357 | $this->m_errors = $this->m_errors + $dv->getErrors(); |
— | — | @@ -406,11 +365,9 @@ |
407 | 366 | } |
408 | 367 | |
409 | 368 | if ($innerdesc === NULL) { // make a wildcard search |
410 | | - if ( ($this->m_defaultns !== NULL) && ($typeid == '_wpg') ) { |
411 | | - $innerdesc = $this->addDescription($innerdesc, $this->m_defaultns, false); |
412 | | - } else { |
413 | | - $innerdesc = $this->addDescription($innerdesc, new SMWThingDescription(), false); |
414 | | - } |
| 369 | + $innerdesc = ( ($this->m_defaultns !== NULL) && ($typeid == '_wpg') )? |
| 370 | + $this->addDescription($innerdesc, $this->m_defaultns, false): |
| 371 | + $this->addDescription($innerdesc, new SMWThingDescription(), false); |
415 | 372 | $this->m_errors[] = wfMsgForContent('smw_propvalueproblem', $property->getWikiValue()); |
416 | 373 | } |
417 | 374 | $properties = array_reverse($properties); |
— | — | @@ -423,31 +380,28 @@ |
424 | 381 | |
425 | 382 | |
426 | 383 | /** |
427 | | - * Prepare a single value string, possibly extracting comparators and |
428 | | - * printmodifier. $value is changed to consist only of the remaining |
429 | | - * effective value string, or of "*" for print statements. |
| 384 | + * Prepare a single value string, possibly extracting comparators. $value is |
| 385 | + * changed to consist only of the remaining effective value string (without the |
| 386 | + * comparator). |
430 | 387 | */ |
431 | | - static public function prepareValue(&$value, &$comparator, &$printmodifier) { |
| 388 | + static public function prepareValue(&$value, &$comparator) { |
432 | 389 | global $smwgQComparators; |
433 | 390 | $list = preg_split('/^(' . $smwgQComparators . ')/u',$value, 2, PREG_SPLIT_DELIM_CAPTURE); |
434 | 391 | $comparator = SMW_CMP_EQ; |
435 | | - if (count($list) == 3) { // initial comparator found ($list[1] should be empty) |
| 392 | + if (count($list) == 3) { // initial comparator found ($list[0] should be empty) |
| 393 | + $value = $list[2]; |
436 | 394 | switch ($list[1]) { |
437 | 395 | case '<': |
438 | 396 | $comparator = SMW_CMP_LEQ; |
439 | | - $value = $list[2]; |
440 | 397 | break; |
441 | 398 | case '>': |
442 | 399 | $comparator = SMW_CMP_GEQ; |
443 | | - $value = $list[2]; |
444 | 400 | break; |
445 | 401 | case '!': |
446 | 402 | $comparator = SMW_CMP_NEQ; |
447 | | - $value = $list[2]; |
448 | 403 | break; |
449 | 404 | case '~': |
450 | 405 | $comparator = SMW_CMP_LIKE; |
451 | | - $value = $list[2]; |
452 | 406 | break; |
453 | 407 | //default: not possible |
454 | 408 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php |
— | — | @@ -23,16 +23,12 @@ |
24 | 24 | private $m_type; |
25 | 25 | /// Should this DV operate on query syntax (special mode for parsing queries in a compatible fashion) |
26 | 26 | private $m_querysyntax = false; |
27 | | - |
| 27 | + /// Array of comparators as might be found in query strings (based on inputs like >, <, etc.) |
28 | 28 | private $m_comparators; |
29 | | - private $m_printstatement = false; |
30 | | - private $m_outputmodifiers; |
31 | 29 | |
32 | 30 | protected function parseUserValue($value) { |
33 | 31 | $this->m_values = array(); |
34 | 32 | $this->m_comparators = array(); // only for query mode |
35 | | - $this->m_printstatement = false; // only for query mode |
36 | | - $this->m_outputmodifiers = array(); // only for query mode |
37 | 33 | if ($value == '') { |
38 | 34 | $this->addError('No values specified.'); |
39 | 35 | return; |
— | — | @@ -46,15 +42,7 @@ |
47 | 43 | // special handling for supporting query parsing |
48 | 44 | if ($this->m_querysyntax) { |
49 | 45 | $comparator = SMW_CMP_EQ; |
50 | | - $printmodifier = ''; |
51 | | - SMWQueryParser::prepareValue($values[$vi], $comparator, $printmodifier); |
52 | | - if ($values[$vi] == '*') { // print statement, treat as omission |
53 | | - $this->m_printstatement = true; |
54 | | - $values[$vi] = ''; |
55 | | - $printmodifiers[$vi] = $printmodifier; |
56 | | - } else { |
57 | | - $printmodifiers[$vi] = ''; |
58 | | - } |
| 46 | + SMWQueryParser::prepareValue($values[$vi], $comparator); |
59 | 47 | } |
60 | 48 | // generating the DVs: |
61 | 49 | if ( (count($values) > $vi) && |
— | — | @@ -264,18 +252,6 @@ |
265 | 253 | return $vl; |
266 | 254 | } |
267 | 255 | |
268 | | - /** |
269 | | - * If in querymode, return all printmodifiers given or false if no print request |
270 | | - * was specified. This requires the input to be given to setUserValue(). |
271 | | - * Otherwise bad things will happen. |
272 | | - */ |
273 | | - public function getPrintModifier() { |
274 | | - if (!$this->m_printstatement || !$this->m_querysyntax) { |
275 | | - return false; |
276 | | - } |
277 | | - return implode(';', $this->m_outputmodifiers); |
278 | | - } |
279 | | - |
280 | 256 | public function getExportData() { |
281 | 257 | if (!$this->isValid()) return NULL; |
282 | 258 | |