r39710 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39709‎ | r39710 | r39711 >
Date:16:29, 20 August 2008
Author:vrandezo
Status:old
Tags:
Comment:
Moved SMW_QueryProcessor::$formats to $smwgResultFormats
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -21,27 +21,6 @@
2222 const CONCEPT_DESC = 2; // query for concept definition
2323
2424 /**
25 - * Array of enabled formats for formatting queries. Can be redefined in the settings to disallow certain
26 - * formats. The formats 'table' and 'list' are defaults that cannot be disabled. The format 'broadtable'
27 - * should not be disabled either in order not to break Special:ask.
28 - */
29 - static $formats = array('table' => 'SMWTableResultPrinter',
30 - 'list' => 'SMWListResultPrinter',
31 - 'ol' => 'SMWListResultPrinter',
32 - 'ul' => 'SMWListResultPrinter',
33 - 'broadtable' => 'SMWTableResultPrinter',
34 - 'embedded' => 'SMWEmbeddedResultPrinter',
35 - 'timeline' => 'SMWTimelineResultPrinter',
36 - 'eventline' => 'SMWTimelineResultPrinter',
37 - 'template' => 'SMWTemplateResultPrinter',
38 - 'count' => 'SMWListResultPrinter',
39 - 'debug' => 'SMWListResultPrinter',
40 - 'rss' => 'SMWRSSResultPrinter',
41 - 'icalendar' => 'SMWiCalendarResultPrinter',
42 - 'vcard' => 'SMWvCardResultPrinter',
43 - 'csv' => 'SMWCsvResultPrinter');
44 -
45 - /**
4625 * Parse a query string given in SMW's query language to create
4726 * an SMWQuery. Parameters are given as key-value-pairs in the
4827 * given array. The parameter $context defines in what context the
@@ -312,7 +291,8 @@
313292 $format = 'auto';
314293 if (array_key_exists('format', $params)) {
315294 $format = strtolower(trim($params['format']));
316 - if ( !array_key_exists($format, SMWQueryProcessor::$formats) ) {
 295+ global $smwgResultFormats;
 296+ if ( !array_key_exists($format, $smwgResultFormats) ) {
317297 $format = 'auto'; // If it is an unknown format, defaults to list/table again
318298 }
319299 }
@@ -328,8 +308,9 @@
329309 $format = 'table';
330310 else $format = 'list';
331311 }
332 - if (array_key_exists($format, SMWQueryProcessor::$formats))
333 - $formatclass = SMWQueryProcessor::$formats[$format];
 312+ global $smwgResultFormats;
 313+ if (array_key_exists($format, $smwgResultFormats))
 314+ $formatclass = $smwgResultFormats[$format];
334315 else
335316 $formatclass = "SMWListResultPrinter";
336317 return new $formatclass($format, ($context != SMWQueryProcessor::SPECIAL_PAGE));
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -740,3 +740,26 @@
741741 return $smwgMasterStore;
742742 }
743743
 744+/**
 745+ * Array of enabled formats for formatting queries. Can be redefined in the
 746+ * settings to disallow certain formats. The formats 'table' and 'list' are
 747+ * defaults that cannot be disabled. The format 'broadtable' should not be
 748+ * disabled either in order not to break Special:ask.
 749+ */
 750+global $smwgResultFormats;
 751+$smwgResultFormats =
 752+ array( 'table' => 'SMWTableResultPrinter',
 753+ 'list' => 'SMWListResultPrinter',
 754+ 'ol' => 'SMWListResultPrinter',
 755+ 'ul' => 'SMWListResultPrinter',
 756+ 'broadtable' => 'SMWTableResultPrinter',
 757+ 'embedded' => 'SMWEmbeddedResultPrinter',
 758+ 'timeline' => 'SMWTimelineResultPrinter',
 759+ 'eventline' => 'SMWTimelineResultPrinter',
 760+ 'template' => 'SMWTemplateResultPrinter',
 761+ 'count' => 'SMWListResultPrinter',
 762+ 'debug' => 'SMWListResultPrinter',
 763+ 'rss' => 'SMWRSSResultPrinter',
 764+ 'icalendar' => 'SMWiCalendarResultPrinter',
 765+ 'vcard' => 'SMWvCardResultPrinter',
 766+ 'csv' => 'SMWCsvResultPrinter');

Status & tagging log