Thread:User talk:Yury Katkov/programming examples/Examples not working/reply

I did manage to do some queries based on the examples, but I think they won't work with the current version of SMW. Here's an example which looks up the value for a property "Master_page" on the current page, and returns the value of that property: function getCanonical { global $wgTitle; $masterPageProperty = new SMWDIProperty('Master_page');

$title = Title::newFromText( $wgTitle->mTextform ); $currentArticle = SMWDIWikiPage::newFromTitle( $title ); $semanticData = smwfGetStore->getSemanticData( $currentArticle );

$masterPagePropVals = $semanticData->getPropertyValues( $masterPageProperty ); $masterPageProp = array_pop( $masterPagePropVals ); if ( is_null( $masterPageProp ) ) return NULL; $masterPage	= $masterPageProp->getDBkey;

$canonicalTitle = Title::newFromText( $masterPage ); return SMWDIWikiPage::newFromTitle( $canonicalTitle ); }

Here's an example that finds all pages which have the same value for a particular property "Master_page", sorted by a "Language_code" property:

function getTranslations(&$canonicalTranslation) { $masterPageProperty = new SMWDIProperty('Master_page');

$description = new SMWValueDescription( $canonicalTranslation ); $property = new SMWSomeProperty( $masterPageProperty, $description );

$query = new SMWQuery( $property ); $query->sort = true; $query->sortkeys = array('Language_code' => 'ASC');

$queryResult = smwfGetStore->getQueryResult( $query ); return $queryResult->getResults; }