@@ -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(); |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | return $this->resource->label($fallback); |
| 138 | 138 | } |
| 139 | 139 | // We need to check all the labels in case one of them matches a subtag of the current language |
| 140 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 140 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 141 | 141 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
| 142 | - if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) { |
|
| 142 | + if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) { |
|
| 143 | 143 | return EasyRdf\Literal::create($label, $fallback); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | public function hasXlLabel($prop = 'prefLabel') |
| 162 | 162 | { |
| 163 | - if ($this->resource->hasProperty('skosxl:' . $prop)) { |
|
| 163 | + if ($this->resource->hasProperty('skosxl:'.$prop)) { |
|
| 164 | 164 | return true; |
| 165 | 165 | } |
| 166 | 166 | return false; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | public function getXlLabel() |
| 170 | 170 | { |
| 171 | 171 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
| 172 | - foreach($labels as $labres) { |
|
| 172 | + foreach ($labels as $labres) { |
|
| 173 | 173 | $label = $labres->getLiteral('skosxl:literalForm'); |
| 174 | 174 | if ($label !== null && $label->getLang() == $this->clang) { |
| 175 | 175 | return new LabelSkosXL($this->model, $labres); |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | // catch external subjects that have $res as object |
| 277 | 277 | $extSubjects = $exGraph->resourcesMatching("schema:about", $res); |
| 278 | 278 | |
| 279 | - $propList = array_unique(array_merge( |
|
| 279 | + $propList = array_unique(array_merge( |
|
| 280 | 280 | $this->DEFAULT_EXT_PROPERTIES, |
| 281 | 281 | $this->getVocab()->getConfig()->getExtProperties(), |
| 282 | 282 | $this->getVocab()->getConfig()->getPlugins()->getExtProperties() |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param string[] $seen Processed resources so far |
| 302 | 302 | * @param string[] $props (optional) limit to these property URIs |
| 303 | 303 | */ |
| 304 | - private function addExternalTriplesToGraph($res, &$seen, $props=null) |
|
| 304 | + private function addExternalTriplesToGraph($res, &$seen, $props = null) |
|
| 305 | 305 | { |
| 306 | 306 | if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) { |
| 307 | 307 | return; |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | private function addPropertyValues($res, $prop, &$seen) |
| 333 | 333 | { |
| 334 | - $resList = $res->allResources('<' . $prop . '>'); |
|
| 334 | + $resList = $res->allResources('<'.$prop.'>'); |
|
| 335 | 335 | |
| 336 | 336 | foreach ($resList as $res2) { |
| 337 | 337 | if ($res2->isBNode()) { |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | $this->addResourceReifications($res, $prop, $res2, $seen); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $litList = $res->allLiterals('<' . $prop . '>'); |
|
| 344 | + $litList = $res->allLiterals('<'.$prop.'>'); |
|
| 345 | 345 | |
| 346 | 346 | foreach ($litList as $lit) { |
| 347 | 347 | $this->graph->addLiteral($res, $prop, $lit); |
@@ -518,15 +518,15 @@ discard block |
||
| 518 | 518 | // if not found in current vocabulary, look up in the default graph to be able |
| 519 | 519 | // to read an ontology loaded in a separate graph |
| 520 | 520 | // note that this imply that the property has an rdf:type declared for the query to work |
| 521 | - if(!$is_well_known && !$proplabel) { |
|
| 521 | + if (!$is_well_known && !$proplabel) { |
|
| 522 | 522 | $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang()); |
| 523 | 523 | |
| 524 | 524 | $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, ''); |
| 525 | 525 | |
| 526 | - if($envLangLabels) { |
|
| 526 | + if ($envLangLabels) { |
|
| 527 | 527 | $proplabel = $envLangLabels[$this->getEnvLang()]; |
| 528 | 528 | } else { |
| 529 | - if($defaultPropLabel) { |
|
| 529 | + if ($defaultPropLabel) { |
|
| 530 | 530 | $proplabel = $defaultPropLabel['']; |
| 531 | 531 | } |
| 532 | 532 | } |
@@ -539,12 +539,12 @@ discard block |
||
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | // also look up superprops in the default graph if not found in current vocabulary |
| 542 | - if(!$is_well_known && (!$superprops || empty($superprops))) { |
|
| 542 | + if (!$is_well_known && (!$superprops || empty($superprops))) { |
|
| 543 | 543 | $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri); |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | // we're reading only one super property, even if there are multiple ones |
| 547 | - $superprop = ($superprops)?$superprops[0]:null; |
|
| 547 | + $superprop = ($superprops) ? $superprops[0] : null; |
|
| 548 | 548 | if ($superprop) { |
| 549 | 549 | $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop; |
| 550 | 550 | } |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | // searching for subproperties of literals too |
| 560 | - if($superprops) { |
|
| 560 | + if ($superprops) { |
|
| 561 | 561 | foreach ($superprops as $subi) { |
| 562 | 562 | $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi; |
| 563 | 563 | $duplicates[$suburi] = $prop; |
@@ -677,14 +677,14 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | // making a human readable string from the timestamps |
| 679 | 679 | if ($created != '') { |
| 680 | - $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short')); |
|
| 680 | + $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short')); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | if ($modified != '') { |
| 684 | 684 | if ($created != '') { |
| 685 | - $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
| 685 | + $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
| 686 | 686 | } else { |
| 687 | - $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
| 687 | + $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | } |
@@ -692,12 +692,12 @@ discard block |
||
| 692 | 692 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 693 | 693 | $ret = ''; |
| 694 | 694 | if ($this->resource->get('dc:modified')) { |
| 695 | - $modified = (string) $this->resource->get('dc:modified'); |
|
| 696 | - $ret = gettext('skosmos:modified') . ' ' . $modified; |
|
| 695 | + $modified = (string)$this->resource->get('dc:modified'); |
|
| 696 | + $ret = gettext('skosmos:modified').' '.$modified; |
|
| 697 | 697 | } |
| 698 | 698 | if ($this->resource->get('dc:created')) { |
| 699 | - $created .= (string) $this->resource->get('dc:created'); |
|
| 700 | - $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; |
|
| 699 | + $created .= (string)$this->resource->get('dc:created'); |
|
| 700 | + $ret .= ' '.gettext('skosmos:created').' '.$created; |
|
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | return $ret; |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | $groups[$collLabel] = array($group); |
| 770 | 770 | |
| 771 | 771 | $res = $collection; |
| 772 | - while($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
| 772 | + while ($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
| 773 | 773 | foreach ($super as $res) { |
| 774 | 774 | $superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang); |
| 775 | 775 | array_unshift($groups[$collLabel], $superprop); |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | $ret = array(); |
| 812 | 812 | foreach ($labels as $lit) { |
| 813 | 813 | // filtering away subsets of the current language eg. en vs en-GB |
| 814 | - if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { |
|
| 814 | + if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { |
|
| 815 | 815 | $prop = in_array($lit, $prefLabels) ? 'skos:prefLabel' : 'skos:altLabel'; |
| 816 | 816 | $ret[$this->literalLanguageToString($lit)][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop); |
| 817 | 817 | } |
@@ -873,10 +873,10 @@ discard block |
||
| 873 | 873 | } |
| 874 | 874 | else if ($context[$vocabPrefix] !== $vocabUriSpace) { |
| 875 | 875 | $i = 2; |
| 876 | - while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) { |
|
| 876 | + while (isset($context[$vocabPrefix.$i]) && $context[$vocabPrefix.$i] !== $vocabUriSpace) { |
|
| 877 | 877 | $i += 1; |
| 878 | 878 | } |
| 879 | - $context[$vocabPrefix . $i] = $vocabUriSpace; |
|
| 879 | + $context[$vocabPrefix.$i] = $vocabUriSpace; |
|
| 880 | 880 | } |
| 881 | 881 | } |
| 882 | 882 | $compactJsonLD = \ML\JsonLD\JsonLD::compact($this->graph->serialise('jsonld'), json_encode($context)); |
@@ -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; |
@@ -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() |
@@ -187,42 +187,42 @@ discard block |
||
| 187 | 187 | 'from' => [ |
| 188 | 188 | 'memberSet' => [ |
| 189 | 189 | [ |
| 190 | - 'uri' => (string) $this->source->getUri(), |
|
| 190 | + 'uri' => (string)$this->source->getUri(), |
|
| 191 | 191 | ] |
| 192 | 192 | ] |
| 193 | 193 | ], |
| 194 | 194 | 'to' => [ |
| 195 | 195 | 'memberSet' => [ |
| 196 | 196 | [ |
| 197 | - 'uri' => (string) $this->getUri() |
|
| 197 | + 'uri' => (string)$this->getUri() |
|
| 198 | 198 | ] |
| 199 | 199 | ] |
| 200 | 200 | ], |
| 201 | 201 | // EXTRA |
| 202 | - 'description' => gettext($this->type . "_help"), // pop-up text |
|
| 202 | + 'description' => gettext($this->type."_help"), // pop-up text |
|
| 203 | 203 | 'hrefLink' => $hrefLink, // link to resource as displayed in the UI |
| 204 | 204 | 'lang' => $propertyLang, // TBD: could it be part of the prefLabel? |
| 205 | - 'vocabName' => (string) $this->getVocabName(), // vocabulary as displayed in the UI |
|
| 205 | + 'vocabName' => (string)$this->getVocabName(), // vocabulary as displayed in the UI |
|
| 206 | 206 | 'typeLabel' => gettext($this->type), // a text used in the UI instead of, for example, skos:closeMatch |
| 207 | 207 | ]; |
| 208 | 208 | |
| 209 | 209 | $fromScheme = $this->vocab->getDefaultConceptScheme(); |
| 210 | 210 | if (isset($fromScheme)) { |
| 211 | 211 | $ret['fromScheme'] = [ |
| 212 | - 'uri' => (string) $fromScheme, |
|
| 212 | + 'uri' => (string)$fromScheme, |
|
| 213 | 213 | ]; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $exvocab = $this->getExvocab(); |
| 217 | 217 | if (isset($exvocab)) { |
| 218 | 218 | $ret['toScheme'] = [ |
| 219 | - 'uri' => (string) $exvocab->getDefaultConceptScheme(), |
|
| 219 | + 'uri' => (string)$exvocab->getDefaultConceptScheme(), |
|
| 220 | 220 | ]; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | $notation = $this->getNotation(); |
| 224 | 224 | if (isset($notation)) { |
| 225 | - $ret['to']['memberSet'][0]['notation'] = (string) $notation; |
|
| 225 | + $ret['to']['memberSet'][0]['notation'] = (string)$notation; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | $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 | /** |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | { |
| 322 | 322 | if ($modifiedDate) { |
| 323 | 323 | $ifModifiedSince = $this->getIfModifiedSince(); |
| 324 | - $this->sendHeader("Last-Modified: " . $modifiedDate->format('Y-m-d H:i:s')); |
|
| 324 | + $this->sendHeader("Last-Modified: ".$modifiedDate->format('Y-m-d H:i:s')); |
|
| 325 | 325 | if ($ifModifiedSince !== null && $ifModifiedSince >= $modifiedDate) { |
| 326 | 326 | $this->sendHeader("HTTP/1.0 304 Not Modified"); |
| 327 | 327 | 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 |
@@ -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 | /* |
@@ -973,20 +973,20 @@ discard block |
||
| 973 | 973 | $schemecond = ''; |
| 974 | 974 | if (!empty($schemes)) { |
| 975 | 975 | $conditions = array(); |
| 976 | - foreach($schemes as $scheme) { |
|
| 976 | + foreach ($schemes as $scheme) { |
|
| 977 | 977 | $conditions[] = "{?s skos:inScheme <$scheme>}"; |
| 978 | 978 | } |
| 979 | - $schemecond = '{'.implode(" UNION ",$conditions).'}'; |
|
| 979 | + $schemecond = '{'.implode(" UNION ", $conditions).'}'; |
|
| 980 | 980 | } |
| 981 | - $filterDeprecated=""; |
|
| 981 | + $filterDeprecated = ""; |
|
| 982 | 982 | //show or hide deprecated concepts |
| 983 | - if(!$showDeprecated){ |
|
| 984 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 983 | + if (!$showDeprecated) { |
|
| 984 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 985 | 985 | } |
| 986 | 986 | // extra conditions for parent and group, if specified |
| 987 | - $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : ""; |
|
| 988 | - $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : ""; |
|
| 989 | - $pgcond = $parentcond . $groupcond; |
|
| 987 | + $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : ""; |
|
| 988 | + $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : ""; |
|
| 989 | + $pgcond = $parentcond.$groupcond; |
|
| 990 | 990 | |
| 991 | 991 | $orderextra = $this->isDefaultEndpoint() ? $this->graph : ''; |
| 992 | 992 | |
@@ -1059,9 +1059,9 @@ discard block |
||
| 1059 | 1059 | $hit['type'][] = $this->shortenUri($typeuri); |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | - if(!empty($fields)) { |
|
| 1062 | + if (!empty($fields)) { |
|
| 1063 | 1063 | foreach ($fields as $prop) { |
| 1064 | - $propname = $prop . 's'; |
|
| 1064 | + $propname = $prop.'s'; |
|
| 1065 | 1065 | if (isset($row->$propname)) { |
| 1066 | 1066 | foreach (explode("\n", $row->$propname->getValue()) as $line) { |
| 1067 | 1067 | $rdata = str_getcsv($line, ',', '"', '"'); |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | $propvals = $rdata[2]; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - $hit['skos:' . $prop][] = $propvals; |
|
| 1079 | + $hit['skos:'.$prop][] = $propvals; |
|
| 1080 | 1080 | } |
| 1081 | 1081 | } |
| 1082 | 1082 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
| 1152 | 1152 | * @return array query result object |
| 1153 | 1153 | */ |
| 1154 | 1154 | public function queryConcepts($vocabs, $fields = null, $unique = false, $params, $showDeprecated = false) { |
| 1155 | - $query = $this->generateConceptSearchQuery($fields, $unique, $params,$showDeprecated); |
|
| 1155 | + $query = $this->generateConceptSearchQuery($fields, $unique, $params, $showDeprecated); |
|
| 1156 | 1156 | $results = $this->query($query); |
| 1157 | 1157 | return $this->transformConceptSearchResults($results, $vocabs, $fields); |
| 1158 | 1158 | } |
@@ -1207,10 +1207,10 @@ discard block |
||
| 1207 | 1207 | $conditions = $this->formatFilterConditions($letter, $lang); |
| 1208 | 1208 | $filtercondLabel = $conditions['filterpref']; |
| 1209 | 1209 | $filtercondALabel = $conditions['filteralt']; |
| 1210 | - $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : ""; |
|
| 1211 | - $filterDeprecated=""; |
|
| 1212 | - if(!$showDeprecated){ |
|
| 1213 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 1210 | + $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : ""; |
|
| 1211 | + $filterDeprecated = ""; |
|
| 1212 | + if (!$showDeprecated) { |
|
| 1213 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 1214 | 1214 | } |
| 1215 | 1215 | $query = <<<EOQ |
| 1216 | 1216 | SELECT DISTINCT ?s ?label ?alabel ?qualifier $fcl |
@@ -1632,7 +1632,7 @@ discard block |
||
| 1632 | 1632 | if (!isset($row->label) || $row->label->getLang() === $lang) { |
| 1633 | 1633 | $ret[$row->object->getUri()] = $val; |
| 1634 | 1634 | } elseif ($row->label->getLang() === $fallbacklang) { |
| 1635 | - $val['label'] .= ' (' . $row->label->getLang() . ')'; |
|
| 1635 | + $val['label'] .= ' ('.$row->label->getLang().')'; |
|
| 1636 | 1636 | $ret[$row->object->getUri()] = $val; |
| 1637 | 1637 | } |
| 1638 | 1638 | } |
@@ -1728,10 +1728,10 @@ discard block |
||
| 1728 | 1728 | |
| 1729 | 1729 | $label = null; |
| 1730 | 1730 | if (isset($row->label)) { |
| 1731 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
| 1731 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
| 1732 | 1732 | $label = $row->label->getValue(); |
| 1733 | 1733 | } else { |
| 1734 | - $label = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
| 1734 | + $label = $row->label->getValue()." (".$row->label->getLang().")"; |
|
| 1735 | 1735 | } |
| 1736 | 1736 | |
| 1737 | 1737 | } |
@@ -1807,8 +1807,8 @@ discard block |
||
| 1807 | 1807 | foreach ($result as $row) { |
| 1808 | 1808 | if (isset($row->top) && isset($row->label)) { |
| 1809 | 1809 | $label = $row->label->getValue(); |
| 1810 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
| 1811 | - $label .= ' (' . $row->label->getLang() . ')'; |
|
| 1810 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
| 1811 | + $label .= ' ('.$row->label->getLang().')'; |
|
| 1812 | 1812 | } |
| 1813 | 1813 | $top = array('uri' => $row->top->getUri(), 'topConceptOf' => $row->topuri->getUri(), 'label' => $label, 'hasChildren' => filter_var($row->children->getValue(), FILTER_VALIDATE_BOOLEAN)); |
| 1814 | 1814 | if (isset($row->notation)) { |
@@ -1901,7 +1901,7 @@ discard block |
||
| 1901 | 1901 | $ret[$uri]['exact'] = $row->exact->getUri(); |
| 1902 | 1902 | } |
| 1903 | 1903 | if (isset($row->tops)) { |
| 1904 | - $topConceptsList=explode(" ", $row->tops->getValue()); |
|
| 1904 | + $topConceptsList = explode(" ", $row->tops->getValue()); |
|
| 1905 | 1905 | // sort to garantee an alphabetical ordering of the URI |
| 1906 | 1906 | sort($topConceptsList); |
| 1907 | 1907 | $ret[$uri]['tops'] = $topConceptsList; |
@@ -1914,8 +1914,8 @@ discard block |
||
| 1914 | 1914 | $label = null; |
| 1915 | 1915 | if (isset($row->childlabel)) { |
| 1916 | 1916 | $label = $row->childlabel->getValue(); |
| 1917 | - if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang . "-") !== 0) { |
|
| 1918 | - $label .= " (" . $row->childlabel->getLang() . ")"; |
|
| 1917 | + if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang."-") !== 0) { |
|
| 1918 | + $label .= " (".$row->childlabel->getLang().")"; |
|
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | 1921 | } |
@@ -1936,8 +1936,8 @@ discard block |
||
| 1936 | 1936 | } |
| 1937 | 1937 | if (isset($row->label)) { |
| 1938 | 1938 | $preflabel = $row->label->getValue(); |
| 1939 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
| 1940 | - $preflabel .= ' (' . $row->label->getLang() . ')'; |
|
| 1939 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
| 1940 | + $preflabel .= ' ('.$row->label->getLang().')'; |
|
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | $ret[$uri]['prefLabel'] = $preflabel; |
@@ -2058,9 +2058,9 @@ discard block |
||
| 2058 | 2058 | */ |
| 2059 | 2059 | private function generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated = false) { |
| 2060 | 2060 | $fcl = $this->generateFromClause(); |
| 2061 | - $filterDeprecated=""; |
|
| 2062 | - if(!$showDeprecated){ |
|
| 2063 | - $filterDeprecated=" FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
| 2061 | + $filterDeprecated = ""; |
|
| 2062 | + if (!$showDeprecated) { |
|
| 2063 | + $filterDeprecated = " FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
| 2064 | 2064 | } |
| 2065 | 2065 | $query = <<<EOQ |
| 2066 | 2066 | SELECT ?conc ?super ?label ?members ?type ?notation $fcl |
@@ -2099,10 +2099,10 @@ discard block |
||
| 2099 | 2099 | 'type' => array($row->type->shorten()), |
| 2100 | 2100 | ); |
| 2101 | 2101 | if (isset($row->label)) { |
| 2102 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
| 2102 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
| 2103 | 2103 | $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue(); |
| 2104 | 2104 | } else { |
| 2105 | - $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
| 2105 | + $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")"; |
|
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | 2108 | } |
@@ -2130,8 +2130,8 @@ discard block |
||
| 2130 | 2130 | * @param boolean $showDeprecated whether to include deprecated concepts in search results |
| 2131 | 2131 | * @return array Result array with concept URI as key and concept label as value |
| 2132 | 2132 | */ |
| 2133 | - public function listConceptGroupContents($groupClass, $group, $lang,$showDeprecated = false) { |
|
| 2134 | - $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang,$showDeprecated); |
|
| 2133 | + public function listConceptGroupContents($groupClass, $group, $lang, $showDeprecated = false) { |
|
| 2134 | + $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated); |
|
| 2135 | 2135 | $result = $this->query($query); |
| 2136 | 2136 | return $this->transformConceptGroupContentsResults($result, $lang); |
| 2137 | 2137 | } |
@@ -2144,7 +2144,7 @@ discard block |
||
| 2144 | 2144 | */ |
| 2145 | 2145 | private function generateChangeListQuery($lang, $offset, $prop) { |
| 2146 | 2146 | $fcl = $this->generateFromClause(); |
| 2147 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
| 2147 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
| 2148 | 2148 | |
| 2149 | 2149 | $query = <<<EOQ |
| 2150 | 2150 | SELECT DISTINCT ?concept ?date ?label $fcl |
@@ -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'])) { |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param string $prop property type eg. 'rdf:type'. |
| 23 | 23 | * @param string $label |
| 24 | 24 | */ |
| 25 | - public function __construct($prop, $label, $super=null, $sort_by_notation=false) |
|
| 25 | + public function __construct($prop, $label, $super = null, $sort_by_notation = false) |
|
| 26 | 26 | { |
| 27 | 27 | $this->prop = $prop; |
| 28 | 28 | $this->label = $label; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getDescription() |
| 63 | 63 | { |
| 64 | - $helpprop = $this->prop . "_help"; |
|
| 64 | + $helpprop = $this->prop."_help"; |
|
| 65 | 65 | |
| 66 | 66 | return gettext($helpprop); // can't use string constant, it'd be picked up by xgettext |
| 67 | 67 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function addValue($value) |
| 82 | 82 | { |
| 83 | - $this->values[ltrim($value->getNotation() . ' ') . $value->getLabel() . rtrim(' ' . $value->getUri())] = $value; |
|
| 83 | + $this->values[ltrim($value->getNotation().' ').$value->getLabel().rtrim(' '.$value->getUri())] = $value; |
|
| 84 | 84 | $this->is_sorted = false; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -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())); |