|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Controller; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* GndController |
|
22
|
|
|
*/ |
|
23
|
|
|
class GndController extends \EWW\Dpf\Controller\AbstractController |
|
24
|
|
|
{ |
|
25
|
|
|
protected $gndHost = 'https://xgnd.bsz-bw.de/'; |
|
26
|
|
|
|
|
27
|
|
|
protected $searchUrl = 'Anfrage?suchfeld=pica.swr&suchfilter=000000&suchoptionen=pica.tbs%3D%22s%22&suchwort='; |
|
28
|
|
|
|
|
29
|
|
|
protected $gndResolverUrl = 'Anfrage?suchfeld=pica.ppn&suchoptionen=pica.tbs%3D"s"+and+&suchwort='; |
|
30
|
|
|
|
|
31
|
|
|
protected $baseGndValueUri = 'http://d-nb.info/gnd/'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param string $search |
|
35
|
|
|
* @return array |
|
36
|
|
|
*/ |
|
37
|
|
|
public function searchAction($search) { |
|
38
|
|
|
|
|
39
|
|
|
$url = $this->gndHost . $this->searchUrl . $search; |
|
40
|
|
|
$content = file_get_contents($url); |
|
41
|
|
|
$json = json_decode($content); |
|
42
|
|
|
|
|
43
|
|
|
$listArray = array(); |
|
44
|
|
|
$i = 0; |
|
45
|
|
|
foreach ($json as $value) { |
|
46
|
|
|
$listArray[$i]['value'] = $value->Ansetzung; |
|
47
|
|
|
$listArray[$i]['ppn'] = $value->PPN; |
|
48
|
|
|
$listArray[$i]['typ'] = $value->Typ; |
|
49
|
|
|
if ($value->GNDNr) { |
|
50
|
|
|
$listArray[$i]['gnd'] = $this->baseGndValueUri.$value->GNDNr; |
|
51
|
|
|
} else { |
|
52
|
|
|
$listArray[$i]['gnd'] = $this->baseGndValueUri.$this->gndAction($value->PPN); |
|
53
|
|
|
} |
|
54
|
|
|
$i++; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if (empty($listArray)) { |
|
58
|
|
|
echo json_encode(null); |
|
59
|
|
|
} else { |
|
60
|
|
|
echo json_encode($listArray); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return ''; |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param string $PPN |
|
68
|
|
|
* @return mixed |
|
69
|
|
|
*/ |
|
70
|
|
|
public function gndAction($PPN) { |
|
71
|
|
|
|
|
72
|
|
|
$url = $this->gndHost . $this->gndResolverUrl . $PPN; |
|
73
|
|
|
$content = file_get_contents($url); |
|
74
|
|
|
$json = json_decode($content); |
|
75
|
|
|
|
|
76
|
|
|
return $json[0]->GNDNr; |
|
77
|
|
|
} |
|
78
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths