Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php |
— | — | @@ -133,11 +133,6 @@ |
134 | 134 | * Used to updates data after changes of templates, but also at each saving of an article. |
135 | 135 | */ |
136 | 136 | 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 | | - } |
142 | 137 | smwfSaveDataForTitle($links_update->mTitle); |
143 | 138 | return true; |
144 | 139 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * Global functions and constants for Semantic MediaWiki. |
5 | 5 | */ |
6 | 6 | |
7 | | -define('SMW_VERSION','1.2d-SVN'); |
| 7 | +define('SMW_VERSION','1.2e-SVN'); |
8 | 8 | |
9 | 9 | // constants for special properties, used for datatype assignment and storage |
10 | 10 | define('SMW_SP_HAS_TYPE',1); |
— | — | @@ -101,6 +101,7 @@ |
102 | 102 | $wgAutoloadClasses['SMWExpResource'] = $smwgIP . '/includes/export/SMW_Exp_Element.php'; |
103 | 103 | //// stores |
104 | 104 | $wgAutoloadClasses['SMWSQLStore'] = $smwgIP . '/includes/storage/SMW_SQLStore.php'; |
| 105 | + $wgAutoloadClasses['SMWSQLStore2'] = $smwgIP . '/includes/storage/SMW_SQLStore2.php'; |
105 | 106 | // Do not autoload RAPStore, since some special pages load all autoloaded classes, which causes |
106 | 107 | // troubles with RAP store if RAP is not installed (require_once fails). |
107 | 108 | //$wgAutoloadClasses['SMWRAPStore'] = $smwgIP . '/includes/storage/SMW_RAPStore.php'; |
— | — | @@ -182,7 +183,7 @@ |
183 | 184 | $wgHooks['ArticleUndelete'][] = 'smwfUndeleteHook'; // restore annotations |
184 | 185 | $wgHooks['ArticleDelete'][] = 'smwfDeleteHook'; // delete annotations |
185 | 186 | $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 |
187 | 188 | $wgHooks['BeforePageDisplay'][]='smwfAddHTMLHeadersOutput'; // add items to HTML header during output |
188 | 189 | $wgHooks['LinksUpdateConstructed'][] = 'smwfLinkUpdateHook'; // update data after template change and at safe |
189 | 190 | |
— | — | @@ -279,17 +280,27 @@ |
280 | 281 | } |
281 | 282 | |
282 | 283 | /** |
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 |
284 | 286 | * output. This is our preferred method of working off the required scripts, since it |
285 | 287 | * exploits parser caching. |
| 288 | + * (2) Fetch category information from parser output. |
286 | 289 | */ |
287 | | -function smwfAddHTMLHeadersParser(&$parser, &$text) { |
| 290 | +function smwfParserAfterTidy(&$parser, &$text) { |
288 | 291 | global $smwgHeadItems, $smwgStoreActive; |
| 292 | + // make HTML header |
289 | 293 | if (!$smwgStoreActive) return true; // avoid doing this in SMW-generated sub-parsers |
290 | 294 | foreach ($smwgHeadItems as $key => $item) { |
291 | 295 | $parser->mOutput->addHeadItem("\t\t" . $item . "\n", $key); |
292 | 296 | } |
293 | 297 | $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 | + } |
294 | 305 | return true; |
295 | 306 | } |
296 | 307 | |