Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 1393-1416 (lines=24) @@
1390
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1391
     * @return string sparql query
1392
     */
1393
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1394
        $fcl = $this->generateFromClause();
1395
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1396
1397
        $query = <<<EOQ
1398
SELECT * $fcl
1399
WHERE {
1400
  <$uri> a skos:Concept .
1401
  OPTIONAL {
1402
    <$uri> $prop ?object .
1403
    OPTIONAL {
1404
      ?object skos:prefLabel ?label .
1405
      FILTER (langMatches(lang(?label), "$lang"))
1406
    }
1407
    OPTIONAL {
1408
      ?object skos:prefLabel ?label .
1409
      FILTER (lang(?label) = "")
1410
    }
1411
    $anylang
1412
  }
1413
}
1414
EOQ;
1415
        return $query;
1416
    }
1417
1418
    /**
1419
     * Transforms the sparql query result into an array or null if the concept doesn't exist.
@@ 2032-2048 (lines=17) @@
2029
     * @param int $offset offset of results to retrieve; 0 for beginning of list
2030
     * @return string sparql query
2031
     */
2032
    private function generateChangeListQuery($lang, $offset, $prop) {
2033
        $fcl = $this->generateFromClause();
2034
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
2035
2036
        $query = <<<EOQ
2037
SELECT DISTINCT ?concept ?date ?label $fcl
2038
WHERE {
2039
  ?concept a skos:Concept .
2040
  ?concept $prop ?date .
2041
  ?concept skos:prefLabel ?label .
2042
  FILTER (langMatches(lang(?label), '$lang'))
2043
}
2044
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
2045
LIMIT 200 $offset
2046
EOQ;
2047
        return $query;
2048
    }
2049
2050
    /**
2051
     * Transforms the sparql query result into an array.