@@ -50,6 +50,7 @@ discard block |
||
| 50 | 50 | * @param Vocabulary $vocab |
| 51 | 51 | * @param EasyRdf\Resource $resource |
| 52 | 52 | * @param EasyRdf\Graph $graph |
| 53 | + * @param string|null $clang |
|
| 53 | 54 | */ |
| 54 | 55 | public function __construct($model, $vocab, $resource, $graph, $clang) |
| 55 | 56 | { |
@@ -526,6 +527,7 @@ discard block |
||
| 526 | 527 | |
| 527 | 528 | /** |
| 528 | 529 | * Gets the groups/arrays the concept belongs to. |
| 530 | + * @param boolean $includeArrays |
|
| 529 | 531 | */ |
| 530 | 532 | public function getReverseResources($includeArrays) { |
| 531 | 533 | $groups = array(); |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | // 3. label in a subtag of the current language |
| 123 | 123 | // We need to check all the labels in case one of them matches a subtag of the current language |
| 124 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 124 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 125 | 125 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
| 126 | - if ($label !== null && strpos($label->getLang(), $lang . '-') === 0) { |
|
| 126 | + if ($label !== null && strpos($label->getLang(), $lang.'-') === 0) { |
|
| 127 | 127 | return EasyRdf\Literal::create($label, $lang); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | // 4. label in any language, including literal with empty language tag |
| 132 | 132 | $label = $this->resource->label(); |
| 133 | 133 | if ($label !== null) { |
| 134 | - return $label->getLang() ? $label->getValue() . " (" . $label->getLang() . ")" : $label->getValue(); |
|
| 134 | + return $label->getLang() ? $label->getValue()." (".$label->getLang().")" : $label->getValue(); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // empty |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | public function hasXlLabel($prop = 'prefLabel') |
| 142 | 142 | { |
| 143 | - if ($this->resource->hasProperty('skosxl:' . $prop)) { |
|
| 143 | + if ($this->resource->hasProperty('skosxl:'.$prop)) { |
|
| 144 | 144 | return true; |
| 145 | 145 | } |
| 146 | 146 | return false; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | public function getXlLabel() |
| 150 | 150 | { |
| 151 | 151 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
| 152 | - foreach($labels as $labres) { |
|
| 152 | + foreach ($labels as $labres) { |
|
| 153 | 153 | $label = $labres->getLiteral('skosxl:literalForm'); |
| 154 | 154 | if ($label->getLang() == $this->clang) { |
| 155 | 155 | return new LabelSkosXL($this->model, $labres); |
@@ -483,14 +483,14 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | // making a human readable string from the timestamps |
| 485 | 485 | if ($created != '') { |
| 486 | - $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short')); |
|
| 486 | + $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short')); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | if ($modified != '') { |
| 490 | 490 | if ($created != '') { |
| 491 | - $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
| 491 | + $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
| 492 | 492 | } else { |
| 493 | - $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
| 493 | + $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | } |
@@ -498,12 +498,12 @@ discard block |
||
| 498 | 498 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 499 | 499 | $ret = ''; |
| 500 | 500 | if ($this->resource->get('dc:modified')) { |
| 501 | - $modified = (string) $this->resource->get('dc:modified'); |
|
| 502 | - $ret = gettext('skosmos:modified') . ' ' . $modified; |
|
| 501 | + $modified = (string)$this->resource->get('dc:modified'); |
|
| 502 | + $ret = gettext('skosmos:modified').' '.$modified; |
|
| 503 | 503 | } |
| 504 | 504 | if ($this->resource->get('dc:created')) { |
| 505 | - $created .= (string) $this->resource->get('dc:created'); |
|
| 506 | - $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; |
|
| 505 | + $created .= (string)$this->resource->get('dc:created'); |
|
| 506 | + $ret .= ' '.gettext('skosmos:created').' '.$created; |
|
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | return $ret; |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | $ret = array(); |
| 614 | 614 | foreach ($labels as $lit) { |
| 615 | 615 | // filtering away subsets of the current language eg. en vs en-GB |
| 616 | - if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { |
|
| 616 | + if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { |
|
| 617 | 617 | $prop = in_array($lit, $prefLabels) ? 'skos:prefLabel' : 'skos:altLabel'; |
| 618 | 618 | $ret[$this->literalLanguageToString($lit)][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop); |
| 619 | 619 | } |
@@ -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 = $this->getNotation() . $label; |
|
| 27 | + $label = $this->getNotation().$label; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | return $label; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function getReifiedPropertyValues() { |
| 121 | 121 | $ret = array(); |
| 122 | 122 | $props = $this->resource->propertyUris(); |
| 123 | - foreach($props as $prop) { |
|
| 123 | + foreach ($props as $prop) { |
|
| 124 | 124 | $prop = (EasyRdf\RdfNamespace::shorten($prop) !== null) ? EasyRdf\RdfNamespace::shorten($prop) : $prop; |
| 125 | 125 | foreach ($this->resource->allLiterals($prop) as $val) { |
| 126 | 126 | if ($prop !== 'rdf:value' && $this->resource->get($prop)) { // shown elsewhere |
@@ -12,6 +12,9 @@ discard block |
||
| 12 | 12 | /** content language */ |
| 13 | 13 | private $clang; |
| 14 | 14 | |
| 15 | + /** |
|
| 16 | + * @param Model $model |
|
| 17 | + */ |
|
| 15 | 18 | public function __construct($model, $vocab, $resource, $prop, $clang = '') |
| 16 | 19 | { |
| 17 | 20 | parent::__construct($model, $vocab, $resource); |
@@ -76,6 +79,9 @@ discard block |
||
| 76 | 79 | return $this->vocab->getTitle(); |
| 77 | 80 | } |
| 78 | 81 | |
| 82 | + /** |
|
| 83 | + * @param ConceptPropertyValue $member |
|
| 84 | + */ |
|
| 79 | 85 | public function addSubMember($member, $lang = '') |
| 80 | 86 | { |
| 81 | 87 | $label = $member->getLabel($lang) ? $member->getLabel($lang) : $member->getLabel(); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | // 1. Ensure characters with special meaning in Lucene are escaped |
| 41 | 41 | $lucenemap = array(); |
| 42 | 42 | foreach (str_split(self::LUCENE_ESCAPE_CHARS) as $char) { |
| 43 | - $lucenemap[$char] = '\\' . $char; // escape with a backslash |
|
| 43 | + $lucenemap[$char] = '\\'.$char; // escape with a backslash |
|
| 44 | 44 | } |
| 45 | 45 | $term = strtr($term, $lucenemap); |
| 46 | 46 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @return string sparql order by clause |
| 83 | 83 | */ |
| 84 | 84 | private function formatOrderBy($expression, $lang) { |
| 85 | - if(!$this->model->getConfig()->getCollationEnabled()) { |
|
| 85 | + if (!$this->model->getConfig()->getCollationEnabled()) { |
|
| 86 | 86 | return $expression; |
| 87 | 87 | } |
| 88 | 88 | $orderby = sprintf('arq:collation(\'%2$s\', %1$s)', $expression, $lang); |
@@ -114,13 +114,13 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | # make text query clause |
| 116 | 116 | $lcletter = mb_strtolower($letter, 'UTF-8'); // convert to lower case, UTF-8 safe |
| 117 | - $textcondPref = $this->createTextQueryCondition($letter . '*', 'skos:prefLabel', $lang); |
|
| 118 | - $textcondAlt = $this->createTextQueryCondition($letter . '*', 'skos:altLabel', $lang); |
|
| 117 | + $textcondPref = $this->createTextQueryCondition($letter.'*', 'skos:prefLabel', $lang); |
|
| 118 | + $textcondAlt = $this->createTextQueryCondition($letter.'*', 'skos:altLabel', $lang); |
|
| 119 | 119 | $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang); |
| 120 | 120 | |
| 121 | - $filterDeprecated=""; |
|
| 122 | - if(!$showDeprecated){ |
|
| 123 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 121 | + $filterDeprecated = ""; |
|
| 122 | + if (!$showDeprecated) { |
|
| 123 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $query = <<<EOQ |
@@ -64,15 +64,15 @@ discard block |
||
| 64 | 64 | private function initializeVocabularies() |
| 65 | 65 | { |
| 66 | 66 | if (!file_exists($this->getConfig()->getVocabularyConfigFile())) { |
| 67 | - throw new Exception($this->getConfig()->getVocabularyConfigFile() . ' is missing, please provide one.'); |
|
| 67 | + throw new Exception($this->getConfig()->getVocabularyConfigFile().' is missing, please provide one.'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | try { |
| 71 | 71 | // use APC user cache to store parsed vocabularies.ttl configuration |
| 72 | 72 | if ($this->cache->isAvailable()) { |
| 73 | 73 | // @codeCoverageIgnoreStart |
| 74 | - $key = realpath($this->getConfig()->getVocabularyConfigFile()) . ", " . filemtime($this->getConfig()->getVocabularyConfigFile()); |
|
| 75 | - $nskey = "namespaces of " . $key; |
|
| 74 | + $key = realpath($this->getConfig()->getVocabularyConfigFile()).", ".filemtime($this->getConfig()->getVocabularyConfigFile()); |
|
| 75 | + $nskey = "namespaces of ".$key; |
|
| 76 | 76 | $this->graph = $this->cache->fetch($key); |
| 77 | 77 | $this->namespaces = $this->cache->fetch($nskey); |
| 78 | 78 | if ($this->graph === false || $this->namespaces === false) { // was not found in cache |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $this->parseVocabularies($this->getConfig()->getVocabularyConfigFile()); |
| 86 | 86 | } |
| 87 | 87 | } catch (Exception $e) { |
| 88 | - echo "Error: " . $e->getMessage(); |
|
| 88 | + echo "Error: ".$e->getMessage(); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -297,18 +297,18 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | $vocabs = $params->getVocabs(); |
| 300 | - $showDeprecated=false; |
|
| 300 | + $showDeprecated = false; |
|
| 301 | 301 | if (sizeof($vocabs) === 1) { // search within vocabulary |
| 302 | 302 | $voc = $vocabs[0]; |
| 303 | 303 | $sparql = $voc->getSparql(); |
| 304 | - $showDeprecated=$voc->getConfig()->getShowDeprecated(); |
|
| 304 | + $showDeprecated = $voc->getConfig()->getShowDeprecated(); |
|
| 305 | 305 | } else { // multi-vocabulary or global search |
| 306 | 306 | $voc = null; |
| 307 | 307 | $sparql = $this->getDefaultSparql(); |
| 308 | 308 | // @TODO : in a global search showDeprecated will always be false and cannot be set globally |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params,$showDeprecated); |
|
| 311 | + $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params, $showDeprecated); |
|
| 312 | 312 | if ($params->getRest() && $results && $params->getSearchLimit() !== 0) { |
| 313 | 313 | $results = array_slice($results, $params->getOffset(), $params->getSearchLimit()); |
| 314 | 314 | } |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | public function getVocabularyCategories() |
| 459 | 459 | { |
| 460 | 460 | $cats = $this->graph->allOfType('skos:Concept'); |
| 461 | - if(empty($cats)) { |
|
| 461 | + if (empty($cats)) { |
|
| 462 | 462 | return array(new VocabularyCategory($this, null)); |
| 463 | 463 | } |
| 464 | 464 | |
@@ -541,9 +541,9 @@ discard block |
||
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | // if there are multiple vocabularies and one is the preferred vocabulary, return it |
| 544 | - if($preferredVocabId != null) { |
|
| 544 | + if ($preferredVocabId != null) { |
|
| 545 | 545 | foreach ($vocabs as $vocab) { |
| 546 | - if($vocab->getId() == $preferredVocabId) { |
|
| 546 | + if ($vocab->getId() == $preferredVocabId) { |
|
| 547 | 547 | return $vocab; |
| 548 | 548 | } |
| 549 | 549 | } |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | // using apc cache for the resource if available |
| 644 | 644 | if ($this->cache->isAvailable()) { |
| 645 | 645 | // @codeCoverageIgnoreStart |
| 646 | - $key = 'fetch: ' . $uri; |
|
| 646 | + $key = 'fetch: '.$uri; |
|
| 647 | 647 | $resource = $this->cache->fetch($key); |
| 648 | 648 | if ($resource === null || $resource === false) { // was not found in cache, or previous request failed |
| 649 | 649 | $resource = $this->fetchResourceFromUri($uri); |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | */ |
| 665 | 665 | public function getSparqlImplementation($dialect, $endpoint, $graph) |
| 666 | 666 | { |
| 667 | - $classname = $dialect . "Sparql"; |
|
| 667 | + $classname = $dialect."Sparql"; |
|
| 668 | 668 | |
| 669 | 669 | return new $classname($endpoint, $graph, $this); |
| 670 | 670 | } |
@@ -108,10 +108,12 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | private function initializeNamespaces() { |
| 110 | 110 | foreach ($this->namespaces as $prefix => $fullUri) { |
| 111 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
| 111 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
| 112 | + // if not already defined |
|
| 112 | 113 | { |
| 113 | 114 | EasyRdf\RdfNamespace::set($prefix, $fullUri); |
| 114 | 115 | } |
| 116 | + } |
|
| 115 | 117 | } |
| 116 | 118 | } |
| 117 | 119 | |
@@ -425,10 +427,12 @@ discard block |
||
| 425 | 427 | // register vocabulary ids as RDF namespace prefixes |
| 426 | 428 | $prefix = preg_replace('/\W+/', '', $voc->getId()); // strip non-word characters |
| 427 | 429 | try { |
| 428 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
| 430 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
| 431 | + // if not already defined |
|
| 429 | 432 | { |
| 430 | 433 | EasyRdf\RdfNamespace::set($prefix, $voc->getUriSpace()); |
| 431 | 434 | } |
| 435 | + } |
|
| 432 | 436 | |
| 433 | 437 | } catch (Exception $e) { |
| 434 | 438 | // not valid as namespace identifier, ignore |
@@ -551,8 +555,9 @@ discard block |
||
| 551 | 555 | |
| 552 | 556 | // no preferred vocabulary, or it was not found, search in which vocabulary the concept has a label |
| 553 | 557 | foreach ($vocabs as $vocab) { |
| 554 | - if ($vocab->getConceptLabel($uri, null) !== null) |
|
| 555 | - return $vocab; |
|
| 558 | + if ($vocab->getConceptLabel($uri, null) !== null) { |
|
| 559 | + return $vocab; |
|
| 560 | + } |
|
| 556 | 561 | } |
| 557 | 562 | |
| 558 | 563 | // if the URI couldn't be found, fall back to the first vocabulary |
@@ -10,6 +10,9 @@ |
||
| 10 | 10 | /** property type */ |
| 11 | 11 | private $type; |
| 12 | 12 | |
| 13 | + /** |
|
| 14 | + * @param EasyRdf\Resource $resource |
|
| 15 | + */ |
|
| 13 | 16 | public function __construct($model, $vocab, $resource, $literal, $prop) |
| 14 | 17 | { |
| 15 | 18 | parent::__construct($model, $vocab, $resource); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | return Punic\Calendar::formatDate($val, 'short'); |
| 50 | 50 | } catch (Exception $e) { |
| 51 | 51 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 52 | - return (string) $this->literal; |
|
| 52 | + return (string)$this->literal; |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | return $this->literal->getValue(); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $resources = $graph->resourcesMatching('skosxl:literalForm', $this->literal); |
| 81 | 81 | foreach ($resources as $xlres) { |
| 82 | 82 | foreach ($xlres->properties() as $prop) { |
| 83 | - foreach($graph->allLiterals($xlres, $prop) as $val) { |
|
| 83 | + foreach ($graph->allLiterals($xlres, $prop) as $val) { |
|
| 84 | 84 | if ($prop !== 'rdf:type') { |
| 85 | 85 | $ret[$prop] = $val; |
| 86 | 86 | } |
@@ -3,6 +3,9 @@ |
||
| 3 | 3 | class LabelSkosXL extends DataObject |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | + /** |
|
| 7 | + * @param Model $model |
|
| 8 | + */ |
|
| 6 | 9 | public function __construct($model, $resource) |
| 7 | 10 | { |
| 8 | 11 | parent::__construct($model, $resource); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | public function getPrefLabel() { |
| 12 | 12 | $label; |
| 13 | 13 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
| 14 | - foreach($labels as $labres) { |
|
| 14 | + foreach ($labels as $labres) { |
|
| 15 | 15 | $label = $labres->getLiteral('skosxl:literalForm'); |
| 16 | 16 | if ($label->getLang() == $this->clang) { |
| 17 | 17 | return $label; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | public function getProperties() { |
| 24 | 24 | $ret = array(); |
| 25 | 25 | $props = $this->resource->properties(); |
| 26 | - foreach($props as $prop) { |
|
| 26 | + foreach ($props as $prop) { |
|
| 27 | 27 | if ($prop !== 'skosxl:prefLabel') { |
| 28 | 28 | $ret[$prop] = $this->resource->get($prop); |
| 29 | 29 | } |