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