Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 1516-1539 (lines=24) @@
1513
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1514
     * @return string sparql query
1515
     */
1516
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1517
        $fcl = $this->generateFromClause();
1518
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1519
1520
        $query = <<<EOQ
1521
SELECT * $fcl
1522
WHERE {
1523
  <$uri> a skos:Concept .
1524
  OPTIONAL {
1525
    <$uri> $prop ?object .
1526
    OPTIONAL {
1527
      ?object skos:prefLabel ?label .
1528
      FILTER (langMatches(lang(?label), "$lang"))
1529
    }
1530
    OPTIONAL {
1531
      ?object skos:prefLabel ?label .
1532
      FILTER (lang(?label) = "")
1533
    }
1534
    $anylang
1535
  }
1536
}
1537
EOQ;
1538
        return $query;
1539
    }
1540
1541
    /**
1542
     * Transforms the sparql query result into an array or null if the concept doesn't exist.
@@ 2166-2182 (lines=17) @@
2163
     * @param int $offset offset of results to retrieve; 0 for beginning of list
2164
     * @return string sparql query
2165
     */
2166
    private function generateChangeListQuery($lang, $offset, $prop) {
2167
        $fcl = $this->generateFromClause();
2168
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
2169
2170
        $query = <<<EOQ
2171
SELECT DISTINCT ?concept ?date ?label $fcl
2172
WHERE {
2173
  ?concept a skos:Concept .
2174
  ?concept $prop ?date .
2175
  ?concept skos:prefLabel ?label .
2176
  FILTER (langMatches(lang(?label), '$lang'))
2177
}
2178
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
2179
LIMIT 200 $offset
2180
EOQ;
2181
        return $query;
2182
    }
2183
2184
    /**
2185
     * Transforms the sparql query result into an array.