Index: trunk/extensions/SemanticResultFormats/SRF_Settings.php |
— | — | @@ -1,68 +1,69 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Initializing file for the diverse query result formats supported in this |
5 | | - * extension. In order to use them, add the following lines to your |
6 | | - * LocalSettings.php: |
| 4 | + * Initializing file for the Semantic Result Formats extension. |
7 | 5 | * |
8 | | - * include_once('path/to/here/SRF_Settings.php'); |
9 | | - * |
10 | | - * If nothing else is added, no format will be included. In order to include a |
11 | | - * format, add the following line to your local settings after the line above: |
12 | | - * |
13 | | - * srfInit( array('formatname', 'formatname') ); |
14 | | - * |
15 | | - * With formatname being one of the following values: |
16 | | - * |
17 | | - * calendar, eventline, googlebar, googlepie, graph, timeline |
18 | | - * |
19 | | - * You can also just use the following command to include all formats: |
20 | | - * |
21 | | - * srfInit('all'); |
22 | | - * |
23 | | - * but this is not recommended. |
| 6 | + * @file |
| 7 | + * @ingroup SemanticResultFormats |
24 | 8 | */ |
25 | 9 | if( !defined( 'MEDIAWIKI' ) ) { |
26 | 10 | die( 'Not an entry point.' ); |
27 | 11 | } |
28 | 12 | |
29 | | -define('SRF_VERSION', '1.4.0'); |
| 13 | +define('SRF_VERSION', '1.4.1'); |
30 | 14 | |
31 | | -global $srfgScriptPath, $srfgIP; |
32 | 15 | $srfgScriptPath = $wgScriptPath . '/extensions/SemanticResultFormats'; |
33 | 16 | $srfgIP = $IP . '/extensions/SemanticResultFormats'; |
34 | | -global $wgExtensionMessagesFiles; |
35 | 17 | $wgExtensionMessagesFiles['SemanticResultFormats'] = $srfgIP . '/SRF_Messages.php'; |
| 18 | +$wgExtensionFunctions[] = 'srffSetup'; |
36 | 19 | |
37 | | -function srfInit( $formatName ) { |
38 | | - if ($formatName == 'all') { |
39 | | - srfInit(array('calendar', 'eventline', 'googlebar', 'googlepie', 'graph', 'timeline')); |
40 | | - } elseif (is_array($formatName)) { |
41 | | - foreach($formatName as $fn) srfInit($fn); |
42 | | - |
43 | | - $formats = implode(', ', $formatName); |
44 | | - global $wgExtensionCredits; |
45 | | - $wgExtensionCredits['other'][]= array( |
46 | | - 'name' => 'Semantic Result Formats', |
47 | | - 'version' => SRF_VERSION, |
48 | | - 'author' => "[http://simia.net Denny Vrandecic], Frank Dengler and Yaron Koren", |
49 | | - 'url' => 'http://www.semantic-mediawiki.org/wiki/Help:Semantic_Result_Formats', |
50 | | - 'description' => 'Additional formats for Semantic MediaWiki inline queries. Available formats: ' . $formats |
51 | | - ); |
52 | | - } else { |
53 | | - global $smwgResultFormats, $wgAutoloadClasses, $srfgIP; |
| 20 | +$srfgFormats = array('calendar', 'eventline', 'timeline', 'sum', 'average', 'min', 'max'); |
54 | 21 | |
55 | | - $class = ''; |
56 | | - $file = ''; |
57 | | - if ($formatName == 'graph') { $class = 'SRFGraph'; $file = $srfgIP . '/GraphViz/SRF_Graph.php'; } |
58 | | - if ($formatName == 'googlebar') { $class = 'SRFGoogleBar'; $file = $srfgIP . '/GoogleCharts/SRF_GoogleBar.php'; } |
59 | | - if ($formatName == 'googlepie') { $class = 'SRFGooglePie'; $file = $srfgIP . '/GoogleCharts/SRF_GooglePie.php'; } |
60 | | - if ($formatName == 'timeline') { $class = 'SRFTimeline'; $file = $srfgIP . '/Timeline/SRF_Timeline.php'; } |
61 | | - if ($formatName == 'eventline') { $class = 'SRFTimeline'; $file = $srfgIP . '/Timeline/SRF_Timeline.php'; } |
62 | | - if ($formatName == 'calendar') { $class = 'SRFCalendar'; $file = $srfgIP . '/Calendar/SRF_Calendar.php'; } |
63 | | - if (($class != '') && ($file)) { |
64 | | - $smwgResultFormats[$formatName] = $class; |
65 | | - $wgAutoloadClasses[$class] = $file; |
66 | | - } |
| 22 | +function srffSetup() { |
| 23 | + global $srfgFormats, $wgExtensionCredits; |
| 24 | + |
| 25 | + foreach($srfgFormats as $fn) srffInitFormat($fn); |
| 26 | + $formats_list = implode(', ', $srfgFormats); |
| 27 | + $wgExtensionCredits['other'][]= array( |
| 28 | + 'name' => 'Semantic Result Formats', |
| 29 | + 'version' => SRF_VERSION, |
| 30 | + 'author' => "[http://simia.net Denny Vrandecic], Frank Dengler, Yaron Koren and Nathan Yergler", |
| 31 | + 'url' => 'http://www.semantic-mediawiki.org/wiki/Help:Semantic_Result_Formats', |
| 32 | + 'description' => 'Additional formats for Semantic MediaWiki inline queries. Available formats: ' . $formats_list |
| 33 | + ); |
| 34 | +} |
| 35 | + |
| 36 | +function srffInitFormat( $format ) { |
| 37 | + global $smwgResultFormats, $wgAutoloadClasses, $srfgIP; |
| 38 | + |
| 39 | + $class = ''; |
| 40 | + $file = ''; |
| 41 | + if ($format == 'graph') { |
| 42 | + $class = 'SRFGraph'; |
| 43 | + $file = $srfgIP . '/GraphViz/SRF_Graph.php'; |
67 | 44 | } |
| 45 | + if ($format == 'googlebar') { |
| 46 | + $class = 'SRFGoogleBar'; |
| 47 | + $file = $srfgIP . '/GoogleCharts/SRF_GoogleBar.php'; |
| 48 | + } |
| 49 | + if ($format == 'googlepie') { |
| 50 | + $class = 'SRFGooglePie'; |
| 51 | + $file = $srfgIP . '/GoogleCharts/SRF_GooglePie.php'; |
| 52 | + } |
| 53 | + if ($format == 'timeline' || $format == 'eventline') { |
| 54 | + $class = 'SRFTimeline'; |
| 55 | + $file = $srfgIP . '/Timeline/SRF_Timeline.php'; |
| 56 | + } |
| 57 | + if ($format == 'calendar') { |
| 58 | + $class = 'SRFCalendar'; |
| 59 | + $file = $srfgIP . '/Calendar/SRF_Calendar.php'; |
| 60 | + } |
| 61 | + if ($format == 'sum' || $format == 'average' || $format == 'min' || $format == 'max') { |
| 62 | + $class = 'SRFMath'; |
| 63 | + $file = $srfgIP . '/Math/SRF_Math.php'; |
| 64 | + } |
| 65 | + if (($class != '') && ($file)) { |
| 66 | + $smwgResultFormats[$format] = $class; |
| 67 | + $wgAutoloadClasses[$class] = $file; |
| 68 | + } |
68 | 69 | } |
69 | 70 | |