@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 |
@@ -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)); |
@@ -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 | } |
@@ -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(); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $opts = array('http' => array('method'=>'HEAD', |
| 14 | 14 | 'user_agent' => 'Skosmos', |
| 15 | 15 | 'timeout' => $timeout)); |
| 16 | - $context = stream_context_create($opts); |
|
| 16 | + $context = stream_context_create($opts); |
|
| 17 | 17 | $fd = fopen($this->uri, 'rb', false, $context); |
| 18 | 18 | $headers = stream_get_meta_data($fd)['wrapper_data']; |
| 19 | 19 | foreach ($headers as $header) { |