Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php |
— | — | @@ -15,18 +15,23 @@ |
16 | 16 | */ |
17 | 17 | class SMWParserExtensions { |
18 | 18 | |
| 19 | + /// Temporarily store parser that cannot be passed to call-back functions otherwise. |
| 20 | + protected static $mTempParser; |
| 21 | + /// Internal state for switchin off/on SMW link annotations during parsing |
| 22 | + protected static $mTempStoreAnnotations; |
| 23 | + |
19 | 24 | /** |
20 | 25 | * This method will be called before an article is displayed or previewed. |
21 | 26 | * For display and preview we strip out the semantic properties and append them |
22 | 27 | * at the end of the article. |
23 | 28 | */ |
24 | 29 | static public function onInternalParseBeforeLinks(&$parser, &$text) { |
25 | | - global $smwgStoreAnnotations, $smwgTempStoreAnnotations, $smwgLinksInValues, $smwgTempParser; |
| 30 | + global $smwgStoreAnnotations, $smwgLinksInValues; |
26 | 31 | SMWParseData::stripMagicWords($text, $parser); |
27 | 32 | // store the results if enabled (we have to parse them in any case, in order to |
28 | 33 | // clean the wiki source for further processing) |
29 | 34 | $smwgStoreAnnotations = smwfIsSemanticsProcessed($parser->getTitle()->getNamespace()); |
30 | | - $smwgTempStoreAnnotations = true; // used for [[SMW::on]] and [[SMW:off]] |
| 35 | + SMWParserExtensions::$mTempStoreAnnotations = true; // used for [[SMW::on]] and [[SMW:off]] |
31 | 36 | |
32 | 37 | // process redirects, if any |
33 | 38 | // (it seems that there is indeed no more direct way of getting this info from MW) |
— | — | @@ -38,7 +43,7 @@ |
39 | 44 | } |
40 | 45 | } |
41 | 46 | |
42 | | - $smwgTempParser = $parser; // only used in subsequent callbacks, forgotten afterwards |
| 47 | + SMWParserExtensions::$mTempParser = $parser; // only used in subsequent callbacks, forgotten afterwards |
43 | 48 | // In the regexp matches below, leading ':' escapes the markup, as |
44 | 49 | // known for Categories. |
45 | 50 | // Parse links to extract semantic properties |
— | — | @@ -104,7 +109,7 @@ |
105 | 110 | * link. Expected parameter: array(linktext, properties, value, caption) |
106 | 111 | */ |
107 | 112 | static public function parsePropertiesCallback($semanticLink) { |
108 | | - global $smwgInlineErrors, $smwgStoreAnnotations, $smwgTempStoreAnnotations, $smwgTempParser; |
| 113 | + global $smwgInlineErrors, $smwgStoreAnnotations; |
109 | 114 | wfProfileIn("smwfParsePropertiesCallback (SMW)"); |
110 | 115 | if (array_key_exists(1,$semanticLink)) { |
111 | 116 | $property = $semanticLink[1]; |
— | — | @@ -115,8 +120,8 @@ |
116 | 121 | |
117 | 122 | if ($property == 'SMW') { |
118 | 123 | switch ($value) { |
119 | | - case 'on': $smwgTempStoreAnnotations = true; break; |
120 | | - case 'off': $smwgTempStoreAnnotations = false; break; |
| 124 | + case 'on': SMWParserExtensions::$mTempStoreAnnotations = true; break; |
| 125 | + case 'off': SMWParserExtensions::$mTempStoreAnnotations = false; break; |
121 | 126 | } |
122 | 127 | wfProfileOut("smwfParsePropertiesCallback (SMW)"); |
123 | 128 | return ''; |
— | — | @@ -129,10 +134,10 @@ |
130 | 135 | //extract annotations and create tooltip |
131 | 136 | $properties = preg_split('/:[=:]/u', $property); |
132 | 137 | foreach($properties as $singleprop) { |
133 | | - $dv = SMWParseData::addProperty($singleprop,$value,$valueCaption, $smwgTempParser, $smwgStoreAnnotations && $smwgTempStoreAnnotations); |
| 138 | + $dv = SMWParseData::addProperty($singleprop,$value,$valueCaption, SMWParserExtensions::$mTempParser, $smwgStoreAnnotations && SMWParserExtensions::$mTempStoreAnnotations); |
134 | 139 | } |
135 | 140 | $result = $dv->getShortWikitext(true); |
136 | | - if ( ($smwgInlineErrors && $smwgStoreAnnotations && $smwgTempStoreAnnotations) && (!$dv->isValid()) ) { |
| 141 | + if ( ($smwgInlineErrors && $smwgStoreAnnotations && SMWParserExtensions::$mTempStoreAnnotations) && (!$dv->isValid()) ) { |
137 | 142 | $result .= $dv->getErrorText(); |
138 | 143 | } |
139 | 144 | wfProfileOut("smwfParsePropertiesCallback (SMW)"); |