Code Duplication    Length = 17-24 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 1460-1483 (lines=24) @@
1457
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1458
     * @return string sparql query
1459
     */
1460
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1461
        $fcl = $this->generateFromClause();
1462
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1463
1464
        $query = <<<EOQ
1465
SELECT * $fcl
1466
WHERE {
1467
  <$uri> a skos:Concept .
1468
  OPTIONAL {
1469
    <$uri> $prop ?object .
1470
    OPTIONAL {
1471
      ?object skos:prefLabel ?label .
1472
      FILTER (langMatches(lang(?label), "$lang"))
1473
    }
1474
    OPTIONAL {
1475
      ?object skos:prefLabel ?label .
1476
      FILTER (lang(?label) = "")
1477
    }
1478
    $anylang
1479
  }
1480
}
1481
EOQ;
1482
        return $query;
1483
    }
1484
1485
    /**
1486
     * Transforms the sparql query result into an array or null if the concept doesn't exist.
@@ 2111-2127 (lines=17) @@
2108
     * @param int $offset offset of results to retrieve; 0 for beginning of list
2109
     * @return string sparql query
2110
     */
2111
    private function generateChangeListQuery($lang, $offset, $prop) {
2112
        $fcl = $this->generateFromClause();
2113
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
2114
2115
        $query = <<<EOQ
2116
SELECT DISTINCT ?concept ?date ?label $fcl
2117
WHERE {
2118
  ?concept a skos:Concept .
2119
  ?concept $prop ?date .
2120
  ?concept skos:prefLabel ?label .
2121
  FILTER (langMatches(lang(?label), '$lang'))
2122
}
2123
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
2124
LIMIT 200 $offset
2125
EOQ;
2126
        return $query;
2127
    }
2128
2129
    /**
2130
     * Transforms the sparql query result into an array.