r24654 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24653‎ | r24654 | r24655 >
Date:15:10, 7 August 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Prevent unnecessary code inclusions (further updates required)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/ExportRDF/SMW_SpecialExportRDF.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/URIResolver/SMW_SpecialURIResolver.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -8,22 +8,10 @@
99
1010 if (!defined('MEDIAWIKI')) die();
1111
12 -global $IP;
13 -require_once( "$IP/includes/SpecialPage.php" );
14 -global $smwgIP;
15 -require_once( "$smwgIP/includes/SMW_QueryProcessor.php" );
16 -
17 -function doSpecialAsk() {
18 - SMW_AskPage::execute();
19 -}
20 -
21 -SpecialPage::addPage( new SpecialPage('Ask','',true,'doSpecialAsk',false) );
22 -
23 -
2412 class SMW_AskPage {
2513
2614 static function execute() {
27 - global $wgRequest, $wgOut, $smwgQEnabled, $smwgQMaxLimit, $wgUser, $smwgQSortingSupport;
 15+ global $wgRequest, $wgOut, $smwgQEnabled, $smwgQMaxLimit, $wgUser, $smwgQSortingSupport, $smwgIP;
2816
2917 $skin = $wgUser->getSkin();
3018
@@ -56,6 +44,7 @@
5745
5846 // print results if any
5947 if ($smwgQEnabled && ('' != $query) ) {
 48+ include_once( "$smwgIP/includes/SMW_QueryProcessor.php" );
6049 $params = array('offset' => $offset, 'limit' => $limit, 'format' => 'broadtable', 'mainlabel' => ' ', 'link' => 'all', 'default' => wfMsg('smw_result_noresults'), 'sort' => $sort, 'order' => $order);
6150 $queryobj = SMWQueryProcessor::createQuery($query, $params, false);
6251 $res = smwfGetStore()->getQueryResult($queryobj);
Index: trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php
@@ -9,14 +9,7 @@
1010
1111 if (!defined('MEDIAWIKI')) die();
1212
13 -// TODO: should these be messages?
14 -global $wgMessageCache;
15 -$wgMessageCache->addMessages(array('smwadmin' => 'Admin functions for Semantic MediaWiki'));
16 -
17 -SpecialPage::addPage( new SpecialPage('SMWAdmin','delete',true,'doSpecialSMWAdmin',false) );
18 -
19 -
20 -function doSpecialSMWAdmin($par = null) {
 13+function smwfSMWAdmin($par = null) {
2114 global $IP;
2215 require_once($IP . '/includes/SpecialPage.php' );
2316 require_once($IP . '/includes/Title.php' );
Index: trunk/extensions/SemanticMediaWiki/specials/URIResolver/SMW_SpecialURIResolver.php
@@ -9,17 +9,6 @@
1010
1111 if (!defined('MEDIAWIKI')) die();
1212
13 -global $IP;
14 -require_once( "$IP/includes/SpecialPage.php" );
15 -
16 -
17 -function doSpecialURIResolver($name = '') {
18 - SMW_URIResolver::execute($name);
19 -}
20 -
21 -SpecialPage::addPage( new SpecialPage('URIResolver','',false,'doSpecialURIResolver',false) );
22 -
23 -
2413 class SMW_URIResolver {
2514
2615 static function execute($query = '') {
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php
@@ -10,17 +10,9 @@
1111
1212 if (!defined('MEDIAWIKI')) die();
1313
14 -global $IP, $smwgIP;
15 -
16 -require_once( "$IP/includes/SpecialPage.php" );
 14+global $smwgIP;
1715 require_once( "$smwgIP/includes/storage/SMW_Store.php" );
1816
19 -function doSpecialSearchByProperty($query = '') {
20 - SMW_SearchByProperty::execute($query);
21 -}
22 -
23 -SpecialPage::addPage( new SpecialPage('SearchByProperty','',true,'doSpecialSearchByProperty',false) );
24 -
2517 class SMW_SearchByProperty {
2618
2719 static function execute($query = '') {
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -9,16 +9,9 @@
1010
1111 if (!defined('MEDIAWIKI')) die();
1212
13 -global $IP, $smwgIP;
14 -require_once( "$IP/includes/SpecialPage.php" );
 13+global $smwgIP;
1514 require_once( "$smwgIP/includes/storage/SMW_Store.php" );
1615
17 -function doSpecialBrowse($query = '') {
18 - SMW_SpecialBrowse::execute($query);
19 -}
20 -
21 -SpecialPage::addPage( new SpecialPage('Browse','',true,'doSpecialBrowse','default',true) );
22 -
2316 /***
2417 * A class to encapsulate the special page that allows browsing through
2518 * the knowledge structure of a Semantic MediaWiki.
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
@@ -14,15 +14,6 @@
1515 require_once( "$IP/includes/SpecialPage.php" );
1616 require_once( "$smwgIP/includes/storage/SMW_Store.php" );
1717
18 -
19 -function doSpecialPageProperty($query = '') {
20 - SMW_PageProperty::execute($query);
21 -}
22 -
23 -SpecialPage::addPage( new SpecialPage('PageProperty','',FALSE,'doSpecialPageProperty',false) );
24 -
25 -
26 -
2718 class SMW_PageProperty {
2819
2920 static function execute($query = '') {
Index: trunk/extensions/SemanticMediaWiki/specials/ExportRDF/SMW_SpecialExportRDF.php
@@ -10,13 +10,13 @@
1111
1212 if (!defined('MEDIAWIKI')) die();
1313
14 -global $IP;
15 -require_once( "$IP/includes/SpecialPage.php" );
 14+// global $IP;
 15+// require_once( "$IP/includes/SpecialPage.php" );
1616
17 -SpecialPage::addPage( new SpecialPage('ExportRDF','',true,'doSpecialExportRDF',false) );
 17+//SpecialPage::addPage( new SpecialPage('ExportRDF','',true,'doSpecialExportRDF',false) );
1818
1919
20 -function doSpecialExportRDF($page = '') {
 20+function smwfExportRDF($page = '') {
2121 global $wgOut, $wgRequest, $wgUser, $smwgAllowRecursiveExport, $smwgExportBacklinks;
2222
2323 $recursive = 0; //default, no recursion
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -12,29 +12,6 @@
1313
1414
1515 /**
16 - * This hook registers a parser-hook to the current parser.
17 - * Note that parser hooks are something different than MW hooks
18 - * in general, which explains the two-level registration.
19 - */
20 -function smwfRegisterInlineQueries( $semantic, $mediawiki, $rules ) {
21 - global $wgParser;
22 - $wgParser->setHook( 'ask', 'smwfProcessInlineQuery' );
23 - return true; // always return true, in order not to stop MW's hook processing!
24 -}
25 -
26 -/**
27 - * The <ask> parser hook processing part.
28 - */
29 -function smwfProcessInlineQuery($text, $param) {
30 - global $smwgQEnabled;
31 - if ($smwgQEnabled) {
32 - return SMWQueryProcessor::getResultHTML($text,$param);
33 - } else {
34 - return smwfEncodeMessages(array(wfMsgForContent('smw_iq_disabled')));
35 - }
36 -}
37 -
38 -/**
3916 * Static class for accessing functions to generate and execute semantic queries
4017 * and to serialise their results.
4118 */
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -44,7 +44,7 @@
4545 // in the Export since we do not want to create a title object here when
4646 // it is not needed in many cases.
4747 if (!$complete && !($smwgNamespace === '')) $smwgNamespace = ".$smwgNamespace";
48 - $wgExtensionFunctions[] = 'smwgSetupExtension';
 48+ $wgExtensionFunctions[] = 'smwfSetupExtension';
4949 return true;
5050 }
5151
@@ -52,7 +52,8 @@
5353 * Do the actual intialisation of the extension. This is just a delayed init that makes sure
5454 * MediaWiki is set up properly before we add our stuff.
5555 */
56 -function smwgSetupExtension() {
 56+function smwfSetupExtension() {
 57+ wfProfileIn('smwfSetupExtension');
5758 global $smwgVersion, $smwgNamespace, $smwgIP, $smwgStoreActive, $wgHooks, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore, $wgArticlePath, $wgScriptPath, $wgServer;
5859
5960 /**
@@ -73,17 +74,9 @@
7475 smwfInitMessages();
7576
7677 ///// register specials /////
 78+ include_once($smwgIP . '/includes/SMW_SpecialPages.php');
7779
78 - //require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchTriple.php'); // no longer supported
79 - require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByProperty.php');
80 - require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialPageProperty.php');
81 - require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php');
82 -
83 - require_once($smwgIP . '/specials/URIResolver/SMW_SpecialURIResolver.php');
84 - require_once($smwgIP . '/specials/ExportRDF/SMW_SpecialExportRDF.php');
85 - require_once($smwgIP . '/specials/SMWAdmin/SMW_SpecialSMWAdmin.php');
8680 //require_once($smwgIP . '/specials/OntologyImport/SMW_SpecialOntologyImport.php'); // broken, TODO: fix or delete
87 - require_once($smwgIP . '/specials/AskSpecial/SMW_SpecialAsk.php');
8881 require_once($smwgIP . '/specials/ExtendedStatistics/SMW_SpecialExtendedStatistics.php');
8982
9083 require_once($smwgIP . '/specials/Relations/SMW_SpecialRelations.php');
@@ -94,10 +87,8 @@
9588 require_once($smwgIP . '/specials/Relations/SMW_SpecialTypes.php');
9689
9790 ///// register hooks /////
98 -
9991 require_once($smwgIP . '/includes/SMW_Hooks.php');
10092 require_once($smwgIP . '/includes/SMW_RefreshTab.php');
101 - require_once($smwgIP . '/includes/SMW_QueryProcessor.php');
10293
10394 if ($smwgEnableTemplateSupport===true) {
10495 $wgHooks['InternalParseBeforeLinks'][] = 'smwfParserHook'; //patch required;
@@ -115,9 +106,34 @@
116107 ///// credits (see "Special:Version") /////
117108 $wgExtensionCredits['parserhook'][]= array('name'=>'Semantic&nbsp;MediaWiki', 'version'=>SMW_VERSION, 'author'=>"Klaus&nbsp;Lassleben, Markus&nbsp;Kr&ouml;tzsch, Denny&nbsp;Vrandecic, S&nbsp;Page, and others. Maintained by [http://www.aifb.uni-karlsruhe.de/Forschungsgruppen/WBS/english AIFB Karlsruhe].", 'url'=>'http://ontoworld.org/wiki/Semantic_MediaWiki', 'description' => 'Making your wiki more accessible&nbsp;&ndash; for machines \'\'and\'\' humans. [http://ontoworld.org/wiki/Help:Semantics View online documentation.]');
118109
 110+ wfProfileOut('smwfSetupExtension');
119111 return true;
120112 }
121113
 114+/**
 115+ * This hook registers a parser-hook to the current parser.
 116+ * Note that parser hooks are something different than MW hooks
 117+ * in general, which explains the two-level registration.
 118+ */
 119+function smwfRegisterInlineQueries( $semantic, $mediawiki, $rules ) {
 120+ global $wgParser;
 121+ $wgParser->setHook( 'ask', 'smwfProcessInlineQuery' );
 122+ return true; // always return true, in order not to stop MW's hook processing!
 123+}
 124+
 125+/**
 126+ * The <ask> parser hook processing part.
 127+ */
 128+function smwfProcessInlineQuery($text, $param) {
 129+ global $smwgQEnabled, $smwgIP;
 130+ if ($smwgQEnabled) {
 131+ require_once($smwgIP . '/includes/SMW_QueryProcessor.php');
 132+ return SMWQueryProcessor::getResultHTML($text,$param);
 133+ } else {
 134+ return smwfEncodeMessages(array(wfMsgForContent('smw_iq_disabled')));
 135+ }
 136+}
 137+
122138 /**********************************************/
123139 /***** Header modifications *****/
124140 /**********************************************/

Status & tagging log