Semantic MediaWiki and related extensions
Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
SMW\SemanticData Class Reference
Inheritance diagram for SMW\SemanticData:
Inheritance graph
[legend]

Public Member Functions

 __construct (DIWikiPage $subject, $noDuplicates=true)
 
 __sleep ()
 
 getSubject ()
 
 getProperties ()
 
 hasProperty (DIProperty $property)
 
 getPropertyValues (DIProperty $property)
 
 setExtensionData ( $key, $value)
 
 getExtensionData ( $key)
 
 getOption ( $key, $default=null)
 
 setOption ( $key, $value)
 
 getErrors ()
 
 addError ( $error)
 
 getHash ()
 
 getSubSemanticData ()
 
 clearSubSemanticData ()
 
 hasVisibleProperties ()
 
 hasVisibleSpecialProperties ()
 
 addPropertyObjectValue (DIProperty $property, SMWDataItem $dataItem)
 
 addPropertyValue ( $propertyName, SMWDataItem $dataItem)
 
 addDataValue (SMWDataValue $dataValue)
 
 addSubobject (Subobject $subobject)
 
 removePropertyObjectValue (DIProperty $property, SMWDataItem $dataItem)
 
 removeProperty (DIProperty $property)
 
 clear ()
 
 isEmpty ()
 
 importDataFrom (SemanticData $semanticData)
 
 removeDataFrom (SemanticData $semanticData)
 
 hasSubSemanticData ( $subobjectName=null)
 
 findSubSemanticData ( $subobjectName)
 
 addSubSemanticData (SemanticData $semanticData)
 
 removeSubSemanticData (SemanticData $semanticData)
 

Public Attributes

const OPT_LAST_MODIFIED = 'opt.last.modified'
 
const OPT_CHECK_REMNANT_ENTITIES = 'opt.check.remnant.entities'
 
const PROC_USER = 'proc.user'
 
const PROC_DELETE = 'proc.delete'
 
 $stubObject
 
 $subContainerDepthCounter = 0
 

Protected Attributes

 $mPropVals = []
 
 $mProperties = []
 
 $mHasVisibleProps = false
 
 $mHasVisibleSpecs = false
 
 $mNoDuplicates
 
 $mSubject
 
 $subSemanticData
 
 $subDataAllowed = true
 
 $errors = []
 
 $options
 
 $extensionData = []
 

Static Protected Attributes

static $mPropertyPrefix = ''
 

Detailed Description

Class for representing chunks of semantic data for one given subject. This consists of property-value pairs, grouped by property, and possibly by SMWSemanticData objects about subobjects.

Data about subobjects can be added in two ways: by directly adding it using addSubSemanticData() or by adding a property value of type SMWDIContainer.

By its very design, the container is unable to hold inverse properties. For one thing, it would not be possible to identify them with mere keys. Since SMW cannot annotate pages with inverses, this is not a limitation.

Author
Markus Krötzsch
Jeroen De Dauw

Constructor & Destructor Documentation

◆ __construct()

SMW\SemanticData::__construct ( DIWikiPage  $subject,
  $noDuplicates = true 
)

Constructor.

Parameters
DIWikiPage$subjectto which this data refers
boolean$noDuplicatesstating if duplicate data should be avoided

Member Function Documentation

◆ __sleep()

SMW\SemanticData::__sleep ( )

This object is added to the parser output of MediaWiki, but it is not useful to have all its data as part of the parser cache since the data is already stored in more accessible format in SMW. Hence this implementation of __sleep() makes sure only the subject is serialised, yielding a minimal stub data container after unserialisation. This is a little safer than serialising nothing: if, for any reason, SMW should ever access an unserialised parser output, then the Semdata container will at least look as if properly initialised (though empty).

Returns
array

◆ addDataValue()

SMW\SemanticData::addDataValue ( SMWDataValue  $dataValue)
Since
1.9
Parameters
SMWDataValue$dataValue

◆ addError()

SMW\SemanticData::addError (   $error)

Adds an error array

Since
1.9
Returns
array|string

◆ addPropertyObjectValue()

SMW\SemanticData::addPropertyObjectValue ( DIProperty  $property,
SMWDataItem  $dataItem 
)

Store a value for a property identified by its SMWDataItem object.

Note
There is no check whether the type of the given data item agrees with the type of the property. Since property types can change, all parts of SMW are prepared to handle mismatched data item types anyway.
Parameters
$propertyDIProperty
$dataItemSMWDataItem

◆ addPropertyValue()

SMW\SemanticData::addPropertyValue (   $propertyName,
SMWDataItem  $dataItem 
)

Store a value for a given property identified by its text label (without namespace prefix).

Parameters
$propertyNamestring
$dataItemSMWDataItem

◆ addSubobject()

SMW\SemanticData::addSubobject ( Subobject  $subobject)
Since
2.1
Parameters
Subobject$subobject

◆ addSubSemanticData()

SMW\SemanticData::addSubSemanticData ( SemanticData  $semanticData)
See also
SubSemanticData::addSubSemanticData
Since
1.8
Parameters
SemanticData$semanticData
Exceptions
SubSemanticDataException

◆ clear()

SMW\SemanticData::clear ( )

Delete all data other than the subject.

◆ clearSubSemanticData()

SMW\SemanticData::clearSubSemanticData ( )
Since
2.5

◆ findSubSemanticData()

SMW\SemanticData::findSubSemanticData (   $subobjectName)
See also
SubSemanticData::findSubSemanticData
Since
1.9
Parameters
string$subobjectName
Returns
SMWContainerSemanticData|null

◆ getErrors()

SMW\SemanticData::getErrors ( )

Returns collected errors occurred during processing

Since
1.9
Returns
array

◆ getExtensionData()

SMW\SemanticData::getExtensionData (   $key)
Since
3.0
Parameters
string$key
Returns
mixed|null

◆ getHash()

SMW\SemanticData::getHash ( )

Generate a hash value to simplify the comparison of this data container with other containers. Subdata is taken into account.

The hash uses PHP's md5 implementation, which is among the fastest hash algorithms that PHP offers.

Note
This function may be used to obtain keys for SemanticData objects or to do simple equality tests. Equal hashes with very high probability indicate equal data.
Returns
string

◆ getOption()

SMW\SemanticData::getOption (   $key,
  $default = null 
)
Since
2.5
Parameters
string$key
mixed$default
Returns
mixed

◆ getProperties()

SMW\SemanticData::getProperties ( )

Get the array of all properties that have stored values.

Returns
array of DIProperty objects

◆ getPropertyValues()

SMW\SemanticData::getPropertyValues ( DIProperty  $property)

Get the array of all stored values for some property.

Parameters
DIProperty$property
Returns
SMWDataItem[]

◆ getSubject()

SMW\SemanticData::getSubject ( )

Return subject to which the stored semantic annotations refer to.

Returns
DIWikiPage subject

◆ getSubSemanticData()

SMW\SemanticData::getSubSemanticData ( )
See also
SubSemanticData::getSubSemanticData
Since
1.8
Returns
ContainerSemanticData[]

◆ hasProperty()

SMW\SemanticData::hasProperty ( DIProperty  $property)
Since
2.4
Parameters
DIProperty$property
Returns
boolean

◆ hasSubSemanticData()

SMW\SemanticData::hasSubSemanticData (   $subobjectName = null)
See also
SubSemanticData::hasSubSemanticData
Since
1.9
Parameters
string$subobjectName,|null
Returns
boolean

◆ hasVisibleProperties()

SMW\SemanticData::hasVisibleProperties ( )

Return true if there are any visible properties.

Note
While called "visible" this check actually refers to the function DIProperty::isShown(). The name is kept for compatibility.
Returns
boolean

◆ hasVisibleSpecialProperties()

SMW\SemanticData::hasVisibleSpecialProperties ( )

Return true if there are any special properties that can be displayed.

Note
While called "visible" this check actually refers to the function DIProperty::isShown(). The name is kept for compatibility.
Returns
boolean

◆ importDataFrom()

SMW\SemanticData::importDataFrom ( SemanticData  $semanticData)

Add all data from the given SMWSemanticData. Only works if the imported SMWSemanticData has the same subject as this SMWSemanticData; an exception is thrown otherwise.

Since
1.7
Parameters
SemanticData$semanticDataobject to copy from
Exceptions
SemanticDataImportException

◆ isEmpty()

SMW\SemanticData::isEmpty ( )

Return true if this SemanticData is empty. This is the case when the subject has neither property values nor data for subobjects.

Since
1.8
Returns
boolean

◆ removeDataFrom()

SMW\SemanticData::removeDataFrom ( SemanticData  $semanticData)

Removes data from the given SMWSemanticData. If the subject of the data that is to be removed is not equal to the subject of this SMWSemanticData, it will just be ignored (nothing to remove). Likewise, removing data that is not present does not change anything.

Since
1.8
Parameters
SemanticData$semanticData

◆ removeProperty()

SMW\SemanticData::removeProperty ( DIProperty  $property)

Removes a property and all the values associated with this property.

Since
2.5
Parameters
$propertyDIProperty

◆ removePropertyObjectValue()

SMW\SemanticData::removePropertyObjectValue ( DIProperty  $property,
SMWDataItem  $dataItem 
)

Remove a value for a property identified by its SMWDataItem object. This method removes a property-value specified by the property and dataitem. If there are no more property-values for this property it also removes the property from the mProperties.

Note
There is no check whether the type of the given data item agrees with the type of the property. Since property types can change, all parts of SMW are prepared to handle mismatched data item types anyway.
Parameters
$propertyDIProperty
$dataItemSMWDataItem
Since
1.8

◆ removeSubSemanticData()

SMW\SemanticData::removeSubSemanticData ( SemanticData  $semanticData)
See also
SubSemanticData::removeSubSemanticData
Since
1.8
Parameters
SemanticData$semanticData

◆ setExtensionData()

SMW\SemanticData::setExtensionData (   $key,
  $value 
)
Since
3.0
Parameters
string$key
mixed$value

◆ setOption()

SMW\SemanticData::setOption (   $key,
  $value 
)
Since
2.5
Parameters
string$key
string$value

Member Data Documentation

◆ $subDataAllowed

SMW\SemanticData::$subDataAllowed = true
protected

Internal flag that indicates if this semantic data will accept subdata. Semantic data objects that are subdata already do not allow (second level) subdata to be added. This ensures that all data is collected on the top level, and in particular that there is only one way to represent the same data with subdata. This is also useful for diff computation.

◆ OPT_CHECK_REMNANT_ENTITIES

const SMW\SemanticData::OPT_CHECK_REMNANT_ENTITIES = 'opt.check.remnant.entities'
See also
$smwgCheckForRemnantEntities

◆ OPT_LAST_MODIFIED

const SMW\SemanticData::OPT_LAST_MODIFIED = 'opt.last.modified'

Returns the last modified timestamp the data were stored to the Store or have been fetched from cache.

◆ PROC_DELETE

const SMW\SemanticData::PROC_DELETE = 'proc.delete'

Identifies that a data block was initiated by a delete request.

◆ PROC_USER

const SMW\SemanticData::PROC_USER = 'proc.user'

Identifies that a data block was created by a user.


The documentation for this class was generated from the following file:

About | General disclaimer | Privacy policy