BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
SMW\SemanticData Class Reference
Inheritance diagram for SMW\SemanticData:

Public Member Functions

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

Public Attributes

 $stubObject
 

Protected Attributes

 $mPropVals = array()
 
 $mProperties = array()
 
 $mHasVisibleProps = false
 
 $mHasVisibleSpecs = false
 
 $mNoDuplicates
 
 $mSubject
 
 $subSemanticData = array()
 
 $subDataAllowed = true
 
 $errors = array()
 

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

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

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
SMW\SemanticData::addDataValue ( SMWDataValue  $dataValue)
Since
1.9
Parameters
SMWDataValue$dataValue
SMW\SemanticData::addError (   $error)

Adds an error array

Since
1.9
Returns
array|string
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
SMW\SemanticData::addPropertyValue (   $propertyName,
SMWDataItem  $dataItem 
)

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

Parameters
$propertyNamestring
$dataItemSMWDataItem
SMW\SemanticData::addSubobject ( Subobject  $subobject)
Since
2.1
Parameters
Subobject$subobject
SMW\SemanticData::addSubSemanticData ( SemanticData  $semanticData)

Add data about subobjects. Will only work if the data that is added is about a subobject of this SMWSemanticData's subject. Otherwise an exception is thrown. The SMWSemanticData object that is given will belong to this object after the operation; it should not be modified further by the caller.

Since
1.8
Parameters
SemanticData$semanticData
Exceptions
MWExceptionif not adding data about a subobject of this data
SMW\SemanticData::clear ( )

Delete all data other than the subject.

SMW\SemanticData::findSubSemanticData (   $subobjectName)

Find a particular subobject container using its name as identifier

Since
1.9
Parameters
string$subobjectName
Returns
SMWContainerSemanticData|[]
SMW\SemanticData::getErrors ( )

Returns collected errors occurred during processing

Since
1.9
Returns
array
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
SMW\SemanticData::getLastModified ( )

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

Since
2.3
Returns
integer|null
SMW\SemanticData::getProperties ( )

Get the array of all properties that have stored values.

Returns
array of DIProperty objects
SMW\SemanticData::getPropertyValues ( DIProperty  $property)

Get the array of all stored values for some property.

Parameters
DIProperty$property
Returns
SMWDataItem[]
SMW\SemanticData::getSubject ( )

Return subject to which the stored semantic annotations refer to.

Returns
DIWikiPage subject
SMW\SemanticData::getSubSemanticData ( )

Return the array of subSemanticData objects for this SemanticData

Since
1.8
Returns
SMWContainerSemanticData[] subobject => SMWContainerSemanticData
SMW\SemanticData::hasProperty ( DIProperty  $property)
Since
2.4
Parameters
DIProperty$property
Returns
boolean
SMW\SemanticData::hasSubSemanticData (   $subobjectName = null)

Whether the SemanticData has a SubSemanticData container and if specified has a particular subobject using its name as identifier

Since
1.9
Parameters
string$subobjectName,|null
Returns
boolean
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
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
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
MWExceptionif subjects do not match
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
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
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
SMW\SemanticData::removeSubSemanticData ( SemanticData  $semanticData)

Remove data about a subobject. If the removed data is not about a subobject of this object, it will silently be ignored (nothing to remove). Likewise, removing data that is not present does not change anything.

Since
1.8
Parameters
SMWSemanticData
SMW\SemanticData::setLastModified (   $lastModified)
Since
2.3
Parameters
string | null$lastModified

Member Data Documentation

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.


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