Jie Bao пишет:
> 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;
> }
>
Aren't strtoupper should be replaced with mb_strtoupper? Lots of "else 
if" probably would look better as "switch case", though the later is a 
matter of personal taste.
Dmitriy

------------------------------------------------------------------------------
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel

Reply via email to