/** * This callback function strips out the semantic attributes from a wiki * link. Expected parameter: array(linktext, properties, value, caption) */ static public function parsePropertiesCallback( $semanticLink ) { global $smwgInlineErrors, $smwgStoreAnnotations; wfProfileIn( 'smwfParsePropertiesCallback (SMW)' ); if ( array_key_exists( 1, $semanticLink ) ) { $property = $semanticLink[1]; } else { $property = ''; } if ( array_key_exists( 2, $semanticLink ) ) { $value = $semanticLink[2]; } else { $value = ''; } if ( $value === '' ) { // silently ignore empty values wfProfileOut( 'smwfParsePropertiesCallback (SMW)' ); return ''; } if ( $property == 'SMW' ) { switch ( $value ) { case 'on': SMWParserExtensions::$mTempStoreAnnotations = true; break; case 'off': SMWParserExtensions::$mTempStoreAnnotations = false; break; } wfProfileOut( 'smwfParsePropertiesCallback (SMW)' ); return ''; } if ( array_key_exists( 3, $semanticLink ) ) { $valueCaption = $semanticLink[3]; } else { $valueCaption = false; } // Extract annotations and create tooltip. $properties = preg_split( '/:[=:]/u', $property ); foreach ( $properties as $singleprop ) { $dv = SMWParseData::addProperty( $singleprop, $value, $valueCaption, SMWParserExtensions::$mTempParser, $smwgStoreAnnotations && SMWParserExtensions::$mTempStoreAnnotations ); } $result = $dv->getShortWikitext( true ); if ( ( $smwgInlineErrors && $smwgStoreAnnotations && SMWParserExtensions::$mTempStoreAnnotations ) && ( !$dv->isValid() ) ) { $result .= $dv->getErrorText(); } wfProfileOut( 'smwfParsePropertiesCallback (SMW)' ); return $result; }