http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72970
Revision: 72970
Author: jeroendedauw
Date: 2010-09-14 12:50:35 +0000 (Tue, 14 Sep 2010)
Log Message:
-----------
Rewrote query printer registration
Modified Paths:
--------------
trunk/extensions/SemanticResultFormats/SRF_Settings.php
Modified: trunk/extensions/SemanticResultFormats/SRF_Settings.php
===================================================================
--- trunk/extensions/SemanticResultFormats/SRF_Settings.php 2010-09-14
12:50:07 UTC (rev 72969)
+++ trunk/extensions/SemanticResultFormats/SRF_Settings.php 2010-09-14
12:50:35 UTC (rev 72970)
@@ -2,6 +2,7 @@
/**
* Settings file for the Semantic Result Formats extension.
+ * http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats
*
* NOTE: Do not use this file as entry point, use SemanticresultFormats.php
instead.
*
@@ -13,7 +14,7 @@
die( 'Not an entry point.' );
}
-define( 'SRF_VERSION', '1.5.1' );
+define( 'SRF_VERSION', '1.5.2 alpha' );
$srfgScriptPath = $wgScriptPath . '/extensions/SemanticResultFormats'; //
TODO: fix hardcoded path
$srfgIP = dirname( __FILE__ );
@@ -35,7 +36,7 @@
function srffSetup() {
global $srfgFormats, $wgExtensionCredits;
- foreach ( $srfgFormats as $fn ) srffInitFormat( $fn );
+ srffInitFormats();
$wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' :
'other'][] = array(
'path' => __FILE__,
@@ -47,94 +48,81 @@
);
}
-function srffInitFormat( $format ) {
- global $smwgResultFormats, $wgAutoloadClasses, $srfgIP;
-
- $class = '';
- $file = '';
- switch ( $format ) {
- case 'timeline': case 'eventline':
- $class = 'SRFTimeline';
- $file = $srfgIP . '/Timeline/SRF_Timeline.php';
- break;
- case 'vcard':
- $class = 'SRFvCard';
- $file = $srfgIP . '/vCard/SRF_vCard.php';
- break;
- case 'icalendar':
- $class = 'SRFiCalendar';
- $file = $srfgIP . '/iCalendar/SRF_iCalendar.php';
- break;
- case 'bibtex':
- $class = 'SRFBibTeX';
- $file = $srfgIP . '/BibTeX/SRF_BibTeX.php';
- break;
- case 'calendar':
- $class = 'SRFCalendar';
- $file = $srfgIP . '/Calendar/SRF_Calendar.php';
- break;
- case 'outline':
- $class = 'SRFOutline';
- $file = $srfgIP . '/Outline/SRF_Outline.php';
- break;
- case 'sum': case 'average': case 'min': case 'max':
- $class = 'SRFMath';
- $file = $srfgIP . '/Math/SRF_Math.php';
- break;
- case 'exhibit':
- $class = 'SRFExhibit';
- $file = $srfgIP . '/Exhibit/SRF_Exhibit.php';
- break;
- case 'googlebar':
- $class = 'SRFGoogleBar';
- $file = $srfgIP . '/GoogleCharts/SRF_GoogleBar.php';
- break;
- case 'googlepie':
- $class = 'SRFGooglePie';
- $file = $srfgIP . '/GoogleCharts/SRF_GooglePie.php';
- break;
- case 'jqplotpie':
- $class = 'SRFjqPlotPie';
- $file = $srfgIP . '/jqPlot/SRF_jqPlotPie.php';
- break;
- case 'jqplotbar':
- $class = 'SRFjqPlotBar';
- $file = $srfgIP . '/jqPlot/SRF_jqPlotBar.php';
- break;
- case 'graph':
- $class = 'SRFGraph';
- $file = $srfgIP . '/GraphViz/SRF_Graph.php';
- break;
- case 'process':
- $class = 'SRFProcess';
- $file = $srfgIP . '/GraphViz/SRF_Process.php';
- break;
- case 'ploticusvbar':
- $class = 'SRFPloticusVBar';
- $file = $srfgIP . '/Ploticus/SRF_PloticusVBar.php';
- break;
- case 'gallery':
- $class = 'SRFGallery';
- $file = $srfgIP . '/Gallery/SRF_Gallery.php';
- break;
+/**
+ * Autoload the query printer classes and associate them with their formats in
the $smwgResultFormats array.
+ *
+ * @since 1.5.2
+ */
+function srffInitFormats() {
+ global $srfgFormats, $smwgResultFormats, $wgAutoloadClasses;
+
+ $formatDir = dirname( __FILE__ ) . '/';
+
+ $wgAutoloadClasses['SRFTimeline'] = $formatDir .
'Timeline/SRF_Timeline.php';
+ $wgAutoloadClasses['SRFvCard'] = $formatDir . 'vCard/SRF_vCard.php';
+ $wgAutoloadClasses['SRFiCalendar'] = $formatDir .
'iCalendar/SRF_iCalendar.php';
+ $wgAutoloadClasses['SRFBibTeX'] = $formatDir . 'BibTeX/SRF_BibTeX.php';
+ $wgAutoloadClasses['SRFCalendar'] = $formatDir .
'Calendar/SRF_Calendar.php';
+ $wgAutoloadClasses['SRFOutline'] = $formatDir .
'Outline/SRF_Outline.php';
+ $wgAutoloadClasses['SRFMath'] = $formatDir . 'Math/SRF_Math.php';
+ $wgAutoloadClasses['SRFExhibit'] = $formatDir .
'Exhibit/SRF_Exhibit.php';
+ $wgAutoloadClasses['SRFGoogleBar'] = $formatDir .
'GoogleCharts/SRF_GoogleBar.php';
+ $wgAutoloadClasses['SRFGooglePie'] = $formatDir .
'GoogleCharts/SRF_GooglePie.php';
+ $wgAutoloadClasses['SRFjqPlotPie'] = $formatDir .
'jqPlot/SRF_jqPlotPie.php';
+ $wgAutoloadClasses['SRFjqPlotBar'] = $formatDir .
'jqPlot/SRF_jqPlotBar.php';
+ $wgAutoloadClasses['SRFGraph'] = $formatDir . 'GraphViz/SRF_Graph.php';
+ $wgAutoloadClasses['SRFProcess'] = $formatDir .
'GraphViz/SRF_Process.php';
+ $wgAutoloadClasses['SRFPloticusVBar'] = $formatDir .
'Ploticus/SRF_PloticusVBar.php';
+ $wgAutoloadClasses['SRFGallery'] = $formatDir .
'Gallery/SRF_Gallery.php';
+
+ $formatClasses = array(
+ 'timeline' => 'SRFTimeline',
+ 'eventline' => 'SRFTimeline',
+ 'vcard' => 'SRFvCard',
+ 'icalendar' => 'SRFiCalendar',
+ 'bibtex' => 'SRFBibTeX',
+ 'calendar' => 'SRFCalendar',
+ 'outline' => 'SRFOutline',
+ 'sum' => 'SRFMath',
+ 'average' => 'SRFMath',
+ 'min' => 'SRFMath',
+ 'max' => 'SRFMath',
+ 'exhibit' => 'SRFExhibit',
+ 'googlebar' => 'SRFGoogleBar',
+ 'googlepie' => 'SRFGooglePie',
+ 'jqplotpie' => 'SRFjqPlotPie',
+ 'jqplotbar' => 'SRFjqPlotBar',
+ 'graph' => 'SRFGraph',
+ 'process' => 'SRFProcess',
+ 'ploticusvbar' => 'SRFPloticusVBar',
+ 'gallery' => 'SRFGallery',
+ );
+
+ foreach ( $srfgFormats as $format ) {
+ if ( array_key_exists( $format, $formatClasses ) ) {
+ $smwgResultFormats[$format] = $formatClasses[$format];
+ }
+ else {
+ wfDebug( "There is not result format class associated
with the format '$format'." );
+ }
}
- if ( ( $class ) && ( $file ) ) {
- $smwgResultFormats[$format] = $class;
- $wgAutoloadClasses[$class] = $file;
- }
}
/**
- * Adds a link to Admin Links page
+ * Adds a link to Admin Links page.
*/
function srffAddToAdminLinks( &$admin_links_tree ) {
$displaying_data_section = $admin_links_tree->getSection( wfMsg(
'smw_adminlinks_displayingdata' ) );
- // escape is SMW hasn't added links
- if ( is_null( $displaying_data_section ) )
+
+ // Escape is SMW hasn't added links.
+ if ( is_null( $displaying_data_section ) ) {
return true;
+ }
+
$smw_docu_row = $displaying_data_section->getRow( 'smw' );
wfLoadExtensionMessages( 'SemanticResultFormats' );
$srf_docu_label = wfMsg( 'adminlinks_documentation', wfMsg( 'srf-name'
) );
$smw_docu_row->addItem( AlItem::newFromExternalLink(
"http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats",
$srf_docu_label ) );
+
return true;
-}
+}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs