@@ -350,10 +350,12 @@ discard block |
||
350 | 350 | // register vocabulary ids as RDF namespace prefixes |
351 | 351 | $prefix = preg_replace('/\W+/', '', $voc->getId()); // strip non-word characters |
352 | 352 | try { |
353 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
353 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
354 | + // if not already defined |
|
354 | 355 | { |
355 | 356 | EasyRdf\RdfNamespace::set($prefix, $voc->getUriSpace()); |
356 | 357 | } |
358 | + } |
|
357 | 359 | |
358 | 360 | } catch (Exception $e) { |
359 | 361 | // not valid as namespace identifier, ignore |
@@ -475,8 +477,9 @@ discard block |
||
475 | 477 | |
476 | 478 | // no preferred vocabulary, or it was not found, search in which vocabulary the concept has a label |
477 | 479 | foreach ($vocabs as $vocab) { |
478 | - if ($vocab->getConceptLabel($uri, null) !== null) |
|
479 | - return $vocab; |
|
480 | + if ($vocab->getConceptLabel($uri, null) !== null) { |
|
481 | + return $vocab; |
|
482 | + } |
|
480 | 483 | } |
481 | 484 | |
482 | 485 | // if the URI couldn't be found, fall back to the first vocabulary |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | $vocabs = $params->getVocabs(); |
223 | - $showDeprecated=false; |
|
223 | + $showDeprecated = false; |
|
224 | 224 | if (sizeof($vocabs) === 1) { // search within vocabulary |
225 | 225 | $voc = $vocabs[0]; |
226 | 226 | $sparql = $voc->getSparql(); |
227 | - $showDeprecated=$voc->getConfig()->getShowDeprecated(); |
|
227 | + $showDeprecated = $voc->getConfig()->getShowDeprecated(); |
|
228 | 228 | } else { // multi-vocabulary or global search |
229 | 229 | $voc = null; |
230 | 230 | $sparql = $this->getDefaultSparql(); |
231 | 231 | // @TODO : in a global search showDeprecated will always be false and cannot be set globally |
232 | 232 | } |
233 | 233 | |
234 | - $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params,$showDeprecated); |
|
234 | + $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params, $showDeprecated); |
|
235 | 235 | if ($params->getRest() && $results && $params->getSearchLimit() !== 0) { |
236 | 236 | $results = array_slice($results, $params->getOffset(), $params->getSearchLimit()); |
237 | 237 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | public function getVocabularyCategories() |
387 | 387 | { |
388 | 388 | $cats = $this->globalConfig->getGraph()->allOfType('skos:Concept'); |
389 | - if(empty($cats)) { |
|
389 | + if (empty($cats)) { |
|
390 | 390 | return array(new VocabularyCategory($this, null)); |
391 | 391 | } |
392 | 392 | |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | } |
470 | 470 | |
471 | 471 | // if there are multiple vocabularies and one is the preferred vocabulary, return it |
472 | - if($preferredVocabId != null) { |
|
472 | + if ($preferredVocabId != null) { |
|
473 | 473 | foreach ($vocabs as $vocab) { |
474 | - if($vocab->getId() == $preferredVocabId) { |
|
474 | + if ($vocab->getId() == $preferredVocabId) { |
|
475 | 475 | // double check that a label exists in the preferred vocabulary |
476 | 476 | if ($vocab->getConceptLabel($uri, null) !== null) { |
477 | 477 | return $vocab; |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | // using apc cache for the resource if available |
554 | 554 | if ($this->globalConfig->getCache()->isAvailable()) { |
555 | 555 | // @codeCoverageIgnoreStart |
556 | - $key = 'fetch: ' . $uri; |
|
556 | + $key = 'fetch: '.$uri; |
|
557 | 557 | $resource = $this->globalConfig->getCache()->fetch($key); |
558 | 558 | if ($resource === null || $resource === false) { // was not found in cache, or previous request failed |
559 | 559 | $resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout()); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public function getSparqlImplementation($dialect, $endpoint, $graph) |
576 | 576 | { |
577 | - $classname = $dialect . "Sparql"; |
|
577 | + $classname = $dialect."Sparql"; |
|
578 | 578 | |
579 | 579 | return new $classname($endpoint, $graph, $this); |
580 | 580 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param string $default default value |
43 | 43 | * @param string $lang preferred language for the literal |
44 | 44 | */ |
45 | - protected function getLiteral($property, $default=null, $lang=null) |
|
45 | + protected function getLiteral($property, $default = null, $lang = null) |
|
46 | 46 | { |
47 | 47 | if (!isset($lang)) {; |
48 | 48 | $lang = $this->getEnvLang(); |
@@ -55,8 +55,9 @@ |
||
55 | 55 | |
56 | 56 | // not found with selected language, try any language |
57 | 57 | $literal = $this->getResource()->getLiteral($property); |
58 | - if ($literal) |
|
59 | - return $literal->getValue(); |
|
58 | + if ($literal) { |
|
59 | + return $literal->getValue(); |
|
60 | + } |
|
60 | 61 | |
61 | 62 | return $default; |
62 | 63 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | abstract class BaseConfig extends DataObject |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Returns a boolean value based on a literal value from the config.ttl configuration. |
|
12 | - * @param string $property the property to query |
|
13 | - * @param boolean $default the default value if the value is not set in configuration |
|
14 | - */ |
|
10 | + /** |
|
11 | + * Returns a boolean value based on a literal value from the config.ttl configuration. |
|
12 | + * @param string $property the property to query |
|
13 | + * @param boolean $default the default value if the value is not set in configuration |
|
14 | + */ |
|
15 | 15 | protected function getBoolean($property, $default = false) |
16 | 16 | { |
17 | 17 | $val = $this->getResource()->getLiteral($property); |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | public function getShortName() |
59 | 59 | { |
60 | 60 | $shortname = $this->getLiteral('skosmos:shortName'); |
61 | - if ($shortname) |
|
62 | - return $shortname; |
|
61 | + if ($shortname) { |
|
62 | + return $shortname; |
|
63 | + } |
|
63 | 64 | |
64 | 65 | // if no shortname exists fall back to the id |
65 | 66 | return $this->getId(); |
@@ -194,10 +195,12 @@ discard block |
||
194 | 195 | $ret = array(); |
195 | 196 | foreach ($resources as $res) { |
196 | 197 | $prop = $res->getURI(); |
197 | - if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible |
|
198 | + if (EasyRdf\RdfNamespace::shorten($prop) !== null) { |
|
199 | + // shortening property labels if possible |
|
198 | 200 | { |
199 | 201 | $prop = EasyRdf\RdfNamespace::shorten($prop); |
200 | 202 | } |
203 | + } |
|
201 | 204 | |
202 | 205 | $ret[] = $prop; |
203 | 206 | } |
@@ -214,10 +217,12 @@ discard block |
||
214 | 217 | $resources = $this->resource->allResources("skosmos:hasMultiLingualProperty"); |
215 | 218 | foreach ($resources as $res) { |
216 | 219 | $prop = $res->getURI(); |
217 | - if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible |
|
220 | + if (EasyRdf\RdfNamespace::shorten($prop) !== null) { |
|
221 | + // shortening property labels if possible |
|
218 | 222 | { |
219 | 223 | $prop = EasyRdf\RdfNamespace::shorten($prop); |
220 | 224 | } |
225 | + } |
|
221 | 226 | |
222 | 227 | if ($prop === $property) { |
223 | 228 | return true; |
@@ -329,11 +334,12 @@ discard block |
||
329 | 334 | public function getId() |
330 | 335 | { |
331 | 336 | $uriparts = explode("#", $this->resource->getURI()); |
332 | - if (count($uriparts) != 1) |
|
333 | - // hash namespace |
|
337 | + if (count($uriparts) != 1) { |
|
338 | + // hash namespace |
|
334 | 339 | { |
335 | 340 | return $uriparts[1]; |
336 | 341 | } |
342 | + } |
|
337 | 343 | |
338 | 344 | // slash namespace |
339 | 345 | $uriparts = explode("/", $this->resource->getURI()); |
@@ -361,10 +367,12 @@ discard block |
||
361 | 367 | $ret = array(); |
362 | 368 | foreach ($resources as $res) { |
363 | 369 | $prop = $res->getURI(); |
364 | - if (EasyRdf\RdfNamespace::shorten($prop) !== null) // prefixing if possible |
|
370 | + if (EasyRdf\RdfNamespace::shorten($prop) !== null) { |
|
371 | + // prefixing if possible |
|
365 | 372 | { |
366 | 373 | $prop = EasyRdf\RdfNamespace::shorten($prop); |
367 | 374 | } |
375 | + } |
|
368 | 376 | |
369 | 377 | $ret[] = $prop; |
370 | 378 | } |
@@ -266,6 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Returns skosmos:marcSourcecode value set in config.ttl. |
269 | + * @param string $lang |
|
269 | 270 | * @return string marcsource name |
270 | 271 | */ |
271 | 272 | public function getMarcSourceCode($lang = null) |
@@ -275,7 +276,7 @@ discard block |
||
275 | 276 | |
276 | 277 | /** |
277 | 278 | * Returns a boolean value set in the config.ttl config. |
278 | - * @return array array of concept class URIs (can be empty) |
|
279 | + * @return string[] array of concept class URIs (can be empty) |
|
279 | 280 | */ |
280 | 281 | public function getIndexClasses() |
281 | 282 | { |
@@ -284,7 +285,7 @@ discard block |
||
284 | 285 | |
285 | 286 | /** |
286 | 287 | * Returns skosmos:externalProperty values set in the config.ttl config. |
287 | - * @return array array of external property URIs (can be empty) |
|
288 | + * @return string[] array of external property URIs (can be empty) |
|
288 | 289 | */ |
289 | 290 | public function getExtProperties() |
290 | 291 | { |
@@ -410,6 +411,7 @@ discard block |
||
410 | 411 | |
411 | 412 | /** |
412 | 413 | * Returns the vocabulary dc:type value(s) with their labels and uris, if set in the vocabulary configuration. |
414 | + * @param string $lang |
|
413 | 415 | * @return array of objects or an empty array |
414 | 416 | */ |
415 | 417 | public function getTypes($lang = null) |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | private $plugins; |
9 | 9 | private $languageOrderCache = array(); |
10 | 10 | |
11 | - public function __construct($resource, $globalPlugins=array()) |
|
11 | + public function __construct($resource, $globalPlugins = array()) |
|
12 | 12 | { |
13 | 13 | $this->resource = $resource; |
14 | 14 | $plugins = $this->resource->allLiterals('skosmos:usePlugin'); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $langs = $this->getLanguages(); |
37 | 37 | $deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric |
38 | 38 | if (sizeof($langs) > 1) { |
39 | - trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING); |
|
39 | + trigger_error("Default language for vocabulary '".$this->getShortName()."' unknown, choosing '$deflang'.", E_USER_WARNING); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $deflang; |
@@ -84,7 +84,7 @@ |
||
84 | 84 | foreach (explode(' ', GLOBAL_PLUGINS) as $pluginName) { |
85 | 85 | $globalPluginsArray[] = "\"$pluginName\""; |
86 | 86 | } |
87 | - $globalPlugins = " " . implode(', ', $globalPluginsArray) . " "; |
|
87 | + $globalPlugins = " ".implode(', ', $globalPluginsArray)." "; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | # print the prefixes |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param string $prop property type eg. 'rdf:type'. |
23 | 23 | * @param string $label |
24 | 24 | */ |
25 | - public function __construct($prop, $label, $super=null, $sort_by_notation=false) |
|
25 | + public function __construct($prop, $label, $super = null, $sort_by_notation = false) |
|
26 | 26 | { |
27 | 27 | $this->prop = $prop; |
28 | 28 | $this->label = $label; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function getDescription() |
63 | 63 | { |
64 | - $helpprop = $this->prop . "_help"; |
|
64 | + $helpprop = $this->prop."_help"; |
|
65 | 65 | |
66 | 66 | return gettext($helpprop); // can't use string constant, it'd be picked up by xgettext |
67 | 67 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | public function addValue($value) |
82 | 82 | { |
83 | - $this->values[$value->getNotation() . $value->getLabel() . $value->getUri()] = $value; |
|
83 | + $this->values[$value->getNotation().$value->getLabel().$value->getUri()] = $value; |
|
84 | 84 | $this->is_sorted = false; |
85 | 85 | } |
86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | if (!empty($this->values)) { |
90 | 90 | uksort($this->values, function($a, $b) { |
91 | - return $this->sort_by_notation ? strnatcasecmp($a, $b) : strcoll(strtolower($a),strtolower($b)); |
|
91 | + return $this->sort_by_notation ? strnatcasecmp($a, $b) : strcoll(strtolower($a), strtolower($b)); |
|
92 | 92 | }); |
93 | 93 | } |
94 | 94 | $this->is_sorted = true; |
@@ -517,13 +517,13 @@ |
||
517 | 517 | |
518 | 518 | $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, ''); |
519 | 519 | |
520 | - if($envLangLabels) { |
|
521 | - $proplabel = $envLangLabels[$this->getEnvLang()]; |
|
520 | + if($envLangLabels) { |
|
521 | + $proplabel = $envLangLabels[$this->getEnvLang()]; |
|
522 | 522 | } else { |
523 | - if($defaultPropLabel) { |
|
524 | - $proplabel = $defaultPropLabel['']; |
|
525 | - } |
|
526 | - } |
|
523 | + if($defaultPropLabel) { |
|
524 | + $proplabel = $defaultPropLabel['']; |
|
525 | + } |
|
526 | + } |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | // look for superproperties in the current graph |
@@ -74,6 +74,7 @@ discard block |
||
74 | 74 | * @param Vocabulary $vocab |
75 | 75 | * @param EasyRdf\Resource $resource |
76 | 76 | * @param EasyRdf\Graph $graph |
77 | + * @param string|null $clang |
|
77 | 78 | */ |
78 | 79 | public function __construct($model, $vocab, $resource, $graph, $clang) |
79 | 80 | { |
@@ -738,6 +739,7 @@ discard block |
||
738 | 739 | |
739 | 740 | /** |
740 | 741 | * Gets the groups/arrays the concept belongs to. |
742 | + * @param boolean $includeArrays |
|
741 | 743 | */ |
742 | 744 | private function getCollections($includeArrays) { |
743 | 745 | $groups = array(); |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | return $this->resource->label($fallback); |
138 | 138 | } |
139 | 139 | // We need to check all the labels in case one of them matches a subtag of the current language |
140 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
140 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
141 | 141 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
142 | - if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) { |
|
142 | + if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) { |
|
143 | 143 | return EasyRdf\Literal::create($label, $fallback); |
144 | 144 | } |
145 | 145 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | public function hasXlLabel($prop = 'prefLabel') |
162 | 162 | { |
163 | - if ($this->resource->hasProperty('skosxl:' . $prop)) { |
|
163 | + if ($this->resource->hasProperty('skosxl:'.$prop)) { |
|
164 | 164 | return true; |
165 | 165 | } |
166 | 166 | return false; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | public function getXlLabel() |
170 | 170 | { |
171 | 171 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
172 | - foreach($labels as $labres) { |
|
172 | + foreach ($labels as $labres) { |
|
173 | 173 | $label = $labres->getLiteral('skosxl:literalForm'); |
174 | 174 | if ($label !== null && $label->getLang() == $this->clang) { |
175 | 175 | return new LabelSkosXL($this->model, $labres); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | // catch external subjects that have $res as object |
277 | 277 | $extSubjects = $exGraph->resourcesMatching("schema:about", $res); |
278 | 278 | |
279 | - $propList = array_unique(array_merge( |
|
279 | + $propList = array_unique(array_merge( |
|
280 | 280 | $this->DEFAULT_EXT_PROPERTIES, |
281 | 281 | $this->getVocab()->getConfig()->getExtProperties(), |
282 | 282 | $this->getVocab()->getConfig()->getPlugins()->getExtProperties() |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param string[] $seen Processed resources so far |
302 | 302 | * @param string[] $props (optional) limit to these property URIs |
303 | 303 | */ |
304 | - private function addExternalTriplesToGraph($res, &$seen, $props=null) |
|
304 | + private function addExternalTriplesToGraph($res, &$seen, $props = null) |
|
305 | 305 | { |
306 | 306 | if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) { |
307 | 307 | return; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | private function addPropertyValues($res, $prop, &$seen) |
333 | 333 | { |
334 | - $resList = $res->allResources('<' . $prop . '>'); |
|
334 | + $resList = $res->allResources('<'.$prop.'>'); |
|
335 | 335 | |
336 | 336 | foreach ($resList as $res2) { |
337 | 337 | if ($res2->isBNode()) { |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | $this->addResourceReifications($res, $prop, $res2, $seen); |
342 | 342 | } |
343 | 343 | |
344 | - $litList = $res->allLiterals('<' . $prop . '>'); |
|
344 | + $litList = $res->allLiterals('<'.$prop.'>'); |
|
345 | 345 | |
346 | 346 | foreach ($litList as $lit) { |
347 | 347 | $this->graph->addLiteral($res, $prop, $lit); |
@@ -518,15 +518,15 @@ discard block |
||
518 | 518 | // if not found in current vocabulary, look up in the default graph to be able |
519 | 519 | // to read an ontology loaded in a separate graph |
520 | 520 | // note that this imply that the property has an rdf:type declared for the query to work |
521 | - if(!$is_well_known && !$proplabel) { |
|
521 | + if (!$is_well_known && !$proplabel) { |
|
522 | 522 | $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang()); |
523 | 523 | |
524 | 524 | $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, ''); |
525 | 525 | |
526 | - if($envLangLabels) { |
|
526 | + if ($envLangLabels) { |
|
527 | 527 | $proplabel = $envLangLabels[$this->getEnvLang()]; |
528 | 528 | } else { |
529 | - if($defaultPropLabel) { |
|
529 | + if ($defaultPropLabel) { |
|
530 | 530 | $proplabel = $defaultPropLabel['']; |
531 | 531 | } |
532 | 532 | } |
@@ -539,12 +539,12 @@ discard block |
||
539 | 539 | } |
540 | 540 | |
541 | 541 | // also look up superprops in the default graph if not found in current vocabulary |
542 | - if(!$is_well_known && (!$superprops || empty($superprops))) { |
|
542 | + if (!$is_well_known && (!$superprops || empty($superprops))) { |
|
543 | 543 | $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri); |
544 | 544 | } |
545 | 545 | |
546 | 546 | // we're reading only one super property, even if there are multiple ones |
547 | - $superprop = ($superprops)?$superprops[0]:null; |
|
547 | + $superprop = ($superprops) ? $superprops[0] : null; |
|
548 | 548 | if ($superprop) { |
549 | 549 | $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop; |
550 | 550 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | } |
558 | 558 | |
559 | 559 | // searching for subproperties of literals too |
560 | - if($superprops) { |
|
560 | + if ($superprops) { |
|
561 | 561 | foreach ($superprops as $subi) { |
562 | 562 | $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi; |
563 | 563 | $duplicates[$suburi] = $prop; |
@@ -677,14 +677,14 @@ discard block |
||
677 | 677 | |
678 | 678 | // making a human readable string from the timestamps |
679 | 679 | if ($created != '') { |
680 | - $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short')); |
|
680 | + $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short')); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | if ($modified != '') { |
684 | 684 | if ($created != '') { |
685 | - $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
685 | + $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
686 | 686 | } else { |
687 | - $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
687 | + $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | } |
@@ -692,12 +692,12 @@ discard block |
||
692 | 692 | trigger_error($e->getMessage(), E_USER_WARNING); |
693 | 693 | $ret = ''; |
694 | 694 | if ($this->resource->get('dc:modified')) { |
695 | - $modified = (string) $this->resource->get('dc:modified'); |
|
696 | - $ret = gettext('skosmos:modified') . ' ' . $modified; |
|
695 | + $modified = (string)$this->resource->get('dc:modified'); |
|
696 | + $ret = gettext('skosmos:modified').' '.$modified; |
|
697 | 697 | } |
698 | 698 | if ($this->resource->get('dc:created')) { |
699 | - $created .= (string) $this->resource->get('dc:created'); |
|
700 | - $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; |
|
699 | + $created .= (string)$this->resource->get('dc:created'); |
|
700 | + $ret .= ' '.gettext('skosmos:created').' '.$created; |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | return $ret; |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | $groups[$collLabel] = array($group); |
770 | 770 | |
771 | 771 | $res = $collection; |
772 | - while($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
772 | + while ($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
773 | 773 | foreach ($super as $res) { |
774 | 774 | $superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang); |
775 | 775 | array_unshift($groups[$collLabel], $superprop); |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | $ret = array(); |
812 | 812 | foreach ($labels as $lit) { |
813 | 813 | // filtering away subsets of the current language eg. en vs en-GB |
814 | - if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { |
|
814 | + if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { |
|
815 | 815 | $prop = in_array($lit, $prefLabels) ? 'skos:prefLabel' : 'skos:altLabel'; |
816 | 816 | $ret[$this->literalLanguageToString($lit)][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop); |
817 | 817 | } |
@@ -873,10 +873,10 @@ discard block |
||
873 | 873 | } |
874 | 874 | else if ($context[$vocabPrefix] !== $vocabUriSpace) { |
875 | 875 | $i = 2; |
876 | - while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) { |
|
876 | + while (isset($context[$vocabPrefix.$i]) && $context[$vocabPrefix.$i] !== $vocabUriSpace) { |
|
877 | 877 | $i += 1; |
878 | 878 | } |
879 | - $context[$vocabPrefix . $i] = $vocabUriSpace; |
|
879 | + $context[$vocabPrefix.$i] = $vocabUriSpace; |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | $compactJsonLD = \ML\JsonLD\JsonLD::compact($this->graph->serialise('jsonld'), json_encode($context)); |
@@ -312,8 +312,7 @@ discard block |
||
312 | 312 | foreach ($res->propertyUris() as $prop) { |
313 | 313 | $this->addPropertyValues($res, $prop, $seen); |
314 | 314 | } |
315 | - } |
|
316 | - else { |
|
315 | + } else { |
|
317 | 316 | foreach ($props as $prop) { |
318 | 317 | if ($res->hasProperty($prop)) { |
319 | 318 | $this->addPropertyValues($res, $prop, $seen); |
@@ -678,7 +677,9 @@ discard block |
||
678 | 677 | $subPrefLabelProps = $this->graph->resourcesMatching('rdfs:subPropertyOf', $prefLabelProp); |
679 | 678 | foreach ($subPrefLabelProps as $subPrefLabelProp) { |
680 | 679 | // return the first available translation |
681 | - if ($subPrefLabelProp->label($lang)) return $subPrefLabelProp->label($lang); |
|
680 | + if ($subPrefLabelProp->label($lang)) { |
|
681 | + return $subPrefLabelProp->label($lang); |
|
682 | + } |
|
682 | 683 | } |
683 | 684 | return null; |
684 | 685 | } |
@@ -909,8 +910,7 @@ discard block |
||
909 | 910 | if (!in_array($vocabUriSpace, $context, true)) { |
910 | 911 | if (!isset($context[$vocabPrefix])) { |
911 | 912 | $context[$vocabPrefix] = $vocabUriSpace; |
912 | - } |
|
913 | - else if ($context[$vocabPrefix] !== $vocabUriSpace) { |
|
913 | + } else if ($context[$vocabPrefix] !== $vocabUriSpace) { |
|
914 | 914 | $i = 2; |
915 | 915 | while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) { |
916 | 916 | $i += 1; |
@@ -30,14 +30,14 @@ |
||
30 | 30 | $url = $baseurl . "$vocid/"; |
31 | 31 | } else { |
32 | 32 | |
33 | - if ($localname !== $uri && $localname === urlencode($localname)) { |
|
34 | - // the URI can be shortened |
|
33 | + if ($localname !== $uri && $localname === urlencode($localname)) { |
|
34 | + // the URI can be shortened |
|
35 | 35 | $url = $baseurl . "$vocid/page/$localname"; |
36 | 36 | } else { |
37 | 37 | // must use full URI |
38 | - $query = http_build_query(array('uri'=>$uri)); |
|
38 | + $query = http_build_query(array('uri'=>$uri)); |
|
39 | 39 | $url = $baseurl . "$vocid/page/?" . $query; |
40 | - } |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | $this->redirect303($url); |
43 | 43 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $baseurl = $this->getBaseHref(); |
17 | 17 | $vocid = $vocab->getId(); |
18 | 18 | $query = http_build_query(array('uri'=>$uri, 'format'=>$targetFormat)); |
19 | - $url = $baseurl . "rest/v1/$vocid/data?$query"; |
|
19 | + $url = $baseurl."rest/v1/$vocid/data?$query"; |
|
20 | 20 | $this->redirect303($url); |
21 | 21 | } |
22 | 22 | |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | $localname = $vocab->getLocalName($uri); |
28 | 28 | |
29 | 29 | if (!$localname) { |
30 | - $url = $baseurl . "$vocid/"; |
|
30 | + $url = $baseurl."$vocid/"; |
|
31 | 31 | } else { |
32 | 32 | |
33 | 33 | if ($localname !== $uri && $localname === urlencode($localname)) { |
34 | 34 | // the URI can be shortened |
35 | - $url = $baseurl . "$vocid/page/$localname"; |
|
35 | + $url = $baseurl."$vocid/page/$localname"; |
|
36 | 36 | } else { |
37 | 37 | // must use full URI |
38 | 38 | $query = http_build_query(array('uri'=>$uri)); |
39 | - $url = $baseurl . "$vocid/page/?" . $query; |
|
39 | + $url = $baseurl."$vocid/page/?".$query; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | $this->redirect303($url); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | // guess vocabulary based on URI |
58 | 58 | $vocab = $this->model->guessVocabularyFromURI($request->getUri()); |
59 | 59 | if ($vocab === null) { |
60 | - return $this->returnError('404', 'Not Found', 'Unrecognized URI ' . $request->getUri()); |
|
60 | + return $this->returnError('404', 'Not Found', 'Unrecognized URI '.$request->getUri()); |
|
61 | 61 | } |
62 | 62 | $request->setVocab($vocab->getId()); |
63 | 63 | } |
@@ -169,6 +169,8 @@ |
||
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Return the mapping as a JSKOS-compatible array. |
172 | + * @param string $lang |
|
173 | + * @param string $hrefLink |
|
172 | 174 | * @return array |
173 | 175 | */ |
174 | 176 | public function asJskos($queryExVocabs = true, $lang = null, $hrefLink = null) |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $label = $this->getLabel(); |
38 | 38 | $notation = $this->getNotation(); |
39 | - return $notation . $label; |
|
39 | + return $notation.$label; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getType() |
@@ -187,42 +187,42 @@ discard block |
||
187 | 187 | 'from' => [ |
188 | 188 | 'memberSet' => [ |
189 | 189 | [ |
190 | - 'uri' => (string) $this->source->getUri(), |
|
190 | + 'uri' => (string)$this->source->getUri(), |
|
191 | 191 | ] |
192 | 192 | ] |
193 | 193 | ], |
194 | 194 | 'to' => [ |
195 | 195 | 'memberSet' => [ |
196 | 196 | [ |
197 | - 'uri' => (string) $this->getUri() |
|
197 | + 'uri' => (string)$this->getUri() |
|
198 | 198 | ] |
199 | 199 | ] |
200 | 200 | ], |
201 | 201 | // EXTRA |
202 | - 'description' => gettext($this->type . "_help"), // pop-up text |
|
202 | + 'description' => gettext($this->type."_help"), // pop-up text |
|
203 | 203 | 'hrefLink' => $hrefLink, // link to resource as displayed in the UI |
204 | 204 | 'lang' => $propertyLang, // TBD: could it be part of the prefLabel? |
205 | - 'vocabName' => (string) $this->getVocabName(), // vocabulary as displayed in the UI |
|
205 | + 'vocabName' => (string)$this->getVocabName(), // vocabulary as displayed in the UI |
|
206 | 206 | 'typeLabel' => gettext($this->type), // a text used in the UI instead of, for example, skos:closeMatch |
207 | 207 | ]; |
208 | 208 | |
209 | 209 | $fromScheme = $this->vocab->getDefaultConceptScheme(); |
210 | 210 | if (isset($fromScheme)) { |
211 | 211 | $ret['fromScheme'] = [ |
212 | - 'uri' => (string) $fromScheme, |
|
212 | + 'uri' => (string)$fromScheme, |
|
213 | 213 | ]; |
214 | 214 | } |
215 | 215 | |
216 | 216 | $exvocab = $this->getExvocab(); |
217 | 217 | if (isset($exvocab)) { |
218 | 218 | $ret['toScheme'] = [ |
219 | - 'uri' => (string) $exvocab->getDefaultConceptScheme(), |
|
219 | + 'uri' => (string)$exvocab->getDefaultConceptScheme(), |
|
220 | 220 | ]; |
221 | 221 | } |
222 | 222 | |
223 | 223 | $notation = $this->getNotation(); |
224 | 224 | if (isset($notation)) { |
225 | - $ret['to']['memberSet'][0]['notation'] = (string) $notation; |
|
225 | + $ret['to']['memberSet'][0]['notation'] = (string)$notation; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | $label = $this->getLabel($lang, $queryExVocabs); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | $localname = $vocab->getLocalName($uri); |
143 | 143 | if ($localname !== $uri && $localname === urlencode($localname)) { |
144 | 144 | // check that the prefix stripping worked, and there are no problematic chars in localname |
145 | - $paramstr = count($params) > 0 ? '?' . http_build_query($params) : ''; |
|
145 | + $paramstr = count($params) > 0 ? '?'.http_build_query($params) : ''; |
|
146 | 146 | if ($type && $type !== '' && $type !== 'vocab' && !($localname === '' && $type === 'page')) { |
147 | - return "$vocid/$lang/$type/$localname" . $paramstr; |
|
147 | + return "$vocid/$lang/$type/$localname".$paramstr; |
|
148 | 148 | } |
149 | 149 | |
150 | - return "$vocid/$lang/$localname" . $paramstr; |
|
150 | + return "$vocid/$lang/$localname".$paramstr; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // case 2: URI outside vocabulary namespace, or has problematic chars |
154 | 154 | // pass the full URI as parameter instead |
155 | 155 | $params['uri'] = $uri; |
156 | - return "$vocid/$lang/$type/?" . http_build_query($params); |
|
156 | + return "$vocid/$lang/$type/?".http_build_query($params); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | if ($modifiedDate) { |
189 | 189 | $ifModifiedSince = $this->getIfModifiedSince(); |
190 | - $this->sendHeader("Last-Modified: " . $modifiedDate->format('Y-m-d H:i:s')); |
|
190 | + $this->sendHeader("Last-Modified: ".$modifiedDate->format('Y-m-d H:i:s')); |
|
191 | 191 | if (!is_null($ifModifiedSince) && $ifModifiedSince >= $modifiedDate) { |
192 | 192 | $this->sendHeader("HTTP/1.0 304 Not Modified"); |
193 | 193 | return true; |