Index: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php |
— | — | @@ -2,6 +2,12 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Main entry point for the SemanticResultFormats extension. |
| 6 | + * http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats |
| 7 | + * |
| 8 | + * @file SemanticresultFormats.php |
| 9 | + * @ingroup SemanticResultFormats |
| 10 | + * |
| 11 | + * @author Jeroen De Dauw |
6 | 12 | */ |
7 | 13 | |
8 | 14 | /** |
— | — | @@ -10,4 +16,127 @@ |
11 | 17 | * @defgroup SemanticResultFormats SemanticResultFormats |
12 | 18 | */ |
13 | 19 | |
14 | | -require_once dirname( __FILE__ ) . '/SRF_Settings.php'; |
\ No newline at end of file |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +define( 'SRF_VERSION', '1.5.2 alpha' ); |
| 25 | + |
| 26 | +// Require the settings file. |
| 27 | +require dirname( __FILE__ ) . '/SRF_Settings.php'; |
| 28 | + |
| 29 | +srffInitFormats(); |
| 30 | + |
| 31 | +$wgExtensionMessagesFiles['SemanticResultFormats'] = dirname( __FILE__ ) . '/SRF_Messages.php'; |
| 32 | + |
| 33 | +// FIXME: hardcoded path |
| 34 | +$srfgScriptPath = $wgScriptPath . '/extensions/SemanticResultFormats'; |
| 35 | +$srfgIP = dirname( __FILE__ ); |
| 36 | + |
| 37 | +$wgHooks['AdminLinks'][] = 'srffAddToAdminLinks'; |
| 38 | +$wgHooks['ParserFirstCallInit'][] = 'SRFParserFunctions::registerFunctions'; |
| 39 | + |
| 40 | +$wgAutoloadClasses['SRFParserFunctions'] = $srfgIP . '/SRF_ParserFunctions.php'; |
| 41 | +// FIXME: Can be removed when new style magic words are used (introduced in r52503) |
| 42 | +$wgHooks['LanguageGetMagic'][] = 'SRFParserFunctions::languageGetMagic'; |
| 43 | + |
| 44 | +$wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'other'][] = array( |
| 45 | + 'path' => __FILE__, |
| 46 | + 'name' => 'Semantic Result Formats', |
| 47 | + 'version' => SRF_VERSION, |
| 48 | + 'author' => array( |
| 49 | + 'Frank Dengler', |
| 50 | + '[http://steren.fr Steren Giannini]', |
| 51 | + 'Sanyam Goyal', |
| 52 | + 'Fabian Howahl', |
| 53 | + 'Yaron Koren', |
| 54 | + '[http://korrekt.org Markus Krötzsch]', |
| 55 | + 'David Loomer', |
| 56 | + 'Joel Natividad', |
| 57 | + '[http://simia.net Denny Vrandecic]', |
| 58 | + 'Nathan Yergler', |
| 59 | + 'Hans-Jörg Happel', |
| 60 | + 'Rowan Rodrik van der Molen' |
| 61 | + ), |
| 62 | + 'url' => 'http://semantic-mediawiki.org/wiki/Help:Semantic_Result_Formats', |
| 63 | + 'descriptionmsg' => 'srf-desc' |
| 64 | +); |
| 65 | + |
| 66 | +/** |
| 67 | + * Autoload the query printer classes and associate them with their formats in the $smwgResultFormats array. |
| 68 | + * |
| 69 | + * @since 1.5.2 |
| 70 | + */ |
| 71 | +function srffInitFormats() { |
| 72 | + global $srfgFormats, $smwgResultFormats, $wgAutoloadClasses; |
| 73 | + |
| 74 | + $formatDir = dirname( __FILE__ ) . '/'; |
| 75 | + |
| 76 | + $wgAutoloadClasses['SRFTimeline'] = $formatDir . 'Timeline/SRF_Timeline.php'; |
| 77 | + $wgAutoloadClasses['SRFvCard'] = $formatDir . 'vCard/SRF_vCard.php'; |
| 78 | + $wgAutoloadClasses['SRFiCalendar'] = $formatDir . 'iCalendar/SRF_iCalendar.php'; |
| 79 | + $wgAutoloadClasses['SRFBibTeX'] = $formatDir . 'BibTeX/SRF_BibTeX.php'; |
| 80 | + $wgAutoloadClasses['SRFCalendar'] = $formatDir . 'Calendar/SRF_Calendar.php'; |
| 81 | + $wgAutoloadClasses['SRFOutline'] = $formatDir . 'Outline/SRF_Outline.php'; |
| 82 | + $wgAutoloadClasses['SRFMath'] = $formatDir . 'Math/SRF_Math.php'; |
| 83 | + $wgAutoloadClasses['SRFExhibit'] = $formatDir . 'Exhibit/SRF_Exhibit.php'; |
| 84 | + $wgAutoloadClasses['SRFGoogleBar'] = $formatDir . 'GoogleCharts/SRF_GoogleBar.php'; |
| 85 | + $wgAutoloadClasses['SRFGooglePie'] = $formatDir . 'GoogleCharts/SRF_GooglePie.php'; |
| 86 | + $wgAutoloadClasses['SRFjqPlotPie'] = $formatDir . 'jqPlot/SRF_jqPlotPie.php'; |
| 87 | + $wgAutoloadClasses['SRFjqPlotBar'] = $formatDir . 'jqPlot/SRF_jqPlotBar.php'; |
| 88 | + $wgAutoloadClasses['SRFGraph'] = $formatDir . 'GraphViz/SRF_Graph.php'; |
| 89 | + $wgAutoloadClasses['SRFProcess'] = $formatDir . 'GraphViz/SRF_Process.php'; |
| 90 | + $wgAutoloadClasses['SRFPloticusVBar'] = $formatDir . 'Ploticus/SRF_PloticusVBar.php'; |
| 91 | + $wgAutoloadClasses['SRFGallery'] = $formatDir . 'Gallery/SRF_Gallery.php'; |
| 92 | + |
| 93 | + $formatClasses = array( |
| 94 | + 'timeline' => 'SRFTimeline', |
| 95 | + 'eventline' => 'SRFTimeline', |
| 96 | + 'vcard' => 'SRFvCard', |
| 97 | + 'icalendar' => 'SRFiCalendar', |
| 98 | + 'bibtex' => 'SRFBibTeX', |
| 99 | + 'calendar' => 'SRFCalendar', |
| 100 | + 'outline' => 'SRFOutline', |
| 101 | + 'sum' => 'SRFMath', |
| 102 | + 'average' => 'SRFMath', |
| 103 | + 'min' => 'SRFMath', |
| 104 | + 'max' => 'SRFMath', |
| 105 | + 'exhibit' => 'SRFExhibit', |
| 106 | + 'googlebar' => 'SRFGoogleBar', |
| 107 | + 'googlepie' => 'SRFGooglePie', |
| 108 | + 'jqplotpie' => 'SRFjqPlotPie', |
| 109 | + 'jqplotbar' => 'SRFjqPlotBar', |
| 110 | + 'graph' => 'SRFGraph', |
| 111 | + 'process' => 'SRFProcess', |
| 112 | + 'ploticusvbar' => 'SRFPloticusVBar', |
| 113 | + 'gallery' => 'SRFGallery', |
| 114 | + ); |
| 115 | + |
| 116 | + foreach ( $srfgFormats as $format ) { |
| 117 | + if ( array_key_exists( $format, $formatClasses ) ) { |
| 118 | + $smwgResultFormats[$format] = $formatClasses[$format]; |
| 119 | + } |
| 120 | + else { |
| 121 | + wfDebug( "There is not result format class associated with the format '$format'." ); |
| 122 | + } |
| 123 | + } |
| 124 | +} |
| 125 | + |
| 126 | +/** |
| 127 | + * Adds a link to Admin Links page. |
| 128 | + */ |
| 129 | +function srffAddToAdminLinks( &$admin_links_tree ) { |
| 130 | + $displaying_data_section = $admin_links_tree->getSection( wfMsg( 'smw_adminlinks_displayingdata' ) ); |
| 131 | + |
| 132 | + // Escape is SMW hasn't added links. |
| 133 | + if ( is_null( $displaying_data_section ) ) { |
| 134 | + return true; |
| 135 | + } |
| 136 | + |
| 137 | + $smw_docu_row = $displaying_data_section->getRow( 'smw' ); |
| 138 | + wfLoadExtensionMessages( 'SemanticResultFormats' ); |
| 139 | + $srf_docu_label = wfMsg( 'adminlinks_documentation', wfMsg( 'srf-name' ) ); |
| 140 | + $smw_docu_row->addItem( AlItem::newFromExternalLink( 'http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats', $srf_docu_label ) ); |
| 141 | + |
| 142 | + return true; |
| 143 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticResultFormats/SRF_Settings.php |
— | — | @@ -6,123 +6,23 @@ |
7 | 7 | * |
8 | 8 | * NOTE: Do not use this file as entry point, use SemanticresultFormats.php instead. |
9 | 9 | * |
10 | | - * @file |
| 10 | + * @file SRF_Settings.php |
11 | 11 | * @ingroup SemanticResultFormats |
| 12 | + * |
| 13 | + * @author Jeroen De Dauw |
12 | 14 | */ |
13 | 15 | |
14 | 16 | if ( !defined( 'MEDIAWIKI' ) ) { |
15 | 17 | die( 'Not an entry point.' ); |
16 | 18 | } |
17 | 19 | |
18 | | -define( 'SRF_VERSION', '1.5.2 alpha' ); |
| 20 | +if ( !defined( 'SRF_VERSION' ) ) { |
| 21 | + require_once dirname( __FILE__ ) . '/SemanticresultFormats.php'; |
| 22 | +} |
19 | 23 | |
20 | | -$srfgScriptPath = $wgScriptPath . '/extensions/SemanticResultFormats'; // TODO: fix hardcoded path |
21 | | -$srfgIP = dirname( __FILE__ ); |
22 | | -$wgExtensionMessagesFiles['SemanticResultFormats'] = $srfgIP . '/SRF_Messages.php'; |
23 | | -$wgExtensionFunctions[] = 'srffSetup'; |
24 | | - |
25 | | -$wgAutoloadClasses['SRFParserFunctions'] = $srfgIP . '/SRF_ParserFunctions.php'; |
26 | | - |
27 | | -// used for jqplot formats |
28 | | -$srfgJQPlotIncluded = false; |
29 | | - |
30 | | -// FIXME: Can be removed when new style magic words are used (introduced in r52503) |
31 | | -$wgHooks['LanguageGetMagic'][] = 'SRFParserFunctions::languageGetMagic'; |
32 | | -$wgHooks['AdminLinks'][] = 'srffAddToAdminLinks'; |
33 | | -$wgHooks['ParserFirstCallInit'][] = 'SRFParserFunctions::registerFunctions'; |
34 | | - |
| 24 | +# The formats you want to be able to use. |
| 25 | +# See the INSTALL file or this url for more info: http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats#Installation |
35 | 26 | $srfgFormats = array( 'icalendar', 'vcard', 'bibtex', 'calendar', 'eventline', 'timeline', 'outline', 'gallery', 'jqplotbar', 'jqplotpie', 'sum', 'average', 'min', 'max' ); |
36 | 27 | |
37 | | -function srffSetup() { |
38 | | - global $srfgFormats, $wgExtensionCredits; |
39 | | - |
40 | | - srffInitFormats(); |
41 | | - |
42 | | - $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'other'][] = array( |
43 | | - 'path' => __FILE__, |
44 | | - 'name' => 'Semantic Result Formats', |
45 | | - 'version' => SRF_VERSION, |
46 | | - 'author' => array( 'Frank Dengler', '[http://steren.fr Steren Giannini]', 'Sanyam Goyal', 'Fabian Howahl', 'Yaron Koren', '[http://korrekt.org Markus Krötzsch]', 'David Loomer', 'Joel Natividad', '[http://simia.net Denny Vrandecic]', 'Nathan Yergler', 'Hans-Jörg Happel', 'Rowan Rodrik van der Molen' ), |
47 | | - 'url' => 'http://semantic-mediawiki.org/wiki/Help:Semantic_Result_Formats', |
48 | | - 'descriptionmsg' => 'srf-desc' |
49 | | - ); |
50 | | -} |
51 | | - |
52 | | -/** |
53 | | - * Autoload the query printer classes and associate them with their formats in the $smwgResultFormats array. |
54 | | - * |
55 | | - * @since 1.5.2 |
56 | | - */ |
57 | | -function srffInitFormats() { |
58 | | - global $srfgFormats, $smwgResultFormats, $wgAutoloadClasses; |
59 | | - |
60 | | - $formatDir = dirname( __FILE__ ) . '/'; |
61 | | - |
62 | | - $wgAutoloadClasses['SRFTimeline'] = $formatDir . 'Timeline/SRF_Timeline.php'; |
63 | | - $wgAutoloadClasses['SRFvCard'] = $formatDir . 'vCard/SRF_vCard.php'; |
64 | | - $wgAutoloadClasses['SRFiCalendar'] = $formatDir . 'iCalendar/SRF_iCalendar.php'; |
65 | | - $wgAutoloadClasses['SRFBibTeX'] = $formatDir . 'BibTeX/SRF_BibTeX.php'; |
66 | | - $wgAutoloadClasses['SRFCalendar'] = $formatDir . 'Calendar/SRF_Calendar.php'; |
67 | | - $wgAutoloadClasses['SRFOutline'] = $formatDir . 'Outline/SRF_Outline.php'; |
68 | | - $wgAutoloadClasses['SRFMath'] = $formatDir . 'Math/SRF_Math.php'; |
69 | | - $wgAutoloadClasses['SRFExhibit'] = $formatDir . 'Exhibit/SRF_Exhibit.php'; |
70 | | - $wgAutoloadClasses['SRFGoogleBar'] = $formatDir . 'GoogleCharts/SRF_GoogleBar.php'; |
71 | | - $wgAutoloadClasses['SRFGooglePie'] = $formatDir . 'GoogleCharts/SRF_GooglePie.php'; |
72 | | - $wgAutoloadClasses['SRFjqPlotPie'] = $formatDir . 'jqPlot/SRF_jqPlotPie.php'; |
73 | | - $wgAutoloadClasses['SRFjqPlotBar'] = $formatDir . 'jqPlot/SRF_jqPlotBar.php'; |
74 | | - $wgAutoloadClasses['SRFGraph'] = $formatDir . 'GraphViz/SRF_Graph.php'; |
75 | | - $wgAutoloadClasses['SRFProcess'] = $formatDir . 'GraphViz/SRF_Process.php'; |
76 | | - $wgAutoloadClasses['SRFPloticusVBar'] = $formatDir . 'Ploticus/SRF_PloticusVBar.php'; |
77 | | - $wgAutoloadClasses['SRFGallery'] = $formatDir . 'Gallery/SRF_Gallery.php'; |
78 | | - |
79 | | - $formatClasses = array( |
80 | | - 'timeline' => 'SRFTimeline', |
81 | | - 'eventline' => 'SRFTimeline', |
82 | | - 'vcard' => 'SRFvCard', |
83 | | - 'icalendar' => 'SRFiCalendar', |
84 | | - 'bibtex' => 'SRFBibTeX', |
85 | | - 'calendar' => 'SRFCalendar', |
86 | | - 'outline' => 'SRFOutline', |
87 | | - 'sum' => 'SRFMath', |
88 | | - 'average' => 'SRFMath', |
89 | | - 'min' => 'SRFMath', |
90 | | - 'max' => 'SRFMath', |
91 | | - 'exhibit' => 'SRFExhibit', |
92 | | - 'googlebar' => 'SRFGoogleBar', |
93 | | - 'googlepie' => 'SRFGooglePie', |
94 | | - 'jqplotpie' => 'SRFjqPlotPie', |
95 | | - 'jqplotbar' => 'SRFjqPlotBar', |
96 | | - 'graph' => 'SRFGraph', |
97 | | - 'process' => 'SRFProcess', |
98 | | - 'ploticusvbar' => 'SRFPloticusVBar', |
99 | | - 'gallery' => 'SRFGallery', |
100 | | - ); |
101 | | - |
102 | | - foreach ( $srfgFormats as $format ) { |
103 | | - if ( array_key_exists( $format, $formatClasses ) ) { |
104 | | - $smwgResultFormats[$format] = $formatClasses[$format]; |
105 | | - } |
106 | | - else { |
107 | | - wfDebug( "There is not result format class associated with the format '$format'." ); |
108 | | - } |
109 | | - } |
110 | | -} |
111 | | - |
112 | | -/** |
113 | | - * Adds a link to Admin Links page. |
114 | | - */ |
115 | | -function srffAddToAdminLinks( &$admin_links_tree ) { |
116 | | - $displaying_data_section = $admin_links_tree->getSection( wfMsg( 'smw_adminlinks_displayingdata' ) ); |
117 | | - |
118 | | - // Escape is SMW hasn't added links. |
119 | | - if ( is_null( $displaying_data_section ) ) { |
120 | | - return true; |
121 | | - } |
122 | | - |
123 | | - $smw_docu_row = $displaying_data_section->getRow( 'smw' ); |
124 | | - wfLoadExtensionMessages( 'SemanticResultFormats' ); |
125 | | - $srf_docu_label = wfMsg( 'adminlinks_documentation', wfMsg( 'srf-name' ) ); |
126 | | - $smw_docu_row->addItem( AlItem::newFromExternalLink( "http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats", $srf_docu_label ) ); |
127 | | - |
128 | | - return true; |
129 | | -} |
\ No newline at end of file |
| 28 | +# Used for jqplot formats. |
| 29 | +$srfgJQPlotIncluded = false; |
\ No newline at end of file |