r41508 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41507‎ | r41508 | r41509 >
Date:17:45, 1 October 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
change globals to protected static class members
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php
@@ -15,18 +15,23 @@
1616 */
1717 class SMWParserExtensions {
1818
 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+
1924 /**
2025 * This method will be called before an article is displayed or previewed.
2126 * For display and preview we strip out the semantic properties and append them
2227 * at the end of the article.
2328 */
2429 static public function onInternalParseBeforeLinks(&$parser, &$text) {
25 - global $smwgStoreAnnotations, $smwgTempStoreAnnotations, $smwgLinksInValues, $smwgTempParser;
 30+ global $smwgStoreAnnotations, $smwgLinksInValues;
2631 SMWParseData::stripMagicWords($text, $parser);
2732 // store the results if enabled (we have to parse them in any case, in order to
2833 // clean the wiki source for further processing)
2934 $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]]
3136
3237 // process redirects, if any
3338 // (it seems that there is indeed no more direct way of getting this info from MW)
@@ -38,7 +43,7 @@
3944 }
4045 }
4146
42 - $smwgTempParser = $parser; // only used in subsequent callbacks, forgotten afterwards
 47+ SMWParserExtensions::$mTempParser = $parser; // only used in subsequent callbacks, forgotten afterwards
4348 // In the regexp matches below, leading ':' escapes the markup, as
4449 // known for Categories.
4550 // Parse links to extract semantic properties
@@ -104,7 +109,7 @@
105110 * link. Expected parameter: array(linktext, properties, value, caption)
106111 */
107112 static public function parsePropertiesCallback($semanticLink) {
108 - global $smwgInlineErrors, $smwgStoreAnnotations, $smwgTempStoreAnnotations, $smwgTempParser;
 113+ global $smwgInlineErrors, $smwgStoreAnnotations;
109114 wfProfileIn("smwfParsePropertiesCallback (SMW)");
110115 if (array_key_exists(1,$semanticLink)) {
111116 $property = $semanticLink[1];
@@ -115,8 +120,8 @@
116121
117122 if ($property == 'SMW') {
118123 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;
121126 }
122127 wfProfileOut("smwfParsePropertiesCallback (SMW)");
123128 return '';
@@ -129,10 +134,10 @@
130135 //extract annotations and create tooltip
131136 $properties = preg_split('/:[=:]/u', $property);
132137 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);
134139 }
135140 $result = $dv->getShortWikitext(true);
136 - if ( ($smwgInlineErrors && $smwgStoreAnnotations && $smwgTempStoreAnnotations) && (!$dv->isValid()) ) {
 141+ if ( ($smwgInlineErrors && $smwgStoreAnnotations && SMWParserExtensions::$mTempStoreAnnotations) && (!$dv->isValid()) ) {
137142 $result .= $dv->getErrorText();
138143 }
139144 wfProfileOut("smwfParsePropertiesCallback (SMW)");

Status & tagging log