@@ -13,7 +13,7 @@ |
||
13 | 13 | $opts = array('http' => array('method'=>'HEAD', |
14 | 14 | 'user_agent' => 'Skosmos', |
15 | 15 | 'timeout' => $timeout)); |
16 | - $context = stream_context_create($opts); |
|
16 | + $context = stream_context_create($opts); |
|
17 | 17 | $fd = fopen($this->uri, 'rb', false, $context); |
18 | 18 | $headers = stream_get_meta_data($fd)['wrapper_data']; |
19 | 19 | foreach ($headers as $header) { |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | { |
33 | 33 | // Encrypt the current time |
34 | 34 | $honey_time_encrypted = $this->getEncryptedTime(); |
35 | - return '<div id="' . $honey_name . '_wrap" style="display:none;">' . "\r\n" . |
|
36 | - '<input name="' . $honey_name . '" type="text" value="" id="' . $honey_name . '"/>' . "\r\n" . |
|
37 | - '<input name="' . $honey_time . '" type="text" value="' . $honey_time_encrypted . '"/>' . "\r\n" . |
|
35 | + return '<div id="'.$honey_name.'_wrap" style="display:none;">'."\r\n". |
|
36 | + '<input name="'.$honey_name.'" type="text" value="" id="'.$honey_name.'"/>'."\r\n". |
|
37 | + '<input name="'.$honey_time.'" type="text" value="'.$honey_time_encrypted.'"/>'."\r\n". |
|
38 | 38 | '</div>'; |
39 | 39 | } |
40 | 40 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // Get the decrypted time |
67 | 67 | $value = $this->decryptTime($value); |
68 | 68 | // The current time should be greater than the time the form was built + the speed option |
69 | - return ( is_numeric($value) && time() > ($value + $parameters[0]) ); |
|
69 | + return (is_numeric($value) && time() > ($value + $parameters[0])); |
|
70 | 70 | } |
71 | 71 | /** |
72 | 72 | * Get encrypted time |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $label = $this->getLabel(); |
38 | 38 | $notation = $this->getNotation(); |
39 | - return ltrim($notation . ' ') . $label; |
|
39 | + return ltrim($notation.' ').$label; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getType() |
@@ -187,42 +187,42 @@ discard block |
||
187 | 187 | 'from' => [ |
188 | 188 | 'memberSet' => [ |
189 | 189 | [ |
190 | - 'uri' => (string) $this->source->getUri(), |
|
190 | + 'uri' => (string)$this->source->getUri(), |
|
191 | 191 | ] |
192 | 192 | ] |
193 | 193 | ], |
194 | 194 | 'to' => [ |
195 | 195 | 'memberSet' => [ |
196 | 196 | [ |
197 | - 'uri' => (string) $this->getUri() |
|
197 | + 'uri' => (string)$this->getUri() |
|
198 | 198 | ] |
199 | 199 | ] |
200 | 200 | ], |
201 | 201 | // EXTRA |
202 | - 'description' => gettext($this->type . "_help"), // pop-up text |
|
202 | + 'description' => gettext($this->type."_help"), // pop-up text |
|
203 | 203 | 'hrefLink' => $hrefLink, // link to resource as displayed in the UI |
204 | 204 | 'lang' => $propertyLang, // TBD: could it be part of the prefLabel? |
205 | - 'vocabName' => (string) $this->getVocabName(), // vocabulary as displayed in the UI |
|
205 | + 'vocabName' => (string)$this->getVocabName(), // vocabulary as displayed in the UI |
|
206 | 206 | 'typeLabel' => gettext($this->type), // a text used in the UI instead of, for example, skos:closeMatch |
207 | 207 | ]; |
208 | 208 | |
209 | 209 | $fromScheme = $this->vocab->getDefaultConceptScheme(); |
210 | 210 | if (isset($fromScheme)) { |
211 | 211 | $ret['fromScheme'] = [ |
212 | - 'uri' => (string) $fromScheme, |
|
212 | + 'uri' => (string)$fromScheme, |
|
213 | 213 | ]; |
214 | 214 | } |
215 | 215 | |
216 | 216 | $exvocab = $this->getExvocab(); |
217 | 217 | if (isset($exvocab)) { |
218 | 218 | $ret['toScheme'] = [ |
219 | - 'uri' => (string) $exvocab->getDefaultConceptScheme(), |
|
219 | + 'uri' => (string)$exvocab->getDefaultConceptScheme(), |
|
220 | 220 | ]; |
221 | 221 | } |
222 | 222 | |
223 | 223 | $notation = $this->getNotation(); |
224 | 224 | if (isset($notation)) { |
225 | - $ret['to']['memberSet'][0]['notation'] = (string) $notation; |
|
225 | + $ret['to']['memberSet'][0]['notation'] = (string)$notation; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | $label = $this->getLabel($lang, $queryExVocabs); |
@@ -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[ltrim($value->getNotation() . ' ') . $value->getLabel() . rtrim(' ' . $value->getUri())] = $value; |
|
83 | + $this->values[ltrim($value->getNotation().' ').$value->getLabel().rtrim(' '.$value->getUri())] = $value; |
|
84 | 84 | $this->is_sorted = false; |
85 | 85 | } |
86 | 86 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | // specify where to look for templates and cache |
43 | 43 | $loader = new Twig_Loader_Filesystem('view'); |
44 | 44 | // initialize Twig environment |
45 | - $this->twig = new Twig_Environment($loader, array('cache' => $tmpDir,'auto_reload' => true)); |
|
45 | + $this->twig = new Twig_Environment($loader, array('cache' => $tmpDir, 'auto_reload' => true)); |
|
46 | 46 | $this->twig->addExtension(new Twig_Extensions_Extension_I18n()); |
47 | 47 | // used for setting the base href for the relative urls |
48 | 48 | $this->twig->addGlobal("BaseHref", $this->getBaseHref()); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $this->twig->addFilter(new Twig_SimpleFilter('link_url', array($this, 'linkUrlFilter'))); |
66 | 66 | |
67 | 67 | // register a Twig filter for generating strings from language codes with CLDR |
68 | - $langFilter = new Twig_SimpleFilter('lang_name', function ($langcode, $lang) { |
|
68 | + $langFilter = new Twig_SimpleFilter('lang_name', function($langcode, $lang) { |
|
69 | 69 | return Language::getName($langcode, $lang); |
70 | 70 | }); |
71 | 71 | $this->twig->addFilter($langFilter); |
@@ -363,17 +363,17 @@ discard block |
||
363 | 363 | |
364 | 364 | private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender) |
365 | 365 | { |
366 | - $headers = "MIME-Version: 1.0" . "\r\n"; |
|
367 | - $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n"; |
|
366 | + $headers = "MIME-Version: 1.0"."\r\n"; |
|
367 | + $headers .= "Content-type: text/html; charset=UTF-8"."\r\n"; |
|
368 | 368 | if (!empty($toMail)) { |
369 | - $headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n"; |
|
369 | + $headers .= "Cc: ".$this->model->getConfig()->getFeedbackAddress()."\r\n"; |
|
370 | 370 | } |
371 | 371 | if (!empty($fromEmail)) { |
372 | 372 | $headers .= "Reply-To: $fromName <$fromEmail>\r\n"; |
373 | 373 | } |
374 | 374 | |
375 | 375 | $service = $this->model->getConfig()->getServiceName(); |
376 | - return $headers . "From: $fromName via $service <$sender>"; |
|
376 | + return $headers."From: $fromName via $service <$sender>"; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | { |
388 | 388 | $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress(); |
389 | 389 | if ($fromVocab !== null && $fromVocab !== '') { |
390 | - $message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message; |
|
390 | + $message = 'Feedback from vocab: '.strtoupper($fromVocab)."<br />".$message; |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | $envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender(); |
394 | - $subject = $this->model->getConfig()->getServiceName() . " feedback"; |
|
394 | + $subject = $this->model->getConfig()->getServiceName()." feedback"; |
|
395 | 395 | // determine the sender address of the message |
396 | 396 | $sender = $this->model->getConfig()->getFeedbackSender(); |
397 | 397 | if (empty($sender)) $sender = $envelopeSender; |
@@ -404,10 +404,10 @@ discard block |
||
404 | 404 | $params = empty($envelopeSender) ? '' : "-f $envelopeSender"; |
405 | 405 | |
406 | 406 | // adding some information about the user for debugging purposes. |
407 | - $message = $message . "<br /><br /> Debugging information:" |
|
408 | - . "<br />Timestamp: " . date(DATE_RFC2822) |
|
409 | - . "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT') |
|
410 | - . "<br />Referer: " . $request->getServerConstant('HTTP_REFERER'); |
|
407 | + $message = $message."<br /><br /> Debugging information:" |
|
408 | + . "<br />Timestamp: ".date(DATE_RFC2822) |
|
409 | + . "<br />User agent: ".$request->getServerConstant('HTTP_USER_AGENT') |
|
410 | + . "<br />Referer: ".$request->getServerConstant('HTTP_REFERER'); |
|
411 | 411 | |
412 | 412 | try { |
413 | 413 | mail($toAddress, $subject, $message, $headers, $params); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | header("HTTP/1.0 404 Not Found"); |
416 | 416 | $template = $this->twig->loadTemplate('error-page.twig'); |
417 | 417 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
418 | - error_log('Caught exception: ' . $e->getMessage()); |
|
418 | + error_log('Caught exception: '.$e->getMessage()); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | echo $template->render( |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : null; |
463 | 463 | $vocabObjects = array(); |
464 | 464 | if ($vocids) { |
465 | - foreach($vocids as $vocid) { |
|
465 | + foreach ($vocids as $vocid) { |
|
466 | 466 | $vocabObjects[] = $this->model->getVocabulary($vocid); |
467 | 467 | } |
468 | 468 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } catch (Exception $e) { |
474 | 474 | header("HTTP/1.0 404 Not Found"); |
475 | 475 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
476 | - error_log('Caught exception: ' . $e->getMessage()); |
|
476 | + error_log('Caught exception: '.$e->getMessage()); |
|
477 | 477 | } |
478 | 478 | $this->invokeGenericErrorPage($request, $e->getMessage()); |
479 | 479 | return; |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | 'search_count' => $counts, |
490 | 490 | 'languages' => $this->languages, |
491 | 491 | 'search_results' => $searchResults, |
492 | - 'rest' => $parameters->getOffset()>0, |
|
492 | + 'rest' => $parameters->getOffset() > 0, |
|
493 | 493 | 'global_search' => true, |
494 | 494 | 'term' => $request->getQueryParamRaw('q'), |
495 | 495 | 'lang_list' => $langList, |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | } catch (Exception $e) { |
515 | 515 | header("HTTP/1.0 404 Not Found"); |
516 | 516 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
517 | - error_log('Caught exception: ' . $e->getMessage()); |
|
517 | + error_log('Caught exception: '.$e->getMessage()); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | echo $template->render( |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | } catch (Exception $e) { |
536 | 536 | header("HTTP/1.0 404 Not Found"); |
537 | 537 | if ($this->model->getConfig()->getLogCaughtExceptions()) { |
538 | - error_log('Caught exception: ' . $e->getMessage()); |
|
538 | + error_log('Caught exception: '.$e->getMessage()); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | echo $template->render( |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | 'vocab' => $vocab, |
553 | 553 | 'search_results' => $searchResults, |
554 | 554 | 'search_count' => $counts, |
555 | - 'rest' => $parameters->getOffset()>0, |
|
555 | + 'rest' => $parameters->getOffset() > 0, |
|
556 | 556 | 'limit_parent' => $parameters->getParentLimit(), |
557 | 557 | 'limit_type' => $request->getQueryParam('type') ? explode('+', $request->getQueryParam('type')) : null, |
558 | 558 | 'limit_group' => $parameters->getGroupLimit(), |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * Loads and renders the view containing a list of recent changes in the vocabulary. |
682 | 682 | * @param Request $request |
683 | 683 | */ |
684 | - public function invokeChangeList($request, $prop='dc:created') |
|
684 | + public function invokeChangeList($request, $prop = 'dc:created') |
|
685 | 685 | { |
686 | 686 | // set language parameters for gettext |
687 | 687 | $this->setLanguageProperties($request->getLang()); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | // 1. Ensure characters with special meaning in Lucene are escaped |
42 | 42 | $lucenemap = array(); |
43 | 43 | foreach (str_split(self::LUCENE_ESCAPE_CHARS) as $char) { |
44 | - $lucenemap[$char] = '\\' . $char; // escape with a backslash |
|
44 | + $lucenemap[$char] = '\\'.$char; // escape with a backslash |
|
45 | 45 | } |
46 | 46 | $term = strtr($term, $lucenemap); |
47 | 47 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @return string sparql order by clause |
93 | 93 | */ |
94 | 94 | private function formatOrderBy($expression, $lang) { |
95 | - if(!$this->model->getConfig()->getCollationEnabled()) { |
|
95 | + if (!$this->model->getConfig()->getCollationEnabled()) { |
|
96 | 96 | return $expression; |
97 | 97 | } |
98 | 98 | $orderby = sprintf('arq:collation(\'%2$s\', %1$s)', $expression, $lang); |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | # make text query clause |
127 | 127 | $lcletter = mb_strtolower($letter, 'UTF-8'); // convert to lower case, UTF-8 safe |
128 | 128 | $langClause = $this->generateLangClause($lang); |
129 | - $textcondPref = $this->createTextQueryCondition($letter . '*', 'skos:prefLabel', $langClause); |
|
130 | - $textcondAlt = $this->createTextQueryCondition($letter . '*', 'skos:altLabel', $langClause); |
|
131 | - $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang) . " STR(?s) LCASE(STR(?qualifier))"; |
|
129 | + $textcondPref = $this->createTextQueryCondition($letter.'*', 'skos:prefLabel', $langClause); |
|
130 | + $textcondAlt = $this->createTextQueryCondition($letter.'*', 'skos:altLabel', $langClause); |
|
131 | + $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang)." STR(?s) LCASE(STR(?qualifier))"; |
|
132 | 132 | |
133 | - $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : ""; |
|
133 | + $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : ""; |
|
134 | 134 | |
135 | - $filterDeprecated=""; |
|
136 | - if(!$showDeprecated){ |
|
137 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
135 | + $filterDeprecated = ""; |
|
136 | + if (!$showDeprecated) { |
|
137 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $query = <<<EOQ |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | private $pluginParameters; |
10 | 10 | private $languageOrderCache = array(); |
11 | 11 | |
12 | - public function __construct($resource, $globalPlugins=array()) |
|
12 | + public function __construct($resource, $globalPlugins = array()) |
|
13 | 13 | { |
14 | 14 | $this->resource = $resource; |
15 | 15 | $plugins = $this->resource->allLiterals('skosmos:usePlugin'); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $paramValue = $paramLiteral->getValue(); |
38 | 38 | $paramLang = $paramLiteral->getLang(); |
39 | 39 | if ($paramLang) { |
40 | - $paramName .= '_' . $paramLang; |
|
40 | + $paramName .= '_'.$paramLang; |
|
41 | 41 | } |
42 | 42 | $this->pluginParameters[$pluginName][$paramName] = $paramValue; |
43 | 43 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $langs = $this->getLanguages(); |
65 | 65 | $deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric |
66 | 66 | if (sizeof($langs) > 1) { |
67 | - trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING); |
|
67 | + trigger_error("Default language for vocabulary '".$this->getShortName()."' unknown, choosing '$deflang'.", E_USER_WARNING); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return $deflang; |
@@ -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 |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | $hiddenLabels = array(); |
1467 | 1467 | |
1468 | 1468 | foreach ($result as $row) { |
1469 | - switch($row->prop){ |
|
1469 | + switch ($row->prop) { |
|
1470 | 1470 | case 'http://www.w3.org/2004/02/skos/core#prefLabel': |
1471 | 1471 | $prefLabels[] = $row->val; |
1472 | 1472 | break; |
@@ -1723,7 +1723,7 @@ discard block |
||
1723 | 1723 | if (!isset($row->label) || $row->label->getLang() === $lang) { |
1724 | 1724 | $ret[$row->object->getUri()] = $val; |
1725 | 1725 | } elseif ($row->label->getLang() === $fallbacklang) { |
1726 | - $val['label'] .= ' (' . $row->label->getLang() . ')'; |
|
1726 | + $val['label'] .= ' ('.$row->label->getLang().')'; |
|
1727 | 1727 | $ret[$row->object->getUri()] = $val; |
1728 | 1728 | } |
1729 | 1729 | } |
@@ -1819,10 +1819,10 @@ discard block |
||
1819 | 1819 | |
1820 | 1820 | $label = null; |
1821 | 1821 | if (isset($row->label)) { |
1822 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
1822 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
1823 | 1823 | $label = $row->label->getValue(); |
1824 | 1824 | } else { |
1825 | - $label = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
1825 | + $label = $row->label->getValue()." (".$row->label->getLang().")"; |
|
1826 | 1826 | } |
1827 | 1827 | |
1828 | 1828 | } |
@@ -1898,8 +1898,8 @@ discard block |
||
1898 | 1898 | foreach ($result as $row) { |
1899 | 1899 | if (isset($row->top) && isset($row->label)) { |
1900 | 1900 | $label = $row->label->getValue(); |
1901 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
1902 | - $label .= ' (' . $row->label->getLang() . ')'; |
|
1901 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
1902 | + $label .= ' ('.$row->label->getLang().')'; |
|
1903 | 1903 | } |
1904 | 1904 | $top = array('uri' => $row->top->getUri(), 'topConceptOf' => $row->topuri->getUri(), 'label' => $label, 'hasChildren' => filter_var($row->children->getValue(), FILTER_VALIDATE_BOOLEAN)); |
1905 | 1905 | if (isset($row->notation)) { |
@@ -1992,7 +1992,7 @@ discard block |
||
1992 | 1992 | $ret[$uri]['exact'] = $row->exact->getUri(); |
1993 | 1993 | } |
1994 | 1994 | if (isset($row->tops)) { |
1995 | - $topConceptsList=explode(" ", $row->tops->getValue()); |
|
1995 | + $topConceptsList = explode(" ", $row->tops->getValue()); |
|
1996 | 1996 | // sort to garantee an alphabetical ordering of the URI |
1997 | 1997 | sort($topConceptsList); |
1998 | 1998 | $ret[$uri]['tops'] = $topConceptsList; |
@@ -2005,8 +2005,8 @@ discard block |
||
2005 | 2005 | $label = null; |
2006 | 2006 | if (isset($row->childlabel)) { |
2007 | 2007 | $label = $row->childlabel->getValue(); |
2008 | - if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang . "-") !== 0) { |
|
2009 | - $label .= " (" . $row->childlabel->getLang() . ")"; |
|
2008 | + if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang."-") !== 0) { |
|
2009 | + $label .= " (".$row->childlabel->getLang().")"; |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | } |
@@ -2027,8 +2027,8 @@ discard block |
||
2027 | 2027 | } |
2028 | 2028 | if (isset($row->label)) { |
2029 | 2029 | $preflabel = $row->label->getValue(); |
2030 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
2031 | - $preflabel .= ' (' . $row->label->getLang() . ')'; |
|
2030 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
2031 | + $preflabel .= ' ('.$row->label->getLang().')'; |
|
2032 | 2032 | } |
2033 | 2033 | |
2034 | 2034 | $ret[$uri]['prefLabel'] = $preflabel; |
@@ -2149,9 +2149,9 @@ discard block |
||
2149 | 2149 | */ |
2150 | 2150 | private function generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated = false) { |
2151 | 2151 | $fcl = $this->generateFromClause(); |
2152 | - $filterDeprecated=""; |
|
2153 | - if(!$showDeprecated){ |
|
2154 | - $filterDeprecated=" FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
2152 | + $filterDeprecated = ""; |
|
2153 | + if (!$showDeprecated) { |
|
2154 | + $filterDeprecated = " FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
2155 | 2155 | } |
2156 | 2156 | $query = <<<EOQ |
2157 | 2157 | SELECT ?conc ?super ?label ?members ?type ?notation $fcl |
@@ -2190,10 +2190,10 @@ discard block |
||
2190 | 2190 | 'type' => array($row->type->shorten()), |
2191 | 2191 | ); |
2192 | 2192 | if (isset($row->label)) { |
2193 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
2193 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
2194 | 2194 | $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue(); |
2195 | 2195 | } else { |
2196 | - $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
2196 | + $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")"; |
|
2197 | 2197 | } |
2198 | 2198 | |
2199 | 2199 | } |
@@ -2221,8 +2221,8 @@ discard block |
||
2221 | 2221 | * @param boolean $showDeprecated whether to include deprecated concepts in search results |
2222 | 2222 | * @return array Result array with concept URI as key and concept label as value |
2223 | 2223 | */ |
2224 | - public function listConceptGroupContents($groupClass, $group, $lang,$showDeprecated = false) { |
|
2225 | - $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang,$showDeprecated); |
|
2224 | + public function listConceptGroupContents($groupClass, $group, $lang, $showDeprecated = false) { |
|
2225 | + $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated); |
|
2226 | 2226 | $result = $this->query($query); |
2227 | 2227 | return $this->transformConceptGroupContentsResults($result, $lang); |
2228 | 2228 | } |
@@ -2235,7 +2235,7 @@ discard block |
||
2235 | 2235 | */ |
2236 | 2236 | private function generateChangeListQuery($lang, $offset, $prop) { |
2237 | 2237 | $fcl = $this->generateFromClause(); |
2238 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
2238 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
2239 | 2239 | |
2240 | 2240 | $query = <<<EOQ |
2241 | 2241 | SELECT DISTINCT ?concept ?date ?label $fcl |