@@ -84,7 +84,7 @@ |
||
84 | 84 | foreach (explode(' ', GLOBAL_PLUGINS) as $pluginName) { |
85 | 85 | $globalPluginsArray[] = "\"$pluginName\""; |
86 | 86 | } |
87 | - $globalPlugins = " " . implode(', ', $globalPluginsArray) . " "; |
|
87 | + $globalPlugins = " ".implode(', ', $globalPluginsArray)." "; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | # print the prefixes |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param string $prop property type eg. 'rdf:type'. |
23 | 23 | * @param string $label |
24 | 24 | */ |
25 | - public function __construct($prop, $label, $super=null, $sort_by_notation=false) |
|
25 | + public function __construct($prop, $label, $super = null, $sort_by_notation = false) |
|
26 | 26 | { |
27 | 27 | $this->prop = $prop; |
28 | 28 | $this->label = $label; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function getDescription() |
63 | 63 | { |
64 | - $helpprop = $this->prop . "_help"; |
|
64 | + $helpprop = $this->prop."_help"; |
|
65 | 65 | |
66 | 66 | return gettext($helpprop); // can't use string constant, it'd be picked up by xgettext |
67 | 67 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | public function addValue($value) |
82 | 82 | { |
83 | - $this->values[$value->getNotation() . $value->getLabel() . $value->getUri()] = $value; |
|
83 | + $this->values[$value->getNotation().$value->getLabel().$value->getUri()] = $value; |
|
84 | 84 | $this->is_sorted = false; |
85 | 85 | } |
86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | if (!empty($this->values)) { |
90 | 90 | uksort($this->values, function($a, $b) { |
91 | - return $this->sort_by_notation ? strnatcasecmp($a, $b) : strcoll(strtolower($a),strtolower($b)); |
|
91 | + return $this->sort_by_notation ? strnatcasecmp($a, $b) : strcoll(strtolower($a), strtolower($b)); |
|
92 | 92 | }); |
93 | 93 | } |
94 | 94 | $this->is_sorted = true; |
@@ -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); |
@@ -107,18 +107,18 @@ discard block |
||
107 | 107 | $localname = $vocab->getLocalName($uri); |
108 | 108 | if ($localname !== $uri && $localname === urlencode($localname)) { |
109 | 109 | // check that the prefix stripping worked, and there are no problematic chars in localname |
110 | - $paramstr = sizeof($params) > 0 ? '?' . http_build_query($params) : ''; |
|
110 | + $paramstr = sizeof($params) > 0 ? '?'.http_build_query($params) : ''; |
|
111 | 111 | if ($type && $type !== '' && $type !== 'vocab' && !($localname === '' && $type === 'page')) { |
112 | - return "$vocid/$lang/$type/$localname" . $paramstr; |
|
112 | + return "$vocid/$lang/$type/$localname".$paramstr; |
|
113 | 113 | } |
114 | 114 | |
115 | - return "$vocid/$lang/$localname" . $paramstr; |
|
115 | + return "$vocid/$lang/$localname".$paramstr; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // case 2: URI outside vocabulary namespace, or has problematic chars |
119 | 119 | // pass the full URI as parameter instead |
120 | 120 | $params['uri'] = $uri; |
121 | - return "$vocid/$lang/$type/?" . http_build_query($params); |
|
121 | + return "$vocid/$lang/$type/?".http_build_query($params); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender) |
277 | 277 | { |
278 | 278 | $headers = "MIME-Version: 1.0″ . '\r\n"; |
279 | - $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n"; |
|
279 | + $headers .= "Content-type: text/html; charset=UTF-8"."\r\n"; |
|
280 | 280 | if (!empty($toMail)) { |
281 | - $headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n"; |
|
281 | + $headers .= "Cc: ".$this->model->getConfig()->getFeedbackAddress()."\r\n"; |
|
282 | 282 | } |
283 | 283 | if (!empty($fromEmail)) { |
284 | 284 | $headers .= "Reply-To: $fromName <$fromEmail>\r\n"; |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | { |
301 | 301 | $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress(); |
302 | 302 | if ($fromVocab !== null && $fromVocab !== '') { |
303 | - $message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message; |
|
303 | + $message = 'Feedback from vocab: '.strtoupper($fromVocab)."<br />".$message; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | $envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender(); |
307 | - $subject = $this->model->getConfig()->getServiceName() . " feedback"; |
|
307 | + $subject = $this->model->getConfig()->getServiceName()." feedback"; |
|
308 | 308 | // determine the sender address of the message |
309 | 309 | $sender = $this->model->getConfig()->getFeedbackSender(); |
310 | 310 | if (empty($sender)) $sender = $envelopeSender; |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | $params = empty($envelopeSender) ? '' : "-f $envelopeSender"; |
318 | 318 | |
319 | 319 | // adding some information about the user for debugging purposes. |
320 | - $message = $message . "<br /><br /> Debugging information:" |
|
321 | - . "<br />Timestamp: " . date(DATE_RFC2822) |
|
322 | - . "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT') |
|
323 | - . "<br />Referer: " . $request->getServerConstant('HTTP_REFERER'); |
|
320 | + $message = $message."<br /><br /> Debugging information:" |
|
321 | + . "<br />Timestamp: ".date(DATE_RFC2822) |
|
322 | + . "<br />User agent: ".$request->getServerConstant('HTTP_USER_AGENT') |
|
323 | + . "<br />Referer: ".$request->getServerConstant('HTTP_REFERER'); |
|
324 | 324 | |
325 | 325 | try { |
326 | 326 | mail($toAddress, $subject, $message, $headers, $params); |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | header("HTTP/1.0 404 Not Found"); |
329 | 329 | $template = $this->twig->loadTemplate('error-page.twig'); |
330 | 330 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
331 | - error_log('Caught exception: ' . $e->getMessage()); |
|
331 | + error_log('Caught exception: '.$e->getMessage()); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | echo $template->render( |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : null; |
376 | 376 | $vocabObjects = array(); |
377 | 377 | if ($vocids) { |
378 | - foreach($vocids as $vocid) { |
|
378 | + foreach ($vocids as $vocid) { |
|
379 | 379 | $vocabObjects[] = $this->model->getVocabulary($vocid); |
380 | 380 | } |
381 | 381 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } catch (Exception $e) { |
387 | 387 | header("HTTP/1.0 404 Not Found"); |
388 | 388 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
389 | - error_log('Caught exception: ' . $e->getMessage()); |
|
389 | + error_log('Caught exception: '.$e->getMessage()); |
|
390 | 390 | } |
391 | 391 | $this->invokeGenericErrorPage($request, $e->getMessage()); |
392 | 392 | return; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | 'search_count' => $counts, |
403 | 403 | 'languages' => $this->languages, |
404 | 404 | 'search_results' => $searchResults, |
405 | - 'rest' => $parameters->getOffset()>0, |
|
405 | + 'rest' => $parameters->getOffset() > 0, |
|
406 | 406 | 'global_search' => true, |
407 | 407 | 'term' => $request->getQueryParamRaw('q'), |
408 | 408 | 'lang_list' => $langList, |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | } catch (Exception $e) { |
428 | 428 | header("HTTP/1.0 404 Not Found"); |
429 | 429 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
430 | - error_log('Caught exception: ' . $e->getMessage()); |
|
430 | + error_log('Caught exception: '.$e->getMessage()); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | echo $template->render( |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | } catch (Exception $e) { |
449 | 449 | header("HTTP/1.0 404 Not Found"); |
450 | 450 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
451 | - error_log('Caught exception: ' . $e->getMessage()); |
|
451 | + error_log('Caught exception: '.$e->getMessage()); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | echo $template->render( |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | 'vocab' => $vocab, |
466 | 466 | 'search_results' => $searchResults, |
467 | 467 | 'search_count' => $counts, |
468 | - 'rest' => $parameters->getOffset()>0, |
|
468 | + 'rest' => $parameters->getOffset() > 0, |
|
469 | 469 | 'limit_parent' => $parameters->getParentLimit(), |
470 | 470 | 'limit_type' => $request->getQueryParam('type') ? explode('+', $request->getQueryParam('type')) : null, |
471 | 471 | 'limit_group' => $parameters->getGroupLimit(), |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * Loads and renders the view containing a list of recent changes in the vocabulary. |
595 | 595 | * @param Request $request |
596 | 596 | */ |
597 | - public function invokeChangeList($request, $prop='dc:created') |
|
597 | + public function invokeChangeList($request, $prop = 'dc:created') |
|
598 | 598 | { |
599 | 599 | // set language parameters for gettext |
600 | 600 | $this->setLanguageProperties($request->getLang()); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | public function getPrefLabel() { |
12 | 12 | $label = null; |
13 | 13 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
14 | - foreach($labels as $labres) { |
|
14 | + foreach ($labels as $labres) { |
|
15 | 15 | $label = $labres->getLiteral('skosxl:literalForm'); |
16 | 16 | if ($label->getLang() == $this->clang) { |
17 | 17 | return $label; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function getProperties() { |
24 | 24 | $ret = array(); |
25 | 25 | $props = $this->resource->properties(); |
26 | - foreach($props as $prop) { |
|
26 | + foreach ($props as $prop) { |
|
27 | 27 | if ($prop !== 'skosxl:prefLabel') { |
28 | 28 | $ret[$prop] = $this->resource->get($prop); |
29 | 29 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | return $this->resource->label($fallback); |
138 | 138 | } |
139 | 139 | // We need to check all the labels in case one of them matches a subtag of the current language |
140 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
140 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
141 | 141 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
142 | - if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) { |
|
142 | + if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) { |
|
143 | 143 | return EasyRdf\Literal::create($label, $fallback); |
144 | 144 | } |
145 | 145 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | public function hasXlLabel($prop = 'prefLabel') |
162 | 162 | { |
163 | - if ($this->resource->hasProperty('skosxl:' . $prop)) { |
|
163 | + if ($this->resource->hasProperty('skosxl:'.$prop)) { |
|
164 | 164 | return true; |
165 | 165 | } |
166 | 166 | return false; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | public function getXlLabel() |
170 | 170 | { |
171 | 171 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
172 | - foreach($labels as $labres) { |
|
172 | + foreach ($labels as $labres) { |
|
173 | 173 | $label = $labres->getLiteral('skosxl:literalForm'); |
174 | 174 | if ($label !== null && $label->getLang() == $this->clang) { |
175 | 175 | return new LabelSkosXL($this->model, $labres); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | // catch external subjects that have $res as object |
277 | 277 | $extSubjects = $exGraph->resourcesMatching("schema:about", $res); |
278 | 278 | |
279 | - $propList = array_unique(array_merge( |
|
279 | + $propList = array_unique(array_merge( |
|
280 | 280 | $this->DEFAULT_EXT_PROPERTIES, |
281 | 281 | $this->getVocab()->getConfig()->getExtProperties(), |
282 | 282 | $this->getVocab()->getConfig()->getPlugins()->getExtProperties() |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param string[] $seen Processed resources so far |
302 | 302 | * @param string[] $props (optional) limit to these property URIs |
303 | 303 | */ |
304 | - private function addExternalTriplesToGraph($res, &$seen, $props=null) |
|
304 | + private function addExternalTriplesToGraph($res, &$seen, $props = null) |
|
305 | 305 | { |
306 | 306 | if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) { |
307 | 307 | return; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | private function addPropertyValues($res, $prop, &$seen) |
333 | 333 | { |
334 | - $resList = $res->allResources('<' . $prop . '>'); |
|
334 | + $resList = $res->allResources('<'.$prop.'>'); |
|
335 | 335 | |
336 | 336 | foreach ($resList as $res2) { |
337 | 337 | if ($res2->isBNode()) { |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | $this->addResourceReifications($res, $prop, $res2, $seen); |
342 | 342 | } |
343 | 343 | |
344 | - $litList = $res->allLiterals('<' . $prop . '>'); |
|
344 | + $litList = $res->allLiterals('<'.$prop.'>'); |
|
345 | 345 | |
346 | 346 | foreach ($litList as $lit) { |
347 | 347 | $this->graph->addLiteral($res, $prop, $lit); |
@@ -512,15 +512,15 @@ discard block |
||
512 | 512 | // if not found in current vocabulary, look up in the default graph to be able |
513 | 513 | // to read an ontology loaded in a separate graph |
514 | 514 | // note that this imply that the property has an rdf:type declared for the query to work |
515 | - if(!$proplabel) { |
|
515 | + if (!$proplabel) { |
|
516 | 516 | $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang()); |
517 | 517 | |
518 | 518 | $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, ''); |
519 | 519 | |
520 | - if($envLangLabels) { |
|
520 | + if ($envLangLabels) { |
|
521 | 521 | $proplabel = $envLangLabels[$this->getEnvLang()]; |
522 | 522 | } else { |
523 | - if($defaultPropLabel) { |
|
523 | + if ($defaultPropLabel) { |
|
524 | 524 | $proplabel = $defaultPropLabel['']; |
525 | 525 | } |
526 | 526 | } |
@@ -533,12 +533,12 @@ discard block |
||
533 | 533 | } |
534 | 534 | |
535 | 535 | // also look up superprops in the default graph if not found in current vocabulary |
536 | - if(!$superprops || empty($superprops)) { |
|
536 | + if (!$superprops || empty($superprops)) { |
|
537 | 537 | $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri); |
538 | 538 | } |
539 | 539 | |
540 | 540 | // we're reading only one super property, even if there are multiple ones |
541 | - $superprop = ($superprops)?$superprops[0]:null; |
|
541 | + $superprop = ($superprops) ? $superprops[0] : null; |
|
542 | 542 | if ($superprop) { |
543 | 543 | $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop; |
544 | 544 | } |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | } |
552 | 552 | |
553 | 553 | // searching for subproperties of literals too |
554 | - if($superprops) { |
|
554 | + if ($superprops) { |
|
555 | 555 | foreach ($superprops as $subi) { |
556 | 556 | $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi; |
557 | 557 | $duplicates[$suburi] = $prop; |
@@ -671,14 +671,14 @@ discard block |
||
671 | 671 | |
672 | 672 | // making a human readable string from the timestamps |
673 | 673 | if ($created != '') { |
674 | - $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short')); |
|
674 | + $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short')); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | if ($modified != '') { |
678 | 678 | if ($created != '') { |
679 | - $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
679 | + $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
680 | 680 | } else { |
681 | - $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
681 | + $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | } |
@@ -686,12 +686,12 @@ discard block |
||
686 | 686 | trigger_error($e->getMessage(), E_USER_WARNING); |
687 | 687 | $ret = ''; |
688 | 688 | if ($this->resource->get('dc:modified')) { |
689 | - $modified = (string) $this->resource->get('dc:modified'); |
|
690 | - $ret = gettext('skosmos:modified') . ' ' . $modified; |
|
689 | + $modified = (string)$this->resource->get('dc:modified'); |
|
690 | + $ret = gettext('skosmos:modified').' '.$modified; |
|
691 | 691 | } |
692 | 692 | if ($this->resource->get('dc:created')) { |
693 | - $created .= (string) $this->resource->get('dc:created'); |
|
694 | - $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; |
|
693 | + $created .= (string)$this->resource->get('dc:created'); |
|
694 | + $ret .= ' '.gettext('skosmos:created').' '.$created; |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | return $ret; |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | $groups[$collLabel] = array($group); |
764 | 764 | |
765 | 765 | $res = $collection; |
766 | - while($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
766 | + while ($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
767 | 767 | foreach ($super as $res) { |
768 | 768 | $superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang); |
769 | 769 | array_unshift($groups[$collLabel], $superprop); |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | $ret = array(); |
806 | 806 | foreach ($labels as $lit) { |
807 | 807 | // filtering away subsets of the current language eg. en vs en-GB |
808 | - if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { |
|
808 | + if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { |
|
809 | 809 | $prop = in_array($lit, $prefLabels) ? 'skos:prefLabel' : 'skos:altLabel'; |
810 | 810 | $ret[$this->literalLanguageToString($lit)][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop); |
811 | 811 | } |
@@ -867,10 +867,10 @@ discard block |
||
867 | 867 | } |
868 | 868 | else if ($context[$vocabPrefix] !== $vocabUriSpace) { |
869 | 869 | $i = 2; |
870 | - while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) { |
|
870 | + while (isset($context[$vocabPrefix.$i]) && $context[$vocabPrefix.$i] !== $vocabUriSpace) { |
|
871 | 871 | $i += 1; |
872 | 872 | } |
873 | - $context[$vocabPrefix . $i] = $vocabUriSpace; |
|
873 | + $context[$vocabPrefix.$i] = $vocabUriSpace; |
|
874 | 874 | } |
875 | 875 | } |
876 | 876 | $compactJsonLD = \ML\JsonLD\JsonLD::compact($this->graph->serialise('jsonld'), json_encode($context)); |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | private function performQuery($query) { |
97 | 97 | $queryId = sprintf("%05d", rand(0, 99999)); |
98 | 98 | $logger = $this->model->getLogger(); |
99 | - $logger->info("[qid $queryId] SPARQL query:\n" . $this->generateQueryPrefixes($query) . "\n$query\n"); |
|
99 | + $logger->info("[qid $queryId] SPARQL query:\n".$this->generateQueryPrefixes($query)."\n$query\n"); |
|
100 | 100 | $starttime = microtime(true); |
101 | 101 | $result = $this->client->query($query); |
102 | 102 | $elapsed = intval(round((microtime(true) - $starttime) * 1000)); |
103 | - if(method_exists($result, 'numRows')) { |
|
103 | + if (method_exists($result, 'numRows')) { |
|
104 | 104 | $numRows = $result->numRows(); |
105 | 105 | $logger->info("[qid $queryId] result: $numRows rows returned in $elapsed ms"); |
106 | 106 | } else { // graph result |
@@ -136,20 +136,20 @@ discard block |
||
136 | 136 | * @param Vocabulary[]|null $vocabs |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - protected function generateFromClause($vocabs=null) { |
|
139 | + protected function generateFromClause($vocabs = null) { |
|
140 | 140 | $graphs = array(); |
141 | 141 | $clause = ''; |
142 | 142 | if (!$vocabs) { |
143 | 143 | return $this->graph !== '?graph' && $this->graph !== NULL ? "FROM <$this->graph>" : ''; |
144 | 144 | } |
145 | - foreach($vocabs as $vocab) { |
|
145 | + foreach ($vocabs as $vocab) { |
|
146 | 146 | $graph = $vocab->getGraph(); |
147 | 147 | if (!in_array($graph, $graphs)) { |
148 | 148 | array_push($graphs, $graph); |
149 | 149 | } |
150 | 150 | } |
151 | 151 | foreach ($graphs as $graph) { |
152 | - if($graph !== NULL) |
|
152 | + if ($graph !== NULL) |
|
153 | 153 | $clause .= "FROM NAMED <$graph> "; |
154 | 154 | } |
155 | 155 | return $clause; |
@@ -693,9 +693,9 @@ discard block |
||
693 | 693 | $conceptscheme['title'] = $row->title->getValue(); |
694 | 694 | } |
695 | 695 | // add dct:subject and their labels in the result |
696 | - if(isset($row->domain) && isset($row->domainLabel)){ |
|
697 | - $conceptscheme['subject']['uri']=$row->domain->getURI(); |
|
698 | - $conceptscheme['subject']['prefLabel']=$row->domainLabel->getValue(); |
|
696 | + if (isset($row->domain) && isset($row->domainLabel)) { |
|
697 | + $conceptscheme['subject']['uri'] = $row->domain->getURI(); |
|
698 | + $conceptscheme['subject']['prefLabel'] = $row->domainLabel->getValue(); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | $ret[$row->cs->getURI()] = $conceptscheme; |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | foreach ($graphs as $graph) { |
759 | 759 | $values[] = "<$graph>"; |
760 | 760 | } |
761 | - return "FILTER (?graph IN (" . implode(',', $values) . "))"; |
|
761 | + return "FILTER (?graph IN (".implode(',', $values)."))"; |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | /** |
@@ -768,16 +768,16 @@ discard block |
||
768 | 768 | * @return string sparql query clauses |
769 | 769 | */ |
770 | 770 | protected function formatLimitAndOffset($limit, $offset) { |
771 | - $limit = ($limit) ? 'LIMIT ' . $limit : ''; |
|
772 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
771 | + $limit = ($limit) ? 'LIMIT '.$limit : ''; |
|
772 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
773 | 773 | // eliminating whitespace and line changes when the conditions aren't needed. |
774 | 774 | $limitandoffset = ''; |
775 | 775 | if ($limit && $offset) { |
776 | - $limitandoffset = "\n" . $limit . "\n" . $offset; |
|
776 | + $limitandoffset = "\n".$limit."\n".$offset; |
|
777 | 777 | } elseif ($limit) { |
778 | - $limitandoffset = "\n" . $limit; |
|
778 | + $limitandoffset = "\n".$limit; |
|
779 | 779 | } elseif ($offset) { |
780 | - $limitandoffset = "\n" . $offset; |
|
780 | + $limitandoffset = "\n".$offset; |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | return $limitandoffset; |
@@ -929,14 +929,14 @@ discard block |
||
929 | 929 | // if search language and UI/display language differ, must also consider case where there is no prefLabel in |
930 | 930 | // the display language; in that case, should use the label with the same language as the matched label |
931 | 931 | $labelcondFallback = ($searchLang != $lang) ? |
932 | - "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" . |
|
932 | + "OPTIONAL { # in case previous OPTIONAL block gives no labels\n". |
|
933 | 933 | "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : ""; |
934 | 934 | |
935 | 935 | // Including the labels if there is no query term given. |
936 | 936 | if ($rawterm === '') { |
937 | 937 | $labelClause = "?s skos:prefLabel ?label ."; |
938 | - $labelClause = ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . ""; |
|
939 | - return $labelClause . " BIND(?label AS ?match)"; |
|
938 | + $labelClause = ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause.""; |
|
939 | + return $labelClause." BIND(?label AS ?match)"; |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /* |
@@ -1000,20 +1000,20 @@ discard block |
||
1000 | 1000 | $schemecond = ''; |
1001 | 1001 | if (!empty($schemes)) { |
1002 | 1002 | $conditions = array(); |
1003 | - foreach($schemes as $scheme) { |
|
1003 | + foreach ($schemes as $scheme) { |
|
1004 | 1004 | $conditions[] = "{?s skos:inScheme <$scheme>}"; |
1005 | 1005 | } |
1006 | - $schemecond = '{'.implode(" UNION ",$conditions).'}'; |
|
1006 | + $schemecond = '{'.implode(" UNION ", $conditions).'}'; |
|
1007 | 1007 | } |
1008 | - $filterDeprecated=""; |
|
1008 | + $filterDeprecated = ""; |
|
1009 | 1009 | //show or hide deprecated concepts |
1010 | - if(!$showDeprecated){ |
|
1011 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
1010 | + if (!$showDeprecated) { |
|
1011 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
1012 | 1012 | } |
1013 | 1013 | // extra conditions for parent and group, if specified |
1014 | - $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : ""; |
|
1015 | - $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : ""; |
|
1016 | - $pgcond = $parentcond . $groupcond; |
|
1014 | + $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : ""; |
|
1015 | + $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : ""; |
|
1016 | + $pgcond = $parentcond.$groupcond; |
|
1017 | 1017 | |
1018 | 1018 | $orderextra = $this->isDefaultEndpoint() ? $this->graph : ''; |
1019 | 1019 | |
@@ -1086,9 +1086,9 @@ discard block |
||
1086 | 1086 | $hit['type'][] = $this->shortenUri($typeuri); |
1087 | 1087 | } |
1088 | 1088 | |
1089 | - if(!empty($fields)) { |
|
1089 | + if (!empty($fields)) { |
|
1090 | 1090 | foreach ($fields as $prop) { |
1091 | - $propname = $prop . 's'; |
|
1091 | + $propname = $prop.'s'; |
|
1092 | 1092 | if (isset($row->$propname)) { |
1093 | 1093 | foreach (explode("\n", $row->$propname->getValue()) as $line) { |
1094 | 1094 | $rdata = str_getcsv($line, ',', '"', '"'); |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | $propvals = $rdata[2]; |
1104 | 1104 | } |
1105 | 1105 | |
1106 | - $hit['skos:' . $prop][] = $propvals; |
|
1106 | + $hit['skos:'.$prop][] = $propvals; |
|
1107 | 1107 | } |
1108 | 1108 | } |
1109 | 1109 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | * @return array query result object |
1180 | 1180 | */ |
1181 | 1181 | public function queryConcepts($vocabs, $fields = null, $unique = false, $params, $showDeprecated = false) { |
1182 | - $query = $this->generateConceptSearchQuery($fields, $unique, $params,$showDeprecated); |
|
1182 | + $query = $this->generateConceptSearchQuery($fields, $unique, $params, $showDeprecated); |
|
1183 | 1183 | $results = $this->query($query); |
1184 | 1184 | return $this->transformConceptSearchResults($results, $vocabs, $fields); |
1185 | 1185 | } |
@@ -1233,9 +1233,9 @@ discard block |
||
1233 | 1233 | $conditions = $this->formatFilterConditions($letter, $lang); |
1234 | 1234 | $filtercondLabel = $conditions['filterpref']; |
1235 | 1235 | $filtercondALabel = $conditions['filteralt']; |
1236 | - $filterDeprecated=""; |
|
1237 | - if(!$showDeprecated){ |
|
1238 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
1236 | + $filterDeprecated = ""; |
|
1237 | + if (!$showDeprecated) { |
|
1238 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
1239 | 1239 | } |
1240 | 1240 | $query = <<<EOQ |
1241 | 1241 | SELECT DISTINCT ?s ?label ?alabel $fcl |
@@ -1311,8 +1311,8 @@ discard block |
||
1311 | 1311 | * @param array $classes |
1312 | 1312 | * @param boolean $showDeprecated whether to include deprecated concepts in the result (default: false) |
1313 | 1313 | */ |
1314 | - public function queryConceptsAlphabetical($letter, $lang, $limit = null, $offset = null, $classes = null,$showDeprecated = false) { |
|
1315 | - $query = $this->generateAlphabeticalListQuery($letter, $lang, $limit, $offset, $classes,$showDeprecated); |
|
1314 | + public function queryConceptsAlphabetical($letter, $lang, $limit = null, $offset = null, $classes = null, $showDeprecated = false) { |
|
1315 | + $query = $this->generateAlphabeticalListQuery($letter, $lang, $limit, $offset, $classes, $showDeprecated); |
|
1316 | 1316 | $results = $this->query($query); |
1317 | 1317 | return $this->transformAlphabeticalListResults($results); |
1318 | 1318 | } |
@@ -1646,7 +1646,7 @@ discard block |
||
1646 | 1646 | if (!isset($row->label) || $row->label->getLang() === $lang) { |
1647 | 1647 | $ret[$row->object->getUri()] = $val; |
1648 | 1648 | } elseif ($row->label->getLang() === $fallbacklang) { |
1649 | - $val['label'] .= ' (' . $row->label->getLang() . ')'; |
|
1649 | + $val['label'] .= ' ('.$row->label->getLang().')'; |
|
1650 | 1650 | $ret[$row->object->getUri()] = $val; |
1651 | 1651 | } |
1652 | 1652 | } |
@@ -1742,10 +1742,10 @@ discard block |
||
1742 | 1742 | |
1743 | 1743 | $label = null; |
1744 | 1744 | if (isset($row->label)) { |
1745 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
1745 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
1746 | 1746 | $label = $row->label->getValue(); |
1747 | 1747 | } else { |
1748 | - $label = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
1748 | + $label = $row->label->getValue()." (".$row->label->getLang().")"; |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | } |
@@ -1821,8 +1821,8 @@ discard block |
||
1821 | 1821 | foreach ($result as $row) { |
1822 | 1822 | if (isset($row->top) && isset($row->label)) { |
1823 | 1823 | $label = $row->label->getValue(); |
1824 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
1825 | - $label .= ' (' . $row->label->getLang() . ')'; |
|
1824 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
1825 | + $label .= ' ('.$row->label->getLang().')'; |
|
1826 | 1826 | } |
1827 | 1827 | $top = array('uri' => $row->top->getUri(), 'topConceptOf' => $row->topuri->getUri(), 'label' => $label, 'hasChildren' => filter_var($row->children->getValue(), FILTER_VALIDATE_BOOLEAN)); |
1828 | 1828 | if (isset($row->notation)) { |
@@ -1915,7 +1915,7 @@ discard block |
||
1915 | 1915 | $ret[$uri]['exact'] = $row->exact->getUri(); |
1916 | 1916 | } |
1917 | 1917 | if (isset($row->tops)) { |
1918 | - $topConceptsList=explode(" ", $row->tops->getValue()); |
|
1918 | + $topConceptsList = explode(" ", $row->tops->getValue()); |
|
1919 | 1919 | // sort to garantee an alphabetical ordering of the URI |
1920 | 1920 | sort($topConceptsList); |
1921 | 1921 | $ret[$uri]['tops'] = $topConceptsList; |
@@ -1928,8 +1928,8 @@ discard block |
||
1928 | 1928 | $label = null; |
1929 | 1929 | if (isset($row->childlabel)) { |
1930 | 1930 | $label = $row->childlabel->getValue(); |
1931 | - if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang . "-") !== 0) { |
|
1932 | - $label .= " (" . $row->childlabel->getLang() . ")"; |
|
1931 | + if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang."-") !== 0) { |
|
1932 | + $label .= " (".$row->childlabel->getLang().")"; |
|
1933 | 1933 | } |
1934 | 1934 | |
1935 | 1935 | } |
@@ -1950,8 +1950,8 @@ discard block |
||
1950 | 1950 | } |
1951 | 1951 | if (isset($row->label)) { |
1952 | 1952 | $preflabel = $row->label->getValue(); |
1953 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
1954 | - $preflabel .= ' (' . $row->label->getLang() . ')'; |
|
1953 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
1954 | + $preflabel .= ' ('.$row->label->getLang().')'; |
|
1955 | 1955 | } |
1956 | 1956 | |
1957 | 1957 | $ret[$uri]['prefLabel'] = $preflabel; |
@@ -2072,9 +2072,9 @@ discard block |
||
2072 | 2072 | */ |
2073 | 2073 | private function generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated = false) { |
2074 | 2074 | $fcl = $this->generateFromClause(); |
2075 | - $filterDeprecated=""; |
|
2076 | - if(!$showDeprecated){ |
|
2077 | - $filterDeprecated=" FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
2075 | + $filterDeprecated = ""; |
|
2076 | + if (!$showDeprecated) { |
|
2077 | + $filterDeprecated = " FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
2078 | 2078 | } |
2079 | 2079 | $query = <<<EOQ |
2080 | 2080 | SELECT ?conc ?super ?label ?members ?type ?notation $fcl |
@@ -2113,10 +2113,10 @@ discard block |
||
2113 | 2113 | 'type' => array($row->type->shorten()), |
2114 | 2114 | ); |
2115 | 2115 | if (isset($row->label)) { |
2116 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
2116 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
2117 | 2117 | $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue(); |
2118 | 2118 | } else { |
2119 | - $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
2119 | + $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")"; |
|
2120 | 2120 | } |
2121 | 2121 | |
2122 | 2122 | } |
@@ -2144,8 +2144,8 @@ discard block |
||
2144 | 2144 | * @param boolean $showDeprecated whether to include deprecated concepts in search results |
2145 | 2145 | * @return array Result array with concept URI as key and concept label as value |
2146 | 2146 | */ |
2147 | - public function listConceptGroupContents($groupClass, $group, $lang,$showDeprecated = false) { |
|
2148 | - $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang,$showDeprecated); |
|
2147 | + public function listConceptGroupContents($groupClass, $group, $lang, $showDeprecated = false) { |
|
2148 | + $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated); |
|
2149 | 2149 | $result = $this->query($query); |
2150 | 2150 | return $this->transformConceptGroupContentsResults($result, $lang); |
2151 | 2151 | } |
@@ -2158,7 +2158,7 @@ discard block |
||
2158 | 2158 | */ |
2159 | 2159 | private function generateChangeListQuery($lang, $offset, $prop) { |
2160 | 2160 | $fcl = $this->generateFromClause(); |
2161 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
2161 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
2162 | 2162 | |
2163 | 2163 | $query = <<<EOQ |
2164 | 2164 | SELECT DISTINCT ?concept ?date ?label $fcl |