From e178e0d8cb8398c06dc524a21ae7fc70a6f531d4 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Mon, 19 May 2014 15:12:14 -0400
Subject: [PATCH] Added limit settings to Primo.

---
 config/vufind/Primo.ini                           | 9 +++++++++
 module/VuFind/src/VuFind/Search/Primo/Options.php | 9 +++++++++
 2 files changed, 18 insertions(+)

diff --git a/config/vufind/Primo.ini b/config/vufind/Primo.ini
index 4d77dcb5c07..48a9fefe090 100644
--- a/config/vufind/Primo.ini
+++ b/config/vufind/Primo.ini
@@ -18,6 +18,15 @@ timeout = 30
 ; Your API id
 apiId = my-id
 
+; This section controls the result limit options for search results. default_limit
+; sets the default number of results per page. limit_options is a comma-separated
+; list of numbers to be presented to the end-user. If only one limit is required,
+; set default_limit and leave limit_options commented out.
+; WARNING: using large limits may require you to raise your PHP memory limits to
+; avoid errors.
+default_limit        = 20
+;limit_options        = 10,20,40,60,80,100
+
 ; These are the default recommendations modules to use when no specific setting
 ; are found in the [TopRecommendations] or [SideRecommendations] sections below.
 ; See the comments above those sections for details on legal settings.  You may
diff --git a/module/VuFind/src/VuFind/Search/Primo/Options.php b/module/VuFind/src/VuFind/Search/Primo/Options.php
index 5ad623e4130..31fb5c6a82f 100644
--- a/module/VuFind/src/VuFind/Search/Primo/Options.php
+++ b/module/VuFind/src/VuFind/Search/Primo/Options.php
@@ -79,6 +79,15 @@ class Options extends \VuFind\Search\Base\Options
         // Load the search configuration file:
         $searchSettings = $configLoader->get($this->searchIni);
 
+        // Set up limit preferences
+        if (isset($searchSettings->General->default_limit)) {
+            $this->defaultLimit = $searchSettings->General->default_limit;
+        }
+        if (isset($searchSettings->General->limit_options)) {
+            $this->limitOptions
+                = explode(",", $searchSettings->General->limit_options);
+        }
+
         // Load search preferences:
         if (isset($searchSettings->General->retain_filters_by_default)) {
             $this->retainFiltersByDefault
-- 
GitLab