SMWpc Documentation API Property

From FollowTheScore
Jump to: navigation, search

SMWpc: API on Property level

The following functions operate on property level. This means that they are applied to MediaWiki pages which describe an SMWpc Property. See also the complete list of SMWpc interfaces.

It is suggested to convert the mentioned properties to SMW built-in properties. Currently the templates do nothing more than just to set the properties (and supplement prefixes like 'Template:'. This may change in future. The principle of assigning properties only via templates is strictly used within SMWpc.


Template:.prop assigned by

States that the property is assigned by the specified template(s).

Syntax: {{.prop assigned by|<template>|...}}

  • expects as parameters the names of templates without the 'Template:' prefix.
  • each of the given templates must be able to assign the current property to the object.

Implementation notes

  • This template assigns the meta property .prop assigned by to the property.


Template:.prop built-in

States that a property is integral part of SMW.

Syntax: {{.prop built-in|<text>}}

  • expects as parameter an arbitrary (short) text which will be displayed.

Implementation notes

  • This template assigns the meta property .prop built-in to a property.

Template:.prop derived from

States that the property is algorithmically derived from another property (of the same class).

Syntax: {{.prop derived from|<property>}}

  • expects as parameter the name of the origin property (without the 'Property:' prefix).

Implementation notes

  • This template assigns the meta property .prop derived from to the property.


Template:.prop describes

States that this property can be used to describe instances of the given class(es).

Syntax: {{.prop describes|<class>|...}}

  • expects as parameters the names of classes without the 'Class' prefix.
  • Inheritance is respected. It is not necessary to repeat the '.prop describes' for derived classes.

Implementation notes

  • This template assigns the meta property .prop describes to the property.


Template:.prop definition

Defines a property and sets its basic attributes.

Syntax: {{.prop definition|[color=<color>]|[icon=<icon>]|doc=<doc>}}

  • color = an optional color (in rrggbb Notation without a leading '#'), defaults to #f7f7f7
  • icon = an optional icon file name (without the Image: prefix)
  • doc = an optional text describing the semantic concept of the class; text must not exceed 255 characters.

This template should only be used within a property definition (like 'Property:Foo').

Implementation notes

  • This template assigns the meta properties .prop color, .prop icon and .prop doc to the property.


Template:.prop mandatory

States that the property must be specified.

Syntax: {{.prop mandatory}}

Issues a warning if the property is never set.

Implementation notes

  • NOT YET IMPLEMENTED, needs hook at the end of document processing. A simple query at the end of a document still delivers the old (former) value of a property. Thus it would still deliver a value if the property assignment was deleted when saving the document. A successive edit would be o.k. unless the property was newly assigned. Then the query would return no value when saving the document.


Template:.prop refers to

States that the property serves as a reference to instances of (another or the same) class.

Syntax: {{.prop refers to|<class>}}

  • expects as parameters the names of classes without the 'Class' prefix.
  • polymorph properties are supported; so you can specify '.prop refers to' more than once for a property.

Implementation notes

  • This template assigns the meta property .prop refers to to the property.


Template:.prop reverse

Specifies an alternate textual representation for the property which is used for the 'opposite direction'

Syntax: {{.prop reverse|<text>}}

  • text must not exceed 255 characters.

Example

  • For a property named 'owns' a reasonable reverse name would be 'is owned by'.

Implementation notes

  • This template assigns the meta property .prop reverse to the property.
  • Currently the reverse property is shown in the model and used in the 'what links here' API (.obj is referenced by')

Template:.prop unique

States that the property must only be assigned once.

Syntax: {{.prop unique}}

Issues a warning if more than one assignment is made.

Implementation notes

  • implementation sets a variable for every property assignment and uses variable names as hash; this is rather inefficient.