Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 1335-1358 (lines=24) @@
1332
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1333
     * @return string sparql query
1334
     */
1335
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1336
        $fcl = $this->generateFromClause();
1337
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1338
1339
        $query = <<<EOQ
1340
SELECT * $fcl
1341
WHERE {
1342
  <$uri> a skos:Concept .
1343
  OPTIONAL {
1344
    <$uri> $prop ?object .
1345
    OPTIONAL {
1346
      ?object skos:prefLabel ?label .
1347
      FILTER (langMatches(lang(?label), "$lang"))
1348
    }
1349
    OPTIONAL {
1350
      ?object skos:prefLabel ?label .
1351
      FILTER (lang(?label) = "")
1352
    }
1353
    $anylang
1354
  }
1355
}
1356
EOQ;
1357
        return $query;
1358
    }
1359
1360
    /**
1361
     * Transforms the sparql query result into an array or null if the concept doesn't exist.
@@ 1959-1975 (lines=17) @@
1956
     * @param int $offset offset of results to retrieve; 0 for beginning of list
1957
     * @return string sparql query
1958
     */
1959
    private function generateChangeListQuery($lang, $offset, $prop) {
1960
        $fcl = $this->generateFromClause();
1961
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
1962
1963
        $query = <<<EOQ
1964
SELECT DISTINCT ?concept ?date ?label $fcl
1965
WHERE {
1966
  ?concept a skos:Concept .
1967
  ?concept $prop ?date .
1968
  ?concept skos:prefLabel ?label .
1969
  FILTER (langMatches(lang(?label), '$lang'))
1970
}
1971
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
1972
LIMIT 200 $offset
1973
EOQ;
1974
        return $query;
1975
    }
1976
1977
    /**
1978
     * Transforms the sparql query result into an array.