@@ -76,10 +76,12 @@ |
||
| 76 | 76 | */ |
| 77 | 77 | public function getUriSpace() |
| 78 | 78 | { |
| 79 | - if ($this->urispace === null) // initialize cache |
|
| 79 | + if ($this->urispace === null) { |
|
| 80 | + // initialize cache |
|
| 80 | 81 | { |
| 81 | 82 | $this->urispace = $this->resource->getLiteral('void:uriSpace')->getValue(); |
| 82 | 83 | } |
| 84 | + } |
|
| 83 | 85 | |
| 84 | 86 | return $this->urispace; |
| 85 | 87 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * Get the localname of a concept in the vocabulary. If the URI is not |
| 132 | 132 | * in the URI space of this vocabulary, return the full URI. |
| 133 | 133 | * |
| 134 | - * @param $uri string full URI of concept |
|
| 134 | + * @param string $uri string full URI of concept |
|
| 135 | 135 | * @return string local name of concept, or original full URI if the local name cannot be determined |
| 136 | 136 | */ |
| 137 | 137 | public function getLocalName($uri) |
@@ -303,6 +303,8 @@ discard block |
||
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | 305 | * Counts the statistics of the vocabulary. |
| 306 | + * @param string $array |
|
| 307 | + * @param string $group |
|
| 306 | 308 | * @return array of the concept/group counts |
| 307 | 309 | */ |
| 308 | 310 | public function getStatistics($lang = '', $array=null, $group=null) |
@@ -342,6 +344,7 @@ discard block |
||
| 342 | 344 | /** |
| 343 | 345 | * Gets the child relations of a concept and whether these children have more children. |
| 344 | 346 | * @param string $uri |
| 347 | + * @param string $lang |
|
| 345 | 348 | */ |
| 346 | 349 | public function getConceptChildren($uri, $lang) |
| 347 | 350 | { |
@@ -450,6 +453,8 @@ discard block |
||
| 450 | 453 | /** |
| 451 | 454 | * Lists the concepts available in the concept group. |
| 452 | 455 | * @param $clname |
| 456 | + * @param string $glname |
|
| 457 | + * @param string $clang |
|
| 453 | 458 | * @return array |
| 454 | 459 | */ |
| 455 | 460 | public function listConceptGroupContents($glname, $clang) |
@@ -476,7 +481,7 @@ discard block |
||
| 476 | 481 | /** |
| 477 | 482 | * Returns the letters of the alphabet which have been used in this vocabulary. |
| 478 | 483 | * The returned letters may also include specials such as '0-9' (digits) and '!*' (special characters). |
| 479 | - * @param $clang content language |
|
| 484 | + * @param string $clang content language |
|
| 480 | 485 | * @return array array of letters |
| 481 | 486 | */ |
| 482 | 487 | public function getAlphabet($clang) |
@@ -511,6 +516,7 @@ discard block |
||
| 511 | 516 | * Also the special tokens '0-9' (digits), '!*' (special characters) and '*' |
| 512 | 517 | * (everything) are supported. |
| 513 | 518 | * @param $letter letter (or special token) to search for |
| 519 | + * @param string $clang |
|
| 514 | 520 | */ |
| 515 | 521 | public function searchConceptsAlphabetical($letter, $limit = null, $offset = null, $clang = null) |
| 516 | 522 | { |
@@ -626,6 +632,9 @@ discard block |
||
| 626 | 632 | return $this->getSparql()->queryChangeList($prop, $clang, $offset, $limit); |
| 627 | 633 | } |
| 628 | 634 | |
| 635 | + /** |
|
| 636 | + * @param string $lang |
|
| 637 | + */ |
|
| 629 | 638 | public function getTitle($lang=null) { |
| 630 | 639 | return $this->config->getTitle($lang); |
| 631 | 640 | } |
@@ -79,10 +79,12 @@ |
||
| 79 | 79 | if ($sortable !== null) { |
| 80 | 80 | uksort($sortable, array($this, 'mycompare')); |
| 81 | 81 | foreach ($sortable as $prop => $vals) { |
| 82 | - if (is_array($prop)) // the ConceptProperty objects have their own sorting methods |
|
| 82 | + if (is_array($prop)) { |
|
| 83 | + // the ConceptProperty objects have their own sorting methods |
|
| 83 | 84 | { |
| 84 | 85 | ksort($sortable[$prop]); |
| 85 | 86 | } |
| 87 | + } |
|
| 86 | 88 | } |
| 87 | 89 | } |
| 88 | 90 | return $sortable; |
@@ -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); |
@@ -69,8 +69,9 @@ |
||
| 69 | 69 | public function getSearchTerm() |
| 70 | 70 | { |
| 71 | 71 | $term = $this->request->getQueryParamRaw('q') ? $this->request->getQueryParamRaw('q') : $this->request->getQueryParamRaw('query'); |
| 72 | - if (!$term && $this->rest) |
|
| 73 | - $term = $this->request->getQueryParamRaw('label'); |
|
| 72 | + if (!$term && $this->rest) { |
|
| 73 | + $term = $this->request->getQueryParamRaw('label'); |
|
| 74 | + } |
|
| 74 | 75 | $term = trim($term); // surrounding whitespace is not considered significant |
| 75 | 76 | if ($this->rest) { |
| 76 | 77 | return $term; |
@@ -400,7 +400,9 @@ discard block |
||
| 400 | 400 | $hits[] = $res; |
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | - if (sizeof($hits) > 0) return $hits; |
|
| 403 | + if (sizeof($hits) > 0) { |
|
| 404 | + return $hits; |
|
| 405 | + } |
|
| 404 | 406 | |
| 405 | 407 | // case 2: case-insensitive match on preferred label |
| 406 | 408 | foreach ($results as $res) { |
@@ -408,7 +410,9 @@ discard block |
||
| 408 | 410 | $hits[] = $res; |
| 409 | 411 | } |
| 410 | 412 | } |
| 411 | - if (sizeof($hits) > 0) return $hits; |
|
| 413 | + if (sizeof($hits) > 0) { |
|
| 414 | + return $hits; |
|
| 415 | + } |
|
| 412 | 416 | |
| 413 | 417 | if ($lang === null) { |
| 414 | 418 | // case 1A: exact match on preferred label in any language |
@@ -419,7 +423,9 @@ discard block |
||
| 419 | 423 | $hits[] = $res; |
| 420 | 424 | } |
| 421 | 425 | } |
| 422 | - if (sizeof($hits) > 0) return $hits; |
|
| 426 | + if (sizeof($hits) > 0) { |
|
| 427 | + return $hits; |
|
| 428 | + } |
|
| 423 | 429 | |
| 424 | 430 | // case 2A: case-insensitive match on preferred label in any language |
| 425 | 431 | foreach ($results as $res) { |
@@ -429,7 +435,9 @@ discard block |
||
| 429 | 435 | $hits[] = $res; |
| 430 | 436 | } |
| 431 | 437 | } |
| 432 | - if (sizeof($hits) > 0) return $hits; |
|
| 438 | + if (sizeof($hits) > 0) { |
|
| 439 | + return $hits; |
|
| 440 | + } |
|
| 433 | 441 | } |
| 434 | 442 | |
| 435 | 443 | // case 3: exact match on alternate label |
@@ -438,7 +446,9 @@ discard block |
||
| 438 | 446 | $hits[] = $res; |
| 439 | 447 | } |
| 440 | 448 | } |
| 441 | - if (sizeof($hits) > 0) return $hits; |
|
| 449 | + if (sizeof($hits) > 0) { |
|
| 450 | + return $hits; |
|
| 451 | + } |
|
| 442 | 452 | |
| 443 | 453 | |
| 444 | 454 | // case 4: case-insensitive match on alternate label |
@@ -447,7 +457,9 @@ discard block |
||
| 447 | 457 | $hits[] = $res; |
| 448 | 458 | } |
| 449 | 459 | } |
| 450 | - if (sizeof($hits) > 0) return $hits; |
|
| 460 | + if (sizeof($hits) > 0) { |
|
| 461 | + return $hits; |
|
| 462 | + } |
|
| 451 | 463 | |
| 452 | 464 | return $hits; |
| 453 | 465 | } |
@@ -97,6 +97,9 @@ discard block |
||
| 97 | 97 | return $this->returnJson($ret); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | + /** |
|
| 101 | + * @param Request $request |
|
| 102 | + */ |
|
| 100 | 103 | private function constructSearchParameters($request) |
| 101 | 104 | { |
| 102 | 105 | $parameters = new ConceptSearchParameters($request, $this->model->getConfig(), true); |
@@ -112,6 +115,10 @@ discard block |
||
| 112 | 115 | return $parameters; |
| 113 | 116 | } |
| 114 | 117 | |
| 118 | + /** |
|
| 119 | + * @param Request $request |
|
| 120 | + * @param ConceptSearchParameters $parameters |
|
| 121 | + */ |
|
| 115 | 122 | private function transformSearchResults($request, $results, $parameters) |
| 116 | 123 | { |
| 117 | 124 | // before serializing to JSON, get rid of the Vocabulary object that came with each resource |
@@ -420,6 +427,10 @@ discard block |
||
| 420 | 427 | return $this->returnJson($ret); |
| 421 | 428 | } |
| 422 | 429 | |
| 430 | + /** |
|
| 431 | + * @param string $label |
|
| 432 | + * @param string $lang |
|
| 433 | + */ |
|
| 423 | 434 | private function findLookupHits($results, $label, $lang) |
| 424 | 435 | { |
| 425 | 436 | $hits = array(); |
@@ -481,6 +492,9 @@ discard block |
||
| 481 | 492 | return $hits; |
| 482 | 493 | } |
| 483 | 494 | |
| 495 | + /** |
|
| 496 | + * @param string $lang |
|
| 497 | + */ |
|
| 484 | 498 | private function transformLookupResults($lang, $hits) |
| 485 | 499 | { |
| 486 | 500 | if (sizeof($hits) == 0) { |
@@ -555,6 +569,9 @@ discard block |
||
| 555 | 569 | return $this->returnJson($ret); |
| 556 | 570 | } |
| 557 | 571 | |
| 572 | + /** |
|
| 573 | + * @param Request $request |
|
| 574 | + */ |
|
| 558 | 575 | private function redirectToVocabData($request) { |
| 559 | 576 | $urls = $request->getVocab()->getConfig()->getDataURLs(); |
| 560 | 577 | if (sizeof($urls) == 0) { |
@@ -580,6 +597,10 @@ discard block |
||
| 580 | 597 | } |
| 581 | 598 | } |
| 582 | 599 | |
| 600 | + /** |
|
| 601 | + * @param string $results |
|
| 602 | + * @param string $format |
|
| 603 | + */ |
|
| 583 | 604 | private function returnDataResults($results, $format) { |
| 584 | 605 | if ($format == 'application/ld+json' || $format == 'application/json') { |
| 585 | 606 | // further compact JSON-LD document using a context |
@@ -791,6 +812,12 @@ discard block |
||
| 791 | 812 | return $this->returnJson($ret); |
| 792 | 813 | } |
| 793 | 814 | |
| 815 | + /** |
|
| 816 | + * @param string $uri |
|
| 817 | + * @param string $lang |
|
| 818 | + * @param string $propname |
|
| 819 | + * @param string $propuri |
|
| 820 | + */ |
|
| 794 | 821 | private function transformPropertyResults($uri, $lang, $objects, $propname, $propuri) |
| 795 | 822 | { |
| 796 | 823 | $results = array(); |
@@ -805,6 +832,14 @@ discard block |
||
| 805 | 832 | ); |
| 806 | 833 | } |
| 807 | 834 | |
| 835 | + /** |
|
| 836 | + * @param string $uri |
|
| 837 | + * @param string $lang |
|
| 838 | + * @param string $tpropname |
|
| 839 | + * @param string $tpropuri |
|
| 840 | + * @param string $dpropname |
|
| 841 | + * @param string $dpropuri |
|
| 842 | + */ |
|
| 808 | 843 | private function transformTransitivePropertyResults($uri, $lang, $objects, $tpropname, $tpropuri, $dpropname, $dpropuri) |
| 809 | 844 | { |
| 810 | 845 | $results = array(); |
@@ -1095,6 +1130,7 @@ discard block |
||
| 1095 | 1130 | * @param Request $request |
| 1096 | 1131 | * @param int $offset starting index offset |
| 1097 | 1132 | * @param int $limit maximum number of concepts to return |
| 1133 | + * @param string $prop |
|
| 1098 | 1134 | * @return object json-ld wrapped list of changed concepts |
| 1099 | 1135 | */ |
| 1100 | 1136 | private function changedConcepts($request, $prop, $offset, $limit) |
@@ -40,8 +40,7 @@ |
||
| 40 | 40 | $ret[$name] = array(); |
| 41 | 41 | if ($raw) { |
| 42 | 42 | $ret[$name] = $files[$type]; |
| 43 | - } |
|
| 44 | - else { |
|
| 43 | + } else { |
|
| 45 | 44 | foreach ($files[$type] as $file) { |
| 46 | 45 | array_push($ret[$name], 'plugins/' . $name . '/' . $file); |
| 47 | 46 | } |
@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function getQueryParam($paramName) |
| 76 | 76 | { |
| 77 | - if (!isset($this->queryParams[$paramName])) return null; |
|
| 77 | + if (!isset($this->queryParams[$paramName])) { |
|
| 78 | + return null; |
|
| 79 | + } |
|
| 78 | 80 | $val = filter_var($this->queryParams[$paramName], FILTER_SANITIZE_STRING); |
| 79 | 81 | return ($val !== null ? str_replace('\\', '', $val) : null); |
| 80 | 82 | } |
@@ -91,7 +93,9 @@ discard block |
||
| 91 | 93 | |
| 92 | 94 | public function getQueryParamPOST($paramName) |
| 93 | 95 | { |
| 94 | - if (!isset($this->queryParamsPOST[$paramName])) return null; |
|
| 96 | + if (!isset($this->queryParamsPOST[$paramName])) { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 95 | 99 | return filter_var($this->queryParamsPOST[$paramName], FILTER_SANITIZE_STRING); |
| 96 | 100 | } |
| 97 | 101 | |
@@ -106,7 +110,9 @@ discard block |
||
| 106 | 110 | |
| 107 | 111 | public function getServerConstant($paramName) |
| 108 | 112 | { |
| 109 | - if (!isset($this->serverConstants[$paramName])) return null; |
|
| 113 | + if (!isset($this->serverConstants[$paramName])) { |
|
| 114 | + return null; |
|
| 115 | + } |
|
| 110 | 116 | return filter_var($this->serverConstants[$paramName], FILTER_SANITIZE_STRING); |
| 111 | 117 | } |
| 112 | 118 | |
@@ -239,9 +245,11 @@ discard block |
||
| 239 | 245 | */ |
| 240 | 246 | public function setVocab($vocabid) |
| 241 | 247 | { |
| 242 | - if (strpos($vocabid, ' ') !== false) // if there are multiple vocabularies just storing the string |
|
| 248 | + if (strpos($vocabid, ' ') !== false) { |
|
| 249 | + // if there are multiple vocabularies just storing the string |
|
| 243 | 250 | { |
| 244 | 251 | $this->setVocabids($vocabid); |
| 252 | + } |
|
| 245 | 253 | } else { |
| 246 | 254 | $this->vocab = $this->model->getVocabulary($vocabid); |
| 247 | 255 | } |
@@ -109,10 +109,12 @@ |
||
| 109 | 109 | */ |
| 110 | 110 | private function initializeNamespaces() { |
| 111 | 111 | foreach ($this->namespaces as $prefix => $fullUri) { |
| 112 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
| 112 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
| 113 | + // if not already defined |
|
| 113 | 114 | { |
| 114 | 115 | EasyRdf\RdfNamespace::set($prefix, $fullUri); |
| 115 | 116 | } |
| 117 | + } |
|
| 116 | 118 | } |
| 117 | 119 | } |
| 118 | 120 | |
@@ -350,10 +350,12 @@ discard block |
||
| 350 | 350 | // register vocabulary ids as RDF namespace prefixes |
| 351 | 351 | $prefix = preg_replace('/\W+/', '', $voc->getId()); // strip non-word characters |
| 352 | 352 | try { |
| 353 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
| 353 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
| 354 | + // if not already defined |
|
| 354 | 355 | { |
| 355 | 356 | EasyRdf\RdfNamespace::set($prefix, $voc->getUriSpace()); |
| 356 | 357 | } |
| 358 | + } |
|
| 357 | 359 | |
| 358 | 360 | } catch (Exception $e) { |
| 359 | 361 | // not valid as namespace identifier, ignore |
@@ -475,8 +477,9 @@ discard block |
||
| 475 | 477 | |
| 476 | 478 | // no preferred vocabulary, or it was not found, search in which vocabulary the concept has a label |
| 477 | 479 | foreach ($vocabs as $vocab) { |
| 478 | - if ($vocab->getConceptLabel($uri, null) !== null) |
|
| 479 | - return $vocab; |
|
| 480 | + if ($vocab->getConceptLabel($uri, null) !== null) { |
|
| 481 | + return $vocab; |
|
| 482 | + } |
|
| 480 | 483 | } |
| 481 | 484 | |
| 482 | 485 | // if the URI couldn't be found, fall back to the first vocabulary |