Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 1320-1343 (lines=24) @@
1317
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1318
     * @return string sparql query
1319
     */
1320
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1321
        $fcl = $this->generateFromClause();
1322
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1323
1324
        $query = <<<EOQ
1325
SELECT * $fcl
1326
WHERE {
1327
  <$uri> a skos:Concept .
1328
  OPTIONAL {
1329
    <$uri> $prop ?object .
1330
    OPTIONAL {
1331
      ?object skos:prefLabel ?label .
1332
      FILTER (langMatches(lang(?label), "$lang"))
1333
    }
1334
    OPTIONAL {
1335
      ?object skos:prefLabel ?label .
1336
      FILTER (lang(?label) = "")
1337
    }
1338
    $anylang
1339
  }
1340
}
1341
EOQ;
1342
        return $query;
1343
    }
1344
1345
    /**
1346
     * Transforms the sparql query result into an array or null if the concept doesn't exist.
@@ 1944-1960 (lines=17) @@
1941
     * @param int $offset offset of results to retrieve; 0 for beginning of list
1942
     * @return string sparql query
1943
     */
1944
    private function generateChangeListQuery($lang, $offset, $prop) {
1945
        $fcl = $this->generateFromClause();
1946
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
1947
1948
        $query = <<<EOQ
1949
SELECT DISTINCT ?concept ?date ?label $fcl
1950
WHERE {
1951
  ?concept a skos:Concept .
1952
  ?concept $prop ?date .
1953
  ?concept skos:prefLabel ?label .
1954
  FILTER (langMatches(lang(?label), '$lang'))
1955
}
1956
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
1957
LIMIT 200 $offset
1958
EOQ;
1959
        return $query;
1960
    }
1961
1962
    /**
1963
     * Transforms the sparql query result into an array.