@@ -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; |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | $labelcondMatch = ($searchLang) ? "&& (?prop = skos:notation || LANGMATCHES(lang(?match), ?langParam))" : ""; |
| 884 | - $hlabelcondMatch = ($unique) ? "" : "\n FILTER(?prop != skos:hiddenLabel || ( NOT EXISTS { ?s skos:prefLabel ?prefLabel . FILTER (" . str_replace("?match", "?prefLabel", $filtercond) . ")} && NOT EXISTS { ?s skos:hiddenLabel ?hiddenLabel . FILTER (" . str_replace("?match", "?hiddenLabel", $filtercond) . " && STR(?hiddenLabel) < STR(?match))}))"; |
|
| 884 | + $hlabelcondMatch = ($unique) ? "" : "\n FILTER(?prop != skos:hiddenLabel || ( NOT EXISTS { ?s skos:prefLabel ?prefLabel . FILTER (".str_replace("?match", "?prefLabel", $filtercond).")} && NOT EXISTS { ?s skos:hiddenLabel ?hiddenLabel . FILTER (".str_replace("?match", "?hiddenLabel", $filtercond)." && STR(?hiddenLabel) < STR(?match))}))"; |
|
| 885 | 885 | |
| 886 | 886 | |
| 887 | 887 | return "?s ?prop ?match . FILTER ($filtercond $labelcondMatch) $hlabelcondMatch"; |
@@ -911,14 +911,14 @@ discard block |
||
| 911 | 911 | // if search language and UI/display language differ, must also consider case where there is no prefLabel in |
| 912 | 912 | // the display language; in that case, should use the label with the same language as the matched label |
| 913 | 913 | $labelcondFallback = ($searchLang != $lang) ? |
| 914 | - "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" . |
|
| 914 | + "OPTIONAL { # in case previous OPTIONAL block gives no labels\n". |
|
| 915 | 915 | "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : ""; |
| 916 | 916 | |
| 917 | 917 | // Including the labels if there is no query term given. |
| 918 | 918 | if ($rawterm === '') { |
| 919 | 919 | $labelClause = "?s skos:prefLabel ?label ."; |
| 920 | - $labelClause = ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . ""; |
|
| 921 | - return $labelClause . " BIND(?label AS ?match)"; |
|
| 920 | + $labelClause = ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause.""; |
|
| 921 | + return $labelClause." BIND(?label AS ?match)"; |
|
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | /* |
@@ -991,20 +991,20 @@ discard block |
||
| 991 | 991 | $schemecond = ''; |
| 992 | 992 | if (!empty($schemes)) { |
| 993 | 993 | $conditions = array(); |
| 994 | - foreach($schemes as $scheme) { |
|
| 994 | + foreach ($schemes as $scheme) { |
|
| 995 | 995 | $conditions[] = "{?s skos:inScheme <$scheme>}"; |
| 996 | 996 | } |
| 997 | - $schemecond = '{'.implode(" UNION ",$conditions).'}'; |
|
| 997 | + $schemecond = '{'.implode(" UNION ", $conditions).'}'; |
|
| 998 | 998 | } |
| 999 | - $filterDeprecated=""; |
|
| 999 | + $filterDeprecated = ""; |
|
| 1000 | 1000 | //show or hide deprecated concepts |
| 1001 | - if(!$showDeprecated){ |
|
| 1002 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 1001 | + if (!$showDeprecated) { |
|
| 1002 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 1003 | 1003 | } |
| 1004 | 1004 | // extra conditions for parent and group, if specified |
| 1005 | - $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : ""; |
|
| 1006 | - $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : ""; |
|
| 1007 | - $pgcond = $parentcond . $groupcond; |
|
| 1005 | + $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : ""; |
|
| 1006 | + $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : ""; |
|
| 1007 | + $pgcond = $parentcond.$groupcond; |
|
| 1008 | 1008 | |
| 1009 | 1009 | $orderextra = $this->isDefaultEndpoint() ? $this->graph : ''; |
| 1010 | 1010 | |
@@ -1090,9 +1090,9 @@ discard block |
||
| 1090 | 1090 | $hit['type'][] = $this->shortenUri($typeuri); |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | - if(!empty($fields)) { |
|
| 1093 | + if (!empty($fields)) { |
|
| 1094 | 1094 | foreach ($fields as $prop) { |
| 1095 | - $propname = $prop . 's'; |
|
| 1095 | + $propname = $prop.'s'; |
|
| 1096 | 1096 | if (isset($row->$propname)) { |
| 1097 | 1097 | foreach (explode("\n", $row->$propname->getValue()) as $line) { |
| 1098 | 1098 | $rdata = str_getcsv($line, ',', '"', '"'); |
@@ -1107,7 +1107,7 @@ discard block |
||
| 1107 | 1107 | $propvals = $rdata[2]; |
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | - $hit['skos:' . $prop][] = $propvals; |
|
| 1110 | + $hit['skos:'.$prop][] = $propvals; |
|
| 1111 | 1111 | } |
| 1112 | 1112 | } |
| 1113 | 1113 | } |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | * @return array query result object |
| 1184 | 1184 | */ |
| 1185 | 1185 | public function queryConcepts($vocabs, $fields = null, $unique = false, $params, $showDeprecated = false) { |
| 1186 | - $query = $this->generateConceptSearchQuery($fields, $unique, $params,$showDeprecated); |
|
| 1186 | + $query = $this->generateConceptSearchQuery($fields, $unique, $params, $showDeprecated); |
|
| 1187 | 1187 | $results = $this->query($query); |
| 1188 | 1188 | return $this->transformConceptSearchResults($results, $vocabs, $fields); |
| 1189 | 1189 | } |
@@ -1238,10 +1238,10 @@ discard block |
||
| 1238 | 1238 | $conditions = $this->formatFilterConditions($letter, $lang); |
| 1239 | 1239 | $filtercondLabel = $conditions['filterpref']; |
| 1240 | 1240 | $filtercondALabel = $conditions['filteralt']; |
| 1241 | - $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : ""; |
|
| 1242 | - $filterDeprecated=""; |
|
| 1243 | - if(!$showDeprecated){ |
|
| 1244 | - $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 1241 | + $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : ""; |
|
| 1242 | + $filterDeprecated = ""; |
|
| 1243 | + if (!$showDeprecated) { |
|
| 1244 | + $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }"; |
|
| 1245 | 1245 | } |
| 1246 | 1246 | $query = <<<EOQ |
| 1247 | 1247 | SELECT DISTINCT ?s ?label ?alabel ?qualifier |
@@ -1715,7 +1715,7 @@ discard block |
||
| 1715 | 1715 | if (!isset($row->label) || $row->label->getLang() === $lang) { |
| 1716 | 1716 | $ret[$row->object->getUri()] = $val; |
| 1717 | 1717 | } elseif ($row->label->getLang() === $fallbacklang) { |
| 1718 | - $val['label'] .= ' (' . $row->label->getLang() . ')'; |
|
| 1718 | + $val['label'] .= ' ('.$row->label->getLang().')'; |
|
| 1719 | 1719 | $ret[$row->object->getUri()] = $val; |
| 1720 | 1720 | } |
| 1721 | 1721 | } |
@@ -1811,10 +1811,10 @@ discard block |
||
| 1811 | 1811 | |
| 1812 | 1812 | $label = null; |
| 1813 | 1813 | if (isset($row->label)) { |
| 1814 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
| 1814 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
| 1815 | 1815 | $label = $row->label->getValue(); |
| 1816 | 1816 | } else { |
| 1817 | - $label = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
| 1817 | + $label = $row->label->getValue()." (".$row->label->getLang().")"; |
|
| 1818 | 1818 | } |
| 1819 | 1819 | |
| 1820 | 1820 | } |
@@ -1890,8 +1890,8 @@ discard block |
||
| 1890 | 1890 | foreach ($result as $row) { |
| 1891 | 1891 | if (isset($row->top) && isset($row->label)) { |
| 1892 | 1892 | $label = $row->label->getValue(); |
| 1893 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
| 1894 | - $label .= ' (' . $row->label->getLang() . ')'; |
|
| 1893 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
| 1894 | + $label .= ' ('.$row->label->getLang().')'; |
|
| 1895 | 1895 | } |
| 1896 | 1896 | $top = array('uri' => $row->top->getUri(), 'topConceptOf' => $row->topuri->getUri(), 'label' => $label, 'hasChildren' => filter_var($row->children->getValue(), FILTER_VALIDATE_BOOLEAN)); |
| 1897 | 1897 | if (isset($row->notation)) { |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | $ret[$uri]['exact'] = $row->exact->getUri(); |
| 1985 | 1985 | } |
| 1986 | 1986 | if (isset($row->tops)) { |
| 1987 | - $topConceptsList=explode(" ", $row->tops->getValue()); |
|
| 1987 | + $topConceptsList = explode(" ", $row->tops->getValue()); |
|
| 1988 | 1988 | // sort to garantee an alphabetical ordering of the URI |
| 1989 | 1989 | sort($topConceptsList); |
| 1990 | 1990 | $ret[$uri]['tops'] = $topConceptsList; |
@@ -1997,8 +1997,8 @@ discard block |
||
| 1997 | 1997 | $label = null; |
| 1998 | 1998 | if (isset($row->childlabel)) { |
| 1999 | 1999 | $label = $row->childlabel->getValue(); |
| 2000 | - if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang . "-") !== 0) { |
|
| 2001 | - $label .= " (" . $row->childlabel->getLang() . ")"; |
|
| 2000 | + if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang."-") !== 0) { |
|
| 2001 | + $label .= " (".$row->childlabel->getLang().")"; |
|
| 2002 | 2002 | } |
| 2003 | 2003 | |
| 2004 | 2004 | } |
@@ -2019,8 +2019,8 @@ discard block |
||
| 2019 | 2019 | } |
| 2020 | 2020 | if (isset($row->label)) { |
| 2021 | 2021 | $preflabel = $row->label->getValue(); |
| 2022 | - if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) { |
|
| 2023 | - $preflabel .= ' (' . $row->label->getLang() . ')'; |
|
| 2022 | + if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) { |
|
| 2023 | + $preflabel .= ' ('.$row->label->getLang().')'; |
|
| 2024 | 2024 | } |
| 2025 | 2025 | |
| 2026 | 2026 | $ret[$uri]['prefLabel'] = $preflabel; |
@@ -2141,9 +2141,9 @@ discard block |
||
| 2141 | 2141 | */ |
| 2142 | 2142 | private function generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated = false) { |
| 2143 | 2143 | $fcl = $this->generateFromClause(); |
| 2144 | - $filterDeprecated=""; |
|
| 2145 | - if(!$showDeprecated){ |
|
| 2146 | - $filterDeprecated=" FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
| 2144 | + $filterDeprecated = ""; |
|
| 2145 | + if (!$showDeprecated) { |
|
| 2146 | + $filterDeprecated = " FILTER NOT EXISTS { ?conc owl:deprecated true }"; |
|
| 2147 | 2147 | } |
| 2148 | 2148 | $query = <<<EOQ |
| 2149 | 2149 | SELECT ?conc ?super ?label ?members ?type ?notation $fcl |
@@ -2182,10 +2182,10 @@ discard block |
||
| 2182 | 2182 | 'type' => array($row->type->shorten()), |
| 2183 | 2183 | ); |
| 2184 | 2184 | if (isset($row->label)) { |
| 2185 | - if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) { |
|
| 2185 | + if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) { |
|
| 2186 | 2186 | $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue(); |
| 2187 | 2187 | } else { |
| 2188 | - $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")"; |
|
| 2188 | + $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")"; |
|
| 2189 | 2189 | } |
| 2190 | 2190 | |
| 2191 | 2191 | } |
@@ -2213,8 +2213,8 @@ discard block |
||
| 2213 | 2213 | * @param boolean $showDeprecated whether to include deprecated concepts in search results |
| 2214 | 2214 | * @return array Result array with concept URI as key and concept label as value |
| 2215 | 2215 | */ |
| 2216 | - public function listConceptGroupContents($groupClass, $group, $lang,$showDeprecated = false) { |
|
| 2217 | - $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang,$showDeprecated); |
|
| 2216 | + public function listConceptGroupContents($groupClass, $group, $lang, $showDeprecated = false) { |
|
| 2217 | + $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated); |
|
| 2218 | 2218 | $result = $this->query($query); |
| 2219 | 2219 | return $this->transformConceptGroupContentsResults($result, $lang); |
| 2220 | 2220 | } |
@@ -2227,9 +2227,9 @@ discard block |
||
| 2227 | 2227 | * @param int $limit maximum number of results to return |
| 2228 | 2228 | * @return string sparql query |
| 2229 | 2229 | */ |
| 2230 | - private function generateChangeListQuery($prop, $lang, $offset, $limit=200) { |
|
| 2230 | + private function generateChangeListQuery($prop, $lang, $offset, $limit = 200) { |
|
| 2231 | 2231 | $fcl = $this->generateFromClause(); |
| 2232 | - $offset = ($offset) ? 'OFFSET ' . $offset : ''; |
|
| 2232 | + $offset = ($offset) ? 'OFFSET '.$offset : ''; |
|
| 2233 | 2233 | |
| 2234 | 2234 | $query = <<<EOQ |
| 2235 | 2235 | SELECT DISTINCT ?concept ?date ?label $fcl |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | return $this->resource->label($fallback); |
| 137 | 137 | } |
| 138 | 138 | // We need to check all the labels in case one of them matches a subtag of the current language |
| 139 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 139 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 140 | 140 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
| 141 | - if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) { |
|
| 141 | + if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) { |
|
| 142 | 142 | return EasyRdf\Literal::create($label, $fallback); |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | public function hasXlLabel($prop = 'prefLabel') |
| 161 | 161 | { |
| 162 | - if ($this->resource->hasProperty('skosxl:' . $prop)) { |
|
| 162 | + if ($this->resource->hasProperty('skosxl:'.$prop)) { |
|
| 163 | 163 | return true; |
| 164 | 164 | } |
| 165 | 165 | return false; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | public function getXlLabel() |
| 169 | 169 | { |
| 170 | 170 | $labels = $this->resource->allResources('skosxl:prefLabel'); |
| 171 | - foreach($labels as $labres) { |
|
| 171 | + foreach ($labels as $labres) { |
|
| 172 | 172 | $label = $labres->getLiteral('skosxl:literalForm'); |
| 173 | 173 | if ($label !== null && $label->getLang() == $this->clang) { |
| 174 | 174 | return new LabelSkosXL($this->model, $labres); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | // catch external subjects that have $res as object |
| 276 | 276 | $extSubjects = $exGraph->resourcesMatching("schema:about", $res); |
| 277 | 277 | |
| 278 | - $propList = array_unique(array_merge( |
|
| 278 | + $propList = array_unique(array_merge( |
|
| 279 | 279 | $this->DEFAULT_EXT_PROPERTIES, |
| 280 | 280 | $this->getVocab()->getConfig()->getExtProperties(), |
| 281 | 281 | $this->getVocab()->getConfig()->getPlugins()->getExtProperties() |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @param string[] $seen Processed resources so far |
| 301 | 301 | * @param string[] $props (optional) limit to these property URIs |
| 302 | 302 | */ |
| 303 | - private function addExternalTriplesToGraph($res, &$seen, $props=null) |
|
| 303 | + private function addExternalTriplesToGraph($res, &$seen, $props = null) |
|
| 304 | 304 | { |
| 305 | 305 | if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) { |
| 306 | 306 | return; |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | private function addPropertyValues($res, $prop, &$seen) |
| 332 | 332 | { |
| 333 | - $resList = $res->allResources('<' . $prop . '>'); |
|
| 333 | + $resList = $res->allResources('<'.$prop.'>'); |
|
| 334 | 334 | |
| 335 | 335 | foreach ($resList as $res2) { |
| 336 | 336 | if ($res2->isBNode()) { |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | $this->addResourceReifications($res, $prop, $res2, $seen); |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - $litList = $res->allLiterals('<' . $prop . '>'); |
|
| 343 | + $litList = $res->allLiterals('<'.$prop.'>'); |
|
| 344 | 344 | |
| 345 | 345 | foreach ($litList as $lit) { |
| 346 | 346 | $this->graph->addLiteral($res, $prop, $lit); |
@@ -528,15 +528,15 @@ discard block |
||
| 528 | 528 | // if not found in current vocabulary, look up in the default graph to be able |
| 529 | 529 | // to read an ontology loaded in a separate graph |
| 530 | 530 | // note that this imply that the property has an rdf:type declared for the query to work |
| 531 | - if(!$is_well_known && !$proplabel) { |
|
| 531 | + if (!$is_well_known && !$proplabel) { |
|
| 532 | 532 | $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang()); |
| 533 | 533 | |
| 534 | 534 | $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, ''); |
| 535 | 535 | |
| 536 | - if($envLangLabels) { |
|
| 536 | + if ($envLangLabels) { |
|
| 537 | 537 | $proplabel = $envLangLabels[$this->getEnvLang()]; |
| 538 | 538 | } else { |
| 539 | - if($defaultPropLabel) { |
|
| 539 | + if ($defaultPropLabel) { |
|
| 540 | 540 | $proplabel = $defaultPropLabel['']; |
| 541 | 541 | } |
| 542 | 542 | } |
@@ -549,12 +549,12 @@ discard block |
||
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // also look up superprops in the default graph if not found in current vocabulary |
| 552 | - if(!$is_well_known && (!$superprops || empty($superprops))) { |
|
| 552 | + if (!$is_well_known && (!$superprops || empty($superprops))) { |
|
| 553 | 553 | $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri); |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | // we're reading only one super property, even if there are multiple ones |
| 557 | - $superprop = ($superprops)?$superprops[0]:null; |
|
| 557 | + $superprop = ($superprops) ? $superprops[0] : null; |
|
| 558 | 558 | if ($superprop) { |
| 559 | 559 | $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop; |
| 560 | 560 | } |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | // searching for subproperties of literals too |
| 570 | - if($superprops) { |
|
| 570 | + if ($superprops) { |
|
| 571 | 571 | foreach ($superprops as $subi) { |
| 572 | 572 | $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi; |
| 573 | 573 | $duplicates[$suburi] = $prop; |
@@ -729,14 +729,14 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | // making a human readable string from the timestamps |
| 731 | 731 | if ($created != '') { |
| 732 | - $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short', $this->getEnvLang())); |
|
| 732 | + $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short', $this->getEnvLang())); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | if ($modified != '') { |
| 736 | 736 | if ($created != '') { |
| 737 | - $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
| 737 | + $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
| 738 | 738 | } else { |
| 739 | - $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
| 739 | + $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); |
|
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | } |
@@ -744,12 +744,12 @@ discard block |
||
| 744 | 744 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 745 | 745 | $ret = ''; |
| 746 | 746 | if ($this->resource->get('dc:modified')) { |
| 747 | - $modified = (string) $this->resource->get('dc:modified'); |
|
| 748 | - $ret = gettext('skosmos:modified') . ' ' . $modified; |
|
| 747 | + $modified = (string)$this->resource->get('dc:modified'); |
|
| 748 | + $ret = gettext('skosmos:modified').' '.$modified; |
|
| 749 | 749 | } |
| 750 | 750 | if ($this->resource->get('dc:created')) { |
| 751 | - $created .= (string) $this->resource->get('dc:created'); |
|
| 752 | - $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; |
|
| 751 | + $created .= (string)$this->resource->get('dc:created'); |
|
| 752 | + $ret .= ' '.gettext('skosmos:created').' '.$created; |
|
| 753 | 753 | } |
| 754 | 754 | } |
| 755 | 755 | return $ret; |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | $groups[$collLabel] = array($group); |
| 822 | 822 | |
| 823 | 823 | $res = $collection; |
| 824 | - while($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
| 824 | + while ($super = $this->graph->resourcesMatching('skos:member', $res)) { |
|
| 825 | 825 | foreach ($super as $res) { |
| 826 | 826 | $superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang); |
| 827 | 827 | array_unshift($groups[$collLabel], $superprop); |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | |
| 867 | 867 | foreach ($labels as $lit) { |
| 868 | 868 | // filtering away subsets of the current language eg. en vs en-GB |
| 869 | - if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { |
|
| 869 | + if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { |
|
| 870 | 870 | $langCode = $lit->getLang() ? $lit->getLang() : ''; |
| 871 | 871 | $ret[$langCode][$key][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop); |
| 872 | 872 | } |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | * @param boolean $sortByLangToString Sort by (subset filtered) language name in UI language (default: true) |
| 880 | 880 | * @return array Language-based multidimensional sorted array ([string][string][ConceptPropertyValueLiteral]) or empty array if no values |
| 881 | 881 | */ |
| 882 | - public function getForeignLabels($sortByLangToString=true) |
|
| 882 | + public function getForeignLabels($sortByLangToString = true) |
|
| 883 | 883 | { |
| 884 | 884 | $prefLabels = $this->getForeignLabelList('skos:prefLabel', 'prefLabel'); |
| 885 | 885 | $altLabels = $this->getForeignLabelList('skos:altLabel', 'altLabel'); |
@@ -958,10 +958,10 @@ discard block |
||
| 958 | 958 | } |
| 959 | 959 | else if ($context[$vocabPrefix] !== $vocabUriSpace) { |
| 960 | 960 | $i = 2; |
| 961 | - while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) { |
|
| 961 | + while (isset($context[$vocabPrefix.$i]) && $context[$vocabPrefix.$i] !== $vocabUriSpace) { |
|
| 962 | 962 | $i += 1; |
| 963 | 963 | } |
| 964 | - $context[$vocabPrefix . $i] = $vocabUriSpace; |
|
| 964 | + $context[$vocabPrefix.$i] = $vocabUriSpace; |
|
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | 967 | $compactJsonLD = \ML\JsonLD\JsonLD::compact($this->graph->serialise('jsonld'), json_encode($context)); |