/usr/share/php/arc/parsers/ARC2_SGAJSONParser.php is in libarc-php 2~20101006-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | <?php
/*
homepage: http://arc.semsol.org/
license: http://arc.semsol.org/license
class: ARC2 SG API JSON Parser
author: Benjamin Nowack
version: 2010-11-16
*/
ARC2::inc('JSONParser');
class ARC2_SGAJSONParser extends ARC2_JSONParser {
function __construct($a, &$caller) {
parent::__construct($a, $caller);
}
function __init() {/* reader */
parent::__init();
$this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
$this->nsp = array($this->rdf => 'rdf');
}
/* */
function done() {
$this->extractRDF();
}
function extractRDF() {
$s = $this->getContext();
$os = $this->getURLs($this->struct);
foreach ($os as $o) {
if ($o != $s) $this->addT($s, 'http://www.w3.org/2000/01/rdf-schema#seeAlso', $o, 'uri', 'uri');
}
}
function getContext() {
if (!isset($this->struct['canonical_mapping'])) return '';
foreach ($this->struct['canonical_mapping'] as $k => $v) return $v;
}
function getURLs($struct) {
$r =array();
if (is_array($struct)) {
foreach ($struct as $k => $v) {
if (preg_match('/^http:\/\//', $k) && !in_array($k, $r)) $r[] = $k;
$sub_r = $this->getURLs($v);
foreach ($sub_r as $sub_v) {
if (!in_array($sub_v, $r)) $r[] = $sub_v;
}
}
}
elseif (preg_match('/^http:\/\//', $struct) && !in_array($struct, $r)) {
$r[] = $struct;
}
return $r;
}
/* */
}
|