Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | |
11 | 11 | if ( !defined( 'MEDIAWIKI' ) ) die(); |
12 | 12 | |
13 | | -define('SF_VERSION','1.3'); |
| 13 | +define('SF_VERSION','1.3.1'); |
14 | 14 | |
15 | 15 | $wgExtensionCredits['specialpage'][]= array( |
16 | 16 | 'name' => 'Semantic Forms', |
— | — | @@ -27,7 +27,10 @@ |
28 | 28 | $wgExtensionFunctions[] = 'sfgParserFunctions'; |
29 | 29 | |
30 | 30 | $wgHooks['LanguageGetMagic'][] = 'sffLanguageGetMagic'; |
31 | | -$wgHooks['BrokenLink'][] = 'sffSetBrokenLink'; |
| 31 | +// the 'BrokenLink' hook exists only in MediaWiki v1.13 - it was replaced |
| 32 | +// by 'LinkBegin' and 'LinkEnd' |
| 33 | +$wgHooks['BrokenLink'][] = 'sffSetBrokenLink_1_13'; |
| 34 | +$wgHooks['LinkEnd'][] = 'sffSetBrokenLink'; |
32 | 35 | $wgHooks['UnknownAction'][] = 'sffEmbeddedEditForm'; |
33 | 36 | |
34 | 37 | $wgAPIModules['sfautocomplete'] = 'SFAutocompleteAPI'; |
— | — | @@ -335,7 +338,7 @@ |
336 | 339 | $form_names = array(); |
337 | 340 | foreach ($prop_vals as $prop_val) { |
338 | 341 | // make sure it's in the form namespace |
339 | | - if (($res[0] instanceof SMWWikiPageValue || $res[0] instanceof Title) && |
| 342 | + if (($prop_val instanceof SMWWikiPageValue || $prop_val instanceof Title) && |
340 | 343 | $prop_val->getNamespace() == SF_NS_FORM) { |
341 | 344 | $form_names[] = str_replace(' ', '_', $prop_val->getTitle()->getText()); |
342 | 345 | } |
— | — | @@ -345,7 +348,7 @@ |
346 | 349 | $property = Title::newFromText("Has_alternate_form", SMW_NS_PROPERTY); |
347 | 350 | $prop_vals = $store->getPropertyValues($title, $property); |
348 | 351 | foreach ($prop_vals as $prop_val) { |
349 | | - if (($res[0] instanceof SMWWikiPageValue || $res[0] instanceof Title) |
| 352 | + if (($prop_val instanceof SMWWikiPageValue || $prop_val instanceof Title) |
350 | 353 | && $prop_val->getNamespace() == SF_NS_FORM) { |
351 | 354 | $form_names[] = str_replace(' ', '_', $prop_val->getTitle()->getText()); |
352 | 355 | } |
— | — | @@ -381,13 +384,27 @@ |
382 | 385 | * Sets the URL for form-based adding of a nonexistent (broken-linked, AKA |
383 | 386 | * red-linked) page |
384 | 387 | */ |
385 | | -function sffSetBrokenLink(&$linker, $title, $query, &$u, &$style, &$prefix, &$text, &$inside, &$trail) { |
| 388 | +function sffSetBrokenLink_1_13(&$linker, $title, $query, &$u, &$style, &$prefix, &$text, &$inside, &$trail) { |
386 | 389 | $link = sffAddDataLink($title); |
387 | 390 | if ($link != '') |
388 | 391 | $u = $link; |
389 | 392 | return true; |
390 | 393 | } |
391 | 394 | |
| 395 | +/** |
| 396 | + * Sets the URL for form-based adding of a nonexistent (broken-linked, AKA |
| 397 | + * red-linked) page |
| 398 | + */ |
| 399 | +function sffSetBrokenLink($linker, $target, $options, $text, &$attribs, &$ret) { |
| 400 | + if (in_array('broken', $options)) { |
| 401 | + $link = sffAddDataLink($target); |
| 402 | + if ($link != '') { |
| 403 | + $attribs['href'] = $link; |
| 404 | + } |
| 405 | + } |
| 406 | + return true; |
| 407 | +} |
| 408 | + |
392 | 409 | function sffAddDataLink($title) { |
393 | 410 | // get all properties pointing to this page, and if |
394 | 411 | // sffGetAddDataLinkForPage() returns a value with any of |