Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 1495-1518 (lines=24) @@
1492
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1493
     * @return string sparql query
1494
     */
1495
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1496
        $fcl = $this->generateFromClause();
1497
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1498
1499
        $query = <<<EOQ
1500
SELECT * $fcl
1501
WHERE {
1502
  <$uri> a skos:Concept .
1503
  OPTIONAL {
1504
    <$uri> $prop ?object .
1505
    OPTIONAL {
1506
      ?object skos:prefLabel ?label .
1507
      FILTER (langMatches(lang(?label), "$lang"))
1508
    }
1509
    OPTIONAL {
1510
      ?object skos:prefLabel ?label .
1511
      FILTER (lang(?label) = "")
1512
    }
1513
    $anylang
1514
  }
1515
}
1516
EOQ;
1517
        return $query;
1518
    }
1519
1520
    /**
1521
     * Transforms the sparql query result into an array or null if the concept doesn't exist.
@@ 2145-2161 (lines=17) @@
2142
     * @param int $offset offset of results to retrieve; 0 for beginning of list
2143
     * @return string sparql query
2144
     */
2145
    private function generateChangeListQuery($lang, $offset, $prop) {
2146
        $fcl = $this->generateFromClause();
2147
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
2148
2149
        $query = <<<EOQ
2150
SELECT DISTINCT ?concept ?date ?label $fcl
2151
WHERE {
2152
  ?concept a skos:Concept .
2153
  ?concept $prop ?date .
2154
  ?concept skos:prefLabel ?label .
2155
  FILTER (langMatches(lang(?label), '$lang'))
2156
}
2157
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
2158
LIMIT 200 $offset
2159
EOQ;
2160
        return $query;
2161
    }
2162
2163
    /**
2164
     * Transforms the sparql query result into an array.