http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72973

Revision: 72973
Author:   jeroendedauw
Date:     2010-09-14 13:16:33 +0000 (Tue, 14 Sep 2010)

Log Message:
-----------
Moved code over from the settings file to the entry point file and did some 
clean up

Modified Paths:
--------------
    trunk/extensions/SemanticResultFormats/SRF_Settings.php
    trunk/extensions/SemanticResultFormats/SemanticResultFormats.php

Modified: trunk/extensions/SemanticResultFormats/SRF_Settings.php
===================================================================
--- trunk/extensions/SemanticResultFormats/SRF_Settings.php     2010-09-14 
13:08:14 UTC (rev 72972)
+++ trunk/extensions/SemanticResultFormats/SRF_Settings.php     2010-09-14 
13:16:33 UTC (rev 72973)
@@ -6,123 +6,23 @@
  * 
  * NOTE: Do not use this file as entry point, use SemanticresultFormats.php 
instead.
  *
- * @file
+ * @file SRF_Settings.php
  * @ingroup SemanticResultFormats
+ * 
+ * @author Jeroen De Dauw
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        die( 'Not an entry point.' );
 }
 
-define( 'SRF_VERSION', '1.5.2 alpha' );
+if ( !defined( 'SRF_VERSION' ) ) {
+       require_once dirname( __FILE__ ) . '/SemanticresultFormats.php';
+}
 
-$srfgScriptPath = $wgScriptPath . '/extensions/SemanticResultFormats'; // 
TODO: fix hardcoded path
-$srfgIP = dirname( __FILE__ );
-$wgExtensionMessagesFiles['SemanticResultFormats'] = $srfgIP . 
'/SRF_Messages.php';
-$wgExtensionFunctions[] = 'srffSetup';
-
-$wgAutoloadClasses['SRFParserFunctions'] = $srfgIP . 
'/SRF_ParserFunctions.php';
-
-// used for jqplot formats
-$srfgJQPlotIncluded = false;
-
-// FIXME: Can be removed when new style magic words are used (introduced in 
r52503)
-$wgHooks['LanguageGetMagic'][] = 'SRFParserFunctions::languageGetMagic';
-$wgHooks['AdminLinks'][] = 'srffAddToAdminLinks';
-$wgHooks['ParserFirstCallInit'][] = 'SRFParserFunctions::registerFunctions';
-
+# The formats you want to be able to use.
+# See the INSTALL file or this url for more info: 
http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats#Installation
 $srfgFormats = array( 'icalendar', 'vcard', 'bibtex', 'calendar', 'eventline', 
'timeline', 'outline', 'gallery', 'jqplotbar', 'jqplotpie', 'sum', 'average', 
'min', 'max' );
 
-function srffSetup() {
-       global $srfgFormats, $wgExtensionCredits;
-
-       srffInitFormats();
-
-       $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 
'other'][] = array(
-               'path' => __FILE__,
-               'name' => 'Semantic Result Formats',
-               'version' => SRF_VERSION,
-               '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' ),
-               'url' => 
'http://semantic-mediawiki.org/wiki/Help:Semantic_Result_Formats',
-               'descriptionmsg' => 'srf-desc'
-       );
-}
-
-/**
- * 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'." );
-               }
-       }
-}
-
-/**
- * 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 ) ) {
-               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
+# Used for jqplot formats.
+$srfgJQPlotIncluded = false;
\ No newline at end of file

Modified: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
===================================================================
--- trunk/extensions/SemanticResultFormats/SemanticResultFormats.php    
2010-09-14 13:08:14 UTC (rev 72972)
+++ trunk/extensions/SemanticResultFormats/SemanticResultFormats.php    
2010-09-14 13:16:33 UTC (rev 72973)
@@ -2,6 +2,12 @@
 
 /**
  * Main entry point for the SemanticResultFormats extension.
+ * http://www.mediawiki.org/wiki/Extension:Semantic_Result_Formats
+ * 
+ * @file SemanticresultFormats.php
+ * @ingroup SemanticResultFormats
+ * 
+ * @author Jeroen De Dauw
  */
 
 /**
@@ -10,4 +16,127 @@
  * @defgroup SemanticResultFormats SemanticResultFormats
  */
 
-require_once dirname( __FILE__ ) . '/SRF_Settings.php';
\ No newline at end of file
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die( 'Not an entry point.' );
+}
+
+define( 'SRF_VERSION', '1.5.2 alpha' );
+
+// Require the settings file.
+require dirname( __FILE__ ) . '/SRF_Settings.php';
+
+srffInitFormats();
+
+$wgExtensionMessagesFiles['SemanticResultFormats'] = dirname( __FILE__ ) . 
'/SRF_Messages.php';
+
+// FIXME: hardcoded path
+$srfgScriptPath = $wgScriptPath . '/extensions/SemanticResultFormats';
+$srfgIP = dirname( __FILE__ );
+
+$wgHooks['AdminLinks'][] = 'srffAddToAdminLinks';
+$wgHooks['ParserFirstCallInit'][] = 'SRFParserFunctions::registerFunctions';
+
+$wgAutoloadClasses['SRFParserFunctions'] = $srfgIP . 
'/SRF_ParserFunctions.php';
+// FIXME: Can be removed when new style magic words are used (introduced in 
r52503)
+$wgHooks['LanguageGetMagic'][] = 'SRFParserFunctions::languageGetMagic';
+
+$wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 
'other'][] = array(
+       'path' => __FILE__,
+       'name' => 'Semantic Result Formats',
+       'version' => SRF_VERSION,
+       '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'
+       ),
+       'url' => 
'http://semantic-mediawiki.org/wiki/Help:Semantic_Result_Formats',
+       'descriptionmsg' => 'srf-desc'
+);
+
+/**
+ * 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'." );
+               }
+       }
+}
+
+/**
+ * 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 ) ) {
+               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

Reply via email to