@@ -167,9 +167,11 @@ |
||
| 167 | 167 | */ |
| 168 | 168 | public function setVocab($vocabid) |
| 169 | 169 | { |
| 170 | - if (strpos($vocabid, ' ') !== false) // if there are multiple vocabularies just storing the string |
|
| 170 | + if (strpos($vocabid, ' ') !== false) { |
|
| 171 | + // if there are multiple vocabularies just storing the string |
|
| 171 | 172 | { |
| 172 | 173 | $this->setVocabids($vocabid); |
| 174 | + } |
|
| 173 | 175 | } else { |
| 174 | 176 | $this->vocab = $this->model->getVocabulary($vocabid); |
| 175 | 177 | } |
@@ -106,7 +106,7 @@ |
||
| 106 | 106 | |
| 107 | 107 | public function getRequestUri() |
| 108 | 108 | { |
| 109 | - return $this->getServerConstant('HTTP_HOST') . $this->getServerConstant('REQUEST_URI'); |
|
| 109 | + return $this->getServerConstant('HTTP_HOST').$this->getServerConstant('REQUEST_URI'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | return Punic\Calendar::formatDate($val, 'short'); |
| 45 | 45 | } catch (Exception $e) { |
| 46 | 46 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 47 | - return (string) $this->literal; |
|
| 47 | + return (string)$this->literal; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | return $this->literal->getValue(); |
@@ -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 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return $lname; |
| 98 | 98 | } |
| 99 | 99 | // already a full URI |
| 100 | - return $this->getUriSpace() . $lname; |
|
| 100 | + return $this->getUriSpace().$lname; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $prop = (substr($prop, 0, 5) == 'dc11:') ? str_replace('dc11:', 'dc:', $prop) : $prop; |
| 160 | 160 | $value = $val->getValue(); |
| 161 | 161 | if ($value instanceof DateTime) { |
| 162 | - $val = Punic\Calendar::formatDate($value, 'full', $lang) . ' ' . Punic\Calendar::format($value, 'HH:mm:ss', $lang); |
|
| 162 | + $val = Punic\Calendar::formatDate($value, 'full', $lang).' '.Punic\Calendar::format($value, 'HH:mm:ss', $lang); |
|
| 163 | 163 | } |
| 164 | 164 | $ret[$prop][] = $val; |
| 165 | 165 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | // don't know how to parse |
| 272 | 272 | $rev = $parts[2]; |
| 273 | - $datestr = $parts[3] . ' ' . $parts[4]; |
|
| 273 | + $datestr = $parts[3].' '.$parts[4]; |
|
| 274 | 274 | |
| 275 | 275 | return "$datestr (r$rev)"; |
| 276 | 276 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * Counts the statistics of the vocabulary. |
| 280 | 280 | * @return array of the concept/group counts |
| 281 | 281 | */ |
| 282 | - public function getStatistics($lang = '', $array=null, $group=null) |
|
| 282 | + public function getStatistics($lang = '', $array = null, $group = null) |
|
| 283 | 283 | { |
| 284 | 284 | $sparql = $this->getSparql(); |
| 285 | 285 | // find the number of concepts |
@@ -595,14 +595,14 @@ discard block |
||
| 595 | 595 | { |
| 596 | 596 | $changelist = $this->getSparql()->queryChangeList($clang, $offset, $prop); |
| 597 | 597 | $bydate = array(); |
| 598 | - foreach($changelist as $concept) { |
|
| 598 | + foreach ($changelist as $concept) { |
|
| 599 | 599 | $concept['datestring'] = Punic\Calendar::formatDate($concept['date'], 'medium', $lang); |
| 600 | - $bydate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true) . Punic\Calendar::format($concept['date'], ' y', $lang) ][strtolower($concept['prefLabel'])] = $concept; |
|
| 600 | + $bydate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true).Punic\Calendar::format($concept['date'], ' y', $lang)][strtolower($concept['prefLabel'])] = $concept; |
|
| 601 | 601 | } |
| 602 | 602 | return $bydate; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - public function getTitle($lang=null) { |
|
| 605 | + public function getTitle($lang = null) { |
|
| 606 | 606 | return $this->config->getTitle($lang); |
| 607 | 607 | } |
| 608 | 608 | |
@@ -67,8 +67,9 @@ |
||
| 67 | 67 | public function getSearchTerm() |
| 68 | 68 | { |
| 69 | 69 | $term = $this->request->getQueryParam('q') ? $this->request->getQueryParam('q') : $this->request->getQueryParam('query'); |
| 70 | - if (!$term && $this->rest) |
|
| 71 | - $term = $this->request->getQueryParam('label'); |
|
| 70 | + if (!$term && $this->rest) { |
|
| 71 | + $term = $this->request->getQueryParam('label'); |
|
| 72 | + } |
|
| 72 | 73 | $term = trim($term); // surrounding whitespace is not considered significant |
| 73 | 74 | return strpos($term, "*") === false ? $term . "*" : $term; // default to prefix search |
| 74 | 75 | } |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | if ($this->rest) { |
| 82 | 82 | return $term; |
| 83 | 83 | } |
| 84 | - return strpos($term, "*") === false ? $term . "*" : $term; // default to prefix search |
|
| 84 | + return strpos($term, "*") === false ? $term."*" : $term; // default to prefix search |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function getContentLang() |
@@ -10,6 +10,9 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class VocabularyCategory extends DataObject |
| 12 | 12 | { |
| 13 | + /** |
|
| 14 | + * @param Model $model |
|
| 15 | + */ |
|
| 13 | 16 | public function __construct($model, $resource) |
| 14 | 17 | { |
| 15 | 18 | if (!($model instanceof Model)) { |
@@ -101,10 +101,12 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | private function initializeNamespaces() { |
| 103 | 103 | foreach ($this->namespaces as $prefix => $full_uri) { |
| 104 | - if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) // if not already defined |
|
| 104 | + if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) { |
|
| 105 | + // if not already defined |
|
| 105 | 106 | { |
| 106 | 107 | EasyRdf_Namespace::set($prefix, $full_uri); |
| 107 | 108 | } |
| 109 | + } |
|
| 108 | 110 | } |
| 109 | 111 | } |
| 110 | 112 | |
@@ -379,10 +381,12 @@ discard block |
||
| 379 | 381 | // register vocabulary ids as RDF namespace prefixes |
| 380 | 382 | $prefix = preg_replace('/\W+/', '', $voc->getId()); // strip non-word characters |
| 381 | 383 | try { |
| 382 | - if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) // if not already defined |
|
| 384 | + if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) { |
|
| 385 | + // if not already defined |
|
| 383 | 386 | { |
| 384 | 387 | EasyRdf_Namespace::set($prefix, $voc->getUriSpace()); |
| 385 | 388 | } |
| 389 | + } |
|
| 386 | 390 | |
| 387 | 391 | } catch (Exception $e) { |
| 388 | 392 | // not valid as namespace identifier, ignore |
@@ -65,15 +65,15 @@ discard block |
||
| 65 | 65 | private function initializeVocabularies() |
| 66 | 66 | { |
| 67 | 67 | if (!file_exists($this->getConfig()->getVocabularyConfigFile())) { |
| 68 | - throw new Exception($this->getConfig()->getVocabularyConfigFile() . ' is missing, please provide one.'); |
|
| 68 | + throw new Exception($this->getConfig()->getVocabularyConfigFile().' is missing, please provide one.'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | try { |
| 72 | 72 | // use APC user cache to store parsed vocabularies.ttl configuration |
| 73 | 73 | if (function_exists('apc_store') && function_exists('apc_fetch')) { |
| 74 | 74 | // @codeCoverageIgnoreStart |
| 75 | - $key = realpath($this->getConfig()->getVocabularyConfigFile()) . ", " . filemtime($this->getConfig()->getVocabularyConfigFile()); |
|
| 76 | - $nskey = "namespaces of " . $key; |
|
| 75 | + $key = realpath($this->getConfig()->getVocabularyConfigFile()).", ".filemtime($this->getConfig()->getVocabularyConfigFile()); |
|
| 76 | + $nskey = "namespaces of ".$key; |
|
| 77 | 77 | $this->graph = apc_fetch($key); |
| 78 | 78 | $this->namespaces = apc_fetch($nskey); |
| 79 | 79 | if ($this->graph === false || $this->namespaces === false) { // was not found in cache |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $this->parseVocabularies($this->getConfig()->getVocabularyConfigFile()); |
| 87 | 87 | } |
| 88 | 88 | } catch (Exception $e) { |
| 89 | - echo "Error: " . $e->getMessage(); |
|
| 89 | + echo "Error: ".$e->getMessage(); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | public function getVocabularyCategories() |
| 425 | 425 | { |
| 426 | 426 | $cats = $this->graph->allOfType('skos:Concept'); |
| 427 | - if(empty($cats)) { |
|
| 427 | + if (empty($cats)) { |
|
| 428 | 428 | return array(new VocabularyCategory($this, null)); |
| 429 | 429 | } |
| 430 | 430 | |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | // using apc cache for the resource if available |
| 572 | 572 | if (function_exists('apc_store') && function_exists('apc_fetch')) { |
| 573 | 573 | // @codeCoverageIgnoreStart |
| 574 | - $key = 'fetch: ' . EasyRdf_Utils::removeFragmentFromUri($uri); |
|
| 574 | + $key = 'fetch: '.EasyRdf_Utils::removeFragmentFromUri($uri); |
|
| 575 | 575 | $resource = apc_fetch($key); |
| 576 | 576 | if ($resource === null || $resource === false) { // was not found in cache, or previous request failed |
| 577 | 577 | $resource = $this->fetchResourceFromUri($uri); |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | */ |
| 593 | 593 | public function getSparqlImplementation($dialect, $endpoint, $graph) |
| 594 | 594 | { |
| 595 | - $classname = $dialect . "Sparql"; |
|
| 595 | + $classname = $dialect."Sparql"; |
|
| 596 | 596 | |
| 597 | 597 | return new $classname($endpoint, $graph, $this); |
| 598 | 598 | } |
@@ -23,6 +23,9 @@ |
||
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | + /** |
|
| 27 | + * @param string $name |
|
| 28 | + */ |
|
| 26 | 29 | private function getConstant($name, $default) |
| 27 | 30 | { |
| 28 | 31 | if (defined($name) && constant($name)) { |
@@ -6,10 +6,10 @@ discard block |
||
| 6 | 6 | class GlobalConfig { |
| 7 | 7 | private $languages; |
| 8 | 8 | |
| 9 | - public function __construct($config_name='/../config.inc') |
|
| 9 | + public function __construct($config_name = '/../config.inc') |
|
| 10 | 10 | { |
| 11 | 11 | try { |
| 12 | - $file_path = dirname(__FILE__) . $config_name; |
|
| 12 | + $file_path = dirname(__FILE__).$config_name; |
|
| 13 | 13 | if (!file_exists($file_path)) { |
| 14 | 14 | throw new Exception('config.inc file is missing, please provide one.'); |
| 15 | 15 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $this->languages = $LANGUAGES; |
| 19 | 19 | } |
| 20 | 20 | } catch (Exception $e) { |
| 21 | - echo "Error: " . $e->getMessage(); |
|
| 21 | + echo "Error: ".$e->getMessage(); |
|
| 22 | 22 | return; |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -68,10 +68,12 @@ |
||
| 68 | 68 | if ($sortable !== null) { |
| 69 | 69 | uksort($sortable, array($this, 'mycompare')); |
| 70 | 70 | foreach ($sortable as $prop => $vals) { |
| 71 | - if (is_array($prop)) // the ConceptProperty objects have their own sorting methods |
|
| 71 | + if (is_array($prop)) { |
|
| 72 | + // the ConceptProperty objects have their own sorting methods |
|
| 72 | 73 | { |
| 73 | 74 | ksort($sortable[$prop]); |
| 74 | 75 | } |
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | } |
| 77 | 79 | } |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | */ |
| 115 | 115 | public function getEnvLang() |
| 116 | 116 | { |
| 117 | - // get language from locale, same as used by gettext, set by Controller |
|
| 118 | - return substr(getenv("LC_ALL"), 0, 2); // @codeCoverageIgnore |
|
| 117 | + // get language from locale, same as used by gettext, set by Controller |
|
| 118 | + return substr(getenv("LC_ALL"), 0, 2); // @codeCoverageIgnore |
|
| 119 | 119 | } |
| 120 | 120 | } |
@@ -407,7 +407,9 @@ discard block |
||
| 407 | 407 | $hits[] = $res; |
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | - if (sizeof($hits) > 0) return $hits; |
|
| 410 | + if (sizeof($hits) > 0) { |
|
| 411 | + return $hits; |
|
| 412 | + } |
|
| 411 | 413 | |
| 412 | 414 | // case 2: case-insensitive match on preferred label |
| 413 | 415 | foreach ($results as $res) { |
@@ -415,7 +417,9 @@ discard block |
||
| 415 | 417 | $hits[] = $res; |
| 416 | 418 | } |
| 417 | 419 | } |
| 418 | - if (sizeof($hits) > 0) return $hits; |
|
| 420 | + if (sizeof($hits) > 0) { |
|
| 421 | + return $hits; |
|
| 422 | + } |
|
| 419 | 423 | |
| 420 | 424 | // case 3: exact match on alternate label |
| 421 | 425 | foreach ($results as $res) { |
@@ -423,7 +427,9 @@ discard block |
||
| 423 | 427 | $hits[] = $res; |
| 424 | 428 | } |
| 425 | 429 | } |
| 426 | - if (sizeof($hits) > 0) return $hits; |
|
| 430 | + if (sizeof($hits) > 0) { |
|
| 431 | + return $hits; |
|
| 432 | + } |
|
| 427 | 433 | |
| 428 | 434 | |
| 429 | 435 | // case 4: case-insensitive match on alternate label |
@@ -114,6 +114,9 @@ discard block |
||
| 114 | 114 | return $this->returnJson($ret); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | + /** |
|
| 118 | + * @param Request $request |
|
| 119 | + */ |
|
| 117 | 120 | private function constructSearchParameters($request) |
| 118 | 121 | { |
| 119 | 122 | $parameters = new ConceptSearchParameters($request, $this->model->getConfig(), true); |
@@ -129,6 +132,9 @@ discard block |
||
| 129 | 132 | return $parameters; |
| 130 | 133 | } |
| 131 | 134 | |
| 135 | + /** |
|
| 136 | + * @param Request $request |
|
| 137 | + */ |
|
| 132 | 138 | private function transformSearchResults($request, $results) |
| 133 | 139 | { |
| 134 | 140 | // before serializing to JSON, get rid of the Vocabulary object that came with each resource |
@@ -504,6 +510,9 @@ discard block |
||
| 504 | 510 | return $this->returnJson($ret); |
| 505 | 511 | } |
| 506 | 512 | |
| 513 | + /** |
|
| 514 | + * @param Request $request |
|
| 515 | + */ |
|
| 507 | 516 | private function redirectToVocabData($request) { |
| 508 | 517 | $urls = $request->getVocab()->getConfig()->getDataURLs(); |
| 509 | 518 | if (sizeof($urls) == 0) { |
@@ -519,6 +528,9 @@ discard block |
||
| 519 | 528 | header("Location: " . $urls[$format]); |
| 520 | 529 | } |
| 521 | 530 | |
| 531 | + /** |
|
| 532 | + * @param string $format |
|
| 533 | + */ |
|
| 522 | 534 | private function returnDataResults($results, $format) { |
| 523 | 535 | if ($format == 'application/ld+json' || $format == 'application/json') { |
| 524 | 536 | // further compact JSON-LD document using a context |
@@ -606,6 +618,12 @@ discard block |
||
| 606 | 618 | return $this->returnJson($ret); |
| 607 | 619 | } |
| 608 | 620 | |
| 621 | + /** |
|
| 622 | + * @param string $uri |
|
| 623 | + * @param string $lang |
|
| 624 | + * @param string $propname |
|
| 625 | + * @param string $propuri |
|
| 626 | + */ |
|
| 609 | 627 | private function transformPropertyResults($uri, $lang, $objects, $propname, $propuri) |
| 610 | 628 | { |
| 611 | 629 | foreach ($objects as $objuri => $vals) { |
@@ -620,6 +638,14 @@ discard block |
||
| 620 | 638 | return $ret; |
| 621 | 639 | } |
| 622 | 640 | |
| 641 | + /** |
|
| 642 | + * @param string $uri |
|
| 643 | + * @param string $lang |
|
| 644 | + * @param string $tpropname |
|
| 645 | + * @param string $tpropuri |
|
| 646 | + * @param string $dpropname |
|
| 647 | + * @param string $dpropuri |
|
| 648 | + */ |
|
| 623 | 649 | private function transformTransitivePropertyResults($uri, $lang, $objects, $tpropname, $tpropuri, $dpropname, $dpropuri) |
| 624 | 650 | { |
| 625 | 651 | $results = array(); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | // wrap with JSONP callback if requested |
| 44 | 44 | if (filter_input(INPUT_GET, 'callback', FILTER_SANITIZE_STRING)) { |
| 45 | 45 | header("Content-type: application/javascript; charset=utf-8"); |
| 46 | - echo filter_input(INPUT_GET, 'callback', FILTER_UNSAFE_RAW) . "(" . json_encode($data) . ");"; |
|
| 46 | + echo filter_input(INPUT_GET, 'callback', FILTER_UNSAFE_RAW)."(".json_encode($data).");"; |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | // convert to vocids array to support multi-vocabulary search |
| 123 | 123 | $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : array(); |
| 124 | 124 | $vocabObjects = array(); |
| 125 | - foreach($vocids as $vocid) { |
|
| 125 | + foreach ($vocids as $vocid) { |
|
| 126 | 126 | $vocabObjects[] = $this->model->getVocabulary($vocid); |
| 127 | 127 | } |
| 128 | 128 | $parameters->setVocabularies($vocabObjects); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | if ($request->getQueryParam('labellang')) { |
| 169 | 169 | $ret['@context']['@language'] = $request->getQueryParam('labellang'); |
| 170 | 170 | } elseif ($request->getQueryParam('lang')) { |
| 171 | - $ret['@context']['@language'] = $request->getQueryParam('lang');; |
|
| 171 | + $ret['@context']['@language'] = $request->getQueryParam('lang'); ; |
|
| 172 | 172 | } |
| 173 | 173 | return $ret; |
| 174 | 174 | } |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | |
| 514 | 514 | $format = $this->negotiateFormat(array_keys($urls), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format')); |
| 515 | 515 | if (!$format) { |
| 516 | - return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . implode(' ', array_keys($urls))); |
|
| 516 | + return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".implode(' ', array_keys($urls))); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - header("Location: " . $urls[$format]); |
|
| 519 | + header("Location: ".$urls[$format]); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | private function returnDataResults($results, $format) { |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $format = $this->negotiateFormat(explode(' ', self::SUPPORTED_FORMATS), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format')); |
| 572 | 572 | if (!$format) { |
| 573 | - return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . self::SUPPORTED_FORMATS); |
|
| 573 | + return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".self::SUPPORTED_FORMATS); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | $vocid = $vocab ? $vocab->getId() : null; |