Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 40 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
SummonController | |
0.00% |
0 / 40 |
|
0.00% |
0 / 7 |
182 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
resultScrollerActive | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
injectSummonMessage | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
attachDefaultListeners | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
advancedAction | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
6 | |||
searchAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
processAdvancedFacets | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
42 |
1 | <?php |
2 | |
3 | /** |
4 | * Summon Controller |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
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 Controller |
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 Site |
28 | */ |
29 | |
30 | namespace VuFind\Controller; |
31 | |
32 | use Laminas\Mvc\MvcEvent; |
33 | use Laminas\ServiceManager\ServiceLocatorInterface; |
34 | |
35 | /** |
36 | * Summon Controller |
37 | * |
38 | * @category VuFind |
39 | * @package Controller |
40 | * @author Demian Katz <demian.katz@villanova.edu> |
41 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
42 | * @link https://vufind.org Main Site |
43 | */ |
44 | class SummonController extends AbstractSearch |
45 | { |
46 | /** |
47 | * Constructor |
48 | * |
49 | * @param ServiceLocatorInterface $sm Service locator |
50 | */ |
51 | public function __construct(ServiceLocatorInterface $sm) |
52 | { |
53 | $this->searchClassId = 'Summon'; |
54 | parent::__construct($sm); |
55 | } |
56 | |
57 | /** |
58 | * Is the result scroller active? |
59 | * |
60 | * @return bool |
61 | */ |
62 | protected function resultScrollerActive() |
63 | { |
64 | $config = $this->serviceLocator->get(\VuFind\Config\PluginManager::class) |
65 | ->get('Summon'); |
66 | return $config->Record->next_prev_navigation ?? false; |
67 | } |
68 | |
69 | /** |
70 | * Use preDispatch event to add Summon message. |
71 | * |
72 | * @param MvcEvent $e Event object |
73 | * |
74 | * @return void |
75 | * |
76 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
77 | */ |
78 | public function injectSummonMessage(MvcEvent $e) |
79 | { |
80 | $this->layout()->poweredBy |
81 | = 'Powered by Summon™ from Serials Solutions, a division of ProQuest.'; |
82 | } |
83 | |
84 | /** |
85 | * Register the default events for this controller |
86 | * |
87 | * @return void |
88 | */ |
89 | protected function attachDefaultListeners() |
90 | { |
91 | parent::attachDefaultListeners(); |
92 | $events = $this->getEventManager(); |
93 | $events->attach( |
94 | MvcEvent::EVENT_DISPATCH, |
95 | [$this, 'injectSummonMessage'], |
96 | 1000 |
97 | ); |
98 | } |
99 | |
100 | /** |
101 | * Handle an advanced search |
102 | * |
103 | * @return mixed |
104 | */ |
105 | public function advancedAction() |
106 | { |
107 | // Standard setup from base class: |
108 | $view = parent::advancedAction(); |
109 | |
110 | // Set up facet information: |
111 | $facets = $this->serviceLocator |
112 | ->get(\VuFind\Search\FacetCache\PluginManager::class)->get('Summon') |
113 | ->getList('Advanced'); |
114 | $view->facetList = $this->processAdvancedFacets($facets, $view->saved); |
115 | $specialFacets = $this->parseSpecialFacetsSetting( |
116 | $view->options->getSpecialAdvancedFacets() |
117 | ); |
118 | if (isset($specialFacets['checkboxes'])) { |
119 | $view->checkboxFacets = $this->processAdvancedCheckboxes( |
120 | $specialFacets['checkboxes'], |
121 | $view->saved |
122 | ); |
123 | } |
124 | $view->ranges = $this |
125 | ->getAllRangeSettings($specialFacets, $view->saved, 'Summon'); |
126 | |
127 | return $view; |
128 | } |
129 | |
130 | /** |
131 | * Search action -- call standard results action |
132 | * |
133 | * @return mixed |
134 | */ |
135 | public function searchAction() |
136 | { |
137 | return $this->resultsAction(); |
138 | } |
139 | |
140 | /** |
141 | * Process the facets to be used as limits on the Advanced Search screen. |
142 | * |
143 | * @param array $facetList The advanced facet values |
144 | * @param object $searchObject Saved search object (false if none) |
145 | * |
146 | * @return array Sorted facets, with selected values flagged. |
147 | */ |
148 | protected function processAdvancedFacets($facetList, $searchObject = false) |
149 | { |
150 | // Process the facets, assuming they came back |
151 | foreach ($facetList as $facet => $list) { |
152 | foreach ($list['list'] as $key => $value) { |
153 | // Build the filter string for the URL: |
154 | $fullFilter = ($value['operator'] == 'OR' ? '~' : '') |
155 | . $facet . ':"' . $value['value'] . '"'; |
156 | |
157 | // If we haven't already found a selected facet and the current |
158 | // facet has been applied to the search, we should store it as |
159 | // the selected facet for the current control. |
160 | if ( |
161 | $searchObject |
162 | && $searchObject->getParams()->hasFilter($fullFilter) |
163 | ) { |
164 | $facetList[$facet]['list'][$key]['selected'] = true; |
165 | // Remove the filter from the search object -- we don't want |
166 | // it to show up in the "applied filters" sidebar since it |
167 | // will already be accounted for by being selected in the |
168 | // filter select list! |
169 | $searchObject->getParams()->removeFilter($fullFilter); |
170 | } |
171 | } |
172 | } |
173 | return $facetList; |
174 | } |
175 | } |