Extension:BlueSpiceSMWConnector

MediaWiki extensions manual
OOjs UI icon advanced.svg
BlueSpiceSMWConnector
Release status: beta
Latest version 3.3.0-alpha
License GNU General Public License 3.0 only
Download
  • $bsgUEModulePDFsmwProperties
Translate the BlueSpiceSMWConnector extension if it is available at translatewiki.net
Check usage and version matrix.


The BlueSpiceSMWConnector extension improves interaction beween Semantic MediaWiki and BlueSpice by providing a tar package builder and some custom functions.

InstallationEdit

Using ComposerEdit

composer require hallowelt/blue-spice-s-m-w-connector
  • Extension will be included by composer's autoloader.

Download from GitHubEdit

  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/BlueSpiceSMWConnector/BlueSpiceSMWConnector.php";
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Use BlueSpice VisualEditor in Free Text fieldEdit

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

Register custom special propertyEdit

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;