r35799 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35798‎ | r35799 | r35800 >
Date:16:24, 3 June 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
Process categories in ParserAfterTidy, since LinkUpdate is not always used for storing data (e.g. in update
scripts). Add AUTOLOAD for SMWSQLStore2 (but not default yet).
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php
@@ -133,11 +133,6 @@
134134 * Used to updates data after changes of templates, but also at each saving of an article.
135135 */
136136 function smwfLinkUpdateHook($links_update) {
137 - foreach ($links_update->mCategories as $name => $sortkey) {
138 - $dv = SMWDataValueFactory::newSpecialValue(SMW_SP_INSTANCE_OF);
139 - $dv->setValues($name,NS_CATEGORY);
140 - SMWFactbox::$semdata->addSpecialValue(SMW_SP_INSTANCE_OF,$dv);
141 - }
142137 smwfSaveDataForTitle($links_update->mTitle);
143138 return true;
144139 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -3,7 +3,7 @@
44 * Global functions and constants for Semantic MediaWiki.
55 */
66
7 -define('SMW_VERSION','1.2d-SVN');
 7+define('SMW_VERSION','1.2e-SVN');
88
99 // constants for special properties, used for datatype assignment and storage
1010 define('SMW_SP_HAS_TYPE',1);
@@ -101,6 +101,7 @@
102102 $wgAutoloadClasses['SMWExpResource'] = $smwgIP . '/includes/export/SMW_Exp_Element.php';
103103 //// stores
104104 $wgAutoloadClasses['SMWSQLStore'] = $smwgIP . '/includes/storage/SMW_SQLStore.php';
 105+ $wgAutoloadClasses['SMWSQLStore2'] = $smwgIP . '/includes/storage/SMW_SQLStore2.php';
105106 // Do not autoload RAPStore, since some special pages load all autoloaded classes, which causes
106107 // troubles with RAP store if RAP is not installed (require_once fails).
107108 //$wgAutoloadClasses['SMWRAPStore'] = $smwgIP . '/includes/storage/SMW_RAPStore.php';
@@ -182,7 +183,7 @@
183184 $wgHooks['ArticleUndelete'][] = 'smwfUndeleteHook'; // restore annotations
184185 $wgHooks['ArticleDelete'][] = 'smwfDeleteHook'; // delete annotations
185186 $wgHooks['TitleMoveComplete'][]='smwfMoveHook'; // move annotations
186 - $wgHooks['ParserAfterTidy'][] = 'smwfAddHTMLHeadersParser'; // add items to HTML header during parsing
 187+ $wgHooks['ParserAfterTidy'][] = 'smwfParserAfterTidy'; // add items to HTML header during parsing
187188 $wgHooks['BeforePageDisplay'][]='smwfAddHTMLHeadersOutput'; // add items to HTML header during output
188189 $wgHooks['LinksUpdateConstructed'][] = 'smwfLinkUpdateHook'; // update data after template change and at safe
189190
@@ -279,17 +280,27 @@
280281 }
281282
282283 /**
283 - * Hook function to insert HTML headers (CSS, JavaScript, and meta tags) into parser
 284+ * Hook function for two tasks:
 285+ * (1) insert HTML headers (CSS, JavaScript, and meta tags) into parser
284286 * output. This is our preferred method of working off the required scripts, since it
285287 * exploits parser caching.
 288+ * (2) Fetch category information from parser output.
286289 */
287 -function smwfAddHTMLHeadersParser(&$parser, &$text) {
 290+function smwfParserAfterTidy(&$parser, &$text) {
288291 global $smwgHeadItems, $smwgStoreActive;
 292+ // make HTML header
289293 if (!$smwgStoreActive) return true; // avoid doing this in SMW-generated sub-parsers
290294 foreach ($smwgHeadItems as $key => $item) {
291295 $parser->mOutput->addHeadItem("\t\t" . $item . "\n", $key);
292296 }
293297 $smwgHeadItems = array(); // flush array so that smwfAddHTMLHeader does not take needless actions
 298+ // fetch category data
 299+ $categories = $parser->mOutput->getCategoryLinks();
 300+ foreach ($categories as $name) {
 301+ $dv = SMWDataValueFactory::newSpecialValue(SMW_SP_INSTANCE_OF);
 302+ $dv->setValues($name,NS_CATEGORY);
 303+ SMWFactbox::$semdata->addSpecialValue(SMW_SP_INSTANCE_OF,$dv);
 304+ }
294305 return true;
295306 }
296307

Status & tagging log