Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
43.48% |
20 / 46 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
Options | |
43.48% |
20 / 46 |
|
0.00% |
0 / 6 |
137.86 | |
0.00% |
0 / 1 |
__construct | |
48.78% |
20 / 41 |
|
0.00% |
0 / 1 |
73.75 | |||
getSearchAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getAdvancedSearchAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCitesAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCitedByAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getAdvancedOperators | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Primo Central Search Options |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2011. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package Search_Primo |
25 | * @author Demian Katz <demian.katz@villanova.edu> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org Main Page |
28 | */ |
29 | |
30 | namespace VuFind\Search\Primo; |
31 | |
32 | use function count; |
33 | |
34 | /** |
35 | * Primo Search Options |
36 | * |
37 | * @category VuFind |
38 | * @package Search_Primo |
39 | * @author Demian Katz <demian.katz@villanova.edu> |
40 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
41 | * @link https://vufind.org Main Page |
42 | */ |
43 | class Options extends \VuFind\Search\Base\Options |
44 | { |
45 | use \VuFind\Config\Feature\ExplodeSettingTrait; |
46 | |
47 | /** |
48 | * Advanced search operators |
49 | * |
50 | * @var array |
51 | */ |
52 | protected $advancedOperators = []; |
53 | |
54 | /** |
55 | * Constructor |
56 | * |
57 | * @param \VuFind\Config\PluginManager $configLoader Config loader |
58 | */ |
59 | public function __construct(\VuFind\Config\PluginManager $configLoader) |
60 | { |
61 | $this->searchIni = $this->facetsIni = 'Primo'; |
62 | parent::__construct($configLoader); |
63 | |
64 | // Load facet preferences: |
65 | $facetSettings = $configLoader->get($this->facetsIni); |
66 | if ( |
67 | isset($facetSettings->Advanced_Facet_Settings->translated_facets) |
68 | && count($facetSettings->Advanced_Facet_Settings->translated_facets) > 0 |
69 | ) { |
70 | $this->setTranslatedFacets( |
71 | $facetSettings->Advanced_Facet_Settings->translated_facets->toArray() |
72 | ); |
73 | } |
74 | if (isset($facetSettings->Advanced_Facet_Settings->special_facets)) { |
75 | $this->specialAdvancedFacets |
76 | = $facetSettings->Advanced_Facet_Settings->special_facets; |
77 | } |
78 | |
79 | // Load the search configuration file: |
80 | $searchSettings = $configLoader->get($this->searchIni); |
81 | |
82 | // Set up limit preferences |
83 | if (isset($searchSettings->General->default_limit)) { |
84 | $this->defaultLimit = $searchSettings->General->default_limit; |
85 | } |
86 | if (isset($searchSettings->General->limit_options)) { |
87 | $this->limitOptions = $this->explodeListSetting($searchSettings->General->limit_options); |
88 | } |
89 | |
90 | // Load search preferences: |
91 | if (isset($searchSettings->General->default_filters)) { |
92 | $this->defaultFilters = $searchSettings->General->default_filters |
93 | ->toArray(); |
94 | } |
95 | $this->highlight = !empty($searchSettings->General->highlighting); |
96 | |
97 | // Result limit: |
98 | if (isset($searchSettings->General->result_limit)) { |
99 | $this->resultLimit = $searchSettings->General->result_limit; |
100 | } else { |
101 | $this->resultLimit = 3980; // default |
102 | } |
103 | |
104 | // Search handler setup: |
105 | if (isset($searchSettings->Basic_Searches)) { |
106 | foreach ($searchSettings->Basic_Searches as $key => $value) { |
107 | $this->basicHandlers[$key] = $value; |
108 | } |
109 | } |
110 | if (isset($searchSettings->Advanced_Searches)) { |
111 | foreach ($searchSettings->Advanced_Searches as $key => $value) { |
112 | $this->advancedHandlers[$key] = $value; |
113 | } |
114 | } |
115 | |
116 | // Advanced operator setup: |
117 | if (isset($searchSettings->Advanced_Operators)) { |
118 | foreach ($searchSettings->Advanced_Operators as $key => $value) { |
119 | $this->advancedOperators[$key] = $value; |
120 | } |
121 | } |
122 | |
123 | // Load sort preferences: |
124 | if (isset($searchSettings->Sorting)) { |
125 | foreach ($searchSettings->Sorting as $key => $value) { |
126 | $this->sortOptions[$key] = $value; |
127 | } |
128 | } |
129 | if (isset($searchSettings->General->default_sort)) { |
130 | $this->defaultSort = $searchSettings->General->default_sort; |
131 | } |
132 | if ( |
133 | isset($searchSettings->DefaultSortingByType) |
134 | && count($searchSettings->DefaultSortingByType) > 0 |
135 | ) { |
136 | foreach ($searchSettings->DefaultSortingByType as $key => $val) { |
137 | $this->defaultSortByHandler[$key] = $val; |
138 | } |
139 | } |
140 | } |
141 | |
142 | /** |
143 | * Return the route name for the search results action. |
144 | * |
145 | * @return string |
146 | */ |
147 | public function getSearchAction() |
148 | { |
149 | return 'primo-search'; |
150 | } |
151 | |
152 | /** |
153 | * Return the route name of the action used for performing advanced searches. |
154 | * Returns false if the feature is not supported. |
155 | * |
156 | * @return string|bool |
157 | */ |
158 | public function getAdvancedSearchAction() |
159 | { |
160 | return 'primo-advanced'; |
161 | } |
162 | |
163 | /** |
164 | * Return the route name for the "cites" search action. Returns false to cover |
165 | * unimplemented support. |
166 | * |
167 | * @return string|bool |
168 | */ |
169 | public function getCitesAction() |
170 | { |
171 | return 'primo-cites'; |
172 | } |
173 | |
174 | /** |
175 | * Return the route name for the "cited by" search action. Returns false to cover |
176 | * unimplemented support. |
177 | * |
178 | * @return string|bool |
179 | */ |
180 | public function getCitedByAction() |
181 | { |
182 | return 'primo-citedby'; |
183 | } |
184 | |
185 | /** |
186 | * Basic 'getter' for Primo advanced search operators. |
187 | * |
188 | * @return array |
189 | */ |
190 | public function getAdvancedOperators() |
191 | { |
192 | return $this->advancedOperators; |
193 | } |
194 | } |