@@ -41,14 +41,13 @@ class SearchObject_SummonSearcher extends SearchObject_BaseSearcher{
41
41
protected $ searchType = 'basic ' ;
42
42
43
43
/** Values for the options array*/
44
- protected $ holdings = false ;
44
+ protected $ holdings = true ;
45
45
protected $ didYouMean = false ;
46
46
protected $ language = 'en ' ;
47
47
protected $ idsToFetch = array ();
48
48
/**@var int */
49
49
protected $ maxTopics = 1 ;
50
50
protected $ groupFilters = array ();
51
- protected $ rangeFilters = array ();
52
51
protected $ openAccessFilter = false ;
53
52
protected $ expand = false ;
54
53
protected $ sortOptions = array ();
@@ -58,6 +57,7 @@ class SearchObject_SummonSearcher extends SearchObject_BaseSearcher{
58
57
protected $ defaultSort = 'relevance ' ;
59
58
protected $ query ;
60
59
protected $ filters = array ();
60
+ protected $ rangeFilters = array ();
61
61
62
62
/**
63
63
* @var int
@@ -92,6 +92,18 @@ class SearchObject_SummonSearcher extends SearchObject_BaseSearcher{
92
92
'SourceType,or,1,30 ' ,
93
93
];
94
94
95
+ protected $ limits = [
96
+ 'IsPeerReviewed,or,1,30 ' ,
97
+ 'IsScholarly,or,1,30 ' ,
98
+ ];
99
+
100
+ protected $ rangeFacets = [
101
+ ];
102
+
103
+ protected $ limitList = [];
104
+ protected $ limitFields ;
105
+
106
+
95
107
protected $ facetFields ;
96
108
97
109
public function __construct () {
@@ -233,13 +245,15 @@ public function getOptions () {
233
245
//Fetch specific records
234
246
's.fids ' =>$ this ->idsToFetch ,
235
247
//Side facets to filter by
236
- 's.ff ' =>$ this ->facets ,
248
+ 's.ff ' =>array_merge ( $ this ->facets , $ this -> limits ) ,
237
249
//Filters that are active - from side facets
238
250
's.fvf ' => $ this ->getSummonFilters (),
239
251
//Default 1
240
252
's.rec.topic.max ' => $ this ->maxTopics ,
241
253
//Filters
242
254
's.fvgf ' => $ this ->groupFilters ,
255
+ //Range Facets
256
+ 's.rff ' => $ this ->rangeFacets ,
243
257
//Filters
244
258
's.rf ' => $ this ->rangeFilters ,
245
259
//Order results
@@ -275,9 +289,28 @@ public function processData($recordData) {
275
289
$ this ->page = $ recordData ['query ' ]['pageNumber ' ];
276
290
$ this ->resultsTotal = $ recordData ['recordCount ' ];
277
291
$ this ->filters = $ recordData ['query ' ]['facetValueFilters ' ];
278
- $ this ->facetFields = $ recordData ['facetFields ' ];
292
+ $ splitFacets = $ this ->splitFacets ($ recordData ['facetFields ' ]);
293
+ $ this ->facetFields = $ splitFacets ['facetFields ' ];
294
+ $ this ->limitFields = $ splitFacets ['limitFields ' ];
279
295
}
280
- return $ recordData ;
296
+ return $ recordData ;
297
+ }
298
+
299
+ public function splitFacets ($ combinedFacets ) {
300
+ $ splitFacets = [];
301
+ foreach ($ combinedFacets as $ facet ) {
302
+ foreach ($ this ->facets as $ facetName ) {
303
+ if (strpos ($ facetName , $ facet ['displayName ' ]) !== false ) {
304
+ $ splitFacets ['facetFields ' ][] = $ facet ;
305
+ }
306
+ }
307
+ foreach ($ this ->limits as $ limitName ) {
308
+ if (strpos ($ limitName , $ facet ['displayName ' ]) !== false ) {
309
+ $ splitFacets ['limitFields ' ][] = $ facet ;
310
+ }
311
+ }
312
+ }
313
+ return $ splitFacets ;
281
314
}
282
315
283
316
/**
@@ -428,7 +461,6 @@ public function renderLinkWithSort($newSort) {
428
461
*/
429
462
public function getFacetSet () {
430
463
$ availableFacets = [];
431
- $ label = '' ;
432
464
$ this ->filters = [];
433
465
if (isset ($ this ->facetFields )) {
434
466
foreach ($ this ->facetFields as $ facetField ) {
@@ -445,6 +477,11 @@ public function getFacetSet() {
445
477
if ($ facetId == 'ContentType ' ) {
446
478
$ availableFacets [$ facetId ]['collapseByDefault ' ] = false ;
447
479
}
480
+
481
+ if ($ facetId == 'IsScholarly ' || $ facetId == 'IsPeerReviewed ' ) {
482
+ $ availableFacets [$ facetId ]['multiSelect ' ] = false ;
483
+ }
484
+
448
485
$ list = [];
449
486
foreach ($ facetField ['counts ' ] as $ value ) {
450
487
$ facetValue = $ value ['value ' ];
@@ -469,6 +506,41 @@ public function getFacetSet() {
469
506
return $ availableFacets ;
470
507
}
471
508
509
+ public function getLimitList () {
510
+
511
+ $ availableLimits =[];
512
+ if (isset ($ this ->limitFields )){
513
+ foreach ($ this ->limitFields as $ limitOption ){
514
+ $ limitId = $ limitOption ['displayName ' ];
515
+ $ parts = preg_split ('/(?=[A-Z])/ ' , $ limitId , -1 , PREG_SPLIT_NO_EMPTY );
516
+ $ displayName = implode (' ' , $ parts );
517
+
518
+ foreach ($ limitOption ['counts ' ] as $ value ){
519
+ if ($ value ['value ' ] == 'true ' ) {
520
+ $ availableLimits [$ limitId ] = [
521
+ 'display ' => $ displayName ,
522
+ 'value ' => $ limitId ,
523
+ 'isApplied ' => ($ this ->limiters [$ limitId ]) == 'y ' ? 1 : 0 ,
524
+ 'url ' => $ this ->renderLinkWithLimiter ($ limitId ),
525
+ 'removalUrl ' => $ this ->renderLinkWithoutLimiter ($ limitId ),
526
+ ];
527
+ }
528
+ }
529
+
530
+ }
531
+ }
532
+ return $ availableLimits ;
533
+ }
534
+
535
+ public function createSearchLimits () {
536
+ foreach ($ this ->limiters as $ limiter => $ limiterOptions ) {
537
+ if ($ this ->limiters [$ limiter ] == 'y ' ) {
538
+ $ this ->limitList [$ limiter ] = $ limiterOptions ;
539
+ }
540
+ }
541
+ return $ this ->limitList ;
542
+ }
543
+
472
544
//Retreive a specific record - used to retreive bookcovers
473
545
public function retrieveRecord ($ id ) {
474
546
$ baseUrl = $ this ->summonBaseApi . '/ ' .$ this ->version . '/ ' .$ this ->service ;
@@ -484,6 +556,10 @@ public function retrieveRecord ($id) {
484
556
//Compile filter options chosen in side facets and add to filter array to be passed in via options array
485
557
public function getSummonFilters () {
486
558
$ this ->filters = array ();
559
+ $ this ->createSearchLimits ();
560
+ if (isset ($ this ->limitList ) && isset ($ this ->filterList )) {
561
+ $ this ->filterList = array_merge ($ this ->limitList , $ this ->filterList );
562
+ }
487
563
foreach ($ this ->filterList as $ key => $ value ) {
488
564
if (is_array ($ value )) {
489
565
foreach ($ value as $ val ) {
0 commit comments