Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -20,7 +20,17 @@ |
21 | 21 | * formats. The formats 'table' and 'list' are defaults that cannot be disabled. The format 'broadtable' |
22 | 22 | * should not be disabled either in order not to break Special:ask. |
23 | 23 | */ |
24 | | - static $formats = array('table', 'list', 'ol', 'ul', 'broadtable', 'embedded', 'timeline', 'eventline', 'template', 'count', 'debug'); |
| 24 | + static $formats = array('table' => "SMWTableResultPrinter", |
| 25 | + 'list' => "SMWListResultPrinter", |
| 26 | + 'ol' => "SMWListResultPrinter", |
| 27 | + 'ul' => "SMWListResultPrinter", |
| 28 | + 'broadtable' => "SMWTableResultPrinter", |
| 29 | + 'embedded' => "SMWEmbeddedResultPrinter", |
| 30 | + 'timeline' => "SMWTimelineResultPrinter", |
| 31 | + 'eventline' => "SMWTimelineResultPrinter", |
| 32 | + 'template' => "SMWTemplateResultPrinter", |
| 33 | + 'count' => "SMWListResultPrinter", |
| 34 | + 'debug' => "SMWListResultPrinter"); |
25 | 35 | |
26 | 36 | /** |
27 | 37 | * Parse a query string given in SMW's query language to create |
— | — | @@ -239,7 +249,7 @@ |
240 | 250 | $format = 'auto'; |
241 | 251 | if (array_key_exists('format', $params)) { |
242 | 252 | $format = strtolower(trim($params['format'])); |
243 | | - if ( !in_array($format,SMWQueryProcessor::$formats) ) { |
| 253 | + if ( !array_key_exists($format, SMWQueryProcessor::$formats) ) { |
244 | 254 | $format = 'auto'; // If it is an unknown format, defaults to list/table again |
245 | 255 | } |
246 | 256 | } |
— | — | @@ -255,19 +265,12 @@ |
256 | 266 | $format = 'table'; |
257 | 267 | else $format = 'list'; |
258 | 268 | } |
259 | | - switch ($format) { |
260 | | - case 'table': case 'broadtable': |
261 | | - return new SMWTableResultPrinter($format,$inline); |
262 | | - case 'ul': case 'ol': case 'list': |
263 | | - return new SMWListResultPrinter($format,$inline); |
264 | | - case 'timeline': case 'eventline': |
265 | | - return new SMWTimelineResultPrinter($format,$inline); |
266 | | - case 'embedded': |
267 | | - return new SMWEmbeddedResultPrinter($format,$inline); |
268 | | - case 'template': |
269 | | - return new SMWTemplateResultPrinter($format,$inline); |
270 | | - default: return new SMWListResultPrinter($format,$inline); |
271 | | - } |
| 269 | + |
| 270 | + if (array_key_exists($format, SMWQueryProcessor::$formats)) |
| 271 | + $formatclass = SMWQueryProcessor::$formats[$format]; |
| 272 | + else |
| 273 | + $formatclass = "SMWListResultPrinter"; |
| 274 | + return new $formatclass($format,$inline); |
272 | 275 | } |
273 | 276 | |
274 | 277 | } |