@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | $exsparql = $exvoc->getSparql(); |
| 51 | 51 | $results = $exsparql->queryLabel($exuri, $lang); |
| 52 | 52 | return isset($results[$lang]) ? $results[$lang] : null; |
| 53 | - } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
|
| 53 | + } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
|
| 54 | 54 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 55 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 55 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | $exsparql = $exvoc->getSparql(); |
| 73 | 73 | $results = $exsparql->queryNotation($exuri); |
| 74 | 74 | return isset($results) ? $results : null; |
| 75 | - } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
|
| 75 | + } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
|
| 76 | 76 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 77 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 77 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -220,18 +220,18 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | $vocabs = $params->getVocabs(); |
| 223 | - $showDeprecated=false; |
|
| 223 | + $showDeprecated = false; |
|
| 224 | 224 | if (sizeof($vocabs) === 1) { // search within vocabulary |
| 225 | 225 | $voc = $vocabs[0]; |
| 226 | 226 | $sparql = $voc->getSparql(); |
| 227 | - $showDeprecated=$voc->getConfig()->getShowDeprecated(); |
|
| 227 | + $showDeprecated = $voc->getConfig()->getShowDeprecated(); |
|
| 228 | 228 | } else { // multi-vocabulary or global search |
| 229 | 229 | $voc = null; |
| 230 | 230 | $sparql = $this->getDefaultSparql(); |
| 231 | 231 | // @TODO : in a global search showDeprecated will always be false and cannot be set globally |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params,$showDeprecated); |
|
| 234 | + $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params, $showDeprecated); |
|
| 235 | 235 | if ($params->getRest() && $results && $params->getSearchLimit() !== 0) { |
| 236 | 236 | $results = array_slice($results, $params->getOffset(), $params->getSearchLimit()); |
| 237 | 237 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | public function getVocabularyCategories() |
| 387 | 387 | { |
| 388 | 388 | $cats = $this->globalConfig->getGraph()->allOfType('skos:Concept'); |
| 389 | - if(empty($cats)) { |
|
| 389 | + if (empty($cats)) { |
|
| 390 | 390 | return array(new VocabularyCategory($this, null)); |
| 391 | 391 | } |
| 392 | 392 | |
@@ -467,9 +467,9 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // if there are multiple vocabularies and one is the preferred vocabulary, return it |
| 470 | - if($preferredVocabId != null) { |
|
| 470 | + if ($preferredVocabId != null) { |
|
| 471 | 471 | foreach ($vocabs as $vocab) { |
| 472 | - if($vocab->getId() == $preferredVocabId) { |
|
| 472 | + if ($vocab->getId() == $preferredVocabId) { |
|
| 473 | 473 | try { |
| 474 | 474 | // double check that a label exists in the preferred vocabulary |
| 475 | 475 | if ($vocab->getConceptLabel($uri, null) !== null) { |
@@ -478,9 +478,9 @@ discard block |
||
| 478 | 478 | // not found in preferred vocabulary, fall back to next method |
| 479 | 479 | break; |
| 480 | 480 | } |
| 481 | - } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
|
| 481 | + } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
|
| 482 | 482 | if ($this->getConfig()->getLogCaughtExceptions()) { |
| 483 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 483 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 484 | 484 | } |
| 485 | 485 | break; |
| 486 | 486 | } |
@@ -494,9 +494,9 @@ discard block |
||
| 494 | 494 | if ($vocab->getConceptLabel($uri, null) !== null) { |
| 495 | 495 | return $vocab; |
| 496 | 496 | } |
| 497 | - } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
|
| 497 | + } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
|
| 498 | 498 | if ($this->getConfig()->getLogCaughtExceptions()) { |
| 499 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 499 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 500 | 500 | } |
| 501 | 501 | break; |
| 502 | 502 | } |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | // using apc cache for the resource if available |
| 567 | 567 | if ($this->globalConfig->getCache()->isAvailable()) { |
| 568 | 568 | // @codeCoverageIgnoreStart |
| 569 | - $key = 'fetch: ' . $uri; |
|
| 569 | + $key = 'fetch: '.$uri; |
|
| 570 | 570 | $resource = $this->globalConfig->getCache()->fetch($key); |
| 571 | 571 | if ($resource === null || $resource === false) { // was not found in cache, or previous request failed |
| 572 | 572 | $resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout()); |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | */ |
| 588 | 588 | public function getSparqlImplementation($dialect, $endpoint, $graph) |
| 589 | 589 | { |
| 590 | - $classname = $dialect . "Sparql"; |
|
| 590 | + $classname = $dialect."Sparql"; |
|
| 591 | 591 | |
| 592 | 592 | return new $classname($endpoint, $graph, $this); |
| 593 | 593 | } |
@@ -354,10 +354,12 @@ |
||
| 354 | 354 | // register vocabulary ids as RDF namespace prefixes |
| 355 | 355 | $prefix = preg_replace('/\W+/', '', $voc->getId()); // strip non-word characters |
| 356 | 356 | try { |
| 357 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
| 357 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
| 358 | + // if not already defined |
|
| 358 | 359 | { |
| 359 | 360 | EasyRdf\RdfNamespace::set($prefix, $voc->getUriSpace()); |
| 360 | 361 | } |
| 362 | + } |
|
| 361 | 363 | |
| 362 | 364 | } catch (Exception $e) { |
| 363 | 365 | // not valid as namespace identifier, ignore |
@@ -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); |
@@ -234,16 +234,16 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender) |
| 236 | 236 | { |
| 237 | - $headers = "MIME-Version: 1.0" . "\r\n"; |
|
| 238 | - $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n"; |
|
| 237 | + $headers = "MIME-Version: 1.0"."\r\n"; |
|
| 238 | + $headers .= "Content-type: text/html; charset=UTF-8"."\r\n"; |
|
| 239 | 239 | if (!empty($toMail)) { |
| 240 | - $headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n"; |
|
| 240 | + $headers .= "Cc: ".$this->model->getConfig()->getFeedbackAddress()."\r\n"; |
|
| 241 | 241 | } |
| 242 | 242 | if (!empty($fromEmail)) { |
| 243 | 243 | $headers .= "Reply-To: $fromName <$fromEmail>\r\n"; |
| 244 | 244 | } |
| 245 | 245 | $service = $this->model->getConfig()->getServiceName(); |
| 246 | - return $headers . "From: $fromName via $service <$sender>"; |
|
| 246 | + return $headers."From: $fromName via $service <$sender>"; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null) |
| 258 | 258 | { |
| 259 | 259 | $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress(); |
| 260 | - $messageSubject = "[" . $this->model->getConfig()->getServiceName() . "] " . $messageSubject; |
|
| 260 | + $messageSubject = "[".$this->model->getConfig()->getServiceName()."] ".$messageSubject; |
|
| 261 | 261 | if ($fromVocab !== null && $fromVocab !== '') { |
| 262 | - $message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message; |
|
| 262 | + $message = 'Feedback from vocab: '.strtoupper($fromVocab)."<br />".$message; |
|
| 263 | 263 | } |
| 264 | 264 | $envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender(); |
| 265 | 265 | // determine the sender address of the message |
@@ -272,10 +272,10 @@ discard block |
||
| 272 | 272 | $headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender); |
| 273 | 273 | $params = empty($envelopeSender) ? '' : "-f $envelopeSender"; |
| 274 | 274 | // adding some information about the user for debugging purposes. |
| 275 | - $message = $message . "<br /><br /> Debugging information:" |
|
| 276 | - . "<br />Timestamp: " . date(DATE_RFC2822) |
|
| 277 | - . "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT') |
|
| 278 | - . "<br />Referer: " . $request->getServerConstant('HTTP_REFERER'); |
|
| 275 | + $message = $message."<br /><br /> Debugging information:" |
|
| 276 | + . "<br />Timestamp: ".date(DATE_RFC2822) |
|
| 277 | + . "<br />User agent: ".$request->getServerConstant('HTTP_USER_AGENT') |
|
| 278 | + . "<br />Referer: ".$request->getServerConstant('HTTP_REFERER'); |
|
| 279 | 279 | |
| 280 | 280 | try { |
| 281 | 281 | mail($toAddress, $messageSubject, $message, $headers, $params); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | header("HTTP/1.0 404 Not Found"); |
| 284 | 284 | $template = $this->twig->loadTemplate('error-page.twig'); |
| 285 | 285 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 286 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 286 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | echo $template->render( |
@@ -328,13 +328,13 @@ discard block |
||
| 328 | 328 | $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : null; |
| 329 | 329 | $vocabObjects = array(); |
| 330 | 330 | if ($vocids) { |
| 331 | - foreach($vocids as $vocid) { |
|
| 331 | + foreach ($vocids as $vocid) { |
|
| 332 | 332 | try { |
| 333 | 333 | $vocabObjects[] = $this->model->getVocabulary($vocid); |
| 334 | 334 | } catch (ValueError $e) { |
| 335 | 335 | // fail fast with an error page if the vocabulary cannot be found |
| 336 | 336 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 337 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 337 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 338 | 338 | } |
| 339 | 339 | header("HTTP/1.0 400 Bad Request"); |
| 340 | 340 | $this->invokeGenericErrorPage($request, $e->getMessage()); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | $vocabObjects = $this->model->getVocabularies(); |
| 353 | 353 | } |
| 354 | 354 | $defaultEndpoint = $this->model->getConfig()->getDefaultEndpoint(); |
| 355 | - foreach($vocabObjects as $voc) { |
|
| 355 | + foreach ($vocabObjects as $voc) { |
|
| 356 | 356 | if ($voc->getEndpoint() !== $defaultEndpoint) { |
| 357 | 357 | $nondefaultEndpointVocs[] = $voc; |
| 358 | 358 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | $errored = true; |
| 372 | 372 | header("HTTP/1.0 500 Internal Server Error"); |
| 373 | 373 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 374 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 374 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | $vocabList = $this->model->getVocabularyList(); |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | 'search_count' => $counts, |
| 384 | 384 | 'languages' => $this->languages, |
| 385 | 385 | 'search_results' => $searchResults, |
| 386 | - 'rest' => $parameters->getOffset()>0, |
|
| 386 | + 'rest' => $parameters->getOffset() > 0, |
|
| 387 | 387 | 'global_search' => true, |
| 388 | 388 | 'search_failed' => $errored, |
| 389 | 389 | 'skipped_vocabs' => $nondefaultEndpointVocs, |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | } catch (Exception $e) { |
| 412 | 412 | header("HTTP/1.0 500 Internal Server Error"); |
| 413 | 413 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 414 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 414 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | echo $template->render( |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | } catch (Exception $e) { |
| 436 | 436 | header("HTTP/1.0 404 Not Found"); |
| 437 | 437 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
| 438 | - error_log('Caught exception: ' . $e->getMessage()); |
|
| 438 | + error_log('Caught exception: '.$e->getMessage()); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | echo $template->render( |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | 'vocab' => $vocab, |
| 454 | 454 | 'search_results' => $searchResults, |
| 455 | 455 | 'search_count' => $counts, |
| 456 | - 'rest' => $parameters->getOffset()>0, |
|
| 456 | + 'rest' => $parameters->getOffset() > 0, |
|
| 457 | 457 | 'limit_parent' => $parameters->getParentLimit(), |
| 458 | 458 | 'limit_type' => $request->getQueryParam('type') ? explode('+', $request->getQueryParam('type')) : null, |
| 459 | 459 | 'limit_group' => $parameters->getGroupLimit(), |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * Loads and renders the view containing a list of recent changes in the vocabulary. |
| 586 | 586 | * @param Request $request |
| 587 | 587 | */ |
| 588 | - public function invokeChangeList($request, $prop='dc:created') |
|
| 588 | + public function invokeChangeList($request, $prop = 'dc:created') |
|
| 589 | 589 | { |
| 590 | 590 | $offset = ($request->getQueryParam('offset') && is_numeric($request->getQueryParam('offset')) && $request->getQueryParam('offset') >= 0) ? $request->getQueryParam('offset') : 0; |
| 591 | 591 | $limit = ($request->getQueryParam('limit') && is_numeric($request->getQueryParam('limit')) && $request->getQueryParam('limit') >= 0) ? $request->getQueryParam('limit') : 200; |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | * @param int $limit maximum number of concepts to return |
| 614 | 614 | * @return Array list of concepts |
| 615 | 615 | */ |
| 616 | - public function getChangeList($request, $prop, $offset=0, $limit=200) |
|
| 616 | + public function getChangeList($request, $prop, $offset = 0, $limit = 200) |
|
| 617 | 617 | { |
| 618 | 618 | // set language parameters for gettext |
| 619 | 619 | $this->setLanguageProperties($request->getLang()); |
@@ -630,9 +630,9 @@ discard block |
||
| 630 | 630 | public function formatChangeList($changeList, $lang) |
| 631 | 631 | { |
| 632 | 632 | $formatByDate = array(); |
| 633 | - foreach($changeList as $concept) { |
|
| 633 | + foreach ($changeList as $concept) { |
|
| 634 | 634 | $concept['datestring'] = Punic\Calendar::formatDate($concept['date'], 'medium', $lang); |
| 635 | - $formatByDate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true) . Punic\Calendar::format($concept['date'], ' y', $lang) ][strtolower($concept['prefLabel'])] = $concept; |
|
| 635 | + $formatByDate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true).Punic\Calendar::format($concept['date'], ' y', $lang)][strtolower($concept['prefLabel'])] = $concept; |
|
| 636 | 636 | } |
| 637 | 637 | return $formatByDate; |
| 638 | 638 | } |