Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 1564-1587 (lines=24) @@
1561
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1562
     * @return string sparql query
1563
     */
1564
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1565
        $fcl = $this->generateFromClause();
1566
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1567
1568
        $query = <<<EOQ
1569
SELECT * $fcl
1570
WHERE {
1571
  <$uri> a skos:Concept .
1572
  OPTIONAL {
1573
    <$uri> $prop ?object .
1574
    OPTIONAL {
1575
      ?object skos:prefLabel ?label .
1576
      FILTER (langMatches(lang(?label), "$lang"))
1577
    }
1578
    OPTIONAL {
1579
      ?object skos:prefLabel ?label .
1580
      FILTER (lang(?label) = "")
1581
    }
1582
    $anylang
1583
  }
1584
}
1585
EOQ;
1586
        return $query;
1587
    }
1588
1589
    /**
1590
     * Transforms the sparql query result into an array or null if the concept doesn't exist.
@@ 2214-2230 (lines=17) @@
2211
     * @param int $offset offset of results to retrieve; 0 for beginning of list
2212
     * @return string sparql query
2213
     */
2214
    private function generateChangeListQuery($lang, $offset, $prop) {
2215
        $fcl = $this->generateFromClause();
2216
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
2217
2218
        $query = <<<EOQ
2219
SELECT DISTINCT ?concept ?date ?label $fcl
2220
WHERE {
2221
  ?concept a skos:Concept .
2222
  ?concept $prop ?date .
2223
  ?concept skos:prefLabel ?label .
2224
  FILTER (langMatches(lang(?label), '$lang'))
2225
}
2226
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
2227
LIMIT 200 $offset
2228
EOQ;
2229
        return $query;
2230
    }
2231
2232
    /**
2233
     * Transforms the sparql query result into an array.