--- a/server/src/app/Http/Controllers/Api/ThemeController.php Thu Oct 06 11:14:32 2016 +0200
+++ b/server/src/app/Http/Controllers/Api/ThemeController.php Thu Oct 06 16:45:37 2016 +0200
@@ -41,16 +41,22 @@
$sort = $request->input('sort', 'count');
if($filter === 'bnf') {
- $include = ".*\|bnf\|.*";
+ $include = ".*\\|bnf\\|.*";
}
elseif($filter === 'lexvo') {
- $include = ".*\|lxv\|.*";
+ $include = ".*\\|lxv\\|.*";
+ }
+ elseif($filter === 'olac') {
+ $include = ".*\\|olac\\|.*";
+ }
+ elseif($filter === 'txt') {
+ $include = ".*\\|txt\\|.*";
}
elseif($filter === 'all') {
$include = false;
}
else {
- abort(401,"Value for filter parameter must be in 'bnf', 'lexvo', 'all'");
+ abort(401,"Value for filter parameter must be in 'bnf', 'lexvo', 'olac', 'txt', 'all'");
}
if($sort == "count" || $sort == "descending") {
@@ -99,12 +105,20 @@
$themes = [];
- $bucketList = array_slice($esRes['aggregations']['subjects']['subjects']['buckets'], $index*$limit, $limit);
+ $bucketList = $esRes['aggregations']['subjects']['subjects']['buckets'];
+ if($limit > 0) {
+ $bucketList = array_slice($bucketList, $index*$limit, $limit);
+ }
foreach($bucketList as $bucket) {
$parts = explode("|", $bucket['key']);
$label = $parts[0];
- $url = ['bnf' => config('corpusparole.bnf_ark_base_url'), 'lxv' => config('corpusparole.lexvo_base_url')][$parts[1]].$parts[2];
+ if($parts[1] === 'bnf' || $parts[1] === 'lxv') {
+ $url = ['bnf' => config('corpusparole.bnf_ark_base_url'), 'lxv' => config('corpusparole.lexvo_base_url')][$parts[1]].$parts[2];
+ }
+ else {
+ $url = $parts[2];
+ }
$themes[$url] = [
"label" => $label,
"count" => $bucket['doc_count']