r26381 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26380‎ | r26381 | r26382 >
Date:18:17, 3 October 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Moved special page registration to include-time, since other extensions can otherwise thwart it by calling
SpecialPage::addPage() in an extension function before we did our registrations for $wgSpecialPages.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -44,7 +44,7 @@
4545 * does not adhere to the naming conventions.
4646 */
4747 function enableSemantics($namespace = '', $complete = false) {
48 - global $smwgNamespace, $wgExtensionFunctions;
 48+ global $smwgNamespace, $wgExtensionFunctions, $wgSpecialPages, $wgAutoloadClasses, $smwgIP;
4949 // The dot tells that the domain is not complete. It will be completed
5050 // in the Export since we do not want to create a title object here when
5151 // it is not needed in many cases.
@@ -54,34 +54,7 @@
5555 $smwgNamespace = $namespace;
5656 }
5757 $wgExtensionFunctions[] = 'smwfSetupExtension';
58 - return true;
59 -}
6058
61 -/**
62 - * Do the actual intialisation of the extension. This is just a delayed init that makes sure
63 - * MediaWiki is set up properly before we add our stuff.
64 - */
65 -function smwfSetupExtension() {
66 - wfProfileIn('smwfSetupExtension (SMW)');
67 - global $smwgIP, $smwgStoreActive, $wgHooks, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore, $wgSpecialPages, $wgAutoloadClasses;
68 -
69 - /**
70 - * Setting this to false prevents any new data from being stored in
71 - * the static SMWSemanticData store, and disables printing of the
72 - * factbox, and clearing of the existing data.
73 - * This is a hack to enable parsing of included articles in a save
74 - * way without importing their annotations. Unfortunately, there
75 - * appears to be no way for finding out whether the current parse
76 - * is the "main" parse, or whether some intro, docu, or whatever
77 - * text is parsed. Using the hook mechanism, we have to rely on
78 - * globals/static fields -- so we cannot somehow differentiate this
79 - * store between parsers.
80 - */
81 - $smwgStoreActive = true;
82 -
83 - $smwgMasterStore = NULL;
84 - smwfInitContentMessages();
85 -
8659 ///// setup some autoloading /////
8760 $wgAutoloadClasses['SMWResultPrinter'] = $smwgIP . '/includes/SMW_QueryPrinter.php';
8861 $wgAutoloadClasses['SMWTableResultPrinter'] = $smwgIP . '/includes/SMW_QP_Table.php';
@@ -90,7 +63,7 @@
9164 $wgAutoloadClasses['SMWEmbeddedResultPrinter'] = $smwgIP . '/includes/SMW_QP_Embedded.php';
9265 $wgAutoloadClasses['SMWTemplateResultPrinter'] = $smwgIP . '/includes/SMW_QP_Template.php';
9366
94 - ///// register specials /////
 67+ ///// register specials, do that early on in case some other extension calls "addPage" /////
9568 $wgAutoloadClasses['SMWAskPage'] = $smwgIP . '/specials/AskSpecial/SMW_SpecialAsk.php';
9669 $wgSpecialPages['Ask'] = array('SMWAskPage');
9770 $wgAutoloadClasses['SMWSpecialBrowse'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php';
@@ -112,8 +85,34 @@
11386 $wgSpecialPages['SemanticStatistics'] = array('SMWSpecialPage','SemanticStatistics', 'smwfExecuteSemanticStatistics', $smwgIP . '/specials/Statistics/SMW_SpecialStatistics.php');
11487 $wgSpecialPages['Types'] = array('SMWSpecialPage','Types', 'smwfDoSpecialTypes', $smwgIP . '/specials/QueryPages/SMW_SpecialTypes.php');
11588
116 - //require_once($smwgIP . '/specials/OntologyImport/SMW_SpecialOntologyImport.php'); // broken, TODO: fix or delete
 89+ return true;
 90+}
11791
 92+/**
 93+ * Do the actual intialisation of the extension. This is just a delayed init that makes sure
 94+ * MediaWiki is set up properly before we add our stuff.
 95+ */
 96+function smwfSetupExtension() {
 97+ wfProfileIn('smwfSetupExtension (SMW)');
 98+ global $smwgIP, $smwgStoreActive, $wgHooks, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore;
 99+
 100+ /**
 101+ * Setting this to false prevents any new data from being stored in
 102+ * the static SMWSemanticData store, and disables printing of the
 103+ * factbox, and clearing of the existing data.
 104+ * This is a hack to enable parsing of included articles in a save
 105+ * way without importing their annotations. Unfortunately, there
 106+ * appears to be no way for finding out whether the current parse
 107+ * is the "main" parse, or whether some intro, docu, or whatever
 108+ * text is parsed. Using the hook mechanism, we have to rely on
 109+ * globals/static fields -- so we cannot somehow differentiate this
 110+ * store between parsers.
 111+ */
 112+ $smwgStoreActive = true;
 113+
 114+ $smwgMasterStore = NULL;
 115+ smwfInitContentMessages(); // this really could not be done in enableSemantics()
 116+
118117 ///// register hooks /////
119118 require_once($smwgIP . '/includes/SMW_Hooks.php');
120119 require_once($smwgIP . '/includes/SMW_RefreshTab.php');

Status & tagging log