@@ -575,9 +575,9 @@ discard block |
||
| 575 | 575 | $vocid = $request->getVocab()->getId(); |
| 576 | 576 | return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang"); |
| 577 | 577 | } |
| 578 | - } else { |
|
| 578 | + } else { |
|
| 579 | 579 | header("Location: " . $urls[$format]); |
| 580 | - } |
|
| 580 | + } |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | private function returnDataResults($results, $format) { |
@@ -1100,15 +1100,15 @@ discard block |
||
| 1100 | 1100 | foreach($changeList as $conceptInfo) { |
| 1101 | 1101 | if (array_key_exists('date', $conceptInfo)) { |
| 1102 | 1102 | $simpleChangeList[] = array( 'uri' => $conceptInfo['uri'], |
| 1103 | - 'prefLabel' => $conceptInfo['prefLabel'], |
|
| 1104 | - 'date' => $conceptInfo['date']->format("Y-m-d\TH:i:sO") ); |
|
| 1103 | + 'prefLabel' => $conceptInfo['prefLabel'], |
|
| 1104 | + 'date' => $conceptInfo['date']->format("Y-m-d\TH:i:sO") ); |
|
| 1105 | 1105 | } |
| 1106 | 1106 | } |
| 1107 | 1107 | return $this->returnJson(array_merge_recursive($this->context, |
| 1108 | 1108 | array('@context' => array( '@language' => $request->getLang(), |
| 1109 | - 'prefLabel' => 'skos:prefLabel', |
|
| 1110 | - 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
|
| 1111 | - 'date' => array( '@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime') ) |
|
| 1109 | + 'prefLabel' => 'skos:prefLabel', |
|
| 1110 | + 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
|
| 1111 | + 'date' => array( '@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime') ) |
|
| 1112 | 1112 | ), |
| 1113 | 1113 | array('changeList' => $simpleChangeList))); |
| 1114 | 1114 | |
@@ -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) |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | // wrap with JSONP callback if requested |
| 26 | 26 | if (filter_input(INPUT_GET, 'callback', FILTER_SANITIZE_STRING)) { |
| 27 | 27 | header("Content-type: application/javascript; charset=utf-8"); |
| 28 | - echo filter_input(INPUT_GET, 'callback', FILTER_UNSAFE_RAW) . "(" . json_encode($data) . ");"; |
|
| 28 | + echo filter_input(INPUT_GET, 'callback', FILTER_UNSAFE_RAW)."(".json_encode($data).");"; |
|
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | 'vocabularies' => 'onki:hasVocabulary', |
| 89 | 89 | 'id' => 'onki:vocabularyIdentifier', |
| 90 | 90 | 'uri' => '@id', |
| 91 | - '@base' => $this->getBaseHref() . "rest/v1/vocabularies", |
|
| 91 | + '@base' => $this->getBaseHref()."rest/v1/vocabularies", |
|
| 92 | 92 | ), |
| 93 | 93 | 'uri' => '', |
| 94 | 94 | 'vocabularies' => $results, |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | // convert to vocids array to support multi-vocabulary search |
| 106 | 106 | $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : array(); |
| 107 | 107 | $vocabObjects = array(); |
| 108 | - foreach($vocids as $vocid) { |
|
| 108 | + foreach ($vocids as $vocid) { |
|
| 109 | 109 | $vocabObjects[] = $this->model->getVocabulary($vocid); |
| 110 | 110 | } |
| 111 | 111 | $parameters->setVocabularies($vocabObjects); |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | foreach ($parameters->getAdditionalFields() as $field) { |
| 137 | 137 | |
| 138 | 138 | // Quick-and-dirty compactification |
| 139 | - $context[$field] = 'skos:' . $field; |
|
| 139 | + $context[$field] = 'skos:'.$field; |
|
| 140 | 140 | foreach ($results as &$result) { |
| 141 | 141 | foreach ($result as $k => $v) { |
| 142 | - if ($k == 'skos:' . $field) { |
|
| 142 | + if ($k == 'skos:'.$field) { |
|
| 143 | 143 | $result[$field] = $v; |
| 144 | - unset($result['skos:' . $field]); |
|
| 144 | + unset($result['skos:'.$field]); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | if ($request->getQueryParam('labellang')) { |
| 161 | 161 | $ret['@context']['@language'] = $request->getQueryParam('labellang'); |
| 162 | 162 | } elseif ($request->getQueryParam('lang')) { |
| 163 | - $ret['@context']['@language'] = $request->getQueryParam('lang');; |
|
| 163 | + $ret['@context']['@language'] = $request->getQueryParam('lang'); ; |
|
| 164 | 164 | } |
| 165 | 165 | return $ret; |
| 166 | 166 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | 'prefLabel' => 'skos:prefLabel', |
| 230 | 230 | 'title' => 'dct:title', |
| 231 | 231 | '@language' => $request->getLang(), |
| 232 | - '@base' => $this->getBaseHref() . "rest/v1/" . $vocab->getId() . "/", |
|
| 232 | + '@base' => $this->getBaseHref()."rest/v1/".$vocab->getId()."/", |
|
| 233 | 233 | ), |
| 234 | 234 | 'uri' => '', |
| 235 | 235 | 'id' => $vocab->getId(), |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | 'subTypes' => array('@id' => 'void:class', '@type' => '@id'), |
| 284 | 284 | 'count' => 'void:entities', |
| 285 | 285 | '@language' => $request->getLang(), |
| 286 | - '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/", |
|
| 286 | + '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/", |
|
| 287 | 287 | ), |
| 288 | 288 | 'uri' => '', |
| 289 | 289 | 'id' => $request->getVocab()->getId(), |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | 'language' => 'void-ext:language', |
| 361 | 361 | 'properties' => 'void:propertyPartition', |
| 362 | 362 | 'labels' => 'void:triples', |
| 363 | - '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/", |
|
| 363 | + '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/", |
|
| 364 | 364 | ), |
| 365 | 365 | 'uri' => '', |
| 366 | 366 | 'id' => $request->getVocab()->getId(), |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | $types[] = $type; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - $base = $request->getVocab() ? $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/" : $this->getBaseHref() . "rest/v1/"; |
|
| 404 | + $base = $request->getVocab() ? $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/" : $this->getBaseHref()."rest/v1/"; |
|
| 405 | 405 | |
| 406 | 406 | $ret = array_merge_recursive($this->context, array( |
| 407 | 407 | '@context' => array( |
@@ -564,19 +564,19 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | $format = $this->negotiateFormat(array_keys($urls), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format')); |
| 566 | 566 | if (!$format) { |
| 567 | - return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . implode(' ', array_keys($urls))); |
|
| 567 | + return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".implode(' ', array_keys($urls))); |
|
| 568 | 568 | } |
| 569 | 569 | if (is_array($urls[$format])) { |
| 570 | 570 | $arr = $urls[$format]; |
| 571 | 571 | $dataLang = $request->getLang(); |
| 572 | 572 | if (isset($arr[$dataLang])) { |
| 573 | - header("Location: " . $arr[$dataLang]); |
|
| 573 | + header("Location: ".$arr[$dataLang]); |
|
| 574 | 574 | } else { |
| 575 | 575 | $vocid = $request->getVocab()->getId(); |
| 576 | 576 | return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang"); |
| 577 | 577 | } |
| 578 | 578 | } else { |
| 579 | - header("Location: " . $urls[$format]); |
|
| 579 | + header("Location: ".$urls[$format]); |
|
| 580 | 580 | } |
| 581 | 581 | } |
| 582 | 582 | |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | |
| 640 | 640 | $format = $this->negotiateFormat(explode(' ', self::SUPPORTED_FORMATS), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format')); |
| 641 | 641 | if (!$format) { |
| 642 | - return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . self::SUPPORTED_FORMATS); |
|
| 642 | + return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".self::SUPPORTED_FORMATS); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | $vocid = $vocab ? $vocab->getId() : null; |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | } |
| 925 | 925 | } |
| 926 | 926 | // if the main concept scheme was not found, set 'top' to the first 'tops' (sorted alphabetically on the URIs) |
| 927 | - if (! isset($results[$uri]['top'])) { |
|
| 927 | + if (!isset($results[$uri]['top'])) { |
|
| 928 | 928 | $results[$uri]['top'] = $results[$uri]['tops'][0]; |
| 929 | 929 | } |
| 930 | 930 | } else { |
@@ -1102,18 +1102,18 @@ discard block |
||
| 1102 | 1102 | $changeList = $request->getVocab()->getChangeList($prop, $request->getLang(), $offset, $limit); |
| 1103 | 1103 | |
| 1104 | 1104 | $simpleChangeList = array(); |
| 1105 | - foreach($changeList as $conceptInfo) { |
|
| 1105 | + foreach ($changeList as $conceptInfo) { |
|
| 1106 | 1106 | if (array_key_exists('date', $conceptInfo)) { |
| 1107 | - $simpleChangeList[] = array( 'uri' => $conceptInfo['uri'], |
|
| 1107 | + $simpleChangeList[] = array('uri' => $conceptInfo['uri'], |
|
| 1108 | 1108 | 'prefLabel' => $conceptInfo['prefLabel'], |
| 1109 | - 'date' => $conceptInfo['date']->format("Y-m-d\TH:i:sO") ); |
|
| 1109 | + 'date' => $conceptInfo['date']->format("Y-m-d\TH:i:sO")); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | } |
| 1112 | 1112 | return $this->returnJson(array_merge_recursive($this->context, |
| 1113 | - array('@context' => array( '@language' => $request->getLang(), |
|
| 1113 | + array('@context' => array('@language' => $request->getLang(), |
|
| 1114 | 1114 | 'prefLabel' => 'skos:prefLabel', |
| 1115 | 1115 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
| 1116 | - 'date' => array( '@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime') ) |
|
| 1116 | + 'date' => array('@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime')) |
|
| 1117 | 1117 | ), |
| 1118 | 1118 | array('changeList' => $simpleChangeList))); |
| 1119 | 1119 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | return $lname; |
| 105 | 105 | } |
| 106 | 106 | // already a full URI |
| 107 | - return $this->getUriSpace() . $lname; |
|
| 107 | + return $this->getUriSpace().$lname; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | foreach ($conceptscheme->allLiterals($prop, null) as $val) { |
| 176 | 176 | $prop = (substr($prop, 0, 5) == 'dc11:') ? str_replace('dc11:', 'dc:', $prop) : $prop; |
| 177 | 177 | if ($val->getValue() instanceof DateTime) { |
| 178 | - $val = Punic\Calendar::formatDate($val->getValue(), 'full', $lang) . ' ' . Punic\Calendar::format($val->getValue(), 'HH:mm:ss', $lang); |
|
| 178 | + $val = Punic\Calendar::formatDate($val->getValue(), 'full', $lang).' '.Punic\Calendar::format($val->getValue(), 'HH:mm:ss', $lang); |
|
| 179 | 179 | } |
| 180 | 180 | $ret[$prop][] = $val; |
| 181 | 181 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | // don't know how to parse |
| 298 | 298 | $rev = $parts[2]; |
| 299 | - $datestr = $parts[3] . ' ' . $parts[4]; |
|
| 299 | + $datestr = $parts[3].' '.$parts[4]; |
|
| 300 | 300 | |
| 301 | 301 | return "$datestr (r$rev)"; |
| 302 | 302 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * Counts the statistics of the vocabulary. |
| 306 | 306 | * @return array of the concept/group counts |
| 307 | 307 | */ |
| 308 | - public function getStatistics($lang = '', $array=null, $group=null) |
|
| 308 | + public function getStatistics($lang = '', $array = null, $group = null) |
|
| 309 | 309 | { |
| 310 | 310 | $sparql = $this->getSparql(); |
| 311 | 311 | // find the number of concepts |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | return $this->getSparql()->queryChangeList($clang, $offset, $prop, $limit); |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - public function getTitle($lang=null) { |
|
| 627 | + public function getTitle($lang = null) { |
|
| 628 | 628 | return $this->config->getTitle($lang); |
| 629 | 629 | } |
| 630 | 630 | |
@@ -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($clang, $offset, $prop, $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 | } |
@@ -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 | } |
@@ -2211,9 +2211,9 @@ discard block |
||
| 2211 | 2211 | * @param int $offset offset of results to retrieve; 0 for beginning of list |
| 2212 | 2212 | * @return string sparql query |
| 2213 | 2213 | */ |
| 2214 | - private function generateChangeListQuery($lang, $offset, $prop, $limit=200) { |
|
| 2214 | + private function generateChangeListQuery($lang, $offset, $prop, $limit = 200) { |
|
| 2215 | 2215 | $fcl = $this->generateFromClause(); |
| 2216 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
| 2216 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
| 2217 | 2217 | |
| 2218 | 2218 | $query = <<<EOQ |
| 2219 | 2219 | SELECT DISTINCT ?concept ?date ?label $fcl |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * Returns the graph instance |
| 154 | - * @return object EasyRDF graph instance. |
|
| 154 | + * @return string|null EasyRDF graph instance. |
|
| 155 | 155 | */ |
| 156 | 156 | public function getGraph() { |
| 157 | 157 | return $this->graph; |
@@ -286,6 +286,7 @@ discard block |
||
| 286 | 286 | /** |
| 287 | 287 | * Counts the number of concepts in a easyRDF graph with a specific language. |
| 288 | 288 | * @param array $langs Languages to query for |
| 289 | + * @param string[] $classes |
|
| 289 | 290 | * @return Array containing count of concepts for each language and property. |
| 290 | 291 | */ |
| 291 | 292 | public function countLangConcepts($langs, $classes = null) { |
@@ -470,7 +471,7 @@ discard block |
||
| 470 | 471 | * Returns information (as a graph) for one or more concept URIs |
| 471 | 472 | * @param mixed $uris concept URI (string) or array of URIs |
| 472 | 473 | * @param string|null $arrayClass the URI for thesaurus array class, or null if not used |
| 473 | - * @param \Vocabulary[]|null $vocabs vocabularies to target |
|
| 474 | + * @param Vocabulary[] $vocabs vocabularies to target |
|
| 474 | 475 | * @return \EasyRdf\Graph |
| 475 | 476 | */ |
| 476 | 477 | public function queryConceptInfoGraph($uris, $arrayClass = null, $vocabs = array()) { |
@@ -486,7 +487,7 @@ discard block |
||
| 486 | 487 | |
| 487 | 488 | /** |
| 488 | 489 | * Returns information (as an array of Concept objects) for one or more concept URIs |
| 489 | - * @param mixed $uris concept URI (string) or array of URIs |
|
| 490 | + * @param string $uris concept URI (string) or array of URIs |
|
| 490 | 491 | * @param string|null $arrayClass the URI for thesaurus array class, or null if not used |
| 491 | 492 | * @param \Vocabulary[] $vocabs vocabularies to target |
| 492 | 493 | * @param string|null $clang content language |
@@ -704,7 +705,7 @@ discard block |
||
| 704 | 705 | |
| 705 | 706 | /** |
| 706 | 707 | * Generate a VALUES clause for limiting the targeted graphs. |
| 707 | - * @param Vocabulary[]|null $vocabs array of Vocabulary objects to target |
|
| 708 | + * @param Vocabulary[] $vocabs array of Vocabulary objects to target |
|
| 708 | 709 | * @return string VALUES clause, or "" if not necessary to limit |
| 709 | 710 | */ |
| 710 | 711 | protected function formatValuesGraph($vocabs) { |
@@ -886,6 +887,7 @@ discard block |
||
| 886 | 887 | * @param string $searchLang language code used for matching labels (null means any language) |
| 887 | 888 | * @param string[] $props properties to target e.g. array('skos:prefLabel','skos:altLabel') |
| 888 | 889 | * @param boolean $unique restrict results to unique concepts (default: false) |
| 890 | + * @param string $filterGraph |
|
| 889 | 891 | * @return string sparql query |
| 890 | 892 | */ |
| 891 | 893 | protected function generateConceptSearchQueryInner($term, $lang, $searchLang, $props, $unique, $filterGraph) |
@@ -1181,6 +1183,7 @@ discard block |
||
| 1181 | 1183 | /** |
| 1182 | 1184 | * Generates sparql query clauses used for creating the alphabetical index. |
| 1183 | 1185 | * @param string $letter the letter (or special class) to search for |
| 1186 | + * @param string $lang |
|
| 1184 | 1187 | * @return array of sparql query clause strings |
| 1185 | 1188 | */ |
| 1186 | 1189 | private function formatFilterConditions($letter, $lang) { |
@@ -1361,6 +1364,7 @@ discard block |
||
| 1361 | 1364 | /** |
| 1362 | 1365 | * Query for the first characters (letter or otherwise) of the labels in the particular language. |
| 1363 | 1366 | * @param string $lang language |
| 1367 | + * @param string[] $classes |
|
| 1364 | 1368 | * @return array array of characters |
| 1365 | 1369 | */ |
| 1366 | 1370 | public function queryFirstCharacters($lang, $classes = null) { |
@@ -1731,7 +1735,7 @@ discard block |
||
| 1731 | 1735 | /** |
| 1732 | 1736 | * Query a single transitive property of a concept. |
| 1733 | 1737 | * @param string $uri |
| 1734 | - * @param array $props the property/properties. |
|
| 1738 | + * @param string[] $props the property/properties. |
|
| 1735 | 1739 | * @param string $lang |
| 1736 | 1740 | * @param string $fallbacklang language to use if label is not available in the preferred language |
| 1737 | 1741 | * @param integer $limit |
@@ -2259,6 +2263,8 @@ discard block |
||
| 2259 | 2263 | * return a list of recently changed or entirely new concepts |
| 2260 | 2264 | * @param string $lang language of labels to return |
| 2261 | 2265 | * @param int $offset offset of results to retrieve; 0 for beginning of list |
| 2266 | + * @param string $prop |
|
| 2267 | + * @param integer $limit |
|
| 2262 | 2268 | * @return array Result array |
| 2263 | 2269 | */ |
| 2264 | 2270 | public function queryChangeList($lang, $offset, $prop, $limit) { |
@@ -590,11 +590,11 @@ |
||
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
| 593 | - * Formats the list of concepts as labels arranged by modification month |
|
| 594 | - * @param Request $request |
|
| 595 | - * @param string $prop the name of the property for a time stamp |
|
| 596 | - * @return Array list of concept labels |
|
| 597 | - */ |
|
| 593 | + * Formats the list of concepts as labels arranged by modification month |
|
| 594 | + * @param Request $request |
|
| 595 | + * @param string $prop the name of the property for a time stamp |
|
| 596 | + * @return Array list of concept labels |
|
| 597 | + */ |
|
| 598 | 598 | public function formatChangeList($request, $prop) |
| 599 | 599 | { |
| 600 | 600 | $offset = ($request->getQueryParam('offset') && is_numeric($request->getQueryParam('offset')) && $request->getQueryParam('offset') >= 0) ? $request->getQueryParam('offset') : 0; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | // specify where to look for templates and cache |
| 38 | 38 | $loader = new Twig_Loader_Filesystem('view'); |
| 39 | 39 | // initialize Twig environment |
| 40 | - $this->twig = new Twig_Environment($loader, array('cache' => $tmpDir,'auto_reload' => true)); |
|
| 40 | + $this->twig = new Twig_Environment($loader, array('cache' => $tmpDir, 'auto_reload' => true)); |
|
| 41 | 41 | $this->twig->addExtension(new Twig_Extensions_Extension_I18n()); |
| 42 | 42 | // used for setting the base href for the relative urls |
| 43 | 43 | $this->twig->addGlobal("BaseHref", $this->getBaseHref()); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->twig->addFilter(new Twig_SimpleFilter('link_url', array($this, 'linkUrlFilter'))); |
| 61 | 61 | |
| 62 | 62 | // register a Twig filter for generating strings from language codes with CLDR |
| 63 | - $langFilter = new Twig_SimpleFilter('lang_name', function ($langcode, $lang) { |
|
| 63 | + $langFilter = new Twig_SimpleFilter('lang_name', function($langcode, $lang) { |
|
| 64 | 64 | return Language::getName($langcode, $lang); |
| 65 | 65 | }); |
| 66 | 66 | $this->twig->addFilter($langFilter); |
@@ -237,17 +237,17 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender) |
| 239 | 239 | { |
| 240 | - $headers = "MIME-Version: 1.0" . "\r\n"; |
|
| 241 | - $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n"; |
|
| 240 | + $headers = "MIME-Version: 1.0"."\r\n"; |
|
| 241 | + $headers .= "Content-type: text/html; charset=UTF-8"."\r\n"; |
|
| 242 | 242 | if (!empty($toMail)) { |
| 243 | - $headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n"; |
|
| 243 | + $headers .= "Cc: ".$this->model->getConfig()->getFeedbackAddress()."\r\n"; |
|
| 244 | 244 | } |
| 245 | 245 | if (!empty($fromEmail)) { |
| 246 | 246 | $headers .= "Reply-To: $fromName <$fromEmail>\r\n"; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | $service = $this->model->getConfig()->getServiceName(); |
| 250 | - return $headers . "From: $fromName via $service <$sender>"; |
|
| 250 | + return $headers."From: $fromName via $service <$sender>"; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | { |
| 262 | 262 | $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress(); |
| 263 | 263 | if ($fromVocab !== null && $fromVocab !== '') { |
| 264 | - $message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message; |
|
| 264 | + $message = 'Feedback from vocab: '.strtoupper($fromVocab)."<br />".$message; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | $envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender(); |
| 268 | - $subject = $this->model->getConfig()->getServiceName() . " feedback"; |
|
| 268 | + $subject = $this->model->getConfig()->getServiceName()." feedback"; |
|
| 269 | 269 | // determine the sender address of the message |
| 270 | 270 | $sender = $this->model->getConfig()->getFeedbackSender(); |
| 271 | 271 | if (empty($sender)) $sender = $envelopeSender; |
@@ -278,10 +278,10 @@ discard block |
||
| 278 | 278 | $params = empty($envelopeSender) ? '' : "-f $envelopeSender"; |
| 279 | 279 | |
| 280 | 280 | // adding some information about the user for debugging purposes. |
| 281 | - $message = $message . "<br /><br /> Debugging information:" |
|
| 282 | - . "<br />Timestamp: " . date(DATE_RFC2822) |
|
| 283 | - . "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT') |
|
| 284 | - . "<br />Referer: " . $request->getServerConstant('HTTP_REFERER'); |
|
| 281 | + $message = $message."<br /><br /> Debugging information:" |
|
| 282 | + . "<br />Timestamp: ".date(DATE_RFC2822) |
|
| 283 | + . "<br />User agent: ".$request->getServerConstant('HTTP_USER_AGENT') |
|
| 284 | + . "<br />Referer: ".$request->getServerConstant('HTTP_REFERER'); |
|
| 285 | 285 | |
| 286 | 286 | try { |
| 287 | 287 | mail($toAddress, $subject, $message, $headers, $params); |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | header("HTTP/1.0 404 Not Found"); |
| 290 | 290 | $template = $this->twig->loadTemplate('error-page.twig'); |
| 291 | 291 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 292 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 292 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | echo $template->render( |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : null; |
| 337 | 337 | $vocabObjects = array(); |
| 338 | 338 | if ($vocids) { |
| 339 | - foreach($vocids as $vocid) { |
|
| 339 | + foreach ($vocids as $vocid) { |
|
| 340 | 340 | $vocabObjects[] = $this->model->getVocabulary($vocid); |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | } catch (Exception $e) { |
| 348 | 348 | header("HTTP/1.0 404 Not Found"); |
| 349 | 349 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 350 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 350 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 351 | 351 | } |
| 352 | 352 | $this->invokeGenericErrorPage($request, $e->getMessage()); |
| 353 | 353 | return; |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | 'search_count' => $counts, |
| 364 | 364 | 'languages' => $this->languages, |
| 365 | 365 | 'search_results' => $searchResults, |
| 366 | - 'rest' => $parameters->getOffset()>0, |
|
| 366 | + 'rest' => $parameters->getOffset() > 0, |
|
| 367 | 367 | 'global_search' => true, |
| 368 | 368 | 'term' => $request->getQueryParamRaw('q'), |
| 369 | 369 | 'lang_list' => $langList, |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | } catch (Exception $e) { |
| 389 | 389 | header("HTTP/1.0 404 Not Found"); |
| 390 | 390 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 391 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 391 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | echo $template->render( |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | } catch (Exception $e) { |
| 410 | 410 | header("HTTP/1.0 404 Not Found"); |
| 411 | 411 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 412 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 412 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | echo $template->render( |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | 'vocab' => $vocab, |
| 427 | 427 | 'search_results' => $searchResults, |
| 428 | 428 | 'search_count' => $counts, |
| 429 | - 'rest' => $parameters->getOffset()>0, |
|
| 429 | + 'rest' => $parameters->getOffset() > 0, |
|
| 430 | 430 | 'limit_parent' => $parameters->getParentLimit(), |
| 431 | 431 | 'limit_type' => $request->getQueryParam('type') ? explode('+', $request->getQueryParam('type')) : null, |
| 432 | 432 | 'limit_group' => $parameters->getGroupLimit(), |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | * Loads and renders the view containing a list of recent changes in the vocabulary. |
| 558 | 558 | * @param Request $request |
| 559 | 559 | */ |
| 560 | - public function invokeChangeList($request, $prop='dc:created') |
|
| 560 | + public function invokeChangeList($request, $prop = 'dc:created') |
|
| 561 | 561 | { |
| 562 | 562 | $bydate = $this->formatChangeList($request, $prop); |
| 563 | 563 | |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @param int $limit maximum number of concepts to return |
| 582 | 582 | * @return Array list of concepts |
| 583 | 583 | */ |
| 584 | - private function getChangeList($request, $prop, $offset=0, $limit=200) |
|
| 584 | + private function getChangeList($request, $prop, $offset = 0, $limit = 200) |
|
| 585 | 585 | { |
| 586 | 586 | // set language parameters for gettext |
| 587 | 587 | $this->setLanguageProperties($request->getLang()); |
@@ -602,9 +602,9 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | $changeList = $this->getChangeList($request, $prop, $offset, $limit); |
| 604 | 604 | $formatByDate = array(); |
| 605 | - foreach($changeList as $concept) { |
|
| 605 | + foreach ($changeList as $concept) { |
|
| 606 | 606 | $concept['datestring'] = Punic\Calendar::formatDate($concept['date'], 'medium', $request->getLang()); |
| 607 | - $formatByDate[Punic\Calendar::getMonthName($concept['date'], 'wide', $request->getLang(), true) . Punic\Calendar::format($concept['date'], ' y', $request->getLang()) ][strtolower($concept['prefLabel'])] = $concept; |
|
| 607 | + $formatByDate[Punic\Calendar::getMonthName($concept['date'], 'wide', $request->getLang(), true).Punic\Calendar::format($concept['date'], ' y', $request->getLang())][strtolower($concept['prefLabel'])] = $concept; |
|
| 608 | 608 | } |
| 609 | 609 | return $formatByDate; |
| 610 | 610 | } |