Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
SummonResultsDeferred | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
init | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
getAjaxModule | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getUrlParams | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * SummonResultsDeferred Recommendations Module |
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 Recommendations |
25 | * @author Lutz Biedinger <lutz.biedinger@gmail.com> |
26 | * @author Demian Katz <demian.katz@villanova.edu> |
27 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
28 | * @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki |
29 | */ |
30 | |
31 | namespace VuFind\Recommend; |
32 | |
33 | use function is_object; |
34 | |
35 | /** |
36 | * SummonResultsDeferred Recommendations Module |
37 | * |
38 | * This class sets up an AJAX call to trigger a call to the SummonResults |
39 | * module. |
40 | * |
41 | * @category VuFind |
42 | * @package Recommendations |
43 | * @author Lutz Biedinger <lutz.biedigner@gmail.com> |
44 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
45 | * @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki |
46 | */ |
47 | class SummonResultsDeferred extends AbstractSummonRecommendDeferred |
48 | { |
49 | /** |
50 | * Label for current search type |
51 | * |
52 | * @var string |
53 | */ |
54 | protected $typeLabel = ''; |
55 | |
56 | /** |
57 | * Number of expected module parameters (from .ini config) |
58 | * |
59 | * @var int |
60 | */ |
61 | protected $paramCount = 2; |
62 | |
63 | /** |
64 | * Called before the Search Results object performs its main search |
65 | * (specifically, in response to \VuFind\Search\SearchRunner::EVENT_CONFIGURED). |
66 | * This method is responsible for setting search parameters needed by the |
67 | * recommendation module and for reading any existing search parameters that may |
68 | * be needed. |
69 | * |
70 | * @param \VuFind\Search\Base\Params $params Search parameter object |
71 | * @param \Laminas\Stdlib\Parameters $request Parameter object representing user |
72 | * request. |
73 | * |
74 | * @return void |
75 | */ |
76 | public function init($params, $request) |
77 | { |
78 | parent::init($params, $request); |
79 | |
80 | // Collect the label for the current search type: |
81 | if (is_object($params)) { |
82 | $this->typeLabel = $params->getOptions()->getLabelForBasicHandler( |
83 | $params->getSearchHandler() |
84 | ); |
85 | } |
86 | } |
87 | |
88 | /** |
89 | * Store the configuration of the recommendation module. |
90 | * |
91 | * @return string Module name in call to AjaxHandler |
92 | */ |
93 | protected function getAjaxModule() |
94 | { |
95 | return 'SummonResults'; |
96 | } |
97 | |
98 | /** |
99 | * Get the URL parameters needed to make the AJAX recommendation request. |
100 | * |
101 | * @return string |
102 | */ |
103 | public function getUrlParams() |
104 | { |
105 | return parent::getUrlParams() . '&typeLabel=' . urlencode($this->typeLabel); |
106 | } |
107 | } |