1 | <?php |
||
50 | class Context |
||
51 | { |
||
52 | /** |
||
53 | * Default vocabularies and their prefixes |
||
54 | * |
||
55 | * @var array |
||
56 | * @see https://www.w3.org/2011/rdfa-context/rdfa-1.1 |
||
57 | * @link https://www.w3.org/2013/json-ld-context/rdfa11 |
||
58 | */ |
||
59 | protected static $defaultVocabularies = [ |
||
60 | 'cat' => 'http://www.w3.org/ns/dcat#', |
||
61 | 'qb' => 'http://purl.org/linked-data/cube#', |
||
62 | 'grddl' => 'http://www.w3.org/2003/g/data-view#', |
||
63 | 'ma' => 'http://www.w3.org/ns/ma-ont#', |
||
64 | 'owl' => 'http://www.w3.org/2002/07/owl#', |
||
65 | 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', |
||
66 | 'rdfa' => 'http://www.w3.org/ns/rdfa#', |
||
67 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', |
||
68 | 'rif' => 'http://www.w3.org/2007/rif#', |
||
69 | 'rr' => 'http://www.w3.org/ns/r2rml#', |
||
70 | 'skos' => 'http://www.w3.org/2004/02/skos/core#', |
||
71 | 'skosxl' => 'http://www.w3.org/2008/05/skos-xl#', |
||
72 | 'wdr' => 'http://www.w3.org/2007/05/powder#', |
||
73 | 'void' => 'http://rdfs.org/ns/void#', |
||
74 | 'wdrs' => 'http://www.w3.org/2007/05/powder-s#', |
||
75 | 'xhv' => 'http://www.w3.org/1999/xhtml/vocab#', |
||
76 | 'xml' => 'http://www.w3.org/XML/1998/namespace', |
||
77 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
||
78 | 'prov' => 'http://www.w3.org/ns/prov#', |
||
79 | 'sd' => 'http://www.w3.org/ns/sparql-service-description#', |
||
80 | 'org' => 'http://www.w3.org/ns/org#', |
||
81 | 'gldp' => 'http://www.w3.org/ns/people#', |
||
82 | 'cnt' => 'http://www.w3.org/2008/content#', |
||
83 | 'dcat' => 'http://www.w3.org/ns/dcat#', |
||
84 | 'earl' => 'http://www.w3.org/ns/earl#', |
||
85 | 'ht' => 'http://www.w3.org/2006/http#', |
||
86 | 'ptr' => 'http://www.w3.org/2009/pointers#', |
||
87 | 'cc' => 'http://creativecommons.org/ns#', |
||
88 | 'ctag' => 'http://commontag.org/ns#', |
||
89 | 'dc' => 'http://purl.org/dc/terms/', |
||
90 | 'dc11' => 'http://purl.org/dc/elements/1.1/', |
||
91 | 'dcterms' => 'http://purl.org/dc/terms/', |
||
92 | 'foaf' => 'http://xmlns.com/foaf/0.1/', |
||
93 | 'gr' => 'http://purl.org/goodrelations/v1#', |
||
94 | 'ical' => 'http://www.w3.org/2002/12/cal/icaltzd#', |
||
95 | 'og' => 'http://ogp.me/ns#', |
||
96 | 'rev' => 'http://purl.org/stuff/rev#', |
||
97 | 'sioc' => 'http://rdfs.org/sioc/ns#', |
||
98 | 'v' => 'http://rdf.data-vocabulary.org/#', |
||
99 | 'vcard' => 'http://www.w3.org/2006/vcard/ns#', |
||
100 | 'schema' => 'http://schema.org/', |
||
101 | 'describedby' => 'http://www.w3.org/2007/05/powder-s#describedby', |
||
102 | 'license' => 'http://www.w3.org/1999/xhtml/vocab#license', |
||
103 | 'role' => 'http://www.w3.org/1999/xhtml/vocab#role' |
||
104 | ]; |
||
105 | |||
106 | /** |
||
107 | * Registered vocabularies |
||
108 | * |
||
109 | * @var array |
||
110 | */ |
||
111 | protected $vocabularies; |
||
112 | |||
113 | /** |
||
114 | * Current default vocabulary |
||
115 | * |
||
116 | * @var VocabularyInterface |
||
117 | */ |
||
118 | protected $defaultVocabulary = null; |
||
119 | |||
120 | /** |
||
121 | * Context constructor |
||
122 | */ |
||
123 | 6 | public function __construct() |
|
127 | |||
128 | /** |
||
129 | * Register a vocabulary and its prefix |
||
130 | * |
||
131 | * @param string $prefix Vocabulary prefix |
||
132 | * @param string $uri Vocabulary URI |
||
133 | * @return Context New context |
||
134 | * |
||
135 | */ |
||
136 | 3 | public function registerVocabulary($prefix, $uri) |
|
150 | |||
151 | /** |
||
152 | * Validata a vocabulary prefix |
||
153 | * |
||
154 | * @param string $prefix Vocabulary prefix |
||
155 | * @return string Valid vocabulary prefix |
||
156 | * @throws RuntimeException If the vocabulary prefix is invalid |
||
157 | */ |
||
158 | 5 | protected static function validateVocabPrefix($prefix) |
|
172 | |||
173 | /** |
||
174 | * Return a particular vocabulary |
||
175 | * |
||
176 | * @param string $prefix Vocabulary Prefix |
||
177 | * @return VocabularyInterface Vocabulary |
||
178 | * @throws OutOfBoundsException If the prefix has not been registered |
||
179 | */ |
||
180 | 3 | public function getVocabulary($prefix) |
|
194 | |||
195 | /** |
||
196 | * Return whether a particular vocabulary prefix has been registered |
||
197 | * |
||
198 | * @param string $prefix Vocabulary prefix |
||
199 | * @return bool Whether the prefix has been registered |
||
200 | */ |
||
201 | 2 | public function hasVocabulary($prefix) |
|
205 | |||
206 | /** |
||
207 | * Return the current default vocabulary |
||
208 | * |
||
209 | * @return VocabularyInterface Current default vocabulary |
||
210 | */ |
||
211 | 1 | public function getDefaultVocabulary() |
|
215 | |||
216 | /** |
||
217 | * Set the default vocabulary by URI |
||
218 | * |
||
219 | * @param VocabularyInterface $vocabulary Current default vocabulary |
||
220 | * @return Context Self reference |
||
221 | */ |
||
222 | 1 | public function setDefaultVocabulary(VocabularyInterface $vocabulary) |
|
227 | } |
||
228 |