Thanks for both examples - they are very helpful.

One related question : What function should I use to get the raw value of a 
property ?

Both getShortText and getLongHTMLText interpret the content of the text when I 
try to display it.

For example, I have a property 'Has URL'. Some values of URLs have %20 in them. 
I would like to retrieve the raw value of a URL and display it as plain text 
(and not as a hyperlink).

- Laurent

----------------------------------------
From: "CNIT" <c...@uniyar.ac.ru>
Sent: Thursday, July 23, 2009 8:14 PM
To: "Jie Bao" <bao...@cs.rpi.edu>
Subject: Re: [SMW-devel] Anybody knows how to get all triples of a page in 
aprogram?

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

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

Reply via email to