1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* SIOC::WikiDokuArticle object |
8
|
|
|
* |
9
|
|
|
* Contains information about a wiki article |
10
|
|
|
*/ |
11
|
|
|
class SIOCDokuWikiArticle extends SIOCObject |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
private $type = 'sioct:WikiArticle'; |
15
|
|
|
private $id = null; |
16
|
|
|
private $url = null; |
17
|
|
|
private $subject = null; |
18
|
|
|
private $creator = array(); |
19
|
|
|
private $contributors = array(); |
20
|
|
|
private $created = null; |
21
|
|
|
private $modified = null; |
22
|
|
|
private $links = array(); |
23
|
|
|
private $backlinks = array(); |
24
|
|
|
private $previous_version = null; |
25
|
|
|
private $next_version = null; |
26
|
|
|
private $latest_version = false; // show latest version |
27
|
|
|
private $has_container = null; |
28
|
|
|
private $has_space = null; |
29
|
|
|
private $content = null; |
30
|
|
|
private $content_encoded = null; |
31
|
|
|
private $is_creator = false; |
32
|
|
|
|
33
|
|
|
public function __construct($id, $url, $subject, $content) |
34
|
|
|
{ |
35
|
|
|
$this->id = $id; |
36
|
|
|
$this->url = $url; |
37
|
|
|
$this->subject = $subject; |
38
|
|
|
$this->content = $content; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function addCreated($created) |
42
|
|
|
{ |
43
|
|
|
$this->created = $created; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function addModified($modified) |
47
|
|
|
{ |
48
|
|
|
$this->modified = $modified; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function addCreator($creator) |
52
|
|
|
{ |
53
|
|
|
$this->creator = $creator; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function addContributors($contributors) |
57
|
|
|
{ |
58
|
|
|
$this->contributors = $contributors; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function isCreator() |
62
|
|
|
{ |
63
|
|
|
$this->is_creator = true; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function addLinks($links) |
67
|
|
|
{ |
68
|
|
|
if (is_array($links) && count($links) > 0) { |
69
|
|
|
$this->links = $links; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function addBacklinks($links) |
74
|
|
|
{ |
75
|
|
|
$this->backlinks = $links; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
//function addLinksExtern($links) { if (is_array($links) && count($links)>0) $this->ext_links = $links; } |
79
|
|
|
public function addVersionPrevious($rev) |
80
|
|
|
{ |
81
|
|
|
$this->previous_version = $rev; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function addVersionNext($rev) |
85
|
|
|
{ |
86
|
|
|
$this->next_version = $rev; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function addVersionLatest() |
90
|
|
|
{ |
91
|
|
|
$this->latest_version = true; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function addContentEncoded($encoded) |
95
|
|
|
{ |
96
|
|
|
$this->content_encoded = $encoded; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function addContainer($id) |
100
|
|
|
{ |
101
|
|
|
$this->has_container = $id; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function addSite($url) |
105
|
|
|
{ |
106
|
|
|
$this->has_space = $url; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getContent(&$exp): string |
110
|
|
|
{ |
111
|
|
|
$rdf = '<' . $this->type . " rdf:about=\"" . clean($this->url, true) . "\">\n"; |
112
|
|
|
if ($this->subject) { |
113
|
|
|
$rdf .= " <dc:title>" . clean($this->subject) . "</dc:title>\n"; |
114
|
|
|
// if(strcmp($this->has_container, 'http://en.wikipedia.org')===0) |
115
|
|
|
// $rdf .= " <foaf:primaryTopic rdf:resource=\"".clean('http://dbpedia.org/resource/' |
116
|
|
|
// .$this->subject)."\"/>\n"; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
$creator_name = null; |
120
|
|
|
|
121
|
|
|
if (count($this->contributors) > 0) { |
122
|
|
|
foreach ($this->contributors as $cont_id => $cont_name) { |
123
|
|
|
if (!isset($this->creator['sioc:modifier']) || ($this->creator['sioc:modifier'] != $cont_id)) { |
124
|
|
|
$rdf .= " <sioc:has_modifier rdf:resource=\"" . normalizeUri( |
|
|
|
|
125
|
|
|
$exp->siocURL('user', $cont_id) |
126
|
|
|
) . "\" rdfs:label=\"" . clean($cont_name) . "\"/>\n"; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
if (isset($this->contributors[$this->creator['sioc:modifier']])) { |
131
|
|
|
$creator_name = 'rdfs:label="' . clean($this->contributors[$this->creator['sioc:modifier']]) . '"'; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
if (is_array($this->creator)) { |
|
|
|
|
136
|
|
|
// if ($this->creator['foaf:maker']) |
137
|
|
|
// $rdf .= " <foaf:maker rdf:resource=\"".clean($this->creator['foaf:maker'])."\"/>\n"; |
138
|
|
|
if ($this->creator['sioc:modifier']) { |
139
|
|
|
if ($this->is_creator === false) { |
140
|
|
|
$rdf .= " <sioc:has_modifier rdf:resource=\"" . normalizeUri( |
|
|
|
|
141
|
|
|
$exp->siocURL('user', $this->creator['sioc:modifier']) |
142
|
|
|
) . "\" $creator_name/>\n"; |
143
|
|
|
} |
144
|
|
|
if ($this->is_creator === true) { |
145
|
|
|
$rdf .= " <sioc:has_creator rdf:resource=\"" . normalizeUri( |
|
|
|
|
146
|
|
|
$exp->siocURL('user', $this->creator['sioc:modifier']) |
147
|
|
|
) . "\" $creator_name/>\n"; |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
if ($this->created) { |
153
|
|
|
$rdf .= " <dcterms:created>" . $this->created . "</dcterms:created>\n"; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
if ($this->modified) { |
157
|
|
|
$rdf .= " <dcterms:modified>" . $this->modified . "</dcterms:modified>\n"; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
if ($this->has_space) { |
161
|
|
|
$rdf .= " <sioc:has_space rdf:resource=\"" . clean($this->has_space, true) . "\" />\n"; |
162
|
|
|
// TODO: rdfs:label |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
if ($this->has_container) { |
166
|
|
|
$rdf .= " <sioc:has_container rdf:resource=\"" . normalizeUri( |
|
|
|
|
167
|
|
|
$exp->siocURL('container', $this->has_container) |
168
|
|
|
) . "\" />\n"; |
169
|
|
|
// TODO: rdfs:label |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
if ($this->content) { |
173
|
|
|
$rdf .= " <sioc:content><![CDATA[" . pureContent($this->content) . "]]></sioc:content>\n"; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
if ($this->content_encoded) { |
177
|
|
|
$rdf .= " <content:encoded><![CDATA[" . $this->content_encoded . "]]></content:encoded>\n"; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/* |
181
|
|
|
if(is_array($this->topics)) { |
182
|
|
|
foreach($this->topics as $topic=>$url) { |
183
|
|
|
$rdf .= " <sioc:topic>\n"; |
184
|
|
|
$rdf .= " <sioct:Category rdf:about=\"" . clean($url) ."\">\n"; |
185
|
|
|
$rdf .= " <rdfs:seeAlso rdf:resource=\"" . |
186
|
|
|
clean('http://ws.sioc-project.org/mediawiki/mediawiki.php?wiki='.$url); |
187
|
|
|
if ($this->api) $rdf .= clean("&api=" . $this->api); |
188
|
|
|
$rdf .= "\"/>\n"; |
189
|
|
|
$rdf .= " </sioct:Category>\n"; |
190
|
|
|
$rdf .= " </sioc:topic>\n"; |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
*/ |
194
|
|
|
|
195
|
|
|
if (is_array($this->links) && count($this->links) > 0) { |
196
|
|
|
foreach ($this->links as $link_id => $link_exists) { |
197
|
|
|
if ($link_exists && !isHiddenPage($link_id)) { |
198
|
|
|
$rdf .= " <sioc:links_to rdf:resource=\"" . normalizeUri( |
|
|
|
|
199
|
|
|
$exp->siocURL('post', $link_id) |
200
|
|
|
) . "\"/>\n"; |
201
|
|
|
// TODO: rdfs:label |
202
|
|
|
} |
203
|
|
|
} |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
if (count($this->backlinks) > 0) { |
207
|
|
|
foreach ($this->backlinks as $link_id) { |
208
|
|
|
if (!isHiddenPage($link_id)) { |
209
|
|
|
$rdf .= " <dcterms:isReferencedBy rdf:resource=\"" . normalizeUri( |
|
|
|
|
210
|
|
|
$exp->siocURL('post', $link_id) |
211
|
|
|
) . "\"/>\n"; |
212
|
|
|
// TODO: rdfs:label |
213
|
|
|
} |
214
|
|
|
} |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/* |
218
|
|
|
if(is_array($this->ext_links)) { |
219
|
|
|
foreach($this->ext_links as $label=>$url) { |
220
|
|
|
$rdf .= " <sioc:links_to rdf:resource=\"" . clean($url) ."\"/>\n"; |
221
|
|
|
} |
222
|
|
|
} |
223
|
|
|
*/ |
224
|
|
|
|
225
|
|
|
if ($this->previous_version) { |
226
|
|
|
$rdf .= " <sioc:previous_version rdf:resource=\"" . normalizeUri( |
|
|
|
|
227
|
|
|
$exp->siocURL( |
228
|
|
|
'post', |
229
|
|
|
$this->id . $exp->_urlseparator . 'rev' . $exp->_urlequal . $this->previous_version |
230
|
|
|
) |
231
|
|
|
) . "\"/>\n"; |
232
|
|
|
// TODO: rdfs:label |
233
|
|
|
|
234
|
|
|
/* If there is support for inference and transitivity the following is not needed */ |
235
|
|
|
$rdf .= " <sioc:earlier_version rdf:resource=\"" . normalizeUri( |
|
|
|
|
236
|
|
|
$exp->siocURL( |
237
|
|
|
'post', |
238
|
|
|
$this->id . $exp->_urlseparator . 'rev' . $exp->_urlequal . $this->previous_version |
239
|
|
|
) |
240
|
|
|
) . "\"/>\n"; |
241
|
|
|
// TODO: rdfs:label |
242
|
|
|
|
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
if ($this->next_version) { |
246
|
|
|
$rdf .= " <sioc:next_version rdf:resource=\"" . normalizeUri( |
|
|
|
|
247
|
|
|
$exp->siocURL( |
248
|
|
|
'post', |
249
|
|
|
$this->id . $exp->_urlseparator . 'rev' . $exp->_urlequal . $this->next_version |
250
|
|
|
) |
251
|
|
|
) . "\"/>\n"; |
252
|
|
|
// TODO: rdfs:label |
253
|
|
|
|
254
|
|
|
/* If there is support for inference and transitivity the following is not needed */ |
255
|
|
|
$rdf .= " <sioc:later_version rdf:resource=\"" . normalizeUri( |
|
|
|
|
256
|
|
|
$exp->siocURL( |
257
|
|
|
'post', |
258
|
|
|
$this->id . $exp->_urlseparator . 'rev' . $exp->_urlequal . $this->next_version |
259
|
|
|
) |
260
|
|
|
) . "\"/>\n"; |
261
|
|
|
// TODO: rdfs:label |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
if ($this->latest_version) { |
265
|
|
|
$rdf .= " <sioc:latest_version rdf:resource=\"" . normalizeUri( |
|
|
|
|
266
|
|
|
$exp->siocURL('post', $this->id) |
267
|
|
|
) . "\"/>\n"; |
268
|
|
|
// TODO: rdfs:label |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/* |
272
|
|
|
if($this->has_discussion && (strpos($this->has_discussion, 'Talk:Talk:') == FALSE)) { |
273
|
|
|
$rdf .= " <sioc:has_discussion>\n"; |
274
|
|
|
$rdf .= " <sioct:WikiArticle rdf:about=\"" . clean($this->has_discussion) ."\">\n"; |
275
|
|
|
$rdf .= " <rdfs:seeAlso rdf:resource=\"" . |
276
|
|
|
clean('http://ws.sioc-project.org/mediawiki/mediawiki.php?wiki='.$this->has_discussion); |
277
|
|
|
if ($this->api) $rdf .= clean("&api=" . $this->api); |
278
|
|
|
$rdf .= "\"/>\n"; |
279
|
|
|
$rdf .= " </sioct:WikiArticle>\n"; |
280
|
|
|
$rdf .= " </sioc:has_discussion>\n"; |
281
|
|
|
} |
282
|
|
|
*/ |
283
|
|
|
|
284
|
|
|
/* |
285
|
|
|
if($this->redirpage) |
286
|
|
|
{ |
287
|
|
|
$rdf .= " <owl:sameAs rdf:resource=\"" . clean($this->redirpage) ."\"/>\n"; |
288
|
|
|
$rdf .= " <rdfs:seeAlso rdf:resource=\"" . |
289
|
|
|
clean('http://ws.sioc-project.org/mediawiki/mediawiki.php?wiki='.$this->redirpage); |
290
|
|
|
if ($this->api) $rdf .= clean("&api=" . $this->api); |
291
|
|
|
$rdf .= "\"/>\n"; |
292
|
|
|
} |
293
|
|
|
*/ |
294
|
|
|
|
295
|
|
|
$rdf .= "</" . $this->type . ">\n"; |
296
|
|
|
return $rdf; |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* SIOC::DokuWikiUser object |
302
|
|
|
* |
303
|
|
|
* Contains information about a wiki user |
304
|
|
|
*/ |
305
|
|
|
class SIOCDokuWikiUser extends SIOCObject |
306
|
|
|
{ |
307
|
|
|
|
308
|
|
|
private $type = 'user'; |
309
|
|
|
|
310
|
|
|
private $id; |
311
|
|
|
private $nick; |
312
|
|
|
private $url; |
313
|
|
|
private $name; |
314
|
|
|
private $email; |
315
|
|
|
private $sha1; |
316
|
|
|
private $homepage; |
|
|
|
|
317
|
|
|
private $foaf_uri; |
|
|
|
|
318
|
|
|
private $role; |
319
|
|
|
private $sioc_url; |
|
|
|
|
320
|
|
|
private $foaf_url; |
321
|
|
|
|
322
|
|
|
public function __construct($id, $url, $userid, $name, $email) |
323
|
|
|
{ |
324
|
|
|
$this->id = $id; |
325
|
|
|
$this->nick = $userid; |
326
|
|
|
$this->name = $name; |
327
|
|
|
//$this->email = $email; |
328
|
|
|
$this->url = $url; |
329
|
|
|
|
330
|
|
|
if (preg_match_all('/^.+@.+\..+$/Ui', $email, $check, PREG_SET_ORDER)) { |
331
|
|
|
if (preg_match_all('/^mailto:(.+@.+\..+$)/Ui', $email, $matches, PREG_SET_ORDER)) { |
332
|
|
|
$this->email = $email; |
333
|
|
|
$this->sha1 = sha1($email); |
334
|
|
|
} else { |
335
|
|
|
$this->email = "mailto:" . $email; |
336
|
|
|
$this->sha1 = sha1("mailto:" . $email); |
337
|
|
|
} |
338
|
|
|
} |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
public function getContent(&$exp): string |
342
|
|
|
{ |
343
|
|
|
$rdf = "<sioc:UserAccount rdf:about=\"" . clean($this->url, true) . "\">\n"; |
344
|
|
|
if ($this->nick) { |
345
|
|
|
$rdf .= " <sioc:name>" . clean($this->nick) . "</sioc:name>\n"; |
346
|
|
|
} |
347
|
|
|
if ($this->email) { |
348
|
|
|
if ($exp->_export_email) { |
349
|
|
|
$rdf .= " <sioc:email rdf:resource=\"" . $this->email . "\"/>\n"; |
350
|
|
|
} |
351
|
|
|
$rdf .= " <sioc:email_sha1>" . $this->sha1 . "</sioc:email_sha1>\n"; |
352
|
|
|
} |
353
|
|
|
if ($this->role) { |
354
|
|
|
$rdf .= " <sioc:has_function>\n"; |
355
|
|
|
$rdf .= " <sioc:Role>\n"; |
356
|
|
|
$rdf .= " <sioc:name>" . $this->role . "</sioc:name>\n"; |
357
|
|
|
$rdf .= " </sioc:Role>\n"; |
358
|
|
|
$rdf .= " </sioc:has_function>\n"; |
359
|
|
|
} |
360
|
|
|
$rdf .= " <sioc:account_of>\n"; |
361
|
|
|
$rdf .= " <foaf:Person>\n"; |
362
|
|
|
if ($this->name) { |
363
|
|
|
$rdf .= " <foaf:name>" . clean($this->name) . "</foaf:name>\n"; |
364
|
|
|
} |
365
|
|
|
if ($this->email) { |
366
|
|
|
$rdf .= " <foaf:mbox_sha1sum>" . $this->sha1 . "</foaf:mbox_sha1sum>\n"; |
367
|
|
|
} |
368
|
|
|
if ($this->foaf_url) { |
369
|
|
|
$rdf .= " <rdfs:seeAlso rdf:resource=\"" . $this->foaf_url . "\"/>\n"; |
370
|
|
|
} |
371
|
|
|
$rdf .= " </foaf:Person>\n"; |
372
|
|
|
$rdf .= " </sioc:account_of>\n"; |
373
|
|
|
//if($this->sioc_url) { $rdf .= " <rdfs:seeAlso rdf:resource=\"". $this->sioc_url ."\"/>\n"; } |
374
|
|
|
$rdf .= "</sioc:UserAccount>\n"; |
375
|
|
|
|
376
|
|
|
return $rdf; |
377
|
|
|
} |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* SIOC::DokuWikiContainer object |
382
|
|
|
* |
383
|
|
|
* Contains information about a wiki container |
384
|
|
|
*/ |
385
|
|
|
class SIOCDokuWikiContainer extends SIOCObject |
386
|
|
|
{ |
387
|
|
|
|
388
|
|
|
private $type = 'sioc:Container'; |
389
|
|
|
|
390
|
|
|
private $id = null; |
391
|
|
|
private $url = null; |
392
|
|
|
private $posts = array(); |
393
|
|
|
private $subcontainers = array(); |
394
|
|
|
private $has_parent = null; |
|
|
|
|
395
|
|
|
private $title = null; |
396
|
|
|
|
397
|
|
|
public function __construct($id, $url) |
398
|
|
|
{ |
399
|
|
|
$this->id = $id; |
400
|
|
|
$this->url = $url; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
public function isWiki() |
404
|
|
|
{ |
405
|
|
|
$this->type = 'sioct:Wiki'; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
public function addArticles($posts) |
409
|
|
|
{ |
410
|
|
|
$this->posts = $posts; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
public function addContainers($containers) |
414
|
|
|
{ |
415
|
|
|
$this->subcontainers = $containers; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
public function addTitle($title) |
419
|
|
|
{ |
420
|
|
|
$this->title = $title; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
public function addParent($id) |
424
|
|
|
{ |
425
|
|
|
$this->_has_parent = $id; |
|
|
|
|
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
public function getContent(&$exp): string |
429
|
|
|
{ |
430
|
|
|
$rdf = '<' . $this->type . " rdf:about=\"" . normalizeUri(clean($this->url, true)) . "\" >\n"; |
|
|
|
|
431
|
|
|
|
432
|
|
|
if ($this->title) { |
433
|
|
|
$rdf .= " <sioc:name>" . clean($this->title) . "</sioc:name>\n"; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
if ($this->_has_parent) { |
437
|
|
|
$rdf .= " <sioc:has_parent rdf:resource=\"" . normalizeUri( |
|
|
|
|
438
|
|
|
$exp->siocURL('container', $this->_has_parent) |
439
|
|
|
) . "\" />\n"; |
440
|
|
|
// TODO: rdfs:label |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
foreach ($this->posts as $article) { |
444
|
|
|
// TODO: test permission before? |
445
|
|
|
$rdf .= " <sioc:container_of rdf:resource=\"" . normalizeUri( |
|
|
|
|
446
|
|
|
$exp->siocURL('post', $article['id']) |
447
|
|
|
) . "\"/>\n"; |
448
|
|
|
// TODO: inluding title/name |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
foreach ($this->subcontainers as $container) { |
452
|
|
|
$rdf .= " <sioc:parent_of rdf:resource=\"" . normalizeUri( |
|
|
|
|
453
|
|
|
$exp->siocURL('container', $container['id']) |
454
|
|
|
) . "\"/>\n"; |
455
|
|
|
// TODO: inluding title/name |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
$rdf .= "</" . $this->type . ">\n"; |
459
|
|
|
return $rdf; |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.