Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
GetResultCount | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
handleRequest | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * "Get Result Counts" AJAX Handler |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
9 | * Copyright (C) Staats- und Universitätsbibliothek 2021-2022. |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License version 2, |
13 | * as published by the Free Software Foundation. |
14 | * |
15 | * This program is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | * GNU General Public License for more details. |
19 | * |
20 | * You should have received a copy of the GNU General Public License |
21 | * along with this program; if not, write to the Free Software |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 | * |
24 | * @category VuFind |
25 | * @package AJAX |
26 | * @author Demian Katz <demian.katz@villanova.edu> |
27 | * @author Hajo Seng <hajo.seng@sub.uni-hamburg.de> |
28 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
29 | * @link https://vufind.org/wiki/development Wiki |
30 | */ |
31 | |
32 | namespace VuFind\AjaxHandler; |
33 | |
34 | use Laminas\Mvc\Controller\Plugin\Params; |
35 | use Laminas\Stdlib\Parameters; |
36 | use VuFind\Search\Results\PluginManager as ResultsManager; |
37 | use VuFind\Session\Settings as SessionSettings; |
38 | |
39 | /** |
40 | * "Get Result Counts" AJAX Handler |
41 | * |
42 | * @category VuFind |
43 | * @package AJAX |
44 | * @author Demian Katz <demian.katz@villanova.edu> |
45 | * @author Hajo Seng <hajo.seng@sub.uni-hamburg.de> |
46 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
47 | * @link https://vufind.org/wiki/development Wiki |
48 | */ |
49 | class GetResultCount extends AbstractBase |
50 | { |
51 | /** |
52 | * ResultsManager |
53 | * |
54 | * @var resultsManager |
55 | */ |
56 | protected $resultsManager; |
57 | |
58 | /** |
59 | * Constructor |
60 | * |
61 | * @param ResultsManager $resultsManager Results Manager |
62 | * @param SessionSettings $ss Session settings |
63 | */ |
64 | public function __construct(ResultsManager $resultsManager, SessionSettings $ss) |
65 | { |
66 | $this->resultsManager = $resultsManager; |
67 | $this->sessionSettings = $ss; |
68 | } |
69 | |
70 | /** |
71 | * Handle a request. |
72 | * |
73 | * @param Params $params Parameter helper from controller |
74 | * |
75 | * @return array [response data, HTTP status code] |
76 | */ |
77 | public function handleRequest(Params $params) |
78 | { |
79 | $this->disableSessionWrites(); |
80 | $queryString = $params->fromQuery('querystring'); |
81 | parse_str(parse_url($queryString, PHP_URL_QUERY), $searchParams); |
82 | |
83 | $backend = $params->fromQuery('source', DEFAULT_SEARCH_BACKEND); |
84 | $results = $this->resultsManager->get($backend); |
85 | $paramsObj = $results->getParams(); |
86 | $paramsObj->getOptions()->disableHighlighting(); |
87 | $paramsObj->getOptions()->spellcheckEnabled(false); |
88 | $paramsObj->getOptions()->setLimitOptions([0]); |
89 | $paramsObj->initFromRequest(new Parameters($searchParams)); |
90 | |
91 | return $this->formatResponse(['total' => $results->getResultTotal()]); |
92 | } |
93 | } |