Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

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