1 | <?php |
||
14 | class CrossRefFilteredHttpResponseParser extends FilteredHttpResponseParser { |
||
15 | |||
16 | /** |
||
17 | * @see http://crosscite.org/cn/ |
||
18 | */ |
||
19 | const CROSSREF_CONTENT_API = "https://dx.doi.org/"; |
||
20 | |||
21 | /** |
||
22 | * @since 0.1 |
||
23 | * |
||
24 | * {@inheritDoc} |
||
25 | */ |
||
26 | 4 | public function getRawResponseById( $doi ) { |
|
27 | 4 | return $this->requestResponseFor( $doi ); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @since 0.1 |
||
32 | * |
||
33 | * {@inheritDoc} |
||
34 | */ |
||
35 | 6 | public function doFilterResponseById( $doi ) { |
|
36 | |||
37 | 6 | $json = json_decode( |
|
38 | 6 | $this->requestResponseFor( $doi ), |
|
39 | true |
||
40 | 6 | ); |
|
41 | |||
42 | 6 | if ( $this->httpRequest->getLastError() !== '' ) { |
|
43 | 1 | return $this->addMessage( array( 'onoi-remi-request-error', $this->httpRequest->getLastError(), $doi ) ); |
|
44 | } |
||
45 | |||
46 | 5 | if ( $json === null || $json === array() ) { |
|
47 | 2 | return $this->addMessage( array( 'onoi-remi-response-empty', $doi ) ); |
|
48 | } |
||
49 | |||
50 | 4 | $this->doProcessCiteproc( $json ); |
|
51 | |||
52 | 4 | $this->filteredRecord->set( 'retrieved-from', self::CROSSREF_CONTENT_API ); |
|
53 | 4 | } |
|
54 | |||
55 | 4 | private function doProcessCiteproc( $json ) { |
|
63 | |||
64 | /** |
||
65 | * @param string $doi |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | 6 | private function requestResponseFor( $doi ) { |
|
86 | |||
87 | } |
||
88 |