-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexpander.php
45 lines (41 loc) · 1.32 KB
/
expander.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
session_start();
include "rest/EBSCOAPI.php";
$api = new EBSCOAPI();
$Info = $api->getInfo();
$results = $_SESSION['results'];
$queryStringUrl = $results['queryString'];
$addExpanderActions = array();
$removeExpanderAction = array();
/*
* Check which expander check boxes are checked, which are not checked
* if is checked add the action to addExpanderActions
* if is not checked, add remove action to removeExpanderActions when the expander is found in applied expanders
* or do nothing when not found in applied expanders.
*/
$i=1;
foreach($Info['expanders'] as $expander){
if(isset($_REQUEST[$expander['Id']])){
$addExpanderActions['action['.$i.']'] = $expander['Action'];
$i++;
}else{
foreach($results['appliedExpanders'] as $filter){
if($filter['Id']==$expander['Id']){
$removeExpanderAction['action['.$i.']'] = $filter['removeAction'];
$i++;
}
}
}
}
$searchTerm = $_REQUEST['query'];
$fieldCode = $_REQUEST['fieldcode'];
$params = array(
'refine'=>'y',
'query' => $searchTerm,
'fieldcode'=>$fieldCode,
);
$params = array_merge($params,$addExpanderActions);
$params = array_merge($params,$removeExpanderAction);
$url = 'results.php?'.http_build_query($params).'&'.$queryStringUrl;
header("location: {$url}");
?>