BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
Register new datatype

This example shows how to register a new dataType/dataValue in Semantic MediaWiki.

Type registration

All IDs must start with an underscore, two underscores indicate a truly internal (non user-interacted type), three underscores should be used by an extension.

TypeList::getList expects that the following information are provided:

  • A type id (e.g. FooValue::TYPE_ID)
  • An associated class
  • An item type (storage type)
  • A declaration whether it is a subData type (e.g subobject) or not
return array(
    // ...
    FooValue::TYPE_ID => array( FooValue::class, DataItem::TYPE_WIKIPAGE, true ),
);
class FooValue extends DataValue {
    /**
     * DV identifier
    const TYPE_ID = '_foo';
    /**
     * 

See Also
DataValue::parseUserValue * *
Parameters
string$valueprotected function parseUserValue( $userValue ) { ... }

}

Label registration

By default, DataTypes (Date, URL etc.) are registered with a corresponding property of the same name to match the expected semantics. For an exemption, see smwgDataTypePropertyExemptionList.

i18n/extra/en.json to extend the canonical description (which is English)

    "dataTypeLabels":{
        "_foo": "SomeType"
        ...
    },
    "dataTypeAliases":{
        "SomeType": "_foo"
        "ExtraAlias": "_foo"
        ...
    },