@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * Initializes the Model object |
31 | 31 | */ |
32 | - public function __construct(string $config_filename="../../config.ttl") |
|
32 | + public function __construct(string $config_filename = "../../config.ttl") |
|
33 | 33 | { |
34 | 34 | $this->resolver = new Resolver($this); |
35 | 35 | $this->globalConfig = new GlobalConfig($this, $config_filename); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $this->translator = new Translator($langcode); |
41 | 41 | } |
42 | 42 | $this->translator->addLoader('json', new JsonFileLoader()); |
43 | - $this->translator->addResource('json', __DIR__.'/../../resource/translations/messages.' . $langcode . '.json', $langcode); |
|
43 | + $this->translator->addResource('json', __DIR__.'/../../resource/translations/messages.'.$langcode.'.json', $langcode); |
|
44 | 44 | } |
45 | 45 | $this->initializeLogging(); |
46 | 46 | } |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | $vocabs = $params->getVocabs(); |
277 | - $showDeprecated=false; |
|
277 | + $showDeprecated = false; |
|
278 | 278 | if (sizeof($vocabs) === 1) { // search within vocabulary |
279 | 279 | $voc = $vocabs[0]; |
280 | 280 | $sparql = $voc->getSparql(); |
281 | - $showDeprecated=$voc->getConfig()->getShowDeprecated(); |
|
281 | + $showDeprecated = $voc->getConfig()->getShowDeprecated(); |
|
282 | 282 | } else { // multi-vocabulary or global search |
283 | 283 | $voc = null; |
284 | 284 | $sparql = $this->getDefaultSparql(); |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | public function getVocabularyCategories() |
440 | 440 | { |
441 | 441 | $cats = $this->globalConfig->getGraph()->allOfType('skos:Concept'); |
442 | - if(empty($cats)) { |
|
442 | + if (empty($cats)) { |
|
443 | 443 | return array(new VocabularyCategory($this, null)); |
444 | 444 | } |
445 | 445 | |
@@ -520,9 +520,9 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | // if there are multiple vocabularies and one is the preferred vocabulary, return it |
523 | - if($preferredVocabId != null) { |
|
523 | + if ($preferredVocabId != null) { |
|
524 | 524 | foreach ($vocabs as $vocab) { |
525 | - if($vocab->getId() == $preferredVocabId) { |
|
525 | + if ($vocab->getId() == $preferredVocabId) { |
|
526 | 526 | try { |
527 | 527 | // double check that a label exists in the preferred vocabulary |
528 | 528 | if ($vocab->getConceptLabel($uri, null) !== null) { |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | } |
534 | 534 | } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
535 | 535 | if ($this->getConfig()->getLogCaughtExceptions()) { |
536 | - error_log('Caught exception: ' . $e->getMessage()); |
|
536 | + error_log('Caught exception: '.$e->getMessage()); |
|
537 | 537 | } |
538 | 538 | break; |
539 | 539 | } |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { |
551 | 551 | if ($this->getConfig()->getLogCaughtExceptions()) { |
552 | - error_log('Caught exception: ' . $e->getMessage()); |
|
552 | + error_log('Caught exception: '.$e->getMessage()); |
|
553 | 553 | } |
554 | 554 | break; |
555 | 555 | } |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | // using apc cache for the resource if available |
623 | 623 | if ($this->globalConfig->getCache()->isAvailable()) { |
624 | 624 | // @codeCoverageIgnoreStart |
625 | - $key = 'fetch: ' . $uri; |
|
625 | + $key = 'fetch: '.$uri; |
|
626 | 626 | $resource = $this->globalConfig->getCache()->fetch($key); |
627 | 627 | if ($resource === null || $resource === false) { // was not found in cache, or previous request failed |
628 | 628 | $resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout()); |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | */ |
644 | 644 | public function getSparqlImplementation($dialect, $endpoint, $graph) |
645 | 645 | { |
646 | - $classname = $dialect . "Sparql"; |
|
646 | + $classname = $dialect."Sparql"; |
|
647 | 647 | |
648 | 648 | return new $classname($endpoint, $graph, $this); |
649 | 649 | } |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | // specify where to look for templates and cache |
40 | - $loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../view'); |
|
40 | + $loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../view'); |
|
41 | 41 | // initialize Twig environment |
42 | - $this->twig = new \Twig\Environment($loader, array('cache' => $tmpDir,'auto_reload' => true)); |
|
42 | + $this->twig = new \Twig\Environment($loader, array('cache' => $tmpDir, 'auto_reload' => true)); |
|
43 | 43 | // used for setting the base href for the relative urls |
44 | 44 | $this->twig->addGlobal("BaseHref", $this->getBaseHref()); |
45 | 45 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->twig->addExtension(new LinkUrlExtension($model)); |
54 | 54 | |
55 | 55 | // register a Twig filter for generating strings from language codes with CLDR |
56 | - $langFilter = new \Twig\TwigFilter('lang_name', function ($langcode, $lang) { |
|
56 | + $langFilter = new \Twig\TwigFilter('lang_name', function($langcode, $lang) { |
|
57 | 57 | return Language::getName($langcode, $lang); |
58 | 58 | }); |
59 | 59 | $this->twig->addFilter($langFilter); |
@@ -239,16 +239,16 @@ discard block |
||
239 | 239 | |
240 | 240 | private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender) |
241 | 241 | { |
242 | - $headers = "MIME-Version: 1.0" . "\r\n"; |
|
243 | - $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n"; |
|
242 | + $headers = "MIME-Version: 1.0"."\r\n"; |
|
243 | + $headers .= "Content-type: text/html; charset=UTF-8"."\r\n"; |
|
244 | 244 | if (!empty($toMail)) { |
245 | - $headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n"; |
|
245 | + $headers .= "Cc: ".$this->model->getConfig()->getFeedbackAddress()."\r\n"; |
|
246 | 246 | } |
247 | 247 | if (!empty($fromEmail)) { |
248 | 248 | $headers .= "Reply-To: $fromName <$fromEmail>\r\n"; |
249 | 249 | } |
250 | 250 | $service = $this->model->getConfig()->getServiceName(); |
251 | - return $headers . "From: $fromName via $service <$sender>"; |
|
251 | + return $headers."From: $fromName via $service <$sender>"; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null) |
263 | 263 | { |
264 | 264 | $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress(); |
265 | - $messageSubject = "[" . $this->model->getConfig()->getServiceName() . "] " . $messageSubject; |
|
265 | + $messageSubject = "[".$this->model->getConfig()->getServiceName()."] ".$messageSubject; |
|
266 | 266 | if ($fromVocab !== null && $fromVocab !== '') { |
267 | - $message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message; |
|
267 | + $message = 'Feedback from vocab: '.strtoupper($fromVocab)."<br />".$message; |
|
268 | 268 | } |
269 | 269 | $envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender(); |
270 | 270 | // determine the sender address of the message |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | $headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender); |
284 | 284 | $params = empty($envelopeSender) ? '' : "-f $envelopeSender"; |
285 | 285 | // adding some information about the user for debugging purposes. |
286 | - $message = $message . "<br /><br /> Debugging information:" |
|
287 | - . "<br />Timestamp: " . date(DATE_RFC2822) |
|
288 | - . "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT') |
|
289 | - . "<br />Referer: " . $request->getServerConstant('HTTP_REFERER'); |
|
286 | + $message = $message."<br /><br /> Debugging information:" |
|
287 | + . "<br />Timestamp: ".date(DATE_RFC2822) |
|
288 | + . "<br />User agent: ".$request->getServerConstant('HTTP_USER_AGENT') |
|
289 | + . "<br />Referer: ".$request->getServerConstant('HTTP_REFERER'); |
|
290 | 290 | |
291 | 291 | try { |
292 | 292 | mail($toAddress, $messageSubject, $message, $headers, $params); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | header("HTTP/1.0 404 Not Found"); |
295 | 295 | $template = $this->twig->load('error.twig'); |
296 | 296 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
297 | - error_log('Caught exception: ' . $e->getMessage()); |
|
297 | + error_log('Caught exception: '.$e->getMessage()); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | echo $template->render( |
@@ -341,13 +341,13 @@ discard block |
||
341 | 341 | $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : null; |
342 | 342 | $vocabObjects = array(); |
343 | 343 | if ($vocids) { |
344 | - foreach($vocids as $vocid) { |
|
344 | + foreach ($vocids as $vocid) { |
|
345 | 345 | try { |
346 | 346 | $vocabObjects[] = $this->model->getVocabulary($vocid); |
347 | 347 | } catch (ValueError $e) { |
348 | 348 | // fail fast with an error page if the vocabulary cannot be 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 | header("HTTP/1.0 400 Bad Request"); |
353 | 353 | $this->invokeGenericErrorPage($request, $e->getMessage()); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | $errored = true; |
370 | 370 | header("HTTP/1.0 500 Internal Server Error"); |
371 | 371 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
372 | - error_log('Caught exception: ' . $e->getMessage()); |
|
372 | + error_log('Caught exception: '.$e->getMessage()); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | $vocabList = $this->model->getVocabularyList(); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | 'search_count' => $counts, |
382 | 382 | 'languages' => $this->languages, |
383 | 383 | 'search_results' => $searchResults, |
384 | - 'rest' => $parameters->getOffset()>0, |
|
384 | + 'rest' => $parameters->getOffset() > 0, |
|
385 | 385 | 'global_search' => true, |
386 | 386 | 'search_failed' => $errored, |
387 | 387 | 'term' => $request->getQueryParamRaw('q'), |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | } catch (Exception $e) { |
410 | 410 | header("HTTP/1.0 500 Internal Server Error"); |
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( |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | } catch (Exception $e) { |
435 | 435 | header("HTTP/1.0 404 Not Found"); |
436 | 436 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
437 | - error_log('Caught exception: ' . $e->getMessage()); |
|
437 | + error_log('Caught exception: '.$e->getMessage()); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | 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(), |
@@ -53,15 +53,15 @@ |
||
53 | 53 | |
54 | 54 | $localname = $vocab->getLocalName($uri); |
55 | 55 | if ($localname !== $uri && $localname === urlencode($localname)) { |
56 | - $paramstr = count($params) > 0 ? '?' . http_build_query($params) : ''; |
|
56 | + $paramstr = count($params) > 0 ? '?'.http_build_query($params) : ''; |
|
57 | 57 | if ($type && $type !== '' && $type !== 'vocab' && !($localname === '' && $type === 'page')) { |
58 | - return "$vocid/$lang/$type/$localname" . $paramstr; |
|
58 | + return "$vocid/$lang/$type/$localname".$paramstr; |
|
59 | 59 | } |
60 | 60 | |
61 | - return "$vocid/$lang/$localname" . $paramstr; |
|
61 | + return "$vocid/$lang/$localname".$paramstr; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $params['uri'] = $uri; |
65 | - return "$vocid/$lang/$type/?" . http_build_query($params); |
|
65 | + return "$vocid/$lang/$type/?".http_build_query($params); |
|
66 | 66 | } |
67 | 67 | } |
@@ -220,7 +220,7 @@ |
||
220 | 220 | { |
221 | 221 | if ($modifiedDate) { |
222 | 222 | $ifModifiedSince = $this->getIfModifiedSince(); |
223 | - $this->sendHeader("Last-Modified: " . $modifiedDate->format('D, d M Y H:i:s \G\M\T')); |
|
223 | + $this->sendHeader("Last-Modified: ".$modifiedDate->format('D, d M Y H:i:s \G\M\T')); |
|
224 | 224 | if ($ifModifiedSince !== null && $ifModifiedSince >= $modifiedDate) { |
225 | 225 | $this->sendHeader("HTTP/1.0 304 Not Modified"); |
226 | 226 | return true; |