XML_FOAF
[ class tree: XML_FOAF ] [ index: XML_FOAF ] [ all elements ]

Basic Usage of XML_FOAF


1 <?php
2 require_once 'XML/FOAF.php';
3 // Main FOAF
4 $foaf = new XML_FOAF();
5
6 $foaf->newAgent('person');
7 $foaf->setName('Davey Shafik');
8 $foaf->setTitle('Mr');
9 $foaf->setFirstName('Davey');
10 $foaf->setSurname('Shafik');
11 $foaf->addMbox('mailto:davey@php.net',TRUE); // see also: XML_FOAF::setMboxSha1Sum();
12 $foaf->addHomepage('http://pixelated-dreams.com/~davey/');
13 $foaf->addWeblog('http://pixelated-dreams.com/blog');
14 $foaf->addImg('http://pixelated-dreams.com/~davey/me.jpg');
15 $foaf->addPage('http://pixelated-dreams.com/~davey/CV','Curriculum Vitae','Davey Shafiks Curriculum Vitae');
16 $foaf->addPage('http://www.php-mag.net/itr/online_artikel/psecom,id,484,nodeid,114.html','Sticking The Fork In','Creating Daemons in PHP');
17 $foaf->addPage('http://pawscon.com/', 'PHP and Web Standards Conference UK 2004', 'A Conference dedicated to PHP, Web Standards and the Semantic Web');
18 $foaf->addPhone('07776293539');
19 $foaf->addJabberID('fractured_realities@jabber.org');
20 $foaf->addTheme('http://php.net');
21 $foaf->addOnlineAccount('Davey','http://freenode.info','http://xmlns.com/foaf/0.1/OnlineChatAccount');
22 $foaf->addOnlineGamingAccount('Davey_S','http://www.there.com');
23 $foaf->addWorkplaceHomepage('http://www.pawscon.com');
24 $foaf->addSchoolHomepage('http://www.nobel.herts.sch.uk/');
25 $foaf->addInterest('http://xmlns.com/foaf/0.1/');
26 $foaf->addFundedBy('http://synapticmedia.net');
27 $foaf->addLogo('http://paws.davey.is-a-geek.com/images/paws.jpg');
28 $foaf->setBasedNear(52.565475,-1.162895);
29 $foaf->addDepiction('http://example.org/depiction/');
30 $foaf->addDepiction('http://example.org/depiction/2');
31
32 // Content of a <foaf:knows><foaf:Person /></foaf:knows>
33 $matt = new XML_FOAF();
34 $matt->newAgent('person');
35 $matt->setName('Matt McClanahan');
36 $matt->addNick('mattmcc');
37 $matt->addMboxSha1Sum('0cd5f54daf6aa59d1071ea6bf2973e0171ece606',TRUE);
38 $matt->addSeeAlso('http://mmcc.cx/foaf.rdf');
39 $matt->addJabberID('mattmcc@jabber.com');
40 $matt->addOnlineChatAccount('mattmcc','http://freenode.info','http://xmlns.com/foaf/0.1/OnlineChatAccount');
41 // Add to Main FOAF
42 $foaf->addKnows($matt);
43
44 // Another <foaf:knows><foaf:Person /></foaf:knows>
45 /*
46 Although we use another instance of XML_FOAF, we could re-use
47 the one from above ($matt)
48 */
49 $libby = new XML_FOAF();
50 $libby->newAgent('person');
51 $libby->setName('Libby Miller');
52 $libby->addMbox('mailto:libby.miller@bristol.ac.uk');
53 $libby->addSeeAlso('http://swordfish.rdfweb.org/people/libby/rdfweb/webwho.xrdf');
54
55 // Add to Main FOAF
56 $foaf->addKnows($libby);
57
58 $mcd = new XML_FOAF();
59 $mcd->newAgent('Organization');
60 $mcd->setName('McDonalds');
61 $mcd->addHomepage('http://www.mcdonalds.com/');
62
63 $foaf->addKnows($mcd);
64
65 if (!isset($_GET['xml'])) {
66 echo "<pre>" .htmlentities($foaf->get()). "</pre>";
67 echo "<hr />";
68 show_source(__FILE__);
69 } else {
70 header('Content-Type: text/xml');
71 $foaf->dump();
72 }
73
74 /* Output
75 <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/"
76 xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
77 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
78 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
79 <foaf:Person>
80 <foaf:name>Davey Shafik</foaf:name>
81 <foaf:title>Mr</foaf:title>
82 <foaf:firstName>Davey</foaf:firstName>
83 <foaf:surname>Shafik</foaf:surname>
84 <foaf:mbox_sha1sum>26b2e3834d83a5ca3fc81e5a942862f7a2bcb653</foaf:mbox_sha1sum>
85 <foaf:homepage rdf:resource="http://pixelated-dreams.com/~davey/" />
86 <foaf:img rdf:resource="http://pixelated-dreams.com/~davey/me.jpg" />
87 <foaf:page>
88 <foaf:Document rdf:about="http://pixelated-dreams.com/~davey/CV/">
89 <dc:title>Curriculum Vitae</dc:title>
90 </foaf:Document>
91 </foaf:page>
92 <foaf:phone rdf:resource="tel:07776293539" />
93 <foaf:workplaceHomepage rdf:resource="http://www.pawscon.com" />
94 <foaf:schoolHomepage rdf:resource="http://www.nobel.herts.sch.uk/" />
95 <foaf:interest rdf:resource="http://xmlns.com/foaf/0.1/" />
96 <foaf:based_near>
97 <geo:Point geo:lat="52.565475" geo:long="-1.162895" />
98 </foaf:based_near>
99 <foaf:knows>
100 <foaf:Person>
101 <foaf:name>Matt McClanahan</foaf:name>
102 <foaf:nick>mattmcc</foaf:nick>
103 <foaf:mbox_sha1sum>0cd5f54daf6aa59d1071ea6bf2973e0171ece606</foaf:mbox_sha1sum>
104 <rdfs:seeAlso rdf:resource="http://mmcc.cx/foaf.rdf" />
105 </foaf:Person>
106 </foaf:knows>
107 <foaf:knows>
108 <foaf:Person>
109 <foaf:name>Libby Miller</foaf:name>
110 <foaf:mbox rdf:resource="mailto:libby.miller@bristol.ac.uk" />
111 <rdfs:seeAlso rdf:resource="http://swordfish.rdfweb.org/people/libby/rdfweb/webwho.xrdf" />
112 </foaf:Person>
113 </foaf:knows>
114 </foaf:Person>
115 </rdf:RDF>
116 */
117 ?>

Documentation generated on Thu, 15 Jan 2004 19:03:08 +0000 by phpDocumentor 1.2.3