3 homepage: http://arc.semsol.org/
4 license: http://arc.semsol.org/license
6 class: ARC2 SG API JSON Parser
7 author: Benjamin Nowack
8 version: 2008-07-17 (Tweak: Moved re-usable code to new ARC2_JSONParser)
11 ARC2::inc('JSONParser');
13 class ARC2_SGAJSONParser extends ARC2_JSONParser {
15 function __construct($a = '', &$caller) {
16 parent::__construct($a, $caller);
19 function ARC2_SGAJSONParser($a = '', &$caller) {
20 $this->__construct($a, $caller);
23 function __init() {/* reader */
25 $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
26 $this->nsp = array($this->rdf => 'rdf');
35 function extractRDF() {
36 $s = $this->getContext();
37 $os = $this->getURLs($this->struct);
39 if ($o != $s) $this->addT($s, 'http://www.w3.org/2000/01/rdf-schema#seeAlso', $o, 'uri', 'uri');
43 function getContext() {
44 if (!isset($this->struct['canonical_mapping'])) return '';
45 foreach ($this->struct['canonical_mapping'] as $k => $v) return $v;
48 function getURLs($struct) {
50 if (is_array($struct)) {
51 foreach ($struct as $k => $v) {
52 if (preg_match('/^http:\/\//', $k) && !in_array($k, $r)) $r[] = $k;
53 $sub_r = $this->getURLs($v);
54 foreach ($sub_r as $sub_v) {
55 if (!in_array($sub_v, $r)) $r[] = $sub_v;
59 elseif (preg_match('/^http:\/\//', $struct) && !in_array($struct, $r)) {