@@ -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(); |
@@ -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; |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | return $this->resource->label($fallback); |
137 | 137 | } |
138 | 138 | // We need to check all the labels in case one of them matches a subtag of the current language |
139 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
139 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
140 | 140 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
141 | - if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) { |
|
141 | + if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) { |
|
142 | 142 | return EasyRdf\Literal::create($label, $fallback); |
143 | 143 | } |
144 | 144 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | public function hasXlLabel($prop = 'prefLabel') |
161 | 161 | { |
162 | - if ($this->resource->hasProperty('skosxl:' . $prop)) { |
|
162 | + if ($this->resource->hasProperty('skosxl:'.$prop)) { |
|
163 | 163 | return true; |
164 | 164 | } |
165 | 165 | return false; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | public function getXlLabel() |
169 | 169 | { |
170 | 170 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
171 | - foreach($labels as $labres) { |
|
171 | + foreach ($labels as $labres) { |
|
172 | 172 | $label = $labres->getLiteral('skosxl:literalForm'); |
173 | 173 | if ($label !== null && $label->getLang() == $this->clang) { |
174 | 174 | return new LabelSkosXL($this->model, $labres); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | // catch external subjects that have $res as object |
276 | 276 | $extSubjects = $exGraph->resourcesMatching("schema:about", $res); |
277 | 277 | |
278 | - $propList = array_unique(array_merge( |
|
278 | + $propList = array_unique(array_merge( |
|
279 | 279 | $this->DEFAULT_EXT_PROPERTIES, |
280 | 280 | $this->getVocab()->getConfig()->getExtProperties(), |
281 | 281 | $this->getVocab()->getConfig()->getPlugins()->getExtProperties() |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param string[] $seen Processed resources so far |
301 | 301 | * @param string[] $props (optional) limit to these property URIs |
302 | 302 | */ |
303 | - private function addExternalTriplesToGraph($res, &$seen, $props=null) |
|
303 | + private function addExternalTriplesToGraph($res, &$seen, $props = null) |
|
304 | 304 | { |
305 | 305 | if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) { |
306 | 306 | return; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | private function addPropertyValues($res, $prop, &$seen) |
332 | 332 | { |
333 | - $resList = $res->allResources('<' . $prop . '>'); |
|
333 | + $resList = $res->allResources('<'.$prop.'>'); |
|
334 | 334 | |
335 | 335 | foreach ($resList as $res2) { |
336 | 336 | if ($res2->isBNode()) { |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $this->addResourceReifications($res, $prop, $res2, $seen); |
341 | 341 | } |
342 | 342 | |
343 | - $litList = $res->allLiterals('<' . $prop . '>'); |
|
343 | + $litList = $res->allLiterals('<'.$prop.'>'); |
|
344 | 344 | |
345 | 345 | foreach ($litList as $lit) { |
346 | 346 | $this->graph->addLiteral($res, $prop, $lit); |
@@ -528,15 +528,15 @@ discard block |
||
528 | 528 | // if not found in current vocabulary, look up in the default graph to be able |
529 | 529 | // to read an ontology loaded in a separate graph |
530 | 530 | // note that this imply that the property has an rdf:type declared for the query to work |
531 | - if(!$is_well_known && !$proplabel) { |
|
531 | + if (!$is_well_known && !$proplabel) { |
|
532 | 532 | $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang()); |
533 | 533 | |
534 | 534 | $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, ''); |
535 | 535 | |
536 | - if($envLangLabels) { |
|
536 | + if ($envLangLabels) { |
|
537 | 537 | $proplabel = $envLangLabels[$this->getEnvLang()]; |
538 | 538 | } else { |
539 | - if($defaultPropLabel) { |
|
539 | + if ($defaultPropLabel) { |
|
540 | 540 | $proplabel = $defaultPropLabel['']; |
541 | 541 | } |
542 | 542 | } |
@@ -549,12 +549,12 @@ discard block |
||
549 | 549 | } |
550 | 550 | |
551 | 551 | // also look up superprops in the default graph if not found in current vocabulary |
552 | - if(!$is_well_known && (!$superprops || empty($superprops))) { |
|
552 | + if (!$is_well_known && (!$superprops || empty($superprops))) { |
|
553 | 553 | $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri); |
554 | 554 | } |
555 | 555 | |
556 | 556 | // we're reading only one super property, even if there are multiple ones |
557 | - $superprop = ($superprops)?$superprops[0]:null; |
|
557 | + $superprop = ($superprops) ? $superprops[0] : null; |
|
558 | 558 | if ($superprop) { |
559 | 559 | $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop; |
560 | 560 | } |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | } |
568 | 568 | |
569 | 569 | // searching for subproperties of literals too |
570 | - if($superprops) { |
|
570 | + if ($superprops) { |
|
571 | 571 | foreach ($superprops as $subi) { |
572 | 572 | $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi; |
573 | 573 | $duplicates[$suburi] = $prop; |
@@ -729,14 +729,14 @@ discard block |
||
729 | 729 | |
730 | 730 | // making a human readable string from the timestamps |
731 | 731 | if ($created != '') { |
732 | - $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short', $this->getEnvLang())); |
|
732 | + $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short', $this->getEnvLang())); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | if ($modified != '') { |
736 | 736 | if ($created != '') { |
737 | - $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
737 | + $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
738 | 738 | } else { |
739 | - $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
739 | + $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | } |
@@ -744,12 +744,12 @@ discard block |
||
744 | 744 | trigger_error($e->getMessage(), E_USER_WARNING); |
745 | 745 | $ret = ''; |
746 | 746 | if ($this->resource->get('dc:modified')) { |
747 | - $modified = (string) $this->resource->get('dc:modified'); |
|
748 | - $ret = gettext('skosmos:modified') . ' ' . $modified; |
|
747 | + $modified = (string)$this->resource->get('dc:modified'); |
|
748 | + $ret = gettext('skosmos:modified').' '.$modified; |
|
749 | 749 | } |
750 | 750 | if ($this->resource->get('dc:created')) { |
751 | - $created .= (string) $this->resource->get('dc:created'); |
|
752 | - $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; |
|
751 | + $created .= (string)$this->resource->get('dc:created'); |
|
752 | + $ret .= ' '.gettext('skosmos:created').' '.$created; |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | return $ret; |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | $groups[$collLabel] = array($group); |
822 | 822 | |
823 | 823 | $res = $collection; |
824 | - while($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
824 | + while ($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
825 | 825 | foreach ($super as $res) { |
826 | 826 | $superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang); |
827 | 827 | array_unshift($groups[$collLabel], $superprop); |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | |
867 | 867 | foreach ($labels as $lit) { |
868 | 868 | // filtering away subsets of the current language eg. en vs en-GB |
869 | - if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { |
|
869 | + if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { |
|
870 | 870 | $langCode = $lit->getLang() ? $lit->getLang() : ''; |
871 | 871 | $ret[$langCode][$key][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop); |
872 | 872 | } |
@@ -957,10 +957,10 @@ discard block |
||
957 | 957 | } |
958 | 958 | else if ($context[$vocabPrefix] !== $vocabUriSpace) { |
959 | 959 | $i = 2; |
960 | - while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) { |
|
960 | + while (isset($context[$vocabPrefix.$i]) && $context[$vocabPrefix.$i] !== $vocabUriSpace) { |
|
961 | 961 | $i += 1; |
962 | 962 | } |
963 | - $context[$vocabPrefix . $i] = $vocabUriSpace; |
|
963 | + $context[$vocabPrefix.$i] = $vocabUriSpace; |
|
964 | 964 | } |
965 | 965 | } |
966 | 966 | $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 | } |
@@ -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 ltrim($notation . ' ') . $label; |
|
39 | + return ltrim($notation.' ').$label; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getType() |
@@ -180,25 +180,25 @@ discard block |
||
180 | 180 | 'from' => [ |
181 | 181 | 'memberSet' => [ |
182 | 182 | [ |
183 | - 'uri' => (string) $this->source->getUri(), |
|
183 | + 'uri' => (string)$this->source->getUri(), |
|
184 | 184 | ] |
185 | 185 | ] |
186 | 186 | ], |
187 | 187 | 'to' => [ |
188 | 188 | 'memberSet' => [ |
189 | 189 | [ |
190 | - 'uri' => (string) $this->getUri() |
|
190 | + 'uri' => (string)$this->getUri() |
|
191 | 191 | ] |
192 | 192 | ] |
193 | 193 | ], |
194 | 194 | // EXTRA |
195 | 195 | 'hrefLink' => $hrefLink, // link to resource as displayed in the UI |
196 | 196 | 'lang' => $propertyLang, // TBD: could it be part of the prefLabel? |
197 | - 'vocabName' => (string) $this->getVocabName(), // vocabulary as displayed in the UI |
|
197 | + 'vocabName' => (string)$this->getVocabName(), // vocabulary as displayed in the UI |
|
198 | 198 | 'typeLabel' => gettext($this->type), // a text used in the UI instead of, for example, skos:closeMatch |
199 | 199 | ]; |
200 | 200 | |
201 | - $helpprop = $this->type . "_help"; |
|
201 | + $helpprop = $this->type."_help"; |
|
202 | 202 | // see if we have a translation for the property help text |
203 | 203 | $help = gettext($helpprop); |
204 | 204 | if ($help != $helpprop) { |
@@ -208,20 +208,20 @@ discard block |
||
208 | 208 | $fromScheme = $this->vocab->getDefaultConceptScheme(); |
209 | 209 | if (isset($fromScheme)) { |
210 | 210 | $ret['fromScheme'] = [ |
211 | - 'uri' => (string) $fromScheme, |
|
211 | + 'uri' => (string)$fromScheme, |
|
212 | 212 | ]; |
213 | 213 | } |
214 | 214 | |
215 | 215 | $exvocab = $this->getExvocab(); |
216 | 216 | if (isset($exvocab)) { |
217 | 217 | $ret['toScheme'] = [ |
218 | - 'uri' => (string) $exvocab->getDefaultConceptScheme(), |
|
218 | + 'uri' => (string)$exvocab->getDefaultConceptScheme(), |
|
219 | 219 | ]; |
220 | 220 | } |
221 | 221 | |
222 | 222 | $notation = $this->getNotation(); |
223 | 223 | if (isset($notation)) { |
224 | - $ret['to']['memberSet'][0]['notation'] = (string) $notation; |
|
224 | + $ret['to']['memberSet'][0]['notation'] = (string)$notation; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | $label = $this->getLabel($lang, $queryExVocabs); |
@@ -23,6 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Initializes the Model object. |
26 | + * @param Model $model |
|
26 | 27 | */ |
27 | 28 | public function __construct($model) |
28 | 29 | { |
@@ -290,7 +291,7 @@ discard block |
||
290 | 291 | * Sends HTTP headers. Simply calls PHP built-in header function. But being |
291 | 292 | * a function here, it can easily be tested/mocked. |
292 | 293 | * |
293 | - * @param $header string header to be sent |
|
294 | + * @param string $header string header to be sent |
|
294 | 295 | */ |
295 | 296 | protected function sendHeader($header) |
296 | 297 | { |
@@ -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; |
@@ -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 |
@@ -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) { |
@@ -33,16 +33,16 @@ |
||
33 | 33 | // Encrypt the current time |
34 | 34 | $honey_time_encrypted = $this->getEncryptedTime(); |
35 | 35 | return '<div id="' . $honey_name . '_wrap" style="display:none;">' . "\r\n" . |
36 | - '<input name="' . $honey_name . '" type="text" value="" id="' . $honey_name . '"/>' . "\r\n" . |
|
37 | - '<input name="' . $honey_time . '" type="text" value="' . $honey_time_encrypted . '"/>' . "\r\n" . |
|
36 | + '<input name="' . $honey_name . '" type="text" value="" id="' . $honey_name . '"/>' . "\r\n" . |
|
37 | + '<input name="' . $honey_time . '" type="text" value="' . $honey_time_encrypted . '"/>' . "\r\n" . |
|
38 | 38 | '</div>'; |
39 | 39 | } |
40 | 40 | /** |
41 | - * Validate honeypot is empty |
|
42 | - * |
|
43 | - * @param mixed $value |
|
44 | - * @return boolean |
|
45 | - */ |
|
41 | + * Validate honeypot is empty |
|
42 | + * |
|
43 | + * @param mixed $value |
|
44 | + * @return boolean |
|
45 | + */ |
|
46 | 46 | public function validateHoneypot($value) |
47 | 47 | { |
48 | 48 | if ($this->disabled) { |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | { |
33 | 33 | // Encrypt the current time |
34 | 34 | $honey_time_encrypted = $this->getEncryptedTime(); |
35 | - return '<div id="' . $honey_name . '_wrap" style="display:none;">' . "\r\n" . |
|
36 | - '<input name="' . $honey_name . '" type="text" value="" id="' . $honey_name . '"/>' . "\r\n" . |
|
37 | - '<input name="' . $honey_time . '" type="text" value="' . $honey_time_encrypted . '"/>' . "\r\n" . |
|
35 | + return '<div id="'.$honey_name.'_wrap" style="display:none;">'."\r\n". |
|
36 | + '<input name="'.$honey_name.'" type="text" value="" id="'.$honey_name.'"/>'."\r\n". |
|
37 | + '<input name="'.$honey_time.'" type="text" value="'.$honey_time_encrypted.'"/>'."\r\n". |
|
38 | 38 | '</div>'; |
39 | 39 | } |
40 | 40 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // Get the decrypted time |
67 | 67 | $value = $this->decryptTime($value); |
68 | 68 | // The current time should be greater than the time the form was built + the speed option |
69 | - return ( is_numeric($value) && time() > ($value + $parameters[0]) ); |
|
69 | + return (is_numeric($value) && time() > ($value + $parameters[0])); |
|
70 | 70 | } |
71 | 71 | /** |
72 | 72 | * Get encrypted time |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Returns the graph instance |
155 | - * @return object EasyRDF graph instance. |
|
155 | + * @return string|null EasyRDF graph instance. |
|
156 | 156 | */ |
157 | 157 | public function getGraph() { |
158 | 158 | return $this->graph; |
@@ -287,6 +287,7 @@ discard block |
||
287 | 287 | /** |
288 | 288 | * Counts the number of concepts in a easyRDF graph with a specific language. |
289 | 289 | * @param array $langs Languages to query for |
290 | + * @param string[] $classes |
|
290 | 291 | * @return Array containing count of concepts for each language and property. |
291 | 292 | */ |
292 | 293 | public function countLangConcepts($langs, $classes = null) { |
@@ -471,7 +472,7 @@ discard block |
||
471 | 472 | * Returns information (as a graph) for one or more concept URIs |
472 | 473 | * @param mixed $uris concept URI (string) or array of URIs |
473 | 474 | * @param string|null $arrayClass the URI for thesaurus array class, or null if not used |
474 | - * @param \Vocabulary[]|null $vocabs vocabularies to target |
|
475 | + * @param Vocabulary[] $vocabs vocabularies to target |
|
475 | 476 | * @return \EasyRdf\Graph |
476 | 477 | */ |
477 | 478 | public function queryConceptInfoGraph($uris, $arrayClass = null, $vocabs = array()) { |
@@ -487,7 +488,7 @@ discard block |
||
487 | 488 | |
488 | 489 | /** |
489 | 490 | * Returns information (as an array of Concept objects) for one or more concept URIs |
490 | - * @param mixed $uris concept URI (string) or array of URIs |
|
491 | + * @param string $uris concept URI (string) or array of URIs |
|
491 | 492 | * @param string|null $arrayClass the URI for thesaurus array class, or null if not used |
492 | 493 | * @param \Vocabulary[] $vocabs vocabularies to target |
493 | 494 | * @param string|null $clang content language |
@@ -705,7 +706,7 @@ discard block |
||
705 | 706 | |
706 | 707 | /** |
707 | 708 | * Generate a VALUES clause for limiting the targeted graphs. |
708 | - * @param Vocabulary[]|null $vocabs array of Vocabulary objects to target |
|
709 | + * @param Vocabulary[] $vocabs array of Vocabulary objects to target |
|
709 | 710 | * @return string VALUES clause, or "" if not necessary to limit |
710 | 711 | */ |
711 | 712 | protected function formatValuesGraph($vocabs) { |
@@ -887,6 +888,7 @@ discard block |
||
887 | 888 | * @param string $searchLang language code used for matching labels (null means any language) |
888 | 889 | * @param string[] $props properties to target e.g. array('skos:prefLabel','skos:altLabel') |
889 | 890 | * @param boolean $unique restrict results to unique concepts (default: false) |
891 | + * @param string $filterGraph |
|
890 | 892 | * @return string sparql query |
891 | 893 | */ |
892 | 894 | protected function generateConceptSearchQueryInner($term, $lang, $searchLang, $props, $unique, $filterGraph) |
@@ -1161,6 +1163,7 @@ discard block |
||
1161 | 1163 | /** |
1162 | 1164 | * Generates sparql query clauses used for creating the alphabetical index. |
1163 | 1165 | * @param string $letter the letter (or special class) to search for |
1166 | + * @param string $lang |
|
1164 | 1167 | * @return array of sparql query clause strings |
1165 | 1168 | */ |
1166 | 1169 | private function formatFilterConditions($letter, $lang) { |
@@ -1328,6 +1331,7 @@ discard block |
||
1328 | 1331 | /** |
1329 | 1332 | * Query for the first characters (letter or otherwise) of the labels in the particular language. |
1330 | 1333 | * @param string $lang language |
1334 | + * @param string[] $classes |
|
1331 | 1335 | * @return array array of characters |
1332 | 1336 | */ |
1333 | 1337 | public function queryFirstCharacters($lang, $classes = null) { |
@@ -1650,7 +1654,7 @@ discard block |
||
1650 | 1654 | /** |
1651 | 1655 | * Query a single transitive property of a concept. |
1652 | 1656 | * @param string $uri |
1653 | - * @param array $props the property/properties. |
|
1657 | + * @param string[] $props the property/properties. |
|
1654 | 1658 | * @param string $lang |
1655 | 1659 | * @param string $fallbacklang language to use if label is not available in the preferred language |
1656 | 1660 | * @param integer $limit |
@@ -47,12 +47,16 @@ discard block |
||
47 | 47 | $this->client = new EasyRdf\Sparql\Client($endpoint); |
48 | 48 | |
49 | 49 | // set graphClause so that it can be used by all queries |
50 | - if ($this->isDefaultEndpoint()) // default endpoint; query any graph (and catch it in a variable) |
|
50 | + if ($this->isDefaultEndpoint()) { |
|
51 | + // default endpoint; query any graph (and catch it in a variable) |
|
51 | 52 | { |
52 | 53 | $this->graphClause = "GRAPH $graph"; |
53 | - } elseif ($graph !== null) // query a specific graph |
|
54 | + } |
|
55 | + } elseif ($graph !== null) { |
|
56 | + // query a specific graph |
|
54 | 57 | { |
55 | 58 | $this->graphClause = "GRAPH <$graph>"; |
59 | + } |
|
56 | 60 | } else // query the default graph |
57 | 61 | { |
58 | 62 | $this->graphClause = ""; |
@@ -1274,8 +1278,7 @@ discard block |
||
1274 | 1278 | if (isset($row->qualifier)) { |
1275 | 1279 | if ($row->qualifier instanceof EasyRdf\Literal) { |
1276 | 1280 | $hit['qualifier'] = $row->qualifier->getValue(); |
1277 | - } |
|
1278 | - else { |
|
1281 | + } else { |
|
1279 | 1282 | $hit['qualifier'] = $row->qualifier->localName(); |
1280 | 1283 | } |
1281 | 1284 | } |
@@ -1955,8 +1958,7 @@ discard block |
||
1955 | 1958 | if (sizeof($ret) > 0) { |
1956 | 1959 | // existing concept, with children |
1957 | 1960 | return $ret; |
1958 | - } |
|
1959 | - else { |
|
1961 | + } else { |
|
1960 | 1962 | // nonexistent concept |
1961 | 1963 | return null; |
1962 | 1964 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param string $query |
67 | 67 | * @return string |
68 | - */ |
|
68 | + */ |
|
69 | 69 | protected function generateQueryPrefixes($query) |
70 | 70 | { |
71 | 71 | // Check for undefined prefixes |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | $gcl = $this->graphClause; |
234 | 234 | $classes = ($classes) ? $classes : array('http://www.w3.org/2004/02/skos/core#Concept'); |
235 | 235 | |
236 | - $quote_string = function($val) { return "'$val'"; }; |
|
237 | - $quoted_values = array_map($quote_string, $langs); |
|
238 | - $langFilter = "FILTER(?lang IN (" . implode(',', $quoted_values) . "))"; |
|
236 | + $quote_string = function($val) { return "'$val'"; }; |
|
237 | + $quoted_values = array_map($quote_string, $langs); |
|
238 | + $langFilter = "FILTER(?lang IN (" . implode(',', $quoted_values) . "))"; |
|
239 | 239 | |
240 | 240 | $values = $this->formatValues('?type', $classes, 'uri'); |
241 | 241 | $valuesProp = $this->formatValues('?prop', $props, null); |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | return $query; |
952 | 952 | } |
953 | 953 | /** |
954 | - * This function can be overwritten in other SPARQL dialects for the possibility of handling the differenc language clauses |
|
954 | + * This function can be overwritten in other SPARQL dialects for the possibility of handling the differenc language clauses |
|
955 | 955 | * @param string $lang |
956 | 956 | * @return string formatted language clause |
957 | 957 | */ |
@@ -1845,7 +1845,7 @@ discard block |
||
1845 | 1845 | |
1846 | 1846 | /** |
1847 | 1847 | * Generates a sparql query for finding the hierarchy for a concept. |
1848 | - * A concept may be a top concept in multiple schemes, returned as a single whitespace-separated literal. |
|
1848 | + * A concept may be a top concept in multiple schemes, returned as a single whitespace-separated literal. |
|
1849 | 1849 | * @param string $uri concept uri. |
1850 | 1850 | * @param string $lang |
1851 | 1851 | * @param string $fallback language to use if label is not available in the preferred language |
@@ -1922,10 +1922,10 @@ discard block |
||
1922 | 1922 | $ret[$uri]['exact'] = $row->exact->getUri(); |
1923 | 1923 | } |
1924 | 1924 | if (isset($row->tops)) { |
1925 | - $topConceptsList=explode(" ", $row->tops->getValue()); |
|
1926 | - // sort to garantee an alphabetical ordering of the URI |
|
1927 | - sort($topConceptsList); |
|
1928 | - $ret[$uri]['tops'] = $topConceptsList; |
|
1925 | + $topConceptsList=explode(" ", $row->tops->getValue()); |
|
1926 | + // sort to garantee an alphabetical ordering of the URI |
|
1927 | + sort($topConceptsList); |
|
1928 | + $ret[$uri]['tops'] = $topConceptsList; |
|
1929 | 1929 | } |
1930 | 1930 | if (isset($row->children)) { |
1931 | 1931 | if (!isset($ret[$uri]['narrower'])) { |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | protected function query($query) { |
89 | 89 | $queryId = sprintf("%05d", rand(0, 99999)); |
90 | 90 | $logger = $this->model->getLogger(); |
91 | - $logger->info("[qid $queryId] SPARQL query:\n" . $this->generateQueryPrefixes($query) . "\n$query\n"); |
|
91 | + $logger->info("[qid $queryId] SPARQL query:\n".$this->generateQueryPrefixes($query)."\n$query\n"); |
|
92 | 92 | $starttime = microtime(true); |
93 | 93 | $result = $this->client->query($query); |
94 | 94 | $elapsed = intval(round((microtime(true) - $starttime) * 1000)); |
95 | - if(method_exists($result, 'numRows')) { |
|
95 | + if (method_exists($result, 'numRows')) { |
|
96 | 96 | $numRows = $result->numRows(); |
97 | 97 | $logger->info("[qid $queryId] result: $numRows rows returned in $elapsed ms"); |
98 | 98 | } else { // graph result |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param Vocabulary[]|null $vocabs |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - protected function generateFromClause($vocabs=null) { |
|
111 | + protected function generateFromClause($vocabs = null) { |
|
112 | 112 | $clause = ''; |
113 | 113 | if (!$vocabs) { |
114 | 114 | return $this->graph !== '?graph' && $this->graph !== NULL ? "FROM <$this->graph>" : ''; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $quote_string = function($val) { return "'$val'"; }; |
237 | 237 | $quoted_values = array_map($quote_string, $langs); |
238 | - $langFilter = "FILTER(?lang IN (" . implode(',', $quoted_values) . "))"; |
|
238 | + $langFilter = "FILTER(?lang IN (".implode(',', $quoted_values)."))"; |
|
239 | 239 | |
240 | 240 | $values = $this->formatValues('?type', $classes, 'uri'); |
241 | 241 | $valuesProp = $this->formatValues('?prop', $props, null); |
@@ -661,9 +661,9 @@ discard block |
||
661 | 661 | $conceptscheme['title'] = $row->title->getValue(); |
662 | 662 | } |
663 | 663 | // add dct:subject and their labels in the result |
664 | - if(isset($row->domain) && isset($row->domainLabel)){ |
|
665 | - $conceptscheme['subject']['uri']=$row->domain->getURI(); |
|
666 | - $conceptscheme['subject']['prefLabel']=$row->domainLabel->getValue(); |
|
664 | + if (isset($row->domain) && isset($row->domainLabel)) { |
|
665 | + $conceptscheme['subject']['uri'] = $row->domain->getURI(); |
|
666 | + $conceptscheme['subject']['prefLabel'] = $row->domainLabel->getValue(); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | $ret[$row->cs->getURI()] = $conceptscheme; |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | $values[] = "<$graph>"; |
731 | 731 | } |
732 | 732 | if (count($values)) { |
733 | - return "FILTER (?graph IN (" . implode(',', $values) . "))"; |
|
733 | + return "FILTER (?graph IN (".implode(',', $values)."))"; |
|
734 | 734 | } |
735 | 735 | } |
736 | 736 | |
@@ -741,16 +741,16 @@ discard block |
||
741 | 741 | * @return string sparql query clauses |
742 | 742 | */ |
743 | 743 | protected function formatLimitAndOffset($limit, $offset) { |
744 | - $limit = ($limit) ? 'LIMIT ' . $limit : ''; |
|
745 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
744 | + $limit = ($limit) ? 'LIMIT '.$limit : ''; |
|
745 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
746 | 746 | // eliminating whitespace and line changes when the conditions aren't needed. |
747 | 747 | $limitandoffset = ''; |
748 | 748 | if ($limit && $offset) { |
749 | - $limitandoffset = "\n" . $limit . "\n" . $offset; |
|
749 | + $limitandoffset = "\n".$limit."\n".$offset; |
|
750 | 750 | } elseif ($limit) { |
751 | - $limitandoffset = "\n" . $limit; |
|
751 | + $limitandoffset = "\n".$limit; |
|
752 | 752 | } elseif ($offset) { |
753 | - $limitandoffset = "\n" . $offset; |
|
753 | + $limitandoffset = "\n".$offset; |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | return $limitandoffset; |
@@ -902,14 +902,14 @@ discard block |
||
902 | 902 | // if search language and UI/display language differ, must also consider case where there is no prefLabel in |
903 | 903 | // the display language; in that case, should use the label with the same language as the matched label |
904 | 904 | $labelcondFallback = ($searchLang != $lang) ? |
905 | - "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" . |
|
905 | + "OPTIONAL { # in case previous OPTIONAL block gives no labels\n". |
|
906 | 906 | "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : ""; |
907 | 907 | |
908 | 908 | // Including the labels if there is no query term given. |
909 | 909 | if ($rawterm === '') { |
910 | 910 | $labelClause = "?s skos:prefLabel ?label ."; |
911 | - $labelClause = ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . ""; |
|
912 | - return $labelClause . " BIND(?label AS ?match)"; |
|
911 | + $labelClause = ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause.""; |
|
912 | + return $labelClause." BIND(?label AS ?match)"; |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | /* |
@@ -981,20 +981,20 @@ discard block |
||
981 | 981 | $schemecond = ''; |
982 | 982 | if (!empty($schemes)) { |
983 | 983 | $conditions = array(); |
984 | - foreach($schemes as $scheme) { |
|
984 | + foreach ($schemes as $scheme) { |
|
985 | 985 | $conditions[] = "{?s skos:inScheme <$scheme>}"; |
986 | 986 | } |
987 | - $schemecond = '{'.implode(" UNION ",$conditions).'}'; |
|
987 | + $schemecond = '{'.implode(" UNION ", $conditions).'}'; |
|
988 | 988 | } |
989 | - $filterDeprecated=""; |
|
989 | + $filterDeprecated = ""; |
|
990 | 990 | //show or hide deprecated concepts |
991 | - if(!$showDeprecated){ |
|
992 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
991 | + if (!$showDeprecated) { |
|
992 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
993 | 993 | } |
994 | 994 | // extra conditions for parent and group, if specified |
995 | - $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : ""; |
|
996 | - $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : ""; |
|
997 | - $pgcond = $parentcond . $groupcond; |
|
995 | + $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : ""; |
|
996 | + $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : ""; |
|
997 | + $pgcond = $parentcond.$groupcond; |
|
998 | 998 | |
999 | 999 | $orderextra = $this->isDefaultEndpoint() ? $this->graph : ''; |
1000 | 1000 | |
@@ -1080,9 +1080,9 @@ discard block |
||
1080 | 1080 | $hit['type'][] = $this->shortenUri($typeuri); |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - if(!empty($fields)) { |
|
1083 | + if (!empty($fields)) { |
|
1084 | 1084 | foreach ($fields as $prop) { |
1085 | - $propname = $prop . 's'; |
|
1085 | + $propname = $prop.'s'; |
|
1086 | 1086 | if (isset($row->$propname)) { |
1087 | 1087 | foreach (explode("\n", $row->$propname->getValue()) as $line) { |
1088 | 1088 | $rdata = str_getcsv($line, ',', '"', '"'); |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $propvals = $rdata[2]; |
1098 | 1098 | } |
1099 | 1099 | |
1100 | - $hit['skos:' . $prop][] = $propvals; |
|
1100 | + $hit['skos:'.$prop][] = $propvals; |
|
1101 | 1101 | } |
1102 | 1102 | } |
1103 | 1103 | } |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | * @return array query result object |
1174 | 1174 | */ |
1175 | 1175 | public function queryConcepts($vocabs, $fields = null, $unique = false, $params, $showDeprecated = false) { |
1176 | - $query = $this->generateConceptSearchQuery($fields, $unique, $params,$showDeprecated); |
|
1176 | + $query = $this->generateConceptSearchQuery($fields, $unique, $params, $showDeprecated); |
|
1177 | 1177 | $results = $this->query($query); |
1178 | 1178 | return $this->transformConceptSearchResults($results, $vocabs, $fields); |
1179 | 1179 | } |
@@ -1228,10 +1228,10 @@ discard block |
||
1228 | 1228 | $conditions = $this->formatFilterConditions($letter, $lang); |
1229 | 1229 | $filtercondLabel = $conditions['filterpref']; |
1230 | 1230 | $filtercondALabel = $conditions['filteralt']; |
1231 | - $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : ""; |
|
1232 | - $filterDeprecated=""; |
|
1233 | - if(!$showDeprecated){ |
|
1234 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
1231 | + $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : ""; |
|
1232 | + $filterDeprecated = ""; |
|
1233 | + if (!$showDeprecated) { |
|
1234 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
1235 | 1235 | } |
1236 | 1236 | $query = <<<EOQ |
1237 | 1237 | SELECT DISTINCT ?s ?label ?alabel ?qualifier $fcl |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | if (!isset($row->label) || $row->label->getLang() === $lang) { |
1702 | 1702 | $ret[$row->object->getUri()] = $val; |
1703 | 1703 | } elseif ($row->label->getLang() === $fallbacklang) { |
1704 | - $val['label'] .= ' (' . $row->label->getLang() . ')'; |
|
1704 | + $val['label'] .= ' ('.$row->label->getLang().')'; |
|
1705 | 1705 | $ret[$row->object->getUri()] = $val; |
1706 | 1706 | } |
1707 | 1707 | } |
@@ -1797,10 +1797,10 @@ discard block |
||
1797 | 1797 | |
1798 | 1798 | $label = null; |
1799 | 1799 | if (isset($row->label)) { |
1800 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
1800 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
1801 | 1801 | $label = $row->label->getValue(); |
1802 | 1802 | } else { |
1803 | - $label = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
1803 | + $label = $row->label->getValue()." (".$row->label->getLang().")"; |
|
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | } |
@@ -1876,8 +1876,8 @@ discard block |
||
1876 | 1876 | foreach ($result as $row) { |
1877 | 1877 | if (isset($row->top) && isset($row->label)) { |
1878 | 1878 | $label = $row->label->getValue(); |
1879 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
1880 | - $label .= ' (' . $row->label->getLang() . ')'; |
|
1879 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
1880 | + $label .= ' ('.$row->label->getLang().')'; |
|
1881 | 1881 | } |
1882 | 1882 | $top = array('uri' => $row->top->getUri(), 'topConceptOf' => $row->topuri->getUri(), 'label' => $label, 'hasChildren' => filter_var($row->children->getValue(), FILTER_VALIDATE_BOOLEAN)); |
1883 | 1883 | if (isset($row->notation)) { |
@@ -1970,7 +1970,7 @@ discard block |
||
1970 | 1970 | $ret[$uri]['exact'] = $row->exact->getUri(); |
1971 | 1971 | } |
1972 | 1972 | if (isset($row->tops)) { |
1973 | - $topConceptsList=explode(" ", $row->tops->getValue()); |
|
1973 | + $topConceptsList = explode(" ", $row->tops->getValue()); |
|
1974 | 1974 | // sort to garantee an alphabetical ordering of the URI |
1975 | 1975 | sort($topConceptsList); |
1976 | 1976 | $ret[$uri]['tops'] = $topConceptsList; |
@@ -1983,8 +1983,8 @@ discard block |
||
1983 | 1983 | $label = null; |
1984 | 1984 | if (isset($row->childlabel)) { |
1985 | 1985 | $label = $row->childlabel->getValue(); |
1986 | - if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang . "-") !== 0) { |
|
1987 | - $label .= " (" . $row->childlabel->getLang() . ")"; |
|
1986 | + if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang."-") !== 0) { |
|
1987 | + $label .= " (".$row->childlabel->getLang().")"; |
|
1988 | 1988 | } |
1989 | 1989 | |
1990 | 1990 | } |
@@ -2005,8 +2005,8 @@ discard block |
||
2005 | 2005 | } |
2006 | 2006 | if (isset($row->label)) { |
2007 | 2007 | $preflabel = $row->label->getValue(); |
2008 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
2009 | - $preflabel .= ' (' . $row->label->getLang() . ')'; |
|
2008 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
2009 | + $preflabel .= ' ('.$row->label->getLang().')'; |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | $ret[$uri]['prefLabel'] = $preflabel; |
@@ -2127,9 +2127,9 @@ discard block |
||
2127 | 2127 | */ |
2128 | 2128 | private function generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated = false) { |
2129 | 2129 | $fcl = $this->generateFromClause(); |
2130 | - $filterDeprecated=""; |
|
2131 | - if(!$showDeprecated){ |
|
2132 | - $filterDeprecated=" FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
2130 | + $filterDeprecated = ""; |
|
2131 | + if (!$showDeprecated) { |
|
2132 | + $filterDeprecated = " FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
2133 | 2133 | } |
2134 | 2134 | $query = <<<EOQ |
2135 | 2135 | SELECT ?conc ?super ?label ?members ?type ?notation $fcl |
@@ -2168,10 +2168,10 @@ discard block |
||
2168 | 2168 | 'type' => array($row->type->shorten()), |
2169 | 2169 | ); |
2170 | 2170 | if (isset($row->label)) { |
2171 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
2171 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
2172 | 2172 | $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue(); |
2173 | 2173 | } else { |
2174 | - $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
2174 | + $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")"; |
|
2175 | 2175 | } |
2176 | 2176 | |
2177 | 2177 | } |
@@ -2199,8 +2199,8 @@ discard block |
||
2199 | 2199 | * @param boolean $showDeprecated whether to include deprecated concepts in search results |
2200 | 2200 | * @return array Result array with concept URI as key and concept label as value |
2201 | 2201 | */ |
2202 | - public function listConceptGroupContents($groupClass, $group, $lang,$showDeprecated = false) { |
|
2203 | - $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang,$showDeprecated); |
|
2202 | + public function listConceptGroupContents($groupClass, $group, $lang, $showDeprecated = false) { |
|
2203 | + $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated); |
|
2204 | 2204 | $result = $this->query($query); |
2205 | 2205 | return $this->transformConceptGroupContentsResults($result, $lang); |
2206 | 2206 | } |
@@ -2213,9 +2213,9 @@ discard block |
||
2213 | 2213 | * @param int $limit maximum number of results to return |
2214 | 2214 | * @return string sparql query |
2215 | 2215 | */ |
2216 | - private function generateChangeListQuery($prop, $lang, $offset, $limit=200) { |
|
2216 | + private function generateChangeListQuery($prop, $lang, $offset, $limit = 200) { |
|
2217 | 2217 | $fcl = $this->generateFromClause(); |
2218 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
2218 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
2219 | 2219 | |
2220 | 2220 | $query = <<<EOQ |
2221 | 2221 | SELECT DISTINCT ?concept ?date ?label $fcl |
@@ -99,17 +99,14 @@ |
||
99 | 99 | return strcoll(strtolower($a->getLabel()), strtolower($b->getLabel())); |
100 | 100 | } |
101 | 101 | return 1; |
102 | - } |
|
103 | - else if ($bnot == null) { |
|
102 | + } else if ($bnot == null) { |
|
104 | 103 | return -1; |
105 | - } |
|
106 | - else { |
|
104 | + } else { |
|
107 | 105 | // assume that notations are unique |
108 | 106 | return strnatcasecmp($anot, $bnot); |
109 | 107 | } |
110 | 108 | }); |
111 | - } |
|
112 | - else { |
|
109 | + } else { |
|
113 | 110 | uasort($this->values, function($a, $b) { |
114 | 111 | // assume that labels are unique |
115 | 112 | return strcoll(strtolower($a->getLabel()), strtolower($b->getLabel())); |
@@ -72,7 +72,7 @@ |
||
72 | 72 | return $help; |
73 | 73 | } |
74 | 74 | |
75 | - // if not, see if there was a comment/definition for the property in the graph |
|
75 | + // if not, see if there was a comment/definition for the property in the graph |
|
76 | 76 | if ($this->tooltip !== null) { |
77 | 77 | return $this->tooltip; |
78 | 78 | } |
@@ -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 |