SMWSemanticData Class Reference
[Semantic MediaWiki]

Class for representing chunks of semantic data for one given article (subject), similar what is typically displayed in the Factbox. More...

Inherited by SMWContainerSemanticData, and SMWSqlStubSemanticData.

List of all members.

Public Member Functions

 __construct (SMWDIWikiPage $subject, $noDuplicates=true)
 Constructor.
 __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.
 getSubject ()
 Return subject to which the stored semantic annotations refer to.
 getProperties ()
 Get the array of all properties that have stored values.
 getPropertyValues (SMWDIProperty $property)
 Get the array of all stored values for some property.
 getHash ()
 Generate a hash value to simplify the comparison of this data container with other containers.
 hasVisibleProperties ()
 Return true if there are any visible properties.
 hasVisibleSpecialProperties ()
 Return true if there are any special properties that can be displayed.
 addPropertyObjectValue (SMWDIProperty $property, SMWDataItem $dataItem)
 Store a value for a property identified by its SMWDataItem object.
 addPropertyValue ($propertyName, SMWDataItem $dataItem)
 Store a value for a given property identified by its text label (without namespace prefix).
 clear ()
 Delete all data other than the subject.
 importDataFrom (SMWSemanticData $semanticData)
 Add all data from the given SMWSemanticData.

Public Attributes

 $stubObject

Protected Attributes

 $mPropVals = array()
 $mProperties = array()
 $mHasVisibleProps = false
 $mHasVisibleSpecs = false
 $mNoDuplicates
 $mSubject

Static Protected Attributes

static $mPropertyPrefix = ''


Detailed Description

Class for representing chunks of semantic data for one given article (subject), similar what is typically displayed in the Factbox.

This is a light-weight data container.

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.

Definition at line 24 of file SMW_SemanticData.php.


Constructor & Destructor Documentation

SMWSemanticData::__construct ( SMWDIWikiPage subject,
noDuplicates = true 
)

Constructor.

Parameters:
SMWDIWikiPage $subject to which this data refers
boolean $noDuplicates stating if duplicate data should be avoided

Definition at line 103 of file SMW_SemanticData.php.

References clear().


Member Function Documentation

SMWSemanticData::__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

Reimplemented in SMWContainerSemanticData.

Definition at line 122 of file SMW_SemanticData.php.

SMWSemanticData::getSubject (  ) 

Return subject to which the stored semantic annotations refer to.

Returns:
SMWDIWikiPage subject

Reimplemented in SMWContainerSemanticData.

Definition at line 131 of file SMW_SemanticData.php.

Referenced by SMWContainerSemanticData::copyDataFrom(), SMWSQLStoreLight::doDataUpdate(), SMWSQLStore2::doDataUpdate(), SMWExporter::makeExportData(), and SMWSqlStubSemanticData::newFromSemanticData().

SMWSemanticData::getProperties (  ) 

Get the array of all properties that have stored values.

Returns:
array of SMWDIProperty objects

Reimplemented in SMWSqlStubSemanticData.

Definition at line 140 of file SMW_SemanticData.php.

Referenced by SMWContainerSemanticData::copyDataFrom(), SMWSpecialBrowse::displayData(), getHash(), and importDataFrom().

SMWSemanticData::getPropertyValues ( SMWDIProperty property  ) 

Get the array of all stored values for some property.

Parameters:
$property SMWDIProperty
Returns:
array of SMWDataItem

Reimplemented in SMWSqlStubSemanticData.

Definition at line 151 of file SMW_SemanticData.php.

References SMWDIProperty::getKey().

Referenced by SMWContainerSemanticData::copyDataFrom(), SMWSpecialBrowse::displayData(), SMWSQLStore2::doDataUpdate(), SMWFactbox::getFactboxText(), getHash(), importDataFrom(), and SMWExporter::makeExportData().

SMWSemanticData::getHash (  ) 

Generate a hash value to simplify the comparison of this data container with other containers.

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

Returns:
string

Definition at line 171 of file SMW_SemanticData.php.

References getProperties(), and getPropertyValues().

SMWSemanticData::hasVisibleProperties (  ) 

Return true if there are any visible properties.

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

Reimplemented in SMWSqlStubSemanticData.

Definition at line 197 of file SMW_SemanticData.php.

Referenced by SMWContainerSemanticData::copyDataFrom(), and importDataFrom().

SMWSemanticData::hasVisibleSpecialProperties (  ) 

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

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

Reimplemented in SMWSqlStubSemanticData.

Definition at line 211 of file SMW_SemanticData.php.

Referenced by SMWContainerSemanticData::copyDataFrom(), and importDataFrom().

SMWSemanticData::addPropertyObjectValue ( SMWDIProperty 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:
$property SMWDIProperty
$dataItem SMWDataItem

Definition at line 226 of file SMW_SemanticData.php.

References SMWDataItem::getHash(), and SMWDIProperty::getKey().

Referenced by addPropertyValue(), and importDataFrom().

SMWSemanticData::addPropertyValue ( propertyName,
SMWDataItem dataItem 
)

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

Parameters:
$propertyName string
$dataItem SMWDataItem

Definition at line 259 of file SMW_SemanticData.php.

References addPropertyObjectValue(), SMWPropertyValue::makeUserProperty(), and smwfNormalTitleDBKey().

SMWSemanticData::clear (  ) 

Delete all data other than the subject.

Reimplemented in SMWSqlStubSemanticData.

Definition at line 285 of file SMW_SemanticData.php.

Referenced by __construct().

SMWSemanticData::importDataFrom ( SMWSemanticData semanticData  ) 

Add all data from the given SMWSemanticData.

Since:
1.7
Parameters:
$semanticData SMWSemanticData object to copy from

Definition at line 300 of file SMW_SemanticData.php.

References addPropertyObjectValue(), getProperties(), getPropertyValues(), hasVisibleProperties(), and hasVisibleSpecialProperties().


Member Data Documentation

SMWSemanticData::$mPropertyPrefix = '' [static, protected]

Definition at line 31 of file SMW_SemanticData.php.

SMWSemanticData::$stubObject

Definition at line 41 of file SMW_SemanticData.php.

SMWSemanticData::$mPropVals = array() [protected]

Definition at line 49 of file SMW_SemanticData.php.

SMWSemanticData::$mProperties = array() [protected]

Definition at line 56 of file SMW_SemanticData.php.

SMWSemanticData::$mHasVisibleProps = false [protected]

Definition at line 63 of file SMW_SemanticData.php.

SMWSemanticData::$mHasVisibleSpecs = false [protected]

Definition at line 73 of file SMW_SemanticData.php.

SMWSemanticData::$mNoDuplicates [protected]

Definition at line 86 of file SMW_SemanticData.php.

SMWSemanticData::$mSubject [protected]

Reimplemented in SMWSqlStubSemanticData.

Definition at line 95 of file SMW_SemanticData.php.


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

Generated on Sun Mar 18 07:15:43 2012 for Semantic MediaWiki by  doxygen 1.5.6