Code Duplication    Length = 19-26 lines in 2 locations

model/sparql/GenericSparql.php 2 locations

@@ 1264-1289 (lines=26) @@
1261
     * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
1262
     * @return string sparql query
1263
     */
1264
    private function generatePropertyQuery($uri, $prop, $lang, $anylang) {
1265
        $gcl = $this->graphClause;
1266
        $anylang = $anylang ? "OPTIONAL { ?object skos:prefLabel ?label }" : "";
1267
1268
        $query = <<<EOQ
1269
SELECT *
1270
WHERE {
1271
  $gcl {
1272
    <$uri> a skos:Concept .
1273
    OPTIONAL {
1274
      <$uri> $prop ?object .
1275
      OPTIONAL {
1276
        ?object skos:prefLabel ?label .
1277
        FILTER (langMatches(lang(?label), "$lang"))
1278
      }
1279
      OPTIONAL {
1280
        ?object skos:prefLabel ?label .
1281
        FILTER (lang(?label) = "")
1282
      }
1283
      $anylang
1284
    }
1285
  }
1286
}
1287
EOQ;
1288
        return $query;
1289
    }
1290
1291
    /**
1292
     * Transforms the sparql query result into an array or null if the concept doesn't exist.
@@ 1902-1920 (lines=19) @@
1899
     * @param int $offset offset of results to retrieve; 0 for beginning of list
1900
     * @return string sparql query
1901
     */
1902
    private function generateChangeListQuery($lang, $offset, $prop) {
1903
        $gcl = $this->graphClause;
1904
        $offset = ($offset) ? 'OFFSET ' . $offset : '';
1905
1906
        $query = <<<EOQ
1907
SELECT DISTINCT ?concept ?date ?label
1908
WHERE {
1909
  $gcl {
1910
    ?concept a skos:Concept .
1911
    ?concept $prop ?date .
1912
    ?concept skos:prefLabel ?label .
1913
    FILTER (langMatches(lang(?label), '$lang'))
1914
  }
1915
}
1916
ORDER BY DESC(YEAR(?date)) DESC(MONTH(?date)) LCASE(?label)
1917
LIMIT 200 $offset
1918
EOQ;
1919
        return $query;
1920
    }
1921
1922
    /**
1923
     * Transforms the sparql query result into an array.