Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -2,14 +2,15 @@ |
3 | 3 | /** |
4 | 4 | * This file contains a static class for accessing functions to generate and execute |
5 | 5 | * semantic queries and to serialise their results. |
6 | | - * |
| 6 | + * |
7 | 7 | * @author Markus Krötzsch |
8 | 8 | */ |
9 | | - |
| 9 | + |
10 | 10 | global $smwgIP; |
11 | 11 | require_once($smwgIP . '/includes/storage/SMW_Store.php'); |
12 | 12 | require_once($smwgIP . '/includes/SMW_QueryPrinters.php'); |
13 | 13 | |
| 14 | + |
14 | 15 | /** |
15 | 16 | * This hook registers a parser-hook to the current parser. |
16 | 17 | * Note that parser hooks are something different than MW hooks |
— | — | @@ -56,6 +57,13 @@ |
57 | 58 | * as a string. Otherwise an object of type SMWQuery is returned. |
58 | 59 | */ |
59 | 60 | static public function createQuery($querystring, $params, $inline = true) { |
| 61 | + // This should be the proper way of substituting templates in a safe and comprehensive way: |
| 62 | + global $wgTitle; |
| 63 | + $parser = new Parser(); |
| 64 | + $parserOptions = new ParserOptions(); |
| 65 | + $parser->startExternalParse( $wgTitle, $parserOptions, OT_HTML ); |
| 66 | + $querystring = $parser->transformMsg( $querystring, $parserOptions ); |
| 67 | + |
60 | 68 | // parse query: |
61 | 69 | $qp = new SMWQueryParser(); |
62 | 70 | $desc = $qp->getQueryDescription($querystring); |
— | — | @@ -383,6 +391,13 @@ |
384 | 392 | } |
385 | 393 | } |
386 | 394 | // note that at this point, we already read one more chunk behind the value |
| 395 | + $list = preg_split('/^\*/',$value,2); |
| 396 | + if (count($list) == 2) { //hit |
| 397 | + $value = '*'; |
| 398 | + $printmodifier = $list[1]; |
| 399 | + } else { |
| 400 | + $printmodifier = ''; |
| 401 | + } |
387 | 402 | switch ($value) { |
388 | 403 | case '*': // print statement |
389 | 404 | /// TODO: no support for selecting output unit yet |
— | — | @@ -398,8 +413,7 @@ |
399 | 414 | $label = $att->getText(); |
400 | 415 | } |
401 | 416 | if ($chunk == ']]') { |
402 | | - $dv = SMWDataValueFactory::newAttributeValue($att->getText()); |
403 | | - return new SMWPrintRequest(SMW_PRINT_ATTS, $label, $att, $dv); |
| 417 | + return new SMWPrintRequest(SMW_PRINT_ATTS, $label, $att, $printmodifier); |
404 | 418 | } else { |
405 | 419 | $this->m_error = 'Misshaped print statement.'; //TODO: internationalise |
406 | 420 | return NULL; |