Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 2049-2065 (lines=17) @@
2046
     * @param int $offset offset of results to retrieve; 0 for beginning of list
2047
     * @return string sparql query
2048
     */
2049
    private function generateChangeListQuery($lang, $offset, $prop) {
2050
        $fcl = $this->generateFromClause();
2051
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
2052
2053
        $query = <<<EOQ
2054
SELECT DISTINCT ?concept ?date ?label $fcl
2055
WHERE {
2056
  ?concept a skos:Concept .
2057
  ?concept $prop ?date .
2058
  ?concept skos:prefLabel ?label .
2059
  FILTER (langMatches(lang(?label), '$lang'))
2060
}
2061
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
2062
LIMIT 200 $offset
2063
EOQ;
2064
        return $query;
2065
    }
2066
2067
    /**
2068
     * Transforms the sparql query result into an array.
@@ 1404-1427 (lines=24) @@
1401
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1402
     * @return string sparql query
1403
     */
1404
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1405
        $fcl = $this->generateFromClause();
1406
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1407
1408
        $query = <<<EOQ
1409
SELECT * $fcl
1410
WHERE {
1411
  <$uri> a skos:Concept .
1412
  OPTIONAL {
1413
    <$uri> $prop ?object .
1414
    OPTIONAL {
1415
      ?object skos:prefLabel ?label .
1416
      FILTER (langMatches(lang(?label), "$lang"))
1417
    }
1418
    OPTIONAL {
1419
      ?object skos:prefLabel ?label .
1420
      FILTER (lang(?label) = "")
1421
    }
1422
    $anylang
1423
  }
1424
}
1425
EOQ;
1426
        return $query;
1427
    }
1428
1429
    /**
1430
     * Transforms the sparql query result into an array or null if the concept doesn't exist.