1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* VocabularyConfig provides access to the vocabulary configuration defined in config.ttl. |
5
|
|
|
*/ |
6
|
|
|
class VocabularyConfig extends BaseConfig |
7
|
|
|
{ |
8
|
|
|
private $pluginRegister; |
9
|
|
|
private $pluginParameters = array(); |
10
|
|
|
private $languageOrderCache = array(); |
11
|
|
|
|
12
|
|
|
const DEFAULT_PROPERTY_ORDER = array("rdf:type", "dc:isReplacedBy", |
13
|
|
|
"skos:definition", "skos:broader", "isothes:broaderGeneric", |
14
|
|
|
"isothes:broaderPartitive", "isothes:broaderInstantial", |
15
|
|
|
"skos:narrower", "isothes:narrowerGeneric", "isothes:narrowerPartitive", |
16
|
|
|
"isothes:narrowerInstantial", "skos:related", "skos:altLabel", |
17
|
|
|
"skos:note", "skos:scopeNote", "skos:historyNote", "rdfs:comment", |
18
|
|
|
"dc11:source", "dc:source", "skosmos:memberOf", "skosmos:memberOfArray"); |
19
|
|
|
|
20
|
|
|
const ISO25964_PROPERTY_ORDER = array("rdf:type", "dc:isReplacedBy", |
21
|
|
|
// ISO 25964 allows placing all text fields (inc. SN and DEF) together |
22
|
|
|
// so we will do that, except for HN, which is clearly administrative |
23
|
|
|
"skos:note", "skos:scopeNote", "skos:definition", "rdfs:comment", |
24
|
|
|
"dc11:source", "dc:source", "skos:altLabel", "skos:broader", |
25
|
|
|
"isothes:broaderGeneric", "isothes:broaderPartitive", |
26
|
|
|
"isothes:broaderInstantial", "skos:narrower", "isothes:narrowerGeneric", |
27
|
|
|
"isothes:narrowerPartitive", "isothes:narrowerInstantial", |
28
|
|
|
"skos:related", "skos:historyNote", "skosmos:memberOf", |
29
|
|
|
"skosmos:memberOfArray"); |
30
|
|
|
|
31
|
|
|
public function __construct($resource, $globalPlugins=array()) |
32
|
|
|
{ |
33
|
|
|
$this->resource = $resource; |
34
|
|
|
$this->globalPlugins = $globalPlugins; |
|
|
|
|
35
|
|
|
$this->setParameterizedPlugins(); |
36
|
|
|
$pluginArray = $this->getPluginArray(); |
37
|
|
|
$this->pluginRegister = new PluginRegister($pluginArray); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get an ordered array of plugin names with order configured in skosmos:vocabularyPlugins |
42
|
|
|
* @return array of plugin names |
43
|
|
|
*/ |
44
|
|
|
public function getPluginArray() : array |
45
|
|
|
{ |
46
|
|
|
$pluginArray = array(); |
47
|
|
|
$vocabularyPlugins = $this->resource->getResource('skosmos:vocabularyPlugins'); |
48
|
|
|
if (!$vocabularyPlugins instanceof EasyRdf\Collection) { |
49
|
|
|
$vocabularyPlugins = $this->resource->all('skosmos:vocabularyPlugins'); |
50
|
|
|
} |
51
|
|
|
if ($vocabularyPlugins) { |
52
|
|
|
foreach ($vocabularyPlugins as $plugin) { |
53
|
|
|
if ($plugin instanceof EasyRdf\Literal) { |
54
|
|
|
$pluginArray[] = $plugin->getValue(); |
55
|
|
|
} |
56
|
|
|
else { |
57
|
|
|
$pluginArray[] = $plugin->getLiteral('skosmos:usePlugin')->getValue(); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
$pluginArray = array_merge($pluginArray, $this->globalPlugins); |
62
|
|
|
|
63
|
|
|
$plugins = $this->resource->allLiterals('skosmos:usePlugin'); |
64
|
|
|
if ($plugins) { |
|
|
|
|
65
|
|
|
foreach ($plugins as $pluginlit) { |
66
|
|
|
$pluginArray[] = $pluginlit->getValue(); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
return array_values(array_unique($pluginArray)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Sets array of parameterized plugins |
74
|
|
|
* @param Easyrdf\Resource $pluginResource |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
private function setParameterizedPlugins() : void |
78
|
|
|
{ |
79
|
|
|
$this->pluginParameters = array(); |
80
|
|
|
|
81
|
|
|
$vocabularyPlugins = $this->resource->getResource('skosmos:vocabularyPlugins'); |
82
|
|
|
if (!$vocabularyPlugins instanceof EasyRdf\Collection) { |
83
|
|
|
$vocabularyPlugins = $this->resource->all('skosmos:vocabularyPlugins'); |
84
|
|
|
} |
85
|
|
|
if ($vocabularyPlugins) { |
86
|
|
|
foreach ($vocabularyPlugins as $plugin) { |
87
|
|
|
if ($plugin instanceof EasyRdf\Resource) { |
88
|
|
|
$this->setPluginParameters($plugin); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
$pluginResources = $this->resource->allResources('skosmos:useParamPlugin'); |
93
|
|
|
if ($pluginResources) { |
|
|
|
|
94
|
|
|
foreach ($pluginResources as $pluginResource) { |
95
|
|
|
$this->setPluginParameters($pluginResource); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Updates array of parameterized plugins adding parameter values |
102
|
|
|
* @param Easyrdf\Resource $pluginResource |
103
|
|
|
* @return void |
104
|
|
|
*/ |
105
|
|
|
private function setPluginParameters(Easyrdf\Resource $pluginResource) : void |
106
|
|
|
{ |
107
|
|
|
$pluginName = $pluginResource->getLiteral('skosmos:usePlugin')->getValue(); |
108
|
|
|
$this->pluginParameters[$pluginName] = array(); |
109
|
|
|
|
110
|
|
|
$pluginParams = $pluginResource->allResources('skosmos:parameters'); |
111
|
|
|
foreach ($pluginParams as $parameter) { |
112
|
|
|
|
113
|
|
|
$paramLiterals = $parameter->allLiterals('schema:value'); |
114
|
|
|
foreach ($paramLiterals as $paramLiteral) { |
115
|
|
|
$paramName = $parameter->getLiteral('schema:propertyID')->getValue(); |
116
|
|
|
$paramValue = $paramLiteral->getValue(); |
117
|
|
|
$paramLang = $paramLiteral->getLang(); |
118
|
|
|
if ($paramLang) { |
119
|
|
|
$paramName .= '_' . $paramLang; |
120
|
|
|
} |
121
|
|
|
$this->pluginParameters[$pluginName][$paramName] = $paramValue; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Get the SPARQL endpoint URL for this vocabulary |
128
|
|
|
* |
129
|
|
|
* @return string|null endpoint URL, or null if not set |
130
|
|
|
*/ |
131
|
|
|
public function getSparqlEndpoint() |
132
|
|
|
{ |
133
|
|
|
$endpoint = $this->resource->get('void:sparqlEndpoint'); |
134
|
|
|
if ($endpoint) { |
135
|
|
|
return $endpoint->getUri(); |
136
|
|
|
} |
137
|
|
|
return null; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Get the SPARQL graph URI for this vocabulary |
142
|
|
|
* |
143
|
|
|
* @return string|null graph URI, or null if not set |
144
|
|
|
*/ |
145
|
|
|
public function getSparqlGraph() |
146
|
|
|
{ |
147
|
|
|
$graph = $this->resource->get('skosmos:sparqlGraph'); |
148
|
|
|
if ($graph) { |
149
|
|
|
$graph = $graph->getUri(); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
return $graph; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Get the SPARQL dialect for this vocabulary |
157
|
|
|
* |
158
|
|
|
* @return string|null dialect name |
159
|
|
|
*/ |
160
|
|
|
public function getSparqlDialect() |
161
|
|
|
{ |
162
|
|
|
$dialect = $this->resource->get('skosmos:sparqlDialect'); |
163
|
|
|
if ($dialect) { |
164
|
|
|
$dialect = $dialect->getValue(); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
return $dialect; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Get the default language of this vocabulary |
172
|
|
|
* @return string default language, e.g. 'en' |
173
|
|
|
*/ |
174
|
|
|
|
175
|
|
|
public function getDefaultLanguage() |
176
|
|
|
{ |
177
|
|
|
$deflang = $this->resource->getLiteral('skosmos:defaultLanguage'); |
178
|
|
|
if ($deflang) { |
|
|
|
|
179
|
|
|
return $deflang->getValue(); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
$langs = $this->getLanguages(); |
183
|
|
|
$deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric |
184
|
|
|
if (sizeof($langs) > 1) { |
185
|
|
|
trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
return $deflang; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Whether the alphabetical index is small enough to be shown all at once. |
193
|
|
|
* @return boolean true if all concepts can be shown at once. |
194
|
|
|
*/ |
195
|
|
|
public function getAlphabeticalFull() |
196
|
|
|
{ |
197
|
|
|
return $this->getBoolean('skosmos:fullAlphabeticalIndex'); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Returns a short name for a vocabulary if configured. If that has not been set |
202
|
|
|
* using vocabId as a fallback. |
203
|
|
|
* @return string |
204
|
|
|
*/ |
205
|
|
|
public function getShortName() |
206
|
|
|
{ |
207
|
|
|
$shortname = $this->getLiteral('skosmos:shortName'); |
208
|
|
|
if ($shortname) |
209
|
|
|
return $shortname; |
210
|
|
|
|
211
|
|
|
// if no shortname exists fall back to the id |
212
|
|
|
return $this->getId(); |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Get the vocabulary feedback e-mail address and return it. |
217
|
|
|
* |
218
|
|
|
* @return string e-mail address or null if not defined. |
219
|
|
|
*/ |
220
|
|
|
public function getFeedbackRecipient() |
221
|
|
|
{ |
222
|
|
|
$email = $this->resource->get('skosmos:feedbackRecipient'); |
223
|
|
|
return isset($email) ? $email->getValue() : null; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Returns the human readable vocabulary title. |
228
|
|
|
* @return string the title of the vocabulary |
229
|
|
|
*/ |
230
|
|
|
public function getTitle($lang = null) |
231
|
|
|
{ |
232
|
|
|
return $this->getLiteral('dc:title', false, $lang); |
|
|
|
|
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Returns the sorting strategy for notation codes set in the config.ttl |
237
|
|
|
* config: either "lexical", "natural", or null if sorting by notations is |
238
|
|
|
* disabled. A "true" value in the configuration file is interpreted as |
239
|
|
|
* "lexical". |
240
|
|
|
* @return string|bool |
241
|
|
|
*/ |
242
|
|
|
public function getSortByNotation(): ?string |
243
|
|
|
{ |
244
|
|
|
$value = $this->getLiteral('skosmos:sortByNotation'); |
245
|
|
|
if ($value == "lexical" || $value == "natural") { |
246
|
|
|
return $value; |
247
|
|
|
} |
248
|
|
|
// not a special value - interpret as boolean instead |
249
|
|
|
$bvalue = $this->getBoolean('skosmos:sortByNotation'); |
250
|
|
|
// "true" is interpreted as "lexical" |
251
|
|
|
return $bvalue ? "lexical" : null; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* Returns a boolean value set in the config.ttl config. |
256
|
|
|
* @return boolean |
257
|
|
|
*/ |
258
|
|
|
public function showChangeList() |
259
|
|
|
{ |
260
|
|
|
return $this->getBoolean('skosmos:showChangeList'); |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* get the URLs from which the vocabulary data can be downloaded |
265
|
|
|
* @return array Array with MIME type as key, URL as value |
266
|
|
|
*/ |
267
|
|
|
public function getDataURLs() |
268
|
|
|
{ |
269
|
|
|
$ret = array(); |
270
|
|
|
$urls = $this->resource->allResources("void:dataDump"); |
271
|
|
|
foreach ($urls as $url) { |
272
|
|
|
// first try dc:format and dc11:format |
273
|
|
|
$mimetypelit = $url->getLiteral('dc:format'); |
274
|
|
|
if ($mimetypelit === null) { |
275
|
|
|
$mimetypelit = $url->getLiteral('dc11:format'); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
if ($mimetypelit !== null) { |
279
|
|
|
$mimetype = $mimetypelit->getValue(); |
280
|
|
|
} else { |
281
|
|
|
$format = EasyRdf\Format::guessFormat(null, $url->getURI()); |
282
|
|
|
if ($format === null) { |
283
|
|
|
trigger_error("Could not guess format for <$url>.", E_USER_WARNING); |
284
|
|
|
continue; |
285
|
|
|
} |
286
|
|
|
$mimetypes = array_keys($format->getMimeTypes()); |
287
|
|
|
$mimetype = $mimetypes[0]; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
$langLit = $url->getLiteral('dc:language'); |
291
|
|
|
|
292
|
|
|
if ($langLit != null) { |
293
|
|
|
//when the mimetype has language variants |
294
|
|
|
$dataUrlLang = $langLit->getValue(); |
295
|
|
|
|
296
|
|
|
if (!isset($ret[$mimetype])) { |
297
|
|
|
$arr = array(); |
298
|
|
|
} else { |
299
|
|
|
$arr = $ret[$mimetype]; |
300
|
|
|
} |
301
|
|
|
$arr[$dataUrlLang] = $url->getURI(); |
302
|
|
|
$ret[$mimetype] = $arr; |
303
|
|
|
} else { |
304
|
|
|
$ret[$mimetype] = $url->getURI(); |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
return $ret; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* Returns the main Concept Scheme URI of that Vocabulary, |
312
|
|
|
* or null if not set. |
313
|
|
|
* @return string concept scheme URI or null |
314
|
|
|
*/ |
315
|
|
|
|
316
|
|
|
public function getMainConceptSchemeURI() |
317
|
|
|
{ |
318
|
|
|
$val = $this->resource->getResource("skosmos:mainConceptScheme"); |
319
|
|
|
if ($val) { |
|
|
|
|
320
|
|
|
return $val->getURI(); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
return null; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* Returns the class URI used for concept groups in this vocabulary, |
328
|
|
|
* or null if not set. |
329
|
|
|
* @return string group class URI or null |
330
|
|
|
*/ |
331
|
|
|
|
332
|
|
|
public function getGroupClassURI() |
333
|
|
|
{ |
334
|
|
|
$val = $this->resource->getResource("skosmos:groupClass"); |
335
|
|
|
if ($val) { |
|
|
|
|
336
|
|
|
return $val->getURI(); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
return null; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* Returns the class URI used for thesaurus arrays in this vocabulary, |
344
|
|
|
* or null if not set. |
345
|
|
|
* @return string array class URI or null |
346
|
|
|
*/ |
347
|
|
|
|
348
|
|
|
public function getArrayClassURI() |
349
|
|
|
{ |
350
|
|
|
$val = $this->resource->getResource("skosmos:arrayClass"); |
351
|
|
|
if ($val) { |
|
|
|
|
352
|
|
|
return $val->getURI(); |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
return null; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Returns custom properties displayed on the search page if configured. |
360
|
|
|
* @return array array class URI or null |
361
|
|
|
*/ |
362
|
|
|
|
363
|
|
|
public function getAdditionalSearchProperties() |
364
|
|
|
{ |
365
|
|
|
$resources = $this->resource->allResources("skosmos:showPropertyInSearch"); |
366
|
|
|
$ret = array(); |
367
|
|
|
foreach ($resources as $res) { |
368
|
|
|
$prop = $res->getURI(); |
369
|
|
|
if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible |
370
|
|
|
{ |
371
|
|
|
$prop = EasyRdf\RdfNamespace::shorten($prop); |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
$ret[] = $prop; |
375
|
|
|
} |
376
|
|
|
return $ret; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Queries whether the property should be shown with all the label language variations. |
381
|
|
|
* @param string $property |
382
|
|
|
* @return boolean |
383
|
|
|
*/ |
384
|
|
|
public function hasMultiLingualProperty($property) |
385
|
|
|
{ |
386
|
|
|
$resources = $this->resource->allResources("skosmos:hasMultiLingualProperty"); |
387
|
|
|
foreach ($resources as $res) { |
388
|
|
|
$prop = $res->getURI(); |
389
|
|
|
if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible |
390
|
|
|
{ |
391
|
|
|
$prop = EasyRdf\RdfNamespace::shorten($prop); |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
if ($prop === $property) { |
395
|
|
|
return true; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
} |
399
|
|
|
return false; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* Returns a boolean value set in the config.ttl config. |
404
|
|
|
* @return boolean |
405
|
|
|
*/ |
406
|
|
|
public function getShowHierarchy() |
407
|
|
|
{ |
408
|
|
|
return $this->getBoolean('skosmos:showTopConcepts'); |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* Returns a boolean value set in the config.ttl config. |
413
|
|
|
* @return boolean |
414
|
|
|
*/ |
415
|
|
|
public function showConceptSchemesInHierarchy() |
416
|
|
|
{ |
417
|
|
|
return $this->getBoolean('skosmos:conceptSchemesInHierarchy'); |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* Returns a boolean value set in the config.ttl config. |
422
|
|
|
* @return boolean defaults to true if fetching hasn't been explicitly denied. |
423
|
|
|
*/ |
424
|
|
|
public function getExternalResourcesLoading() |
425
|
|
|
{ |
426
|
|
|
return $this->getBoolean('skosmos:loadExternalResources', true); |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Returns a boolean value set in the config.ttl config. |
431
|
|
|
* @return boolean |
432
|
|
|
*/ |
433
|
|
|
public function getShowLangCodes() |
434
|
|
|
{ |
435
|
|
|
return $this->getBoolean('skosmos:explicitLanguageTags'); |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* Returns a boolean value set in the config.ttl config. |
440
|
|
|
* @return boolean |
441
|
|
|
*/ |
442
|
|
|
public function searchByNotation() |
443
|
|
|
{ |
444
|
|
|
return $this->getBoolean('skosmos:searchByNotation'); |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Returns skosmos:marcSourcecode value set in config.ttl. |
449
|
|
|
* @return string marcsource name |
450
|
|
|
*/ |
451
|
|
|
public function getMarcSourceCode($lang = null) |
452
|
|
|
{ |
453
|
|
|
return $this->getLiteral('skosmos:marcSourceCode', false, $lang); |
|
|
|
|
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* Returns the boolean value of the skosmos:showNotationAsProperty setting. |
458
|
|
|
* @return boolean |
459
|
|
|
*/ |
460
|
|
|
public function getShowNotationAsProperty() |
461
|
|
|
{ |
462
|
|
|
return $this->getBoolean('skosmos:showNotationAsProperty', true); |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
/** |
466
|
|
|
* Returns a boolean value set in the config.ttl config. |
467
|
|
|
* @return array array of concept class URIs (can be empty) |
468
|
|
|
*/ |
469
|
|
|
public function getIndexClasses() |
470
|
|
|
{ |
471
|
|
|
return $this->getResources("skosmos:indexShowClass"); |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
/** |
475
|
|
|
* Returns skosmos:externalProperty values set in the config.ttl config. |
476
|
|
|
* @return array array of external property URIs (can be empty) |
477
|
|
|
*/ |
478
|
|
|
public function getExtProperties() |
479
|
|
|
{ |
480
|
|
|
return $this->getResources("skosmos:externalProperty"); |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
/** |
484
|
|
|
* Get the languages supported by this vocabulary |
485
|
|
|
* @return array languages supported by this vocabulary (as language tag strings) |
486
|
|
|
*/ |
487
|
|
|
public function getLanguages() |
488
|
|
|
{ |
489
|
|
|
$langs = $this->resource->allLiterals('skosmos:language'); |
490
|
|
|
$ret = array(); |
491
|
|
|
foreach ($langs as $lang) { |
492
|
|
|
$langlit = Punic\Language::getName($lang->getValue(), $this->getEnvLang()); |
493
|
|
|
$ret[$langlit] = $lang->getValue(); |
494
|
|
|
} |
495
|
|
|
ksort($ret); |
496
|
|
|
|
497
|
|
|
return $ret; |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
/** |
501
|
|
|
* Returns the parameters of parameterized plugins |
502
|
|
|
* @return array of plugin parameters |
503
|
|
|
*/ |
504
|
|
|
public function getPluginParameters() { |
505
|
|
|
return $this->pluginParameters; |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
/** |
509
|
|
|
* Returns the vocabulary default sidebar view. |
510
|
|
|
* @return string name of the view |
511
|
|
|
*/ |
512
|
|
|
public function getDefaultSidebarView() |
513
|
|
|
{ |
514
|
|
|
$defview = $this->resource->getLiteral('skosmos:defaultSidebarView'); |
515
|
|
|
if ($defview) { |
|
|
|
|
516
|
|
|
$value = $defview->getValue(); |
517
|
|
|
if ($value === 'groups' || $value === 'hierarchy') { |
518
|
|
|
return $value; |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
} |
522
|
|
|
if ($this->showAlphabeticalIndex() === false) { |
523
|
|
|
if ($this->getShowHierarchy()) { |
524
|
|
|
return 'hierarchy'; |
525
|
|
|
} else if ($this->getGroupClassURI()) { |
526
|
|
|
return 'groups'; |
527
|
|
|
} |
528
|
|
|
} |
529
|
|
|
return 'alphabetical'; // if not defined displaying the alphabetical index |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
/** |
533
|
|
|
* Extracts the vocabulary id string from the baseuri of the vocabulary. |
534
|
|
|
* @return string identifier eg. 'mesh'. |
535
|
|
|
*/ |
536
|
|
|
public function getId() |
537
|
|
|
{ |
538
|
|
|
$uriparts = explode("#", $this->resource->getURI()); |
539
|
|
|
if (count($uriparts) != 1) |
540
|
|
|
// hash namespace |
541
|
|
|
{ |
542
|
|
|
return $uriparts[1]; |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
// slash namespace |
546
|
|
|
$uriparts = explode("/", $this->resource->getURI()); |
547
|
|
|
|
548
|
|
|
return $uriparts[count($uriparts) - 1]; |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
public function getShowStatistics() { |
552
|
|
|
return $this->getBoolean('skosmos:showStatistics', true); |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
public function getPluginRegister() |
556
|
|
|
{ |
557
|
|
|
return $this->pluginRegister; |
558
|
|
|
} |
559
|
|
|
|
560
|
|
|
/** |
561
|
|
|
* Returns the property/properties used for visualizing concept hierarchies. |
562
|
|
|
* @return array array class URI or null |
563
|
|
|
*/ |
564
|
|
|
|
565
|
|
|
public function getHierarchyProperty() |
566
|
|
|
{ |
567
|
|
|
$resources = $this->resource->allResources("skosmos:hierarchyProperty"); |
568
|
|
|
$ret = array(); |
569
|
|
|
foreach ($resources as $res) { |
570
|
|
|
$prop = $res->getURI(); |
571
|
|
|
if (EasyRdf\RdfNamespace::shorten($prop) !== null) // prefixing if possible |
572
|
|
|
{ |
573
|
|
|
$prop = EasyRdf\RdfNamespace::shorten($prop); |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
$ret[] = $prop; |
577
|
|
|
} |
578
|
|
|
return empty($ret) ? array('skos:broader') : $ret; |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
/** |
582
|
|
|
* Returns a boolean value set in the config.ttl config. |
583
|
|
|
* @return boolean |
584
|
|
|
*/ |
585
|
|
|
public function showNotation() |
586
|
|
|
{ |
587
|
|
|
return $this->getBoolean('skosmos:showNotation', true); |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
/** |
591
|
|
|
* Returns a boolean value set in the config.ttl config. |
592
|
|
|
* @return boolean |
593
|
|
|
*/ |
594
|
|
|
public function showAlphabeticalIndex() |
595
|
|
|
{ |
596
|
|
|
return $this->getBoolean('skosmos:showAlphabeticalIndex', true); |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
/** |
600
|
|
|
* Returns the alphabetical list qualifier in this vocabulary, |
601
|
|
|
* or null if not set. |
602
|
|
|
* @return EasyRdf\Resource|null alphabetical list qualifier resource or null |
603
|
|
|
*/ |
604
|
|
|
public function getAlphabeticalListQualifier() |
605
|
|
|
{ |
606
|
|
|
return $this->resource->getResource('skosmos:alphabeticalListQualifier'); |
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
/** |
610
|
|
|
* Returns a boolean value set in the config.ttl config. |
611
|
|
|
* @return boolean |
612
|
|
|
*/ |
613
|
|
|
public function getShowDeprecated() |
614
|
|
|
{ |
615
|
|
|
return $this->getBoolean('skosmos:showDeprecated', false); |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* Returns the vocabulary dc:type value(s) with their labels and uris, if set in the vocabulary configuration. |
620
|
|
|
* @return array of objects or an empty array |
621
|
|
|
*/ |
622
|
|
|
public function getTypes($lang = null) |
623
|
|
|
{ |
624
|
|
|
$resources = $this->resource->allResources("dc:type"); |
625
|
|
|
$ret = array(); |
626
|
|
|
foreach ($resources as $res) { |
627
|
|
|
$prop = $res->getURI(); |
628
|
|
|
$label = $res->label($lang) ? $res->label($lang) : $res->label($this->getDefaultLanguage()); |
629
|
|
|
$ret[] = array('uri' => $prop, 'prefLabel' => $label->getValue()); |
630
|
|
|
} |
631
|
|
|
return $ret; |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
/** |
635
|
|
|
* Returns an array of fallback languages that is ordered by priority and |
636
|
|
|
* defined in the vocabulary configuration as a collection. |
637
|
|
|
* Additionally, the chosen content language is inserted with the highest priority |
638
|
|
|
* and the vocab default language is inserted with the lowest priority. |
639
|
|
|
* @param string $clang |
640
|
|
|
* @return array of language code strings |
641
|
|
|
*/ |
642
|
|
|
public function getLanguageOrder($clang) |
643
|
|
|
{ |
644
|
|
|
if (array_key_exists($clang, $this->languageOrderCache)) { |
645
|
|
|
return $this->languageOrderCache[$clang]; |
646
|
|
|
} |
647
|
|
|
$ret = array($clang); |
648
|
|
|
$fallbacks = !empty($this->resource->get('skosmos:fallbackLanguages')) ? $this->resource->get('skosmos:fallbackLanguages') : array(); |
649
|
|
|
foreach ($fallbacks as $lang) { |
650
|
|
|
if (!in_array($lang, $ret)) { |
651
|
|
|
$ret[] = (string)$lang; // Literal to string conversion |
652
|
|
|
} |
653
|
|
|
} |
654
|
|
|
if (!in_array($this->getDefaultLanguage(), $ret)) { |
655
|
|
|
$ret[] = (string)$this->getDefaultLanguage(); |
656
|
|
|
} |
657
|
|
|
foreach ($this->getLanguages() as $lang) { |
658
|
|
|
if (!in_array($lang, $ret)) { |
659
|
|
|
$ret[] = $lang; |
660
|
|
|
} |
661
|
|
|
} |
662
|
|
|
// store in cache so this doesn't have to be computed again |
663
|
|
|
$this->languageOrderCache[$clang] = $ret; |
664
|
|
|
return $ret; |
665
|
|
|
} |
666
|
|
|
|
667
|
|
|
/** |
668
|
|
|
* @return boolean |
669
|
|
|
*/ |
670
|
|
|
public function isUseModifiedDate() |
671
|
|
|
{ |
672
|
|
|
return $this->getBoolean('skosmos:useModifiedDate', false); |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
/** |
676
|
|
|
* @return array |
677
|
|
|
*/ |
678
|
|
|
public function getPropertyOrder() |
679
|
|
|
{ |
680
|
|
|
$order = $this->getResource()->getResource('skosmos:propertyOrder'); |
681
|
|
|
if ($order === null) { |
682
|
|
|
return self::DEFAULT_PROPERTY_ORDER; |
683
|
|
|
} |
684
|
|
|
|
685
|
|
|
$short = EasyRdf\RdfNamespace::shorten($order); |
686
|
|
|
if ($short == 'skosmos:iso25964PropertyOrder') { |
687
|
|
|
return self::ISO25964_PROPERTY_ORDER; |
688
|
|
|
} elseif ($short == 'skosmos:defaultPropertyOrder') { |
689
|
|
|
return self::DEFAULT_PROPERTY_ORDER; |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
// check for custom order definition |
693
|
|
|
$orderList = $order->getResource('rdf:value'); |
694
|
|
|
if ($orderList !== null && $orderList instanceof EasyRdf\Collection) { |
695
|
|
|
$ret = array(); |
696
|
|
|
foreach ($orderList as $prop) { |
697
|
|
|
$short = $prop->shorten(); |
|
|
|
|
698
|
|
|
$ret[] = ($short !== null) ? $short : $prop->getURI(); |
699
|
|
|
} |
700
|
|
|
return $ret; |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
trigger_error("Property order for vocabulary '{$this->getShortName()}' unknown, using default order", E_USER_WARNING); |
704
|
|
|
return self::DEFAULT_PROPERTY_ORDER; |
705
|
|
|
} |
706
|
|
|
} |
707
|
|
|
|