|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SCI\FilteredMetadata; |
|
4
|
|
|
|
|
5
|
|
|
use Onoi\Remi\OpenLibrary\OLFilteredHttpResponseParser; |
|
6
|
|
|
use Onoi\Remi\ResponseParser; |
|
7
|
|
|
use SCI\DataValues\ResourceIdentifierFactory; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @license GNU GPL v2+ |
|
11
|
|
|
* @since 1.0 |
|
12
|
|
|
* |
|
13
|
|
|
* @author mwjames |
|
14
|
|
|
*/ |
|
15
|
|
|
class OLResponseParser implements ResponseParser { |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var OLFilteredHttpResponseParser |
|
19
|
|
|
*/ |
|
20
|
|
|
private $olFilteredHttpResponseParser; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @since 1.0 |
|
24
|
|
|
* |
|
25
|
|
|
* @param OLFilteredHttpResponseParser $olFilteredHttpResponseParser |
|
26
|
|
|
*/ |
|
27
|
6 |
|
public function __construct( OLFilteredHttpResponseParser $olFilteredHttpResponseParser ) { |
|
28
|
6 |
|
$this->olFilteredHttpResponseParser = $olFilteredHttpResponseParser; |
|
29
|
6 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @since 1.0 |
|
33
|
|
|
* |
|
34
|
|
|
* {@inheritDoc} |
|
35
|
|
|
*/ |
|
36
|
1 |
|
public function usesCache() { |
|
37
|
1 |
|
return $this->olFilteredHttpResponseParser->usesCache(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @since 1.0 |
|
42
|
|
|
* |
|
43
|
|
|
* {@inheritDoc} |
|
44
|
|
|
*/ |
|
45
|
1 |
|
public function getMessages() { |
|
46
|
1 |
|
return $this->olFilteredHttpResponseParser->getMessages(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @since 1.0 |
|
51
|
|
|
* |
|
52
|
|
|
* {@inheritDoc} |
|
53
|
|
|
*/ |
|
54
|
3 |
|
public function getFilteredRecord() { |
|
55
|
3 |
|
return $this->olFilteredHttpResponseParser->getFilteredRecord(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @since 1.0 |
|
60
|
|
|
* |
|
61
|
|
|
* {@inheritDoc} |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function getRawResponse( $id ) { |
|
64
|
1 |
|
return $this->olFilteredHttpResponseParser->getRawResponse( $id ); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @since 1.0 |
|
69
|
|
|
* |
|
70
|
|
|
* {@inheritDoc} |
|
71
|
|
|
*/ |
|
72
|
4 |
|
public function doFilterResponseFor( $olID ) { |
|
73
|
|
|
|
|
74
|
4 |
|
$this->olFilteredHttpResponseParser->doFilterResponseFor( $olID ); |
|
75
|
4 |
|
$filteredRecord = $this->olFilteredHttpResponseParser->getFilteredRecord(); |
|
76
|
|
|
|
|
77
|
|
|
// Fetch the OLID has one could search for an ISBN as well |
|
78
|
4 |
|
if ( $filteredRecord->has( 'olid' ) ) { |
|
79
|
2 |
|
$olID = $filteredRecord->get( 'olid' ); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
4 |
|
if ( is_array( $olID ) ) { |
|
83
|
2 |
|
$olID = end( $olID ); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
4 |
|
$filteredRecord->setTitleForPageCreation( |
|
|
|
|
|
|
87
|
4 |
|
'OL:' . str_replace( 'OL', '', $olID ) |
|
88
|
|
|
); |
|
89
|
|
|
|
|
90
|
4 |
|
$filteredRecord->setSciteTransclusionHead( |
|
|
|
|
|
|
91
|
4 |
|
$olID |
|
92
|
|
|
); |
|
93
|
|
|
|
|
94
|
4 |
|
$filteredRecord->addSearchMatchSet( 'olid', $olID ); |
|
|
|
|
|
|
95
|
|
|
|
|
96
|
4 |
|
if ( $filteredRecord->has( 'lccn' ) ) { |
|
97
|
2 |
|
$filteredRecord->addSearchMatchSet( |
|
98
|
2 |
|
'lccn', |
|
99
|
2 |
|
$filteredRecord->get( 'lccn' ) |
|
100
|
|
|
); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
4 |
|
$dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
104
|
4 |
|
$filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); |
|
105
|
4 |
|
} |
|
106
|
|
|
|
|
107
|
|
|
} |
|
108
|
|
|
|