Extension:BlueSpiceSMWConnector

From mediawiki.org
(Redirected from Extension:SMWConnector)
Jump to navigation Jump to search


MediaWiki extensions manual
OOjs UI icon advanced.svg
BlueSpiceSMWConnector
Release status: stable
BlueSpice Logo v2020.png
Description Integrates SemanticMediaWiki into BlueSpice.
Author(s) Hallo Welt! GmbH
Maintainer(s) Hallo Welt! GmbH
Latest version 3.1.8 (2020-07-09)
Compatibility policy LTS release branches
MediaWiki 1.31 (LTS)
License GNU General Public License 3.0 only
Download See BlueSpice on SourceForge
Example en.demo.bluespice.com
  • $bsgUEModulePDFsmwProperties
Translate the BlueSpiceSMWConnector extension if it is available at translatewiki.net
Check usage and version matrix.
Issues Open tasks · Report a bug

SMWConnector is the central interface between BlueSpice and Semantic MediaWiki.

Use BlueSpice VisualEditor in Free Text field[edit]

{{{standard input|free text|class=bsvisualeditor|rows=10}}}

Register custom special property[edit]

To create a special property as provided by Extension:Semantic Extra Special Properties, this connector offer a simple way to do this.

  1. add config definition
  2. define mapping function
  3. define language / i18n message key
  4. activate property in LocalSettings.php
  5. update semantic data tables
  • Add the folowing config to your <Extension.php>:
<?php
$GLOBALS["bssDefinitions"]["_EXTENSION"] = array(
    "id" => "___EXTENSION",
    "type" => 9, //available types can be found in SMWDataItem class Definition or at the bottom of this wiki page
    "show" => false,
    "msgkey" => "prefs-extension",
    "alias" => "prefs-extension",
    "label" => "Property name",
    "mapping" => "ExtensionClass::mappingFunction"
);
  • Define mapping function for title link:
<?php
class ExtensionClass{
    public static function mappingFunction( SMW\SemanticData $aSemanticData, WikiPage $aWikiPage, SMW\DIProperty $aProperty ) {
        $oTitle = $aWikiPage->getTitle();
        $fTitle = $oTitle->getFullText();
        $sTitle = $oTitle->getSubpageText();
        $pTitle = trim(substr( $fTitle, 0, strlen( $fTitle ) - strlen( $sTitle ) ), "/");
        $aSemanticData->addPropertyObjectValue( //this is the only relevant step, data from above is just for example
            $aProperty, SMW\DIWikiPage::newFromTitle( Title::newFromText( $pTitle ) )
        );
    }
}
  • Define mapping function for string:
<?php
class ExtensionClass{
    /**
	 * Callback for BlueSpiceSMWConnector that adds a semantic special property
	 * @param SMW\SemanticData $oSemanticData
	 * @param WikiPage $oWikiPage
	 * @param SMW\DIProperty $oProperty
	 */
	public static function smwDataMapping( SMW\SemanticData $oSemanticData, WikiPage $oWikiPage, SMW\DIProperty $oProperty ) {
		//Prepare your data for selected page...
		//..
		$sData = "Example";
		$oSemanticData->addPropertyObjectValue(
			$oProperty, new SMWDIBlob( $sData )
		);
	}
}
  • Define mapping function for boolean:
<?php
class ExtensionClass{
    public static function mappingFunction( SMW\SemanticData $aSemanticData, WikiPage $aWikiPage, SMW\DIProperty $aProperty ) {
        self::$bCheckboxFound = ( strpos( $oWikiPage->getContent()->getNativeData(), "<bs:checklist" ) === false ) ?
			  false : true;
        $aSemanticData->addPropertyObjectValue( //this is the only relevant step, data from above is just for example
            $oProperty, new SMWDIBoolean( self::$bCheckboxFound )
        );
    }
}
  • Add message key "prefs-extension" in your language files.
  • add "_EXTENSION" to "$GLOBALS[ 'bssSpecialProperties' ]" array definition in LocalSettings.php file:
<?php
$GLOBALS[ 'bssSpecialProperties' ] = array(
	'_EXTENSION', ...
);
  • go to your semantic admin page and update tables

Available SMWDataItem Types (from SMWDataItem)[edit]

    /// Data item ID that can be used to indicate that no data item class is appropriate
	const TYPE_NOTYPE    = 0;
	/// Data item ID for SMWDINumber
	const TYPE_NUMBER    = 1;
	/**
	 * Data item ID for SMWDIString.
	 * @deprecated Will vanish after SMW 1.9; use TYPE_BLOB instead.
	 */
	const TYPE_STRING    = 2;
	/// Data item ID for SMWDIBlob
	const TYPE_BLOB      = 2;
	///  Data item ID for SMWDIBoolean
	const TYPE_BOOLEAN   = 4;
	///  Data item ID for SMWDIUri
	const TYPE_URI       = 5;
	///  Data item ID for SMWDITimePoint
	const TYPE_TIME      = 6;
	///  Data item ID for SMWDIGeoCoord
	const TYPE_GEO       = 7;
	///  Data item ID for SMWDIContainer
	const TYPE_CONTAINER = 8;
	///  Data item ID for SMWDIWikiPage
	const TYPE_WIKIPAGE  = 9;
	///  Data item ID for SMWDIConcept
	const TYPE_CONCEPT   = 10;
	///  Data item ID for SMWDIProperty
	const TYPE_PROPERTY  = 11;
	///  Data item ID for SMWDIError
	const TYPE_ERROR     = 12;

External links[edit]

See also[edit]


Bluespice icon
This extension was originally made for BlueSpice. BlueSpice is a MediaWiki distribution for enterprises and organizations. It enhances MediaWiki, in particular in the areas of quality management, process support, administration, editing and security.

You can download this extension with BlueSpice pro.

BlueSpice: Portal - Website - Demo - Helpdesk - BlueSpice free download - Setup Portal - News - Twitter