@@ -109,10 +109,12 @@ |
||
109 | 109 | */ |
110 | 110 | private function initializeNamespaces() { |
111 | 111 | foreach ($this->namespaces as $prefix => $fullUri) { |
112 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
112 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
113 | + // if not already defined |
|
113 | 114 | { |
114 | 115 | EasyRdf\RdfNamespace::set($prefix, $fullUri); |
115 | 116 | } |
117 | + } |
|
116 | 118 | } |
117 | 119 | } |
118 | 120 |
@@ -28,17 +28,17 @@ discard block |
||
28 | 28 | */ |
29 | 29 | private $configModifiedTime = null; |
30 | 30 | |
31 | - public function __construct($config_name='/../config.ttl') |
|
31 | + public function __construct($config_name = '/../config.ttl') |
|
32 | 32 | { |
33 | 33 | $this->cache = new Cache(); |
34 | 34 | try { |
35 | - $this->filePath = realpath( dirname(__FILE__) . $config_name ); |
|
35 | + $this->filePath = realpath(dirname(__FILE__).$config_name); |
|
36 | 36 | if (!file_exists($this->filePath)) { |
37 | 37 | throw new Exception('config.ttl file is missing, please provide one.'); |
38 | 38 | } |
39 | 39 | $this->initializeConfig(); |
40 | 40 | } catch (Exception $e) { |
41 | - echo "Error: " . $e->getMessage(); |
|
41 | + echo "Error: ".$e->getMessage(); |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | // use APC user cache to store parsed config.ttl configuration |
73 | 73 | if ($this->cache->isAvailable() && !is_null($this->configModifiedTime)) { |
74 | 74 | // @codeCoverageIgnoreStart |
75 | - $key = realpath($this->filePath) . ", " . $this->configModifiedTime; |
|
76 | - $nskey = "namespaces of " . $key; |
|
75 | + $key = realpath($this->filePath).", ".$this->configModifiedTime; |
|
76 | + $nskey = "namespaces of ".$key; |
|
77 | 77 | $this->graph = $this->cache->fetch($key); |
78 | 78 | $this->namespaces = $this->cache->fetch($nskey); |
79 | 79 | if ($this->graph === false || $this->namespaces === false) { // was not found in cache |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $this->resource = $configResources[0]; |
95 | 95 | $this->initializeNamespaces(); |
96 | 96 | } catch (Exception $e) { |
97 | - echo "Error: " . $e->getMessage(); |
|
97 | + echo "Error: ".$e->getMessage(); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | public function getGlobalPlugins() |
325 | 325 | { |
326 | 326 | $globalPlugins = array(); |
327 | - $globalPluginsResource = $this->getResource()->getResource("skosmos:globalPlugins"); |
|
327 | + $globalPluginsResource = $this->getResource()->getResource("skosmos:globalPlugins"); |
|
328 | 328 | if ($globalPluginsResource) { |
329 | 329 | foreach ($globalPluginsResource as $resource) { |
330 | 330 | $globalPlugins[] = $resource->getValue(); |
@@ -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 |
@@ -218,18 +218,18 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | $vocabs = $params->getVocabs(); |
221 | - $showDeprecated=false; |
|
221 | + $showDeprecated = false; |
|
222 | 222 | if (sizeof($vocabs) === 1) { // search within vocabulary |
223 | 223 | $voc = $vocabs[0]; |
224 | 224 | $sparql = $voc->getSparql(); |
225 | - $showDeprecated=$voc->getConfig()->getShowDeprecated(); |
|
225 | + $showDeprecated = $voc->getConfig()->getShowDeprecated(); |
|
226 | 226 | } else { // multi-vocabulary or global search |
227 | 227 | $voc = null; |
228 | 228 | $sparql = $this->getDefaultSparql(); |
229 | 229 | // @TODO : in a global search showDeprecated will always be false and cannot be set globally |
230 | 230 | } |
231 | 231 | |
232 | - $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params,$showDeprecated); |
|
232 | + $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params, $showDeprecated); |
|
233 | 233 | if ($params->getRest() && $results && $params->getSearchLimit() !== 0) { |
234 | 234 | $results = array_slice($results, $params->getOffset(), $params->getSearchLimit()); |
235 | 235 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | public function getVocabularyCategories() |
385 | 385 | { |
386 | 386 | $cats = $this->globalConfig->getGraph()->allOfType('skos:Concept'); |
387 | - if(empty($cats)) { |
|
387 | + if (empty($cats)) { |
|
388 | 388 | return array(new VocabularyCategory($this, null)); |
389 | 389 | } |
390 | 390 | |
@@ -467,9 +467,9 @@ discard block |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | // if there are multiple vocabularies and one is the preferred vocabulary, return it |
470 | - if($preferredVocabId != null) { |
|
470 | + if ($preferredVocabId != null) { |
|
471 | 471 | foreach ($vocabs as $vocab) { |
472 | - if($vocab->getId() == $preferredVocabId) { |
|
472 | + if ($vocab->getId() == $preferredVocabId) { |
|
473 | 473 | // double check that a label exists in the preferred vocabulary |
474 | 474 | if ($vocab->getConceptLabel($uri, null) !== null) { |
475 | 475 | return $vocab; |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | // using apc cache for the resource if available |
576 | 576 | if ($this->globalConfig->getCache()->isAvailable()) { |
577 | 577 | // @codeCoverageIgnoreStart |
578 | - $key = 'fetch: ' . $uri; |
|
578 | + $key = 'fetch: '.$uri; |
|
579 | 579 | $resource = $this->globalConfig->getCache()->fetch($key); |
580 | 580 | if ($resource === null || $resource === false) { // was not found in cache, or previous request failed |
581 | 581 | $resource = $this->fetchResourceFromUri($uri); |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | */ |
597 | 597 | public function getSparqlImplementation($dialect, $endpoint, $graph) |
598 | 598 | { |
599 | - $classname = $dialect . "Sparql"; |
|
599 | + $classname = $dialect."Sparql"; |
|
600 | 600 | |
601 | 601 | return new $classname($endpoint, $graph, $this); |
602 | 602 | } |
@@ -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; |
@@ -137,7 +137,7 @@ |
||
137 | 137 | { |
138 | 138 | if ($modifiedDate) { |
139 | 139 | $ifModifiedSince = $this->getIfModifiedSince(); |
140 | - $this->sendHeader("Last-Modified: " . $modifiedDate->format('Y-m-d H:i:s')); |
|
140 | + $this->sendHeader("Last-Modified: ".$modifiedDate->format('Y-m-d H:i:s')); |
|
141 | 141 | if (!is_null($ifModifiedSince) && $ifModifiedSince >= $modifiedDate) { |
142 | 142 | $this->sendHeader("HTTP/1.0 304 Not Modified"); |
143 | 143 | return true; |
@@ -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 | } |
@@ -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() |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | 'from' => [ |
179 | 179 | 'memberSet' => [ |
180 | 180 | [ |
181 | - 'uri' => (string) $this->source->getUri(), |
|
181 | + 'uri' => (string)$this->source->getUri(), |
|
182 | 182 | ] |
183 | 183 | ] |
184 | 184 | ], |
185 | 185 | 'to' => [ |
186 | 186 | 'memberSet' => [ |
187 | 187 | [ |
188 | - 'uri' => (string) $this->getUri() |
|
188 | + 'uri' => (string)$this->getUri() |
|
189 | 189 | ] |
190 | 190 | ] |
191 | 191 | ] |
@@ -194,20 +194,20 @@ discard block |
||
194 | 194 | $fromScheme = $this->vocab->getDefaultConceptScheme(); |
195 | 195 | if (isset($fromScheme)) { |
196 | 196 | $ret['fromScheme'] = [ |
197 | - 'uri' => (string) $fromScheme, |
|
197 | + 'uri' => (string)$fromScheme, |
|
198 | 198 | ]; |
199 | 199 | } |
200 | 200 | |
201 | 201 | $exvocab = $this->getExvocab(); |
202 | 202 | if (isset($exvocab)) { |
203 | 203 | $ret['toScheme'] = [ |
204 | - 'uri' => (string) $exvocab->getDefaultConceptScheme(), |
|
204 | + 'uri' => (string)$exvocab->getDefaultConceptScheme(), |
|
205 | 205 | ]; |
206 | 206 | } |
207 | 207 | |
208 | 208 | $notation = $this->getNotation(); |
209 | 209 | if (isset($notation)) { |
210 | - $ret['to']['memberSet'][0]['notation'] = (string) $notation; |
|
210 | + $ret['to']['memberSet'][0]['notation'] = (string)$notation; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | $label = $this->getLabel(null, $queryExVocabs); |