@@ -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(); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $label = is_string($this->getLabel()) ? $this->getLabel() : $this->getLabel()->getValue(); |
26 | 26 | if ($this->vocab->getConfig()->sortByNotation()) { |
27 | - $label = ltrim($this->getNotation() . ' ') . $label; |
|
27 | + $label = ltrim($this->getNotation().' ').$label; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | return $label; |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | } |
48 | 48 | // We need to check all the labels in case one of them matches a subtag of the current language |
49 | 49 | if ($this->resource->allLiterals('skos:prefLabel')) { |
50 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
50 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
51 | 51 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
52 | - if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) { |
|
52 | + if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) { |
|
53 | 53 | return EasyRdf\Literal::create($label, $fallback); |
54 | 54 | } |
55 | 55 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function getReifiedPropertyValues() { |
142 | 142 | $ret = array(); |
143 | 143 | $props = $this->resource->propertyUris(); |
144 | - foreach($props as $prop) { |
|
144 | + foreach ($props as $prop) { |
|
145 | 145 | $prop = (EasyRdf\RdfNamespace::shorten($prop) !== null) ? EasyRdf\RdfNamespace::shorten($prop) : $prop; |
146 | 146 | foreach ($this->resource->allLiterals($prop) as $val) { |
147 | 147 | if ($prop !== 'rdf:value') { // shown elsewhere |
@@ -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 | } |
@@ -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) { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | // 1. Ensure characters with special meaning in Lucene are escaped |
42 | 42 | $lucenemap = array(); |
43 | 43 | foreach (str_split(self::LUCENE_ESCAPE_CHARS) as $char) { |
44 | - $lucenemap[$char] = '\\' . $char; // escape with a backslash |
|
44 | + $lucenemap[$char] = '\\'.$char; // escape with a backslash |
|
45 | 45 | } |
46 | 46 | $term = strtr($term, $lucenemap); |
47 | 47 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @return string sparql order by clause |
93 | 93 | */ |
94 | 94 | private function formatOrderBy($expression, $lang) { |
95 | - if(!$this->model->getConfig()->getCollationEnabled()) { |
|
95 | + if (!$this->model->getConfig()->getCollationEnabled()) { |
|
96 | 96 | return $expression; |
97 | 97 | } |
98 | 98 | $orderby = sprintf('arq:collation(\'%2$s\', %1$s)', $expression, $lang); |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | # make text query clause |
127 | 127 | $lcletter = mb_strtolower($letter, 'UTF-8'); // convert to lower case, UTF-8 safe |
128 | 128 | $langClause = $this->generateLangClause($lang); |
129 | - $textcondPref = $this->createTextQueryCondition($letter . '*', 'skos:prefLabel', $langClause); |
|
130 | - $textcondAlt = $this->createTextQueryCondition($letter . '*', 'skos:altLabel', $langClause); |
|
131 | - $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang) . " STR(?s) LCASE(STR(?qualifier))"; |
|
129 | + $textcondPref = $this->createTextQueryCondition($letter.'*', 'skos:prefLabel', $langClause); |
|
130 | + $textcondAlt = $this->createTextQueryCondition($letter.'*', 'skos:altLabel', $langClause); |
|
131 | + $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang)." STR(?s) LCASE(STR(?qualifier))"; |
|
132 | 132 | |
133 | - $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : ""; |
|
133 | + $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : ""; |
|
134 | 134 | |
135 | - $filterDeprecated=""; |
|
136 | - if(!$showDeprecated){ |
|
137 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
135 | + $filterDeprecated = ""; |
|
136 | + if (!$showDeprecated) { |
|
137 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $query = <<<EOQ |
@@ -156,18 +156,18 @@ discard block |
||
156 | 156 | $localname = $vocab->getLocalName($uri); |
157 | 157 | if ($localname !== $uri && $localname === urlencode($localname)) { |
158 | 158 | // check that the prefix stripping worked, and there are no problematic chars in localname |
159 | - $paramstr = count($params) > 0 ? '?' . http_build_query($params) : ''; |
|
159 | + $paramstr = count($params) > 0 ? '?'.http_build_query($params) : ''; |
|
160 | 160 | if ($type && $type !== '' && $type !== 'vocab' && !($localname === '' && $type === 'page')) { |
161 | - return "$vocid/$lang/$type/$localname" . $paramstr; |
|
161 | + return "$vocid/$lang/$type/$localname".$paramstr; |
|
162 | 162 | } |
163 | 163 | |
164 | - return "$vocid/$lang/$localname" . $paramstr; |
|
164 | + return "$vocid/$lang/$localname".$paramstr; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // case 2: URI outside vocabulary namespace, or has problematic chars |
168 | 168 | // pass the full URI as parameter instead |
169 | 169 | $params['uri'] = $uri; |
170 | - return "$vocid/$lang/$type/?" . http_build_query($params); |
|
170 | + return "$vocid/$lang/$type/?".http_build_query($params); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | { |
294 | 294 | if ($modifiedDate) { |
295 | 295 | $ifModifiedSince = $this->getIfModifiedSince(); |
296 | - $this->sendHeader("Last-Modified: " . $modifiedDate->format('D, d M Y H:i:s \G\M\T')); |
|
296 | + $this->sendHeader("Last-Modified: ".$modifiedDate->format('D, d M Y H:i:s \G\M\T')); |
|
297 | 297 | if ($ifModifiedSince !== null && $ifModifiedSince >= $modifiedDate) { |
298 | 298 | $this->sendHeader("HTTP/1.0 304 Not Modified"); |
299 | 299 | return true; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | "skos:related", "skos:historyNote", "skosmos:memberOf", |
29 | 29 | "skosmos:memberOfArray"); |
30 | 30 | |
31 | - public function __construct($resource, $globalPlugins=array()) |
|
31 | + public function __construct($resource, $globalPlugins = array()) |
|
32 | 32 | { |
33 | 33 | $this->resource = $resource; |
34 | 34 | $plugins = $this->resource->allLiterals('skosmos:usePlugin'); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $paramValue = $paramLiteral->getValue(); |
57 | 57 | $paramLang = $paramLiteral->getLang(); |
58 | 58 | if ($paramLang) { |
59 | - $paramName .= '_' . $paramLang; |
|
59 | + $paramName .= '_'.$paramLang; |
|
60 | 60 | } |
61 | 61 | $this->pluginParameters[$pluginName][$paramName] = $paramValue; |
62 | 62 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $langs = $this->getLanguages(); |
84 | 84 | $deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric |
85 | 85 | if (sizeof($langs) > 1) { |
86 | - trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING); |
|
86 | + trigger_error("Default language for vocabulary '".$this->getShortName()."' unknown, choosing '$deflang'.", E_USER_WARNING); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $deflang; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param string $super URI of superproperty |
28 | 28 | * @param boolean $sort_by_notation whether to sort the property values by their notation code |
29 | 29 | */ |
30 | - public function __construct($prop, $label, $tooltip=null, $super=null, $sort_by_notation=false) |
|
30 | + public function __construct($prop, $label, $tooltip = null, $super = null, $sort_by_notation = false) |
|
31 | 31 | { |
32 | 32 | $this->prop = $prop; |
33 | 33 | $this->label = $label; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function getDescription() |
69 | 69 | { |
70 | - $helpprop = $this->prop . "_help"; |
|
70 | + $helpprop = $this->prop."_help"; |
|
71 | 71 | |
72 | 72 | // see if we have a translation with the help text |
73 | 73 | $help = gettext($helpprop); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | public function addValue($value) |
100 | 100 | { |
101 | - $this->values[ltrim($value->getNotation() . ' ') . $value->getLabel() . rtrim(' ' . $value->getUri())] = $value; |
|
101 | + $this->values[ltrim($value->getNotation().' ').$value->getLabel().rtrim(' '.$value->getUri())] = $value; |
|
102 | 102 | $this->is_sorted = false; |
103 | 103 | } |
104 | 104 |