@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } elseif ($parts[1] == 'data') { |
| 38 | 38 | $controller->data($request); |
| 39 | 39 | } elseif (sizeof($parts) == 2) { |
| 40 | - header("Location: " . $parts[1] . "/"); |
|
| 40 | + header("Location: ".$parts[1]."/"); |
|
| 41 | 41 | } else { |
| 42 | 42 | $vocab = $parts[1]; |
| 43 | 43 | try { |
@@ -93,5 +93,5 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | } catch (Exception $e) { |
| 95 | 95 | header("HTTP/1.0 500 Internal Server Error"); |
| 96 | - echo('ERROR: ' . $e->getMessage()); |
|
| 96 | + echo('ERROR: '.$e->getMessage()); |
|
| 97 | 97 | } |
@@ -23,5 +23,5 @@ |
||
| 23 | 23 | |
| 24 | 24 | } catch (Exception $e) { |
| 25 | 25 | header("HTTP/1.0 500 Internal Server Error"); |
| 26 | - echo('ERROR: ' . $e->getMessage()); |
|
| 26 | + echo('ERROR: '.$e->getMessage()); |
|
| 27 | 27 | } |
@@ -79,10 +79,12 @@ |
||
| 79 | 79 | if ($sortable !== null) { |
| 80 | 80 | uksort($sortable, array($this, 'mycompare')); |
| 81 | 81 | foreach ($sortable as $prop => $vals) { |
| 82 | - if (is_array($prop)) // the ConceptProperty objects have their own sorting methods |
|
| 82 | + if (is_array($prop)) { |
|
| 83 | + // the ConceptProperty objects have their own sorting methods |
|
| 83 | 84 | { |
| 84 | 85 | ksort($sortable[$prop]); |
| 85 | 86 | } |
| 87 | + } |
|
| 86 | 88 | } |
| 87 | 89 | } |
| 88 | 90 | return $sortable; |
@@ -124,8 +124,8 @@ |
||
| 124 | 124 | */ |
| 125 | 125 | public function getEnvLang() |
| 126 | 126 | { |
| 127 | - // get language from locale, same as used by gettext, set by Controller |
|
| 128 | - return substr(getenv("LC_ALL"), 0, 2); // @codeCoverageIgnore |
|
| 127 | + // get language from locale, same as used by gettext, set by Controller |
|
| 128 | + return substr(getenv("LC_ALL"), 0, 2); // @codeCoverageIgnore |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return isset($results[$lang]) ? $results[$lang] : null; |
| 53 | 53 | } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
| 54 | 54 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 55 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 55 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | return isset($results) ? $results : null; |
| 75 | 75 | } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
| 76 | 76 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 77 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 77 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -400,7 +400,9 @@ discard block |
||
| 400 | 400 | $hits[] = $res; |
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | - if (sizeof($hits) > 0) return $hits; |
|
| 403 | + if (sizeof($hits) > 0) { |
|
| 404 | + return $hits; |
|
| 405 | + } |
|
| 404 | 406 | |
| 405 | 407 | // case 2: case-insensitive match on preferred label |
| 406 | 408 | foreach ($results as $res) { |
@@ -408,7 +410,9 @@ discard block |
||
| 408 | 410 | $hits[] = $res; |
| 409 | 411 | } |
| 410 | 412 | } |
| 411 | - if (sizeof($hits) > 0) return $hits; |
|
| 413 | + if (sizeof($hits) > 0) { |
|
| 414 | + return $hits; |
|
| 415 | + } |
|
| 412 | 416 | |
| 413 | 417 | if ($lang === null) { |
| 414 | 418 | // case 1A: exact match on preferred label in any language |
@@ -419,7 +423,9 @@ discard block |
||
| 419 | 423 | $hits[] = $res; |
| 420 | 424 | } |
| 421 | 425 | } |
| 422 | - if (sizeof($hits) > 0) return $hits; |
|
| 426 | + if (sizeof($hits) > 0) { |
|
| 427 | + return $hits; |
|
| 428 | + } |
|
| 423 | 429 | |
| 424 | 430 | // case 2A: case-insensitive match on preferred label in any language |
| 425 | 431 | foreach ($results as $res) { |
@@ -429,7 +435,9 @@ discard block |
||
| 429 | 435 | $hits[] = $res; |
| 430 | 436 | } |
| 431 | 437 | } |
| 432 | - if (sizeof($hits) > 0) return $hits; |
|
| 438 | + if (sizeof($hits) > 0) { |
|
| 439 | + return $hits; |
|
| 440 | + } |
|
| 433 | 441 | } |
| 434 | 442 | |
| 435 | 443 | // case 3: exact match on alternate label |
@@ -438,7 +446,9 @@ discard block |
||
| 438 | 446 | $hits[] = $res; |
| 439 | 447 | } |
| 440 | 448 | } |
| 441 | - if (sizeof($hits) > 0) return $hits; |
|
| 449 | + if (sizeof($hits) > 0) { |
|
| 450 | + return $hits; |
|
| 451 | + } |
|
| 442 | 452 | |
| 443 | 453 | |
| 444 | 454 | // case 4: case-insensitive match on alternate label |
@@ -447,7 +457,9 @@ discard block |
||
| 447 | 457 | $hits[] = $res; |
| 448 | 458 | } |
| 449 | 459 | } |
| 450 | - if (sizeof($hits) > 0) return $hits; |
|
| 460 | + if (sizeof($hits) > 0) { |
|
| 461 | + return $hits; |
|
| 462 | + } |
|
| 451 | 463 | |
| 452 | 464 | return $hits; |
| 453 | 465 | } |
@@ -575,9 +575,9 @@ discard block |
||
| 575 | 575 | $vocid = $request->getVocab()->getId(); |
| 576 | 576 | return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang"); |
| 577 | 577 | } |
| 578 | - } else { |
|
| 578 | + } else { |
|
| 579 | 579 | header("Location: " . $urls[$format]); |
| 580 | - } |
|
| 580 | + } |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | private function returnDataResults($results, $format) { |
@@ -1120,9 +1120,9 @@ discard block |
||
| 1120 | 1120 | } |
| 1121 | 1121 | return $this->returnJson(array_merge_recursive($this->context, |
| 1122 | 1122 | array('@context' => array( '@language' => $request->getLang(), |
| 1123 | - 'prefLabel' => 'skos:prefLabel', |
|
| 1124 | - 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
|
| 1125 | - 'date' => array( '@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime') ) |
|
| 1123 | + 'prefLabel' => 'skos:prefLabel', |
|
| 1124 | + 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
|
| 1125 | + 'date' => array( '@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime') ) |
|
| 1126 | 1126 | ), |
| 1127 | 1127 | array('changeList' => $simpleChangeList))); |
| 1128 | 1128 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | // wrap with JSONP callback if requested |
| 26 | 26 | if (filter_input(INPUT_GET, 'callback', FILTER_SANITIZE_FULL_SPECIAL_CHARS)) { |
| 27 | 27 | header("Content-type: application/javascript; charset=utf-8"); |
| 28 | - echo filter_input(INPUT_GET, 'callback', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_FLAG_NO_ENCODE_QUOTES) . "(" . json_encode($data) . ");"; |
|
| 28 | + echo filter_input(INPUT_GET, 'callback', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_FLAG_NO_ENCODE_QUOTES)."(".json_encode($data).");"; |
|
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | 'vocabularies' => 'onki:hasVocabulary', |
| 89 | 89 | 'id' => 'onki:vocabularyIdentifier', |
| 90 | 90 | 'uri' => '@id', |
| 91 | - '@base' => $this->getBaseHref() . "rest/v1/vocabularies", |
|
| 91 | + '@base' => $this->getBaseHref()."rest/v1/vocabularies", |
|
| 92 | 92 | ), |
| 93 | 93 | 'uri' => '', |
| 94 | 94 | 'vocabularies' => $results, |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | // convert to vocids array to support multi-vocabulary search |
| 106 | 106 | $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : array(); |
| 107 | 107 | $vocabObjects = array(); |
| 108 | - foreach($vocids as $vocid) { |
|
| 108 | + foreach ($vocids as $vocid) { |
|
| 109 | 109 | $vocabObjects[] = $this->model->getVocabulary($vocid); |
| 110 | 110 | } |
| 111 | 111 | $parameters->setVocabularies($vocabObjects); |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | foreach ($parameters->getAdditionalFields() as $field) { |
| 137 | 137 | |
| 138 | 138 | // Quick-and-dirty compactification |
| 139 | - $context[$field] = 'skos:' . $field; |
|
| 139 | + $context[$field] = 'skos:'.$field; |
|
| 140 | 140 | foreach ($results as &$result) { |
| 141 | 141 | foreach ($result as $k => $v) { |
| 142 | - if ($k == 'skos:' . $field) { |
|
| 142 | + if ($k == 'skos:'.$field) { |
|
| 143 | 143 | $result[$field] = $v; |
| 144 | - unset($result['skos:' . $field]); |
|
| 144 | + unset($result['skos:'.$field]); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | 'prefLabel' => 'skos:prefLabel', |
| 233 | 233 | 'title' => 'dct:title', |
| 234 | 234 | '@language' => $request->getLang(), |
| 235 | - '@base' => $this->getBaseHref() . "rest/v1/" . $vocab->getId() . "/", |
|
| 235 | + '@base' => $this->getBaseHref()."rest/v1/".$vocab->getId()."/", |
|
| 236 | 236 | ), |
| 237 | 237 | 'uri' => '', |
| 238 | 238 | 'id' => $vocab->getId(), |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | 'subTypes' => array('@id' => 'void:class', '@type' => '@id'), |
| 288 | 288 | 'count' => 'void:entities', |
| 289 | 289 | '@language' => $request->getLang(), |
| 290 | - '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/", |
|
| 290 | + '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/", |
|
| 291 | 291 | ), |
| 292 | 292 | 'uri' => '', |
| 293 | 293 | 'id' => $request->getVocab()->getId(), |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | 'language' => 'void-ext:language', |
| 370 | 370 | 'properties' => 'void:propertyPartition', |
| 371 | 371 | 'labels' => 'void:triples', |
| 372 | - '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/", |
|
| 372 | + '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/", |
|
| 373 | 373 | ), |
| 374 | 374 | 'uri' => '', |
| 375 | 375 | 'id' => $request->getVocab()->getId(), |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $types[] = $type; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - $base = $request->getVocab() ? $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/" : $this->getBaseHref() . "rest/v1/"; |
|
| 413 | + $base = $request->getVocab() ? $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/" : $this->getBaseHref()."rest/v1/"; |
|
| 414 | 414 | |
| 415 | 415 | $ret = array_merge_recursive($this->context, array( |
| 416 | 416 | '@context' => array( |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | if ($lang === null) { |
| 452 | 452 | // case 1A: exact match on preferred label in any language |
| 453 | 453 | foreach ($results as $res) { |
| 454 | - if (isset($res['matchedPrefLabel']) && $res['matchedPrefLabel'] == $label) { |
|
| 454 | + if (isset($res['matchedPrefLabel']) && $res['matchedPrefLabel'] == $label) { |
|
| 455 | 455 | $res['prefLabel'] = $res['matchedPrefLabel']; |
| 456 | 456 | unset($res['matchedPrefLabel']); |
| 457 | 457 | $hits[] = $res; |
@@ -573,19 +573,19 @@ discard block |
||
| 573 | 573 | |
| 574 | 574 | $format = $this->negotiateFormat(array_keys($urls), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format')); |
| 575 | 575 | if (!$format) { |
| 576 | - return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . implode(' ', array_keys($urls))); |
|
| 576 | + return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".implode(' ', array_keys($urls))); |
|
| 577 | 577 | } |
| 578 | 578 | if (is_array($urls[$format])) { |
| 579 | 579 | $arr = $urls[$format]; |
| 580 | 580 | $dataLang = $request->getLang(); |
| 581 | 581 | if (isset($arr[$dataLang])) { |
| 582 | - header("Location: " . $arr[$dataLang]); |
|
| 582 | + header("Location: ".$arr[$dataLang]); |
|
| 583 | 583 | } else { |
| 584 | 584 | $vocid = $request->getVocab()->getId(); |
| 585 | 585 | return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang"); |
| 586 | 586 | } |
| 587 | 587 | } else { |
| 588 | - header("Location: " . $urls[$format]); |
|
| 588 | + header("Location: ".$urls[$format]); |
|
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | $format = $this->negotiateFormat(explode(' ', self::SUPPORTED_FORMATS), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format')); |
| 650 | 650 | if (!$format) { |
| 651 | - return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . self::SUPPORTED_FORMATS); |
|
| 651 | + return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".self::SUPPORTED_FORMATS); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | $vocid = $vocab ? $vocab->getId() : null; |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | } |
| 934 | 934 | } |
| 935 | 935 | // if the main concept scheme was not found, set 'top' to the first 'tops' (sorted alphabetically on the URIs) |
| 936 | - if (! isset($results[$uri]['top'])) { |
|
| 936 | + if (!isset($results[$uri]['top'])) { |
|
| 937 | 937 | $results[$uri]['top'] = $results[$uri]['tops'][0]; |
| 938 | 938 | } |
| 939 | 939 | } else { |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | $changeList = $request->getVocab()->getChangeList($prop, $request->getLang(), $offset, $limit); |
| 1112 | 1112 | |
| 1113 | 1113 | $simpleChangeList = array(); |
| 1114 | - foreach($changeList as $conceptInfo) { |
|
| 1114 | + foreach ($changeList as $conceptInfo) { |
|
| 1115 | 1115 | if (array_key_exists('date', $conceptInfo)) { |
| 1116 | 1116 | $concept = array( |
| 1117 | 1117 | 'uri' => $conceptInfo['uri'], |
@@ -1127,10 +1127,10 @@ discard block |
||
| 1127 | 1127 | } |
| 1128 | 1128 | } |
| 1129 | 1129 | return $this->returnJson(array_merge_recursive($this->context, |
| 1130 | - array('@context' => array( '@language' => $request->getLang(), |
|
| 1130 | + array('@context' => array('@language' => $request->getLang(), |
|
| 1131 | 1131 | 'prefLabel' => 'skos:prefLabel', |
| 1132 | 1132 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
| 1133 | - 'date' => array( '@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime') ) |
|
| 1133 | + 'date' => array('@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime')) |
|
| 1134 | 1134 | ), |
| 1135 | 1135 | array('changeList' => $simpleChangeList))); |
| 1136 | 1136 | |
@@ -40,8 +40,7 @@ |
||
| 40 | 40 | $ret[$name] = array(); |
| 41 | 41 | if ($raw) { |
| 42 | 42 | $ret[$name] = $files[$type]; |
| 43 | - } |
|
| 44 | - else { |
|
| 43 | + } else { |
|
| 45 | 44 | foreach ($files[$type] as $file) { |
| 46 | 45 | array_push($ret[$name], 'plugins/' . $name . '/' . $file); |
| 47 | 46 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class PluginRegister { |
| 4 | 4 | private $requestedPlugins; |
| 5 | 5 | |
| 6 | - public function __construct($requestedPlugins=array()) { |
|
| 6 | + public function __construct($requestedPlugins = array()) { |
|
| 7 | 7 | $this->requestedPlugins = $requestedPlugins; |
| 8 | 8 | $this->pluginOrder = array(); |
| 9 | 9 | foreach ($this->requestedPlugins as $index => $value) { |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param boolean $raw interpret $type values as raw text instead of files |
| 46 | 46 | * @return array |
| 47 | 47 | */ |
| 48 | - private function filterPlugins($type, $raw=false) { |
|
| 48 | + private function filterPlugins($type, $raw = false) { |
|
| 49 | 49 | $plugins = $this->getPlugins(); |
| 50 | 50 | $plugins = $this->sortPlugins($plugins); |
| 51 | 51 | $ret = array(); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | else { |
| 60 | 60 | foreach ($files[$type] as $file) { |
| 61 | - array_push($ret[$name], 'plugins/' . $name . '/' . $file); |
|
| 61 | + array_push($ret[$name], 'plugins/'.$name.'/'.$file); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param array $names the plugin name strings (foldernames) in an array |
| 90 | 90 | * @return array |
| 91 | 91 | */ |
| 92 | - public function getPluginsJS($names=null) { |
|
| 92 | + public function getPluginsJS($names = null) { |
|
| 93 | 93 | if ($names) { |
| 94 | 94 | $names = array_merge($this->requestedPlugins, $names); |
| 95 | 95 | return $this->filterPluginsByName('js', $names); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @param array $names the plugin name strings (foldernames) in an array |
| 103 | 103 | * @return array |
| 104 | 104 | */ |
| 105 | - public function getPluginsCSS($names=null) { |
|
| 105 | + public function getPluginsCSS($names = null) { |
|
| 106 | 106 | if ($names) { |
| 107 | 107 | $names = array_merge($this->requestedPlugins, $names); |
| 108 | 108 | return $this->filterPluginsByName('css', $names); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param array $names the plugin name strings (foldernames) in an array |
| 116 | 116 | * @return array |
| 117 | 117 | */ |
| 118 | - public function getPluginsTemplates($names=null) { |
|
| 118 | + public function getPluginsTemplates($names = null) { |
|
| 119 | 119 | if ($names) { |
| 120 | 120 | $names = array_merge($this->requestedPlugins, $names); |
| 121 | 121 | return $this->filterPluginsByName('templates', $names); |
@@ -128,15 +128,15 @@ discard block |
||
| 128 | 128 | * @param array $names the plugin name strings (foldernames) in an array |
| 129 | 129 | * @return array |
| 130 | 130 | */ |
| 131 | - public function getTemplates($names=null) { |
|
| 131 | + public function getTemplates($names = null) { |
|
| 132 | 132 | $templateStrings = array(); |
| 133 | 133 | $plugins = $this->getPluginsTemplates($names); |
| 134 | 134 | foreach ($plugins as $folder => $templates) { |
| 135 | 135 | foreach ($templates as $path) { |
| 136 | 136 | if (file_exists($path)) { |
| 137 | 137 | $filename = explode('/', $path); |
| 138 | - $filename = $filename[sizeof($filename)-1]; |
|
| 139 | - $id = $folder . '-' . substr($filename, 0 , (strrpos($filename, "."))); |
|
| 138 | + $filename = $filename[sizeof($filename) - 1]; |
|
| 139 | + $id = $folder.'-'.substr($filename, 0, (strrpos($filename, "."))); |
|
| 140 | 140 | $templateStrings[$id] = file_get_contents($path); |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param array $names the plugin name strings (foldernames) in an array |
| 150 | 150 | * @return array |
| 151 | 151 | */ |
| 152 | - public function getPluginCallbacks($names=null) { |
|
| 152 | + public function getPluginCallbacks($names = null) { |
|
| 153 | 153 | if ($names) { |
| 154 | 154 | $names = array_merge($this->requestedPlugins, $names); |
| 155 | 155 | return $this->filterPluginsByName('callback', $names); |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | /** |
| 20 | 20 | * Wraps apc_store() and apcu_store() |
| 21 | 21 | */ |
| 22 | - public function store($key, $value, $ttl=3600) { |
|
| 22 | + public function store($key, $value, $ttl = 3600) { |
|
| 23 | 23 | if (function_exists('apcu_store')) { |
| 24 | 24 | return apcu_store($key, $value, $ttl); |
| 25 | 25 | } |
@@ -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(); |
@@ -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 |
@@ -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 |
@@ -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; |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | return $this->resource->label($fallback); |
| 143 | 143 | } |
| 144 | 144 | // We need to check all the labels in case one of them matches a subtag of the current language |
| 145 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 145 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 146 | 146 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
| 147 | - if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) { |
|
| 147 | + if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) { |
|
| 148 | 148 | return EasyRdf\Literal::create($label, $fallback); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | public function getXlLabel() |
| 173 | 173 | { |
| 174 | 174 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
| 175 | - foreach($labels as $labres) { |
|
| 175 | + foreach ($labels as $labres) { |
|
| 176 | 176 | $label = $labres->getLiteral('skosxl:literalForm'); |
| 177 | 177 | if ($label !== null && $label->getLang() == $this->clang) { |
| 178 | 178 | return new LabelSkosXL($this->model, $labres); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | // catch external subjects that have $res as object |
| 280 | 280 | $extSubjects = $exGraph->resourcesMatching("schema:about", $res); |
| 281 | 281 | |
| 282 | - $propList = array_unique(array_merge( |
|
| 282 | + $propList = array_unique(array_merge( |
|
| 283 | 283 | $this->DEFAULT_EXT_PROPERTIES, |
| 284 | 284 | $this->getVocab()->getConfig()->getExtProperties(), |
| 285 | 285 | $this->getVocab()->getConfig()->getPluginRegister()->getExtProperties() |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @param string[] $seen Processed resources so far |
| 305 | 305 | * @param string[] $props (optional) limit to these property URIs |
| 306 | 306 | */ |
| 307 | - private function addExternalTriplesToGraph($res, &$seen, $props=null) |
|
| 307 | + private function addExternalTriplesToGraph($res, &$seen, $props = null) |
|
| 308 | 308 | { |
| 309 | 309 | if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) { |
| 310 | 310 | return; |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | private function addPropertyValues($res, $prop, &$seen) |
| 336 | 336 | { |
| 337 | - $resList = $res->allResources('<' . $prop . '>'); |
|
| 337 | + $resList = $res->allResources('<'.$prop.'>'); |
|
| 338 | 338 | |
| 339 | 339 | foreach ($resList as $res2) { |
| 340 | 340 | if ($res2->isBNode()) { |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $this->addResourceReifications($res, $prop, $res2, $seen); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $litList = $res->allLiterals('<' . $prop . '>'); |
|
| 347 | + $litList = $res->allLiterals('<'.$prop.'>'); |
|
| 348 | 348 | |
| 349 | 349 | foreach ($litList as $lit) { |
| 350 | 350 | $this->graph->addLiteral($res, $prop, $lit); |
@@ -532,15 +532,15 @@ discard block |
||
| 532 | 532 | // if not found in current vocabulary, look up in the default graph to be able |
| 533 | 533 | // to read an ontology loaded in a separate graph |
| 534 | 534 | // note that this imply that the property has an rdf:type declared for the query to work |
| 535 | - if(!$is_well_known && !$proplabel) { |
|
| 535 | + if (!$is_well_known && !$proplabel) { |
|
| 536 | 536 | $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang()); |
| 537 | 537 | |
| 538 | 538 | $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, ''); |
| 539 | 539 | |
| 540 | - if($envLangLabels) { |
|
| 540 | + if ($envLangLabels) { |
|
| 541 | 541 | $proplabel = $envLangLabels[$this->getEnvLang()]; |
| 542 | 542 | } else { |
| 543 | - if($defaultPropLabel) { |
|
| 543 | + if ($defaultPropLabel) { |
|
| 544 | 544 | $proplabel = $defaultPropLabel['']; |
| 545 | 545 | } |
| 546 | 546 | } |
@@ -553,12 +553,12 @@ discard block |
||
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | // also look up superprops in the default graph if not found in current vocabulary |
| 556 | - if(!$is_well_known && (!$superprops || empty($superprops))) { |
|
| 556 | + if (!$is_well_known && (!$superprops || empty($superprops))) { |
|
| 557 | 557 | $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri); |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | // we're reading only one super property, even if there are multiple ones |
| 561 | - $superprop = ($superprops)?$superprops[0]:null; |
|
| 561 | + $superprop = ($superprops) ? $superprops[0] : null; |
|
| 562 | 562 | if ($superprop) { |
| 563 | 563 | $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop; |
| 564 | 564 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | // searching for subproperties of literals too |
| 574 | - if($superprops) { |
|
| 574 | + if ($superprops) { |
|
| 575 | 575 | foreach ($superprops as $subi) { |
| 576 | 576 | $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi; |
| 577 | 577 | $duplicates[$suburi] = $prop; |
@@ -732,14 +732,14 @@ discard block |
||
| 732 | 732 | |
| 733 | 733 | // making a human readable string from the timestamps |
| 734 | 734 | if ($created != '') { |
| 735 | - $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short', $this->getEnvLang())); |
|
| 735 | + $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short', $this->getEnvLang())); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | if ($modified != '') { |
| 739 | 739 | if ($created != '') { |
| 740 | - $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
| 740 | + $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
| 741 | 741 | } else { |
| 742 | - $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
| 742 | + $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | } |
@@ -747,12 +747,12 @@ discard block |
||
| 747 | 747 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 748 | 748 | $ret = ''; |
| 749 | 749 | if ($this->resource->get('dc:modified')) { |
| 750 | - $modified = (string) $this->resource->get('dc:modified'); |
|
| 751 | - $ret = gettext('skosmos:modified') . ' ' . $modified; |
|
| 750 | + $modified = (string)$this->resource->get('dc:modified'); |
|
| 751 | + $ret = gettext('skosmos:modified').' '.$modified; |
|
| 752 | 752 | } |
| 753 | 753 | if ($this->resource->get('dc:created')) { |
| 754 | - $created .= (string) $this->resource->get('dc:created'); |
|
| 755 | - $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; |
|
| 754 | + $created .= (string)$this->resource->get('dc:created'); |
|
| 755 | + $ret .= ' '.gettext('skosmos:created').' '.$created; |
|
| 756 | 756 | } |
| 757 | 757 | } |
| 758 | 758 | return $ret; |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | $groups[$collLabel] = array($group); |
| 825 | 825 | |
| 826 | 826 | $res = $collection; |
| 827 | - while($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
| 827 | + while ($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
| 828 | 828 | foreach ($super as $res) { |
| 829 | 829 | $superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang); |
| 830 | 830 | array_unshift($groups[$collLabel], $superprop); |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | foreach ($labels as $lit) { |
| 871 | 871 | // filtering away subsets of the current language eg. en vs en-GB |
| 872 | 872 | $langCode = strval($lit->getLang()); |
| 873 | - if ($langCode != $this->clang && strpos($langCode, $this->getEnvLang() . '-') !== 0) { |
|
| 873 | + if ($langCode != $this->clang && strpos($langCode, $this->getEnvLang().'-') !== 0) { |
|
| 874 | 874 | $ret[$langCode][$key][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop); |
| 875 | 875 | } |
| 876 | 876 | } |
@@ -961,10 +961,10 @@ discard block |
||
| 961 | 961 | } |
| 962 | 962 | else if ($context[$vocabPrefix] !== $vocabUriSpace) { |
| 963 | 963 | $i = 2; |
| 964 | - while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) { |
|
| 964 | + while (isset($context[$vocabPrefix.$i]) && $context[$vocabPrefix.$i] !== $vocabUriSpace) { |
|
| 965 | 965 | $i += 1; |
| 966 | 966 | } |
| 967 | - $context[$vocabPrefix . $i] = $vocabUriSpace; |
|
| 967 | + $context[$vocabPrefix.$i] = $vocabUriSpace; |
|
| 968 | 968 | } |
| 969 | 969 | } |
| 970 | 970 | $compactJsonLD = \ML\JsonLD\JsonLD::compact($this->graph->serialise('jsonld'), json_encode($context)); |