Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
GetRecordDetails | |
0.00% |
0 / 28 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
handleRequest | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * "Get Record Details" 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 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org/wiki/development Wiki |
28 | */ |
29 | |
30 | namespace VuFind\AjaxHandler; |
31 | |
32 | use Laminas\Http\PhpEnvironment\Request; |
33 | use Laminas\Mvc\Controller\Plugin\Params; |
34 | use Laminas\View\Renderer\RendererInterface; |
35 | use VuFind\Record\Loader; |
36 | use VuFind\RecordTab\TabManager; |
37 | |
38 | /** |
39 | * "Get Record Details" AJAX handler |
40 | * |
41 | * Get record for integrated list view. |
42 | * |
43 | * @category VuFind |
44 | * @package AJAX |
45 | * @author Demian Katz <demian.katz@villanova.edu> |
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 GetRecordDetails extends AbstractBase |
50 | { |
51 | /** |
52 | * Framework configuration |
53 | * |
54 | * @var array |
55 | */ |
56 | protected $config; |
57 | |
58 | /** |
59 | * Request |
60 | * |
61 | * @var Request |
62 | */ |
63 | protected $request; |
64 | |
65 | /** |
66 | * Record loader |
67 | * |
68 | * @var Loader |
69 | */ |
70 | protected $recordLoader; |
71 | |
72 | /** |
73 | * Record tab plugin manager |
74 | * |
75 | * @var TabManager |
76 | */ |
77 | protected $tabManager; |
78 | |
79 | /** |
80 | * View renderer |
81 | * |
82 | * @var RendererInterface |
83 | */ |
84 | protected $renderer; |
85 | |
86 | /** |
87 | * Constructor |
88 | * |
89 | * @param array $config Framework configuration |
90 | * @param Request $request HTTP request |
91 | * @param Loader $loader Record loader |
92 | * @param TabManager $tm Record Tab manager |
93 | * @param RendererInterface $renderer Renderer |
94 | */ |
95 | public function __construct( |
96 | array $config, |
97 | Request $request, |
98 | Loader $loader, |
99 | TabManager $tm, |
100 | RendererInterface $renderer |
101 | ) { |
102 | $this->config = $config; |
103 | $this->request = $request; |
104 | $this->recordLoader = $loader; |
105 | $this->tabManager = $tm; |
106 | $this->renderer = $renderer; |
107 | } |
108 | |
109 | /** |
110 | * Handle a request. |
111 | * |
112 | * @param Params $params Parameter helper from controller |
113 | * |
114 | * @return array [response data, HTTP status code] |
115 | */ |
116 | public function handleRequest(Params $params) |
117 | { |
118 | $driver = $this->recordLoader |
119 | ->load($params->fromQuery('id'), $params->fromQuery('source')); |
120 | $viewtype = preg_replace( |
121 | '/\W/', |
122 | '', |
123 | trim(strtolower($params->fromQuery('type'))) |
124 | ); |
125 | |
126 | $details = $this->tabManager->getTabDetailsForRecord( |
127 | $driver, |
128 | $this->request, |
129 | 'Information' |
130 | ); |
131 | |
132 | $html = $this->renderer->render( |
133 | 'record/ajaxview-' . $viewtype . '.phtml', |
134 | [ |
135 | 'defaultTab' => $details['default'], |
136 | 'driver' => $driver, |
137 | 'tabs' => $details['tabs'], |
138 | 'backgroundTabs' => $this->tabManager |
139 | ->getBackgroundTabNames($driver), |
140 | ] |
141 | ); |
142 | return $this->formatResponse(compact('html')); |
143 | } |
144 | } |