Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
GetIlsStatus | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
handleRequest | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | /** |
4 | * "Get ILS Status" AJAX handler |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2018. |
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 AJAX |
25 | * @author Demian Katz <demian.katz@villanova.edu> |
26 | * @author André Lahmann <lahmann@ub.uni-leipzig.de> |
27 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
28 | * @link https://vufind.org/wiki/development Wiki |
29 | */ |
30 | |
31 | namespace VuFind\AjaxHandler; |
32 | |
33 | use Laminas\Mvc\Controller\Plugin\Params; |
34 | use Laminas\View\Renderer\RendererInterface; |
35 | use VuFind\ILS\Connection; |
36 | use VuFind\Session\Settings as SessionSettings; |
37 | |
38 | /** |
39 | * "Get ILS Status" AJAX handler |
40 | * |
41 | * This will check the ILS for being online and will return the ils-offline |
42 | * template upon failure. |
43 | * |
44 | * @category VuFind |
45 | * @package AJAX |
46 | * @author Demian Katz <demian.katz@villanova.edu> |
47 | * @author André Lahmann <lahmann@ub.uni-leipzig.de> |
48 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
49 | * @link https://vufind.org/wiki/development Wiki |
50 | */ |
51 | class GetIlsStatus extends AbstractBase |
52 | { |
53 | /** |
54 | * ILS connection |
55 | * |
56 | * @var Connection |
57 | */ |
58 | protected $ils; |
59 | |
60 | /** |
61 | * View renderer |
62 | * |
63 | * @var RendererInterface |
64 | */ |
65 | protected $renderer; |
66 | |
67 | /** |
68 | * Constructor |
69 | * |
70 | * @param SessionSettings $ss Session settings |
71 | * @param Connection $ils ILS connection |
72 | * @param RendererInterface $renderer View renderer |
73 | */ |
74 | public function __construct( |
75 | SessionSettings $ss, |
76 | Connection $ils, |
77 | RendererInterface $renderer |
78 | ) { |
79 | $this->sessionSettings = $ss; |
80 | $this->ils = $ils; |
81 | $this->renderer = $renderer; |
82 | } |
83 | |
84 | /** |
85 | * Handle a request. |
86 | * |
87 | * @param Params $params Parameter helper from controller |
88 | * |
89 | * @return array [response data, HTTP status code] |
90 | */ |
91 | public function handleRequest(Params $params) |
92 | { |
93 | $html = null; |
94 | $this->disableSessionWrites(); |
95 | if ($this->ils->getOfflineMode(true) == 'ils-offline') { |
96 | $offlineModeMsg = $params->fromPost( |
97 | 'offlineModeMsg', |
98 | $params->fromQuery('offlineModeMsg') |
99 | ); |
100 | $html = $this->renderer |
101 | ->render('Helpers/ils-offline.phtml', compact('offlineModeMsg')); |
102 | } |
103 | return $this->formatResponse(['html' => $html ?? '']); |
104 | } |
105 | } |