On Freitag, 24. Juli 2009, Laurent Alquier wrote:
> Yes - I am trying to display the raw value in a wiki page.
>
> I will try to look into the code of Semantic Forms again. I know it is
> possible since SF displays the raw value inside form fields :)

The right method here somewhat depends on what you want to do with the value. 
If you want a value string that would be understood if entered into a query by 
a user, then you should use getWikiValue(). To get values as used internally, 
use getDBkeys(): this returns an array of "raw" values that are useful if you 
want to work with the value in your own code without parsing it again first. 
But the details depend on the datatype here. The getShort... and getLong... 
functions are only for displaying data, not for further processing it. 

-- Markus

>
> - Laurent
>
> ----------------------------------------
> From: "Friederichs, Anja" <anja.friederi...@detecon.com>
> Sent: Friday, July 24, 2009 9:02 AM
> To: laur...@alquier.org, semediawiki-devel@lists.sourceforge.net
> Subject: RE: [SMW-devel] Anybody knows how to get all triples of a page
> inaprogram?
>
> Hi Laurent,
>
>
> did you try to display your property value in a wikipage again? If I
> remember correctly a had a quite similar problem. In my code the string had
> the right content, but the wiki always displayed the encoded string (I'm
> not sure if it was in this particular case). Did you try to save your
> property value in a file to show the difference and if there even is any?
> It's just an idea, but maybe it helps?
>
>
> Anja
>
>
> -----Original Message-----
>
> From: Laurent Alquier [mailto:laur...@alquier.org]
>
> Sent: Fri 24.07.2009 20:40
>
> To: semediawiki-devel@lists.sourceforge.net
>
> Subject: Re: [SMW-devel] Anybody knows how to get all triples of a page
> inaprogram?
>
>
> 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


-- 
Markus Krötzsch
Semantic MediaWiki    http://semantic-mediawiki.org
http://korrekt.org    mar...@semantic-mediawiki.org

Attachment: signature.asc
Description: This is a digitally signed message part.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel

Reply via email to