3 homepage: http://arc.semsol.org/
4 license: http://arc.semsol.org/license
6 class: ARC2 DC Extractor
7 author: Benjamin Nowack
8 version: 2008-04-09 (Fix: base URL (not doc URL) was used for annotations)
11 ARC2::inc('RDFExtractor');
13 class ARC2_DcExtractor extends ARC2_RDFExtractor {
15 function __construct($a = '', &$caller) {
16 parent::__construct($a, $caller);
19 function ARC2_DcExtractor($a = '', &$caller) {
20 $this->__construct($a, $caller);
25 $this->a['ns']['dc'] = 'http://purl.org/dc/elements/1.1/';
30 function extractRDF() {
33 foreach ($this->nodes as $n) {
34 foreach (array('title', 'link', 'meta') as $tag) {
35 if ($n['tag'] == $tag) {
36 $m = 'extract' . ucfirst($tag);
37 list ($t_vals, $t) = $this->$m($n, $t_vals, $t);
42 $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']);
43 $this->addTs(ARC2::getTriplesFromIndex($doc));
49 function extractTitle($n, $t_vals, $t) {
50 if ($t_vals['title'] = $this->getPlainContent($n)) {
51 $t .= '<' . $n['doc_url'] . '> dc:title ?title . ';
53 return array($t_vals, $t);
58 function extractLink($n, $t_vals, $t) {
59 if ($this->hasRel($n, 'alternate') || $this->hasRel($n, 'meta')) {
60 if ($href = $this->v('href uri', '', $n['a'])) {
61 $t .= '<' . $n['doc_url'] . '> rdfs:seeAlso <' . $href . '> . ';
62 if ($v = $this->v('type', '', $n['a'])) {
63 $t .= '<' .$href. '> dc:format "' . $v . '" . ';
65 if ($v = $this->v('title', '', $n['a'])) {
66 $t .= '<' .$href. '> dc:title "' . $v . '" . ';
70 return array($t_vals, $t);
73 function extractMeta($n, $t_vals, $t) {
74 if ($this->hasAttribute('http-equiv', $n, 'Content-Type') || $this->hasAttribute('http-equiv', $n, 'content-type')) {
75 if ($v = $this->v('content', '', $n['a'])) {
76 $t .= '<' . $n['doc_url'] . '> dc:format "' . $v . '" . ';
79 return array($t_vals, $t);