@@ -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 |