@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Returns the graph instance |
154 | - * @return object EasyRDF graph instance. |
|
154 | + * @return string|null EasyRDF graph instance. |
|
155 | 155 | */ |
156 | 156 | public function getGraph() { |
157 | 157 | return $this->graph; |
@@ -286,6 +286,7 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * Counts the number of concepts in a easyRDF graph with a specific language. |
288 | 288 | * @param array $langs Languages to query for |
289 | + * @param string[] $classes |
|
289 | 290 | * @return Array containing count of concepts for each language and property. |
290 | 291 | */ |
291 | 292 | public function countLangConcepts($langs, $classes = null) { |
@@ -476,7 +477,7 @@ discard block |
||
476 | 477 | * Returns information (as a graph) for one or more concept URIs |
477 | 478 | * @param mixed $uris concept URI (string) or array of URIs |
478 | 479 | * @param string|null $arrayClass the URI for thesaurus array class, or null if not used |
479 | - * @param \Vocabulary[]|null $vocabs vocabularies to target |
|
480 | + * @param Vocabulary[] $vocabs vocabularies to target |
|
480 | 481 | * @return \EasyRdf\Graph |
481 | 482 | */ |
482 | 483 | public function queryConceptInfoGraph($uris, $arrayClass = null, $vocabs = array()) { |
@@ -492,7 +493,7 @@ discard block |
||
492 | 493 | |
493 | 494 | /** |
494 | 495 | * Returns information (as an array of Concept objects) for one or more concept URIs |
495 | - * @param mixed $uris concept URI (string) or array of URIs |
|
496 | + * @param string $uris concept URI (string) or array of URIs |
|
496 | 497 | * @param string|null $arrayClass the URI for thesaurus array class, or null if not used |
497 | 498 | * @param \Vocabulary[] $vocabs vocabularies to target |
498 | 499 | * @param string|null $clang content language |
@@ -710,7 +711,7 @@ discard block |
||
710 | 711 | |
711 | 712 | /** |
712 | 713 | * Generate a VALUES clause for limiting the targeted graphs. |
713 | - * @param Vocabulary[]|null $vocabs array of Vocabulary objects to target |
|
714 | + * @param Vocabulary[] $vocabs array of Vocabulary objects to target |
|
714 | 715 | * @return string VALUES clause, or "" if not necessary to limit |
715 | 716 | */ |
716 | 717 | protected function formatValuesGraph($vocabs) { |
@@ -892,6 +893,7 @@ discard block |
||
892 | 893 | * @param string $searchLang language code used for matching labels (null means any language) |
893 | 894 | * @param string[] $props properties to target e.g. array('skos:prefLabel','skos:altLabel') |
894 | 895 | * @param boolean $unique restrict results to unique concepts (default: false) |
896 | + * @param string $filterGraph |
|
895 | 897 | * @return string sparql query |
896 | 898 | */ |
897 | 899 | protected function generateConceptSearchQueryInner($term, $lang, $searchLang, $props, $unique, $filterGraph) |
@@ -1187,6 +1189,7 @@ discard block |
||
1187 | 1189 | /** |
1188 | 1190 | * Generates sparql query clauses used for creating the alphabetical index. |
1189 | 1191 | * @param string $letter the letter (or special class) to search for |
1192 | + * @param string $lang |
|
1190 | 1193 | * @return array of sparql query clause strings |
1191 | 1194 | */ |
1192 | 1195 | private function formatFilterConditions($letter, $lang) { |
@@ -1367,6 +1370,7 @@ discard block |
||
1367 | 1370 | /** |
1368 | 1371 | * Query for the first characters (letter or otherwise) of the labels in the particular language. |
1369 | 1372 | * @param string $lang language |
1373 | + * @param string[] $classes |
|
1370 | 1374 | * @return array array of characters |
1371 | 1375 | */ |
1372 | 1376 | public function queryFirstCharacters($lang, $classes = null) { |
@@ -1743,7 +1747,7 @@ discard block |
||
1743 | 1747 | /** |
1744 | 1748 | * Query a single transitive property of a concept. |
1745 | 1749 | * @param string $uri |
1746 | - * @param array $props the property/properties. |
|
1750 | + * @param string[] $props the property/properties. |
|
1747 | 1751 | * @param string $lang |
1748 | 1752 | * @param integer $limit |
1749 | 1753 | * @param boolean $anylang if you want a label even when it isn't available in the language you requested. |
@@ -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); |
@@ -667,9 +667,9 @@ discard block |
||
667 | 667 | $conceptscheme['title'] = $row->title->getValue(); |
668 | 668 | } |
669 | 669 | // add dct:subject and their labels in the result |
670 | - if(isset($row->domain) && isset($row->domainLabel)){ |
|
671 | - $conceptscheme['subject']['uri']=$row->domain->getURI(); |
|
672 | - $conceptscheme['subject']['prefLabel']=$row->domainLabel->getValue(); |
|
670 | + if (isset($row->domain) && isset($row->domainLabel)) { |
|
671 | + $conceptscheme['subject']['uri'] = $row->domain->getURI(); |
|
672 | + $conceptscheme['subject']['prefLabel'] = $row->domainLabel->getValue(); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | $ret[$row->cs->getURI()] = $conceptscheme; |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | $values[] = "<$graph>"; |
737 | 737 | } |
738 | 738 | if (count($values)) { |
739 | - return "FILTER (?graph IN (" . implode(',', $values) . "))"; |
|
739 | + return "FILTER (?graph IN (".implode(',', $values)."))"; |
|
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
@@ -747,16 +747,16 @@ discard block |
||
747 | 747 | * @return string sparql query clauses |
748 | 748 | */ |
749 | 749 | protected function formatLimitAndOffset($limit, $offset) { |
750 | - $limit = ($limit) ? 'LIMIT ' . $limit : ''; |
|
751 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
750 | + $limit = ($limit) ? 'LIMIT '.$limit : ''; |
|
751 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
752 | 752 | // eliminating whitespace and line changes when the conditions aren't needed. |
753 | 753 | $limitandoffset = ''; |
754 | 754 | if ($limit && $offset) { |
755 | - $limitandoffset = "\n" . $limit . "\n" . $offset; |
|
755 | + $limitandoffset = "\n".$limit."\n".$offset; |
|
756 | 756 | } elseif ($limit) { |
757 | - $limitandoffset = "\n" . $limit; |
|
757 | + $limitandoffset = "\n".$limit; |
|
758 | 758 | } elseif ($offset) { |
759 | - $limitandoffset = "\n" . $offset; |
|
759 | + $limitandoffset = "\n".$offset; |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | return $limitandoffset; |
@@ -908,14 +908,14 @@ discard block |
||
908 | 908 | // if search language and UI/display language differ, must also consider case where there is no prefLabel in |
909 | 909 | // the display language; in that case, should use the label with the same language as the matched label |
910 | 910 | $labelcondFallback = ($searchLang != $lang) ? |
911 | - "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" . |
|
911 | + "OPTIONAL { # in case previous OPTIONAL block gives no labels\n". |
|
912 | 912 | "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : ""; |
913 | 913 | |
914 | 914 | // Including the labels if there is no query term given. |
915 | 915 | if ($rawterm === '') { |
916 | 916 | $labelClause = "?s skos:prefLabel ?label ."; |
917 | - $labelClause = ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . ""; |
|
918 | - return $labelClause . " BIND(?label AS ?match)"; |
|
917 | + $labelClause = ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause.""; |
|
918 | + return $labelClause." BIND(?label AS ?match)"; |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | /* |
@@ -987,20 +987,20 @@ discard block |
||
987 | 987 | $schemecond = ''; |
988 | 988 | if (!empty($schemes)) { |
989 | 989 | $conditions = array(); |
990 | - foreach($schemes as $scheme) { |
|
990 | + foreach ($schemes as $scheme) { |
|
991 | 991 | $conditions[] = "{?s skos:inScheme <$scheme>}"; |
992 | 992 | } |
993 | - $schemecond = '{'.implode(" UNION ",$conditions).'}'; |
|
993 | + $schemecond = '{'.implode(" UNION ", $conditions).'}'; |
|
994 | 994 | } |
995 | - $filterDeprecated=""; |
|
995 | + $filterDeprecated = ""; |
|
996 | 996 | //show or hide deprecated concepts |
997 | - if(!$showDeprecated){ |
|
998 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
997 | + if (!$showDeprecated) { |
|
998 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
999 | 999 | } |
1000 | 1000 | // extra conditions for parent and group, if specified |
1001 | - $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : ""; |
|
1002 | - $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : ""; |
|
1003 | - $pgcond = $parentcond . $groupcond; |
|
1001 | + $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : ""; |
|
1002 | + $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : ""; |
|
1003 | + $pgcond = $parentcond.$groupcond; |
|
1004 | 1004 | |
1005 | 1005 | $orderextra = $this->isDefaultEndpoint() ? $this->graph : ''; |
1006 | 1006 | |
@@ -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 | } |
@@ -1234,10 +1234,10 @@ discard block |
||
1234 | 1234 | $conditions = $this->formatFilterConditions($letter, $lang); |
1235 | 1235 | $filtercondLabel = $conditions['filterpref']; |
1236 | 1236 | $filtercondALabel = $conditions['filteralt']; |
1237 | - $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : ""; |
|
1238 | - $filterDeprecated=""; |
|
1239 | - if(!$showDeprecated){ |
|
1240 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
1237 | + $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : ""; |
|
1238 | + $filterDeprecated = ""; |
|
1239 | + if (!$showDeprecated) { |
|
1240 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
1241 | 1241 | } |
1242 | 1242 | $query = <<<EOQ |
1243 | 1243 | SELECT DISTINCT ?s ?label ?alabel ?qualifier $fcl |
@@ -1688,7 +1688,7 @@ discard block |
||
1688 | 1688 | * @param boolean $explicitLanguageTags Explictly show (add to label) language tag |
1689 | 1689 | * @return array of property values (key: URI, val: label), or null if concept doesn't exist |
1690 | 1690 | */ |
1691 | - private function transformTransitivePropertyResults($result, $lang, $fallbacklang, $explicitLanguageTags=False) { |
|
1691 | + private function transformTransitivePropertyResults($result, $lang, $fallbacklang, $explicitLanguageTags = False) { |
|
1692 | 1692 | $ret = array(); |
1693 | 1693 | foreach ($result as $row) { |
1694 | 1694 | if (!isset($row->object)) { |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | if (isset($row->label)) { |
1699 | 1699 | $val = array('label' => $row->label->getValue()); |
1700 | 1700 | if ($explicitLanguageTags) { |
1701 | - $val['label'] .= ' (' . $row->label->getLang() . ')'; |
|
1701 | + $val['label'] .= ' ('.$row->label->getLang().')'; |
|
1702 | 1702 | } |
1703 | 1703 | } else { |
1704 | 1704 | $val = array('label' => null); |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | $ret[$row->object->getUri()] = $val; |
1713 | 1713 | } elseif ($row->label->getLang() === $fallbacklang) { |
1714 | 1714 | if (!$explicitLanguageTags) { |
1715 | - $val['label'] .= ' (' . $row->label->getLang() . ')'; |
|
1715 | + $val['label'] .= ' ('.$row->label->getLang().')'; |
|
1716 | 1716 | } |
1717 | 1717 | $ret[$row->object->getUri()] = $val; |
1718 | 1718 | } |
@@ -1810,10 +1810,10 @@ discard block |
||
1810 | 1810 | |
1811 | 1811 | $label = null; |
1812 | 1812 | if (isset($row->label)) { |
1813 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
1813 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
1814 | 1814 | $label = $row->label->getValue(); |
1815 | 1815 | } else { |
1816 | - $label = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
1816 | + $label = $row->label->getValue()." (".$row->label->getLang().")"; |
|
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | } |
@@ -1889,8 +1889,8 @@ discard block |
||
1889 | 1889 | foreach ($result as $row) { |
1890 | 1890 | if (isset($row->top) && isset($row->label)) { |
1891 | 1891 | $label = $row->label->getValue(); |
1892 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
1893 | - $label .= ' (' . $row->label->getLang() . ')'; |
|
1892 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
1893 | + $label .= ' ('.$row->label->getLang().')'; |
|
1894 | 1894 | } |
1895 | 1895 | $top = array('uri' => $row->top->getUri(), 'topConceptOf' => $row->topuri->getUri(), 'label' => $label, 'hasChildren' => filter_var($row->children->getValue(), FILTER_VALIDATE_BOOLEAN)); |
1896 | 1896 | if (isset($row->notation)) { |
@@ -1983,7 +1983,7 @@ discard block |
||
1983 | 1983 | $ret[$uri]['exact'] = $row->exact->getUri(); |
1984 | 1984 | } |
1985 | 1985 | if (isset($row->tops)) { |
1986 | - $topConceptsList=explode(" ", $row->tops->getValue()); |
|
1986 | + $topConceptsList = explode(" ", $row->tops->getValue()); |
|
1987 | 1987 | // sort to garantee an alphabetical ordering of the URI |
1988 | 1988 | sort($topConceptsList); |
1989 | 1989 | $ret[$uri]['tops'] = $topConceptsList; |
@@ -1996,8 +1996,8 @@ discard block |
||
1996 | 1996 | $label = null; |
1997 | 1997 | if (isset($row->childlabel)) { |
1998 | 1998 | $label = $row->childlabel->getValue(); |
1999 | - if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang . "-") !== 0) { |
|
2000 | - $label .= " (" . $row->childlabel->getLang() . ")"; |
|
1999 | + if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang."-") !== 0) { |
|
2000 | + $label .= " (".$row->childlabel->getLang().")"; |
|
2001 | 2001 | } |
2002 | 2002 | |
2003 | 2003 | } |
@@ -2018,8 +2018,8 @@ discard block |
||
2018 | 2018 | } |
2019 | 2019 | if (isset($row->label)) { |
2020 | 2020 | $preflabel = $row->label->getValue(); |
2021 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
2022 | - $preflabel .= ' (' . $row->label->getLang() . ')'; |
|
2021 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
2022 | + $preflabel .= ' ('.$row->label->getLang().')'; |
|
2023 | 2023 | } |
2024 | 2024 | |
2025 | 2025 | $ret[$uri]['prefLabel'] = $preflabel; |
@@ -2140,9 +2140,9 @@ discard block |
||
2140 | 2140 | */ |
2141 | 2141 | private function generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated = false) { |
2142 | 2142 | $fcl = $this->generateFromClause(); |
2143 | - $filterDeprecated=""; |
|
2144 | - if(!$showDeprecated){ |
|
2145 | - $filterDeprecated=" FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
2143 | + $filterDeprecated = ""; |
|
2144 | + if (!$showDeprecated) { |
|
2145 | + $filterDeprecated = " FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
2146 | 2146 | } |
2147 | 2147 | $query = <<<EOQ |
2148 | 2148 | SELECT ?conc ?super ?label ?members ?type ?notation $fcl |
@@ -2181,10 +2181,10 @@ discard block |
||
2181 | 2181 | 'type' => array($row->type->shorten()), |
2182 | 2182 | ); |
2183 | 2183 | if (isset($row->label)) { |
2184 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
2184 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
2185 | 2185 | $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue(); |
2186 | 2186 | } else { |
2187 | - $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
2187 | + $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")"; |
|
2188 | 2188 | } |
2189 | 2189 | |
2190 | 2190 | } |
@@ -2212,8 +2212,8 @@ discard block |
||
2212 | 2212 | * @param boolean $showDeprecated whether to include deprecated concepts in search results |
2213 | 2213 | * @return array Result array with concept URI as key and concept label as value |
2214 | 2214 | */ |
2215 | - public function listConceptGroupContents($groupClass, $group, $lang,$showDeprecated = false) { |
|
2216 | - $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang,$showDeprecated); |
|
2215 | + public function listConceptGroupContents($groupClass, $group, $lang, $showDeprecated = false) { |
|
2216 | + $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated); |
|
2217 | 2217 | $result = $this->query($query); |
2218 | 2218 | return $this->transformConceptGroupContentsResults($result, $lang); |
2219 | 2219 | } |
@@ -2226,9 +2226,9 @@ discard block |
||
2226 | 2226 | * @param int $limit maximum number of results to return |
2227 | 2227 | * @return string sparql query |
2228 | 2228 | */ |
2229 | - private function generateChangeListQuery($prop, $lang, $offset, $limit=200) { |
|
2229 | + private function generateChangeListQuery($prop, $lang, $offset, $limit = 200) { |
|
2230 | 2230 | $fcl = $this->generateFromClause(); |
2231 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
2231 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
2232 | 2232 | |
2233 | 2233 | $query = <<<EOQ |
2234 | 2234 | SELECT DISTINCT ?concept ?date ?label $fcl |