Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -197,7 +197,7 @@ |
198 | 198 | */ |
199 | 199 | function smwfSetupExtension() { |
200 | 200 | wfProfileIn('smwfSetupExtension (SMW)'); |
201 | | - global $smwgIP, $smwgStoreActive, $wgHooks, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore, $smwgIQRunningNumber, $wgLanguageCode; |
| 201 | + global $smwgIP, $smwgStoreActive, $wgHooks, $wgParser, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore, $smwgIQRunningNumber, $wgLanguageCode; |
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Setting this to false prevents any new data from being stored in |
— | — | @@ -215,8 +215,9 @@ |
216 | 216 | |
217 | 217 | $smwgMasterStore = NULL; |
218 | 218 | smwfInitContentLanguage($wgLanguageCode); // this really could not be done in enableSemantics() |
219 | | - wfLoadExtensionMessages('SemanticMediaWiki'); /// FIXME: this is extremely slow; up to 10% of page display time (on a page with queries!) are consumed by loading unnecessary messages from a large file ... |
| 219 | + wfLoadExtensionMessages('SemanticMediaWiki'); /// TODO: this is extremely slow; up to 10% of page display time (on a page with queries!) are consumed by loading unnecessary messages from a large file ... |
220 | 220 | /// Past SMW releases had an average of about 1% extension loading time per call, while we are now up at 10%! |
| 221 | + /// (if no PHP caching is enabled, things become better with ACP but impact still is noticeable) |
221 | 222 | /// Should we return to our earlier message management for releases? |
222 | 223 | $smwgIQRunningNumber = 0; |
223 | 224 | |
— | — | @@ -225,7 +226,6 @@ |
226 | 227 | require_once($smwgIP . '/includes/SMW_RefreshTab.php'); |
227 | 228 | |
228 | 229 | $wgHooks['InternalParseBeforeLinks'][] = 'smwfParserHook'; // parse annotations |
229 | | - $wgHooks['ParserBeforeStrip'][] = 'smwfRegisterInlineQueries'; // register the <ask> parser hook |
230 | 230 | $wgHooks['ArticleSave'][] = 'smwfPreSaveHook'; // check some settings here |
231 | 231 | $wgHooks['ArticleUndelete'][] = 'smwfUndeleteHook'; // restore annotations |
232 | 232 | $wgHooks['ArticleDelete'][] = 'smwfDeleteHook'; // delete annotations |
— | — | @@ -237,6 +237,15 @@ |
238 | 238 | |
239 | 239 | $wgHooks['ArticleFromTitle'][] = 'smwfShowListPage'; // special implementations for property/type articles |
240 | 240 | |
| 241 | + if( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
| 242 | + $wgHooks['ParserFirstCallInit'][] = 'smwfRegisterParserFunctions'; |
| 243 | + } else { |
| 244 | + if ( class_exists( 'StubObject' ) && !StubObject::isRealObject( $wgParser ) ) { |
| 245 | + $wgParser->_unstub(); |
| 246 | + } |
| 247 | + smwfRegisterParserFunctions( $wgParser ); |
| 248 | + } |
| 249 | + |
241 | 250 | ///// credits (see "Special:Version") ///// |
242 | 251 | $wgExtensionCredits['parserhook'][]= array('name'=>'Semantic MediaWiki', 'version'=>SMW_VERSION, 'author'=>"Klaus Lassleben, [http://korrekt.org Markus Krötzsch], [http://simia.net Denny Vrandecic], S Page, and others. Maintained by [http://www.aifb.uni-karlsruhe.de/Forschungsgruppen/WBS/english AIFB Karlsruhe].", 'url'=>'http://semantic-mediawiki.org', 'description' => 'Making your wiki more accessible – for machines \'\'and\'\' humans. [http://semantic-mediawiki.org/wiki/Help:User_manual View online documentation.]'); |
243 | 252 | |
— | — | @@ -245,21 +254,16 @@ |
246 | 255 | } |
247 | 256 | |
248 | 257 | /** |
249 | | - * This hook registers a parser-hook to the current parser. |
| 258 | + * This hook registers parser functions and hooks to the given parser. |
250 | 259 | * Note that parser hooks are something different than MW hooks |
251 | 260 | * in general, which explains the two-level registration. |
252 | 261 | */ |
253 | | -function smwfRegisterInlineQueries( &$parser, &$text, &$stripstate ) { |
254 | | - SMWFactbox::initStorage($parser->getTitle()); |
255 | | - |
256 | | - $oldhook = $parser->setFunctionHook( 'ask', 'smwfProcessInlineQueryParserFunction' ); |
257 | | - if ($oldhook != 'smwfProcessInlineQueryParserFunction') { |
258 | | - $parser->setHook( 'ask', 'smwfProcessInlineQuery' ); |
259 | | - $parser->setFunctionHook( 'ask', 'smwfProcessInlineQueryParserFunction' ); |
260 | | - $parser->setFunctionHook( 'show', 'smwfProcessShowParserFunction' ); |
261 | | - $parser->setFunctionHook( 'info', 'smwfProcessInfoParserFunction' ); |
262 | | - $parser->setFunctionHook( 'concept', 'smwfProcessConceptParserFunction' ); |
263 | | - } |
| 262 | +function smwfRegisterParserFunctions( &$parser) { |
| 263 | + $parser->setHook( 'ask', 'smwfProcessInlineQuery' ); |
| 264 | + $parser->setFunctionHook( 'ask', 'smwfProcessInlineQueryParserFunction' ); |
| 265 | + $parser->setFunctionHook( 'show', 'smwfProcessShowParserFunction' ); |
| 266 | + $parser->setFunctionHook( 'info', 'smwfProcessInfoParserFunction' ); |
| 267 | + $parser->setFunctionHook( 'concept', 'smwfProcessConceptParserFunction' ); |
264 | 268 | return true; // always return true, in order not to stop MW's hook processing! |
265 | 269 | } |
266 | 270 | |
— | — | @@ -314,6 +318,7 @@ |
315 | 319 | // The global $smwgConceptText is used to pass information to the MW hooks for storing it, |
316 | 320 | // $smwgPreviousConcept is used to detect if we already have a concept defined for this page. |
317 | 321 | $title = $parser->getTitle(); |
| 322 | + SMWFactbox::initStorage($title); // make sure we have the right title |
318 | 323 | if ($title->getNamespace() != SMW_NS_CONCEPT) { |
319 | 324 | return smwfEncodeMessages(array(wfMsgForContent('smw_no_concept_namespace'))); |
320 | 325 | } elseif (isset($smwgPreviousConcept) && ($smwgPreviousConcept == $title->getText())) { |
Index: trunk/extensions/SemanticMediaWiki/README |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | |
47 | 47 | * Code has been contributed by (in no particular order) Kai Hüner, Fernando Correia, |
48 | 48 | Yaron Koren, Nick Grandy, Jörg Heizmann, Daniel Herzig, Nikolas Iwan, Tobias Matzner, |
49 | | - Thomas Bleher, Felix Kratzer, Frank Dengler, Nathan R. Yergler. |
| 49 | + Thomas Bleher, Felix Kratzer, Frank Dengler, Nathan R. Yergler, Daniel Friesen. |
50 | 50 | |
51 | 51 | * The new logo and related artwork for Semantic MediaWiki (see semanticweb.org) |
52 | 52 | has been designed and realised by Rozana Vrandecic. |