Thanks Anja. I have a slightly different coding based yours that works: // return an array of arraies of predicate-value pairs of the page function getTriple($title) {
$page = SMWDataValueFactory::newTypeIDValue( '_wpg', $title->getFullText()); $semdata = smwfGetStore()->getSemanticData($page->getTitle() ); // build the semantic data if ($semdata == null) { return null; } $s = $title->getFullText(); $arr = array(); foreach($semdata->getProperties() as $key => $property){ $p = $property->getShortText(false,NULL); $p2 = $property->getPropertyID(); if (!$arr[$p]) $arr[$p] = array(); // http://semantic-mediawiki.org/doc/SMW__SQLStore2_8php-source.html if ($p2 == '_MDAT') continue; //time stamp else if ($p2 == '_INST') $p = 'rdf:type'; else if ($p2 == '_SUBC') $p = 'rdfs:subClassOf'; else if ($p2 == '_SUBP') $p = 'rdfs:subPropertyOf'; else if ($p2 == '_REDI') $p = 'owl:sameAs'; else if ($p2 == '_TYPE') $p = 'has_type'; else { $p = str_replace('Property:','',$p); } $p[0] = strtoupper($p[0]); $propvalues = $semdata->getPropertyValues($property); foreach ($propvalues as $propvalue) { $o=$propvalue->getShortText(false); $arr[$p][] =$o; } } return $arr; } On Wed, Jul 8, 2009 at 4:09 AM, Friederichs, Anja< anja.friederi...@detecon.com> wrote: > Hi Jie, > > in my extension I have a function readproperties. Maybe this can help? > > Anja > > public function readProperties( $namespace, $pagename ) { > if($pagename == '') { > return 'No configpage available'; > } > else { > $page = SMWDataValueFactory::newTypeIDValue( '_wpg', $namespace . ':' . $pagename ); > $data = smwfGetStore()->getSemanticData($page->getTitle()); > $properties = $data->getProperties(); > $proparray = array(); > foreach ($properties as $property) { > $propname = array(); > $propname = explode(':', $property->getlongHTMLText()); > $propnametext = $propname[1]; > $propvalue = array(); > $propvalue = $data->getPropertyValues($property); > $propvaluetext = $propvalue[0]->getLongHTMLText(); > $proparray[$propnametext] = $propvaluetext; > } > } > return $proparray; > } > >>-----Ursprüngliche Nachricht----- >>Von: Jie Bao [mailto:bao...@cs.rpi.edu] >>Gesendet: Mittwoch, 8. Juli 2009 04:33 >>An: semediawiki-devel; Semantic MediaWiki users >>Betreff: [SMW-devel] Anybody knows how to get all triples of a >>page in aprogram? >> >>I need to get all triples about a page in a php program. Anybody knows >>how? Thanks >> >>jie >> >>-- >>Jie Bao >>http://www.cs.rpi.edu/~baojie >> >>--------------------------------------------------------------- >>--------------- >>Enter the BlackBerry Developer Challenge >>This is your chance to win up to $100,000 in prizes! For a >>limited time, >>vendors submitting new applications to BlackBerry App >>World(TM) will have >>the opportunity to enter the BlackBerry Developer Challenge. >>See full prize >>details at: http://p.sf.net/sfu/Challenge >>_______________________________________________ >>Semediawiki-devel mailing list >>Semediawiki-devel@lists.sourceforge.net >>https://lists.sourceforge.net/lists/listinfo/semediawiki-devel >> > -- Jie Bao http://www.cs.rpi.edu/~baojie
------------------------------------------------------------------------------
_______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel