How to read SMW data from PHP code
From semantic-mediawiki.org
<?php
class SomeClass{
//Return all Semantic Properties with Values for given Title object
public static function getSMWPropertyValuesForTitle(Title $oTitle){
$store = SMW\StoreFactory::getStore()->getSemanticData( \SMW\DIWikiPage::newFromTitle( $oTitle ) );
//$store instanceof SMWSql3StubSemanticData;
$arrSMWProps = $store->getProperties();
$arrValues = [ ];
foreach ( $arrSMWProps as $smwProp ) {
//$smwProp instanceof SMW\DIProperty;
$arrSMWPropValues = $store->getPropertyValues( $smwProp );
foreach ( $arrSMWPropValues as $smwPropValue ) {
$arrValues[ $smwProp->getLabel() ][] = $smwPropValue->getSerialization();
}
}
return $arrValues;
}
}