@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param HttpRequest $httpRequest |
25 | 25 | */ |
26 | - public function __construct( HttpRequest $httpRequest ) { |
|
26 | + public function __construct(HttpRequest $httpRequest) { |
|
27 | 27 | $this->httpRequest = $httpRequest; |
28 | 28 | } |
29 | 29 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return ResponseParser |
36 | 36 | */ |
37 | - public function newResponseParserForType( $type ) { |
|
37 | + public function newResponseParserForType($type) { |
|
38 | 38 | |
39 | 39 | $bibliographicFilteredRecord = new BibliographicFilteredRecord(); |
40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $this->httpRequest |
43 | 43 | ); |
44 | 44 | |
45 | - switch ( strtolower( $type ) ) { |
|
45 | + switch (strtolower($type)) { |
|
46 | 46 | case 'doi': |
47 | 47 | $responseParser = new CrossRefResponseParser( |
48 | 48 | $filteredHttpResponseParserFactory->newCrossRefFilteredHttpResponseParser( |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return string|null |
67 | 67 | */ |
68 | - public function getSearchMatchSetValueFor( $key ) { |
|
68 | + public function getSearchMatchSetValueFor($key) { |
|
69 | 69 | |
70 | - if ( isset( $this->searchMatchSet[$key] ) ) { |
|
70 | + if (isset($this->searchMatchSet[$key])) { |
|
71 | 71 | return $this->searchMatchSet[$key]; |
72 | 72 | } |
73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param string $key |
81 | 81 | * @param string $value |
82 | 82 | */ |
83 | - public function addSearchMatchSet( $key, $value ) { |
|
83 | + public function addSearchMatchSet($key, $value) { |
|
84 | 84 | $this->searchMatchSet[$key] = $value; |
85 | 85 | } |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - public function setTitleForPageCreation( $titleForPageCreation ) { |
|
92 | + public function setTitleForPageCreation($titleForPageCreation) { |
|
93 | 93 | $this->titleForPageCreation = 'CR:' . $titleForPageCreation; |
94 | 94 | } |
95 | 95 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public function setSciteTransclusionHead( $sciteTransclusionHead ) { |
|
110 | + public function setSciteTransclusionHead($sciteTransclusionHead) { |
|
111 | 111 | $this->sciteTransclusionHead = $sciteTransclusionHead; |
112 | 112 | } |
113 | 113 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | |
121 | 121 | $text = ''; |
122 | 122 | |
123 | - foreach ( $this->recordFields as $key => $value ) { |
|
123 | + foreach ($this->recordFields as $key => $value) { |
|
124 | 124 | |
125 | - if ( is_array( $value ) ) { |
|
126 | - $value = implode( ';', $value ) . ( count( $value ) > 1 ? '|+sep=;' : '' ); |
|
125 | + if (is_array($value)) { |
|
126 | + $value = implode(';', $value) . (count($value) > 1 ? '|+sep=;' : ''); |
|
127 | 127 | } |
128 | 128 | |
129 | - if ( $value === '' || $value === null ) { |
|
129 | + if ($value === '' || $value === null) { |
|
130 | 130 | continue; |
131 | 131 | } |
132 | 132 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return string |
143 | 143 | */ |
144 | 144 | public function asSciteTransclusion() { |
145 | - return '{{#scite:' . $this->sciteTransclusionHead ."\n" . $this . "}}";; |
|
145 | + return '{{#scite:' . $this->sciteTransclusionHead . "\n" . $this . "}}"; ; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param CrossRefFilteredHttpResponseParser $crossRefFilteredHttpResponseParser |
26 | 26 | */ |
27 | - public function __construct( CrossRefFilteredHttpResponseParser $crossRefFilteredHttpResponseParser ) { |
|
27 | + public function __construct(CrossRefFilteredHttpResponseParser $crossRefFilteredHttpResponseParser) { |
|
28 | 28 | $this->crossRefFilteredHttpResponseParser = $crossRefFilteredHttpResponseParser; |
29 | 29 | } |
30 | 30 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * |
61 | 61 | * {@inheritDoc} |
62 | 62 | */ |
63 | - public function getRawResponse( $doi ) { |
|
64 | - return $this->crossRefFilteredHttpResponseParser->getRawResponse( $doi ); |
|
63 | + public function getRawResponse($doi) { |
|
64 | + return $this->crossRefFilteredHttpResponseParser->getRawResponse($doi); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,23 +69,23 @@ discard block |
||
69 | 69 | * |
70 | 70 | * {@inheritDoc} |
71 | 71 | */ |
72 | - public function doFilterResponseFor( $doi ) { |
|
72 | + public function doFilterResponseFor($doi) { |
|
73 | 73 | |
74 | 74 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); |
75 | 75 | |
76 | - $doiValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( 'doi' ); |
|
77 | - $doiValue->setUserValue( $doi ); |
|
76 | + $doiValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType('doi'); |
|
77 | + $doiValue->setUserValue($doi); |
|
78 | 78 | |
79 | - if ( !$doiValue->isValid() ) { |
|
80 | - return $this->crossRefFilteredHttpResponseParser->addMessage( $doiValue->getErrors() ); |
|
79 | + if (!$doiValue->isValid()) { |
|
80 | + return $this->crossRefFilteredHttpResponseParser->addMessage($doiValue->getErrors()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $doi = $doiValue->getWikiValue(); |
84 | 84 | |
85 | - $this->crossRefFilteredHttpResponseParser->doFilterResponseFor( $doi ); |
|
85 | + $this->crossRefFilteredHttpResponseParser->doFilterResponseFor($doi); |
|
86 | 86 | $filteredRecord = $this->crossRefFilteredHttpResponseParser->getFilteredRecord(); |
87 | 87 | |
88 | - $filteredRecord->setTitleForPageCreation( 'DOI:' . md5( $doi ) ); |
|
88 | + $filteredRecord->setTitleForPageCreation('DOI:' . md5($doi)); |
|
89 | 89 | |
90 | 90 | $filteredRecord->addSearchMatchSet( |
91 | 91 | 'doi', |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | |
95 | 95 | $filteredRecord->addSearchMatchSet( |
96 | 96 | 'reference', |
97 | - $this->crossRefFilteredHttpResponseParser->getFilteredRecord()->get( 'reference' ) |
|
97 | + $this->crossRefFilteredHttpResponseParser->getFilteredRecord()->get('reference') |
|
98 | 98 | ); |
99 | 99 | |
100 | - $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
101 | - $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); |
|
100 | + $dateTimeUtc = new \DateTime('now', new \DateTimeZone('UTC')); |
|
101 | + $filteredRecord->set('retrieved-on', $dateTimeUtc->format('Y-m-d')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param ParserData $parserData |
28 | 28 | */ |
29 | - public function __construct( ParserData $parserData ) { |
|
29 | + public function __construct(ParserData $parserData) { |
|
30 | 30 | $this->parserData = $parserData; |
31 | 31 | $this->dataValueFactory = DataValueFactory::getInstance(); |
32 | 32 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param ParserParameterProcessor $parserParameterProcessor |
44 | 44 | */ |
45 | - public function doProcess( ParserParameterProcessor $parserParameterProcessor ) { |
|
45 | + public function doProcess(ParserParameterProcessor $parserParameterProcessor) { |
|
46 | 46 | |
47 | - list( $header, $headerElement, $attributes ) = $this->getElementsForHtml( |
|
47 | + list($header, $headerElement, $attributes) = $this->getElementsForHtml( |
|
48 | 48 | $parserParameterProcessor->toArray() |
49 | 49 | ); |
50 | 50 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | return $html . "<!-- end marker -->\n"; |
72 | 72 | } |
73 | 73 | |
74 | - private function getElementsForHtml( $parameters ) { |
|
74 | + private function getElementsForHtml($parameters) { |
|
75 | 75 | |
76 | - $header = wfMessage( 'sci-referencelist-header' )->text(); |
|
76 | + $header = wfMessage('sci-referencelist-header')->text(); |
|
77 | 77 | |
78 | 78 | // The span placeholder will hide the header from the TOC by default |
79 | 79 | $headerElement = 'span'; |
@@ -82,51 +82,51 @@ discard block |
||
82 | 82 | 'id' => 'scite-custom-referencelist' |
83 | 83 | ]; |
84 | 84 | |
85 | - foreach ( $parameters as $key => $values ) { |
|
85 | + foreach ($parameters as $key => $values) { |
|
86 | 86 | |
87 | - if ( $key === 'references' ) { |
|
88 | - $attributes['data-references'] = $this->doProcessReferenceValues( $values ); |
|
87 | + if ($key === 'references') { |
|
88 | + $attributes['data-references'] = $this->doProcessReferenceValues($values); |
|
89 | 89 | continue; |
90 | 90 | } |
91 | 91 | |
92 | - foreach ( $values as $value ) { |
|
92 | + foreach ($values as $value) { |
|
93 | 93 | |
94 | - if ( $key === 'header' ) { |
|
94 | + if ($key === 'header') { |
|
95 | 95 | $header = $value; |
96 | 96 | } |
97 | 97 | |
98 | - if ( $key === 'toc' && filter_var( $value, FILTER_VALIDATE_BOOLEAN ) ) { |
|
98 | + if ($key === 'toc' && filter_var($value, FILTER_VALIDATE_BOOLEAN)) { |
|
99 | 99 | $headerElement = 'h2'; |
100 | 100 | } |
101 | 101 | |
102 | - $attributes['data-'. $key] = $value; |
|
102 | + $attributes['data-' . $key] = $value; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - return [ $header, $headerElement, $attributes ]; |
|
106 | + return [$header, $headerElement, $attributes]; |
|
107 | 107 | } |
108 | 108 | |
109 | - private function doProcessReferenceValues( array $values ) { |
|
109 | + private function doProcessReferenceValues(array $values) { |
|
110 | 110 | |
111 | 111 | $subject = $this->parserData->getSubject(); |
112 | 112 | |
113 | - foreach ( $values as $value ) { |
|
113 | + foreach ($values as $value) { |
|
114 | 114 | $dataValue = $this->dataValueFactory->newPropertyValue( |
115 | - new DIProperty( PropertyRegistry::SCI_CITE_REFERENCE ), |
|
116 | - trim( $value ), |
|
115 | + new DIProperty(PropertyRegistry::SCI_CITE_REFERENCE), |
|
116 | + trim($value), |
|
117 | 117 | false, |
118 | 118 | $subject |
119 | 119 | ); |
120 | 120 | |
121 | - $this->parserData->addDataValue( $dataValue ); |
|
121 | + $this->parserData->addDataValue($dataValue); |
|
122 | 122 | } |
123 | 123 | |
124 | - if ( !$this->parserData->getSemanticData()->isEmpty() ) { |
|
125 | - $this->parserData->getSubject()->setContextReference( 'referencelistp:' . uniqid() ); |
|
124 | + if (!$this->parserData->getSemanticData()->isEmpty()) { |
|
125 | + $this->parserData->getSubject()->setContextReference('referencelistp:' . uniqid()); |
|
126 | 126 | $this->parserData->pushSemanticDataToParserOutput(); |
127 | 127 | } |
128 | 128 | |
129 | - return json_encode( $values ); |
|
129 | + return json_encode($values); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param WikitextTemplateRenderer $wikitextTemplateRenderer |
35 | 35 | * @param Parser $parser |
36 | 36 | */ |
37 | - public function __construct( WikitextTemplateRenderer $wikitextTemplateRenderer, Parser $parser ) { |
|
37 | + public function __construct(WikitextTemplateRenderer $wikitextTemplateRenderer, Parser $parser) { |
|
38 | 38 | $this->wikitextTemplateRenderer = $wikitextTemplateRenderer; |
39 | 39 | $this->parser = $parser; |
40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @param string $templateName |
46 | 46 | */ |
47 | - public function packFieldsForTemplate( $templateName ) { |
|
47 | + public function packFieldsForTemplate($templateName) { |
|
48 | 48 | $this->templateName = $templateName; |
49 | 49 | } |
50 | 50 | |
@@ -55,36 +55,36 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public function renderFor( array $parameters ) { |
|
58 | + public function renderFor(array $parameters) { |
|
59 | 59 | |
60 | - $wikiText = $this->doFormat( $parameters ); |
|
60 | + $wikiText = $this->doFormat($parameters); |
|
61 | 61 | |
62 | - if ( $wikiText === '' ) { |
|
62 | + if ($wikiText === '') { |
|
63 | 63 | return ''; |
64 | 64 | } |
65 | 65 | |
66 | - return $this->parser->recursivePreprocess( $wikiText ); |
|
66 | + return $this->parser->recursivePreprocess($wikiText); |
|
67 | 67 | } |
68 | 68 | |
69 | - private function doFormat( array $parameters ) { |
|
69 | + private function doFormat(array $parameters) { |
|
70 | 70 | |
71 | - if ( $this->templateName === '' ) { |
|
71 | + if ($this->templateName === '') { |
|
72 | 72 | return ''; |
73 | 73 | } |
74 | 74 | |
75 | - foreach ( $parameters as $key => $values ) { |
|
75 | + foreach ($parameters as $key => $values) { |
|
76 | 76 | |
77 | - $key = strtolower( trim( $key ) ); |
|
77 | + $key = strtolower(trim($key)); |
|
78 | 78 | $pieces = []; |
79 | 79 | |
80 | - foreach ( $values as $value ) { |
|
81 | - $pieces[] = trim( $value ); |
|
80 | + foreach ($values as $value) { |
|
81 | + $pieces[] = trim($value); |
|
82 | 82 | } |
83 | 83 | |
84 | - $this->wikitextTemplateRenderer->addField( $key, implode( ', ', $pieces ) ); |
|
84 | + $this->wikitextTemplateRenderer->addField($key, implode(', ', $pieces)); |
|
85 | 85 | } |
86 | 86 | |
87 | - $this->wikitextTemplateRenderer->packFieldsForTemplate( $this->templateName ); |
|
87 | + $this->wikitextTemplateRenderer->packFieldsForTemplate($this->templateName); |
|
88 | 88 | |
89 | 89 | return $this->wikitextTemplateRenderer->render(); |
90 | 90 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param CitationReferencePositionJournal $citationReferencePositionJournal |
73 | 73 | * @param HtmlColumnListRenderer $htmlColumnListRenderer |
74 | 74 | */ |
75 | - public function __construct( CitationResourceMatchFinder $citationResourceMatchFinder, CitationReferencePositionJournal $citationReferencePositionJournal, HtmlColumnListRenderer $htmlColumnListRenderer ) { |
|
75 | + public function __construct(CitationResourceMatchFinder $citationResourceMatchFinder, CitationReferencePositionJournal $citationReferencePositionJournal, HtmlColumnListRenderer $htmlColumnListRenderer) { |
|
76 | 76 | $this->citationResourceMatchFinder = $citationResourceMatchFinder; |
77 | 77 | $this->citationReferencePositionJournal = $citationReferencePositionJournal; |
78 | 78 | $this->htmlColumnListRenderer = $htmlColumnListRenderer; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @param integer $citationReferenceCaptionFormat |
85 | 85 | */ |
86 | - public function setCitationReferenceCaptionFormat( $citationReferenceCaptionFormat ) { |
|
86 | + public function setCitationReferenceCaptionFormat($citationReferenceCaptionFormat) { |
|
87 | 87 | $this->citationReferenceCaptionFormat = (int)$citationReferenceCaptionFormat; |
88 | 88 | } |
89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param integer $responsiveMonoColumnCharacterBoundLength |
94 | 94 | */ |
95 | - public function setResponsiveMonoColumnCharacterBoundLength( $responsiveMonoColumnCharacterBoundLength ) { |
|
95 | + public function setResponsiveMonoColumnCharacterBoundLength($responsiveMonoColumnCharacterBoundLength) { |
|
96 | 96 | $this->responsiveMonoColumnCharacterBoundLength = (int)$responsiveMonoColumnCharacterBoundLength; |
97 | 97 | } |
98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @param integer $numberOfReferenceListColumns |
103 | 103 | */ |
104 | - public function setNumberOfReferenceListColumns( $numberOfReferenceListColumns ) { |
|
104 | + public function setNumberOfReferenceListColumns($numberOfReferenceListColumns) { |
|
105 | 105 | $this->numberOfReferenceListColumns = (int)$numberOfReferenceListColumns; |
106 | 106 | } |
107 | 107 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @param string $referenceListType |
121 | 121 | */ |
122 | - public function setReferenceListType( $referenceListType ) { |
|
122 | + public function setReferenceListType($referenceListType) { |
|
123 | 123 | $this->referenceListType = $referenceListType; |
124 | 124 | } |
125 | 125 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @param boolean $browseLinkToCitationResourceVisibility |
139 | 139 | */ |
140 | - public function setBrowseLinkToCitationResourceVisibility( $browseLinkToCitationResourceVisibility ) { |
|
140 | + public function setBrowseLinkToCitationResourceVisibility($browseLinkToCitationResourceVisibility) { |
|
141 | 141 | $this->browseLinkToCitationResourceVisibility = (bool)$browseLinkToCitationResourceVisibility; |
142 | 142 | } |
143 | 143 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param string $referenceListHeader |
157 | 157 | */ |
158 | - public function setReferenceListHeader( $referenceListHeader ) { |
|
158 | + public function setReferenceListHeader($referenceListHeader) { |
|
159 | 159 | $this->referenceListHeader = (string)$referenceListHeader; |
160 | 160 | } |
161 | 161 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param string $referenceListHeaderTocId |
166 | 166 | */ |
167 | - public function setReferenceListHeaderTocId( $referenceListHeaderTocId ) { |
|
167 | + public function setReferenceListHeaderTocId($referenceListHeaderTocId) { |
|
168 | 168 | $this->referenceListHeaderTocId = (string)$referenceListHeaderTocId; |
169 | 169 | } |
170 | 170 | |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string |
178 | 178 | */ |
179 | - public function doRenderReferenceListFor( DIWikiPage $subject, array $referenceList = null ) { |
|
179 | + public function doRenderReferenceListFor(DIWikiPage $subject, array $referenceList = null) { |
|
180 | 180 | |
181 | - if ( $referenceList !== null ) { |
|
181 | + if ($referenceList !== null) { |
|
182 | 182 | $journal = $this->citationReferencePositionJournal->buildJournalForUnboundReferenceList( |
183 | 183 | $referenceList |
184 | 184 | ); |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | ); |
189 | 189 | } |
190 | 190 | |
191 | - if ( $journal !== null ) { |
|
192 | - return $this->createHtmlFromJournal( $journal ); |
|
191 | + if ($journal !== null) { |
|
192 | + return $this->createHtmlFromJournal($journal); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | return ''; |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | * 'reference-list' => array of hashes for references used |
203 | 203 | * 'reference-pos' => individual reference links (1-a, 1-b) assigned to a hash |
204 | 204 | */ |
205 | - private function createHtmlFromJournal( array $journal ) { |
|
205 | + private function createHtmlFromJournal(array $journal) { |
|
206 | 206 | |
207 | 207 | $listOfFormattedReferences = []; |
208 | 208 | $targetList = []; |
209 | 209 | $length = 0; |
210 | 210 | |
211 | - foreach ( $journal['reference-pos'] as $hash => $linkList ) { |
|
211 | + foreach ($journal['reference-pos'] as $hash => $linkList) { |
|
212 | 212 | |
213 | 213 | $citationText = ''; |
214 | 214 | // Get the "human" readable citation key/reference from the hashmap |
215 | 215 | // intead of trying to access the DB/Store |
216 | 216 | $reference = $journal['reference-list'][$hash]; |
217 | 217 | |
218 | - list( $subjects, $citationText ) = $this->findCitationTextFor( |
|
218 | + list($subjects, $citationText) = $this->findCitationTextFor( |
|
219 | 219 | $reference |
220 | 220 | ); |
221 | 221 | |
222 | - $length += mb_strlen( $citationText ); |
|
222 | + $length += mb_strlen($citationText); |
|
223 | 223 | |
224 | 224 | $flatHtmlReferenceLinks = $this->createFlatHtmlListForReferenceLinks( |
225 | 225 | $linkList, |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | $citationText |
233 | 233 | ); |
234 | 234 | |
235 | - if ( method_exists( $this->htmlColumnListRenderer, 'setItemAttributes' ) ) { |
|
235 | + if (method_exists($this->htmlColumnListRenderer, 'setItemAttributes')) { |
|
236 | 236 | $attribs = [ |
237 | 237 | 'class' => 'scite-referencelinks' |
238 | 238 | ]; |
239 | 239 | } else { |
240 | 240 | $attribs = [ |
241 | - 'id' => 'scite-'. $hash, |
|
241 | + 'id' => 'scite-' . $hash, |
|
242 | 242 | 'class' => 'scite-referencelinks' |
243 | 243 | ]; |
244 | 244 | } |
@@ -248,54 +248,54 @@ discard block |
||
248 | 248 | $attribs, |
249 | 249 | $flatHtmlReferenceLinks |
250 | 250 | ) . |
251 | - ( $flatHtmlReferenceLinks !== '' ? ' ' : '' ) . |
|
251 | + ($flatHtmlReferenceLinks !== '' ? ' ' : '') . |
|
252 | 252 | Html::rawElement( |
253 | 253 | 'span', |
254 | 254 | [ |
255 | 255 | 'class' => 'scite-citation' |
256 | 256 | ], |
257 | - ( $browseLinks !== '' ? $browseLinks . ' ' : '' ) . Html::rawElement( |
|
257 | + ($browseLinks !== '' ? $browseLinks . ' ' : '') . Html::rawElement( |
|
258 | 258 | 'span', |
259 | - [ 'class' => 'scite-citation-text' ], |
|
259 | + ['class' => 'scite-citation-text'], |
|
260 | 260 | $citationText |
261 | 261 | ) |
262 | 262 | ); |
263 | 263 | |
264 | 264 | $listOfFormattedReferences[] = $ref; |
265 | - $targetList[md5($ref)] = [ 'id' => 'scite-'. $hash ]; |
|
265 | + $targetList[md5($ref)] = ['id' => 'scite-' . $hash]; |
|
266 | 266 | } |
267 | 267 | |
268 | - return $this->makeList( $listOfFormattedReferences, $targetList, $length ); |
|
268 | + return $this->makeList($listOfFormattedReferences, $targetList, $length); |
|
269 | 269 | } |
270 | 270 | |
271 | - private function makeList( $listOfFormattedReferences, $targetList, $length ) { |
|
271 | + private function makeList($listOfFormattedReferences, $targetList, $length) { |
|
272 | 272 | |
273 | - $monoClass = ( $length > $this->responsiveMonoColumnCharacterBoundLength ? '' : '-mono' ); |
|
273 | + $monoClass = ($length > $this->responsiveMonoColumnCharacterBoundLength ? '' : '-mono'); |
|
274 | 274 | |
275 | 275 | // #33, #32 |
276 | 276 | $this->htmlColumnListRenderer->setColumnListClass( |
277 | - 'scite-referencelist' . ( $this->numberOfReferenceListColumns == 0 ? ' responsive-list' . $monoClass : '' ) |
|
277 | + 'scite-referencelist' . ($this->numberOfReferenceListColumns == 0 ? ' responsive-list' . $monoClass : '') |
|
278 | 278 | ); |
279 | 279 | |
280 | - $this->htmlColumnListRenderer->setListType( $this->referenceListType ); |
|
281 | - $this->htmlColumnListRenderer->addContentsByNoIndex( $listOfFormattedReferences ); |
|
280 | + $this->htmlColumnListRenderer->setListType($this->referenceListType); |
|
281 | + $this->htmlColumnListRenderer->addContentsByNoIndex($listOfFormattedReferences); |
|
282 | 282 | |
283 | - if ( method_exists( $this->htmlColumnListRenderer, 'setItemAttributes' ) ) { |
|
284 | - $this->htmlColumnListRenderer->setItemAttributes( $targetList ); |
|
283 | + if (method_exists($this->htmlColumnListRenderer, 'setItemAttributes')) { |
|
284 | + $this->htmlColumnListRenderer->setItemAttributes($targetList); |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( $this->numberOfReferenceListColumns == 0 ) { |
|
288 | - $this->htmlColumnListRenderer->setColumnClass( 'scite-referencelist-columns-responsive'. $monoClass ); |
|
287 | + if ($this->numberOfReferenceListColumns == 0) { |
|
288 | + $this->htmlColumnListRenderer->setColumnClass('scite-referencelist-columns-responsive' . $monoClass); |
|
289 | 289 | } else { |
290 | - $this->htmlColumnListRenderer->setNumberOfColumns( $this->numberOfReferenceListColumns ); |
|
291 | - $this->htmlColumnListRenderer->setColumnClass( 'scite-referencelist-columns-fixed' ); |
|
290 | + $this->htmlColumnListRenderer->setNumberOfColumns($this->numberOfReferenceListColumns); |
|
291 | + $this->htmlColumnListRenderer->setColumnClass('scite-referencelist-columns-fixed'); |
|
292 | 292 | } |
293 | 293 | |
294 | - if ( $this->referenceListHeader === '' ) { |
|
295 | - $this->referenceListHeader = wfMessage( 'sci-referencelist-header' )->text(); |
|
294 | + if ($this->referenceListHeader === '') { |
|
295 | + $this->referenceListHeader = wfMessage('sci-referencelist-header')->text(); |
|
296 | 296 | } |
297 | 297 | |
298 | - if ( $this->referenceListHeaderTocId === '' ) { |
|
298 | + if ($this->referenceListHeaderTocId === '') { |
|
299 | 299 | $this->referenceListHeaderTocId = $this->referenceListHeader; |
300 | 300 | } |
301 | 301 | |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | ); |
315 | 315 | } |
316 | 316 | |
317 | - private function findCitationTextFor( $reference ) { |
|
317 | + private function findCitationTextFor($reference) { |
|
318 | 318 | |
319 | - list( $subjects, $text ) = $this->citationResourceMatchFinder->findCitationTextFor( |
|
319 | + list($subjects, $text) = $this->citationResourceMatchFinder->findCitationTextFor( |
|
320 | 320 | $reference |
321 | 321 | ); |
322 | 322 | |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | // parsed and escaped which saves the trouble to deal with Parser stubobject |
325 | 325 | return [ |
326 | 326 | $subjects, |
327 | - wfMessage( 'sci-referencelist-text', $text )->parse() |
|
327 | + wfMessage('sci-referencelist-text', $text)->parse() |
|
328 | 328 | ]; |
329 | 329 | } |
330 | 330 | |
331 | - private function createFlatHtmlListForReferenceLinks( array $linkList, $referenceHash ) { |
|
331 | + private function createFlatHtmlListForReferenceLinks(array $linkList, $referenceHash) { |
|
332 | 332 | |
333 | 333 | $referenceLinks = []; |
334 | 334 | $class = 'scite-backlinks'; |
335 | 335 | |
336 | - foreach ( $linkList as $value ) { |
|
336 | + foreach ($linkList as $value) { |
|
337 | 337 | |
338 | - $isOneLinkElement = count( $linkList ) == 1; |
|
338 | + $isOneLinkElement = count($linkList) == 1; |
|
339 | 339 | |
340 | 340 | // Split a value of 1-a, 1-b, 2-a into its parts |
341 | - list( $major, $minor ) = explode( '-', $value ); |
|
341 | + list($major, $minor) = explode('-', $value); |
|
342 | 342 | |
343 | 343 | // Show a simple link similar to what is done on en.wp |
344 | 344 | // for a one-link-reference |
345 | - if ( $isOneLinkElement ) { |
|
345 | + if ($isOneLinkElement) { |
|
346 | 346 | $minor = '^'; |
347 | 347 | $class = 'scite-backlink'; |
348 | 348 | } |
349 | 349 | |
350 | 350 | // Only display the "full" number for the combination of UL/SCI_CITEREF_NUM |
351 | - if ( $this->referenceListType === 'ul' && $this->citationReferenceCaptionFormat === SCI_CITEREF_NUM ) { |
|
352 | - $minor = $isOneLinkElement ? $major : str_replace( '-', '.', $value ); |
|
351 | + if ($this->referenceListType === 'ul' && $this->citationReferenceCaptionFormat === SCI_CITEREF_NUM) { |
|
352 | + $minor = $isOneLinkElement ? $major : str_replace('-', '.', $value); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | $referenceLinks[] = Html::rawElement( |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | ); |
364 | 364 | } |
365 | 365 | |
366 | - return implode( ' ', $referenceLinks ); |
|
366 | + return implode(' ', $referenceLinks); |
|
367 | 367 | } |
368 | 368 | |
369 | - private function createBrowseLinksWith( array $subjects, $reference, $citationText ) { |
|
369 | + private function createBrowseLinksWith(array $subjects, $reference, $citationText) { |
|
370 | 370 | |
371 | 371 | // If no text is available at least show the reference |
372 | - if ( $citationText === '' ) { |
|
372 | + if ($citationText === '') { |
|
373 | 373 | return Html::rawElement( |
374 | 374 | 'span', |
375 | 375 | [ |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | // No browse links means nothing will be displayed |
383 | - if ( !$this->browseLinkToCitationResourceVisibility ) { |
|
383 | + if (!$this->browseLinkToCitationResourceVisibility) { |
|
384 | 384 | return ''; |
385 | 385 | } |
386 | 386 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | // Normally we should have only one subject to host a citation resource |
393 | 393 | // for the reference in question but it might be that double assingments |
394 | 394 | // did occur and therefore show them all |
395 | - return implode( ' | ', $citationResourceLinks ); |
|
395 | + return implode(' | ', $citationResourceLinks); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param Cache $cache |
59 | 59 | * @param CacheKeyProvider $cacheKeyProvider |
60 | 60 | */ |
61 | - public function __construct( ReferenceListOutputRenderer $referenceListOutputRenderer, MediaWikiContextInteractor $contextInteractor, NamespaceExaminer $namespaceExaminer, Cache $cache, CacheKeyProvider $cacheKeyProvider ) { |
|
61 | + public function __construct(ReferenceListOutputRenderer $referenceListOutputRenderer, MediaWikiContextInteractor $contextInteractor, NamespaceExaminer $namespaceExaminer, Cache $cache, CacheKeyProvider $cacheKeyProvider) { |
|
62 | 62 | $this->referenceListOutputRenderer = $referenceListOutputRenderer; |
63 | 63 | $this->contextInteractor = $contextInteractor; |
64 | 64 | $this->namespaceExaminer = $namespaceExaminer; |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getSubject() { |
75 | 75 | |
76 | - if ( $this->subject === null ) { |
|
77 | - $this->subject = DIWikiPage::newFromTitle( $this->contextInteractor->getTitle() ); |
|
76 | + if ($this->subject === null) { |
|
77 | + $this->subject = DIWikiPage::newFromTitle($this->contextInteractor->getTitle()); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | return $this->subject; |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param string &$text |
87 | 87 | */ |
88 | - public function addReferenceListToText( &$text ) { |
|
88 | + public function addReferenceListToText(&$text) { |
|
89 | 89 | |
90 | - if ( $this->contextInteractor->hasMagicWord( 'SCI_NOREFERENCELIST' ) || !$this->contextInteractor->hasAction( 'view' ) ) { |
|
91 | - return $this->removeReferenceListPlaceholder( $text ); |
|
90 | + if ($this->contextInteractor->hasMagicWord('SCI_NOREFERENCELIST') || !$this->contextInteractor->hasAction('view')) { |
|
91 | + return $this->removeReferenceListPlaceholder($text); |
|
92 | 92 | } |
93 | 93 | |
94 | - if ( !$this->namespaceExaminer->isSemanticEnabled( $this->getSubject()->getNamespace() ) ) { |
|
94 | + if (!$this->namespaceExaminer->isSemanticEnabled($this->getSubject()->getNamespace())) { |
|
95 | 95 | return ''; |
96 | 96 | } |
97 | 97 | |
98 | - $this->addReferenceListToCorrectTextPosition( $text ); |
|
98 | + $this->addReferenceListToCorrectTextPosition($text); |
|
99 | 99 | } |
100 | 100 | |
101 | - private function removeReferenceListPlaceholder( &$text ) { |
|
101 | + private function removeReferenceListPlaceholder(&$text) { |
|
102 | 102 | |
103 | - if ( strpos( $text, 'scite-custom-referencelist' ) === false ) { |
|
103 | + if (strpos($text, 'scite-custom-referencelist') === false) { |
|
104 | 104 | return null; |
105 | 105 | } |
106 | 106 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | ); |
112 | 112 | } |
113 | 113 | |
114 | - private function addReferenceListToCorrectTextPosition( &$text ) { |
|
114 | + private function addReferenceListToCorrectTextPosition(&$text) { |
|
115 | 115 | |
116 | 116 | // Remember the default options before trying to replace all list |
117 | 117 | // placeholders to ensure to reset options to the default option |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | ]; |
124 | 124 | |
125 | 125 | // Find out whether to place the list into a custom position or not |
126 | - if ( strpos( $text, 'scite-custom-referencelist' ) !== false ) { |
|
126 | + if (strpos($text, 'scite-custom-referencelist') !== false) { |
|
127 | 127 | return $text = preg_replace_callback( |
128 | 128 | "/" . "<div id=\"scite-custom-referencelist\"(.*)?>(<h2>|<span>)(.*)?<\/div>" . "/m", |
129 | 129 | 'self::getCustomizedRenderedHtmlReferenceList', |
@@ -133,67 +133,67 @@ discard block |
||
133 | 133 | |
134 | 134 | // #27 auto-referencelist for the NS_FILE can not be managed accurately therefore |
135 | 135 | // disable such list |
136 | - if ( $this->contextInteractor->getTitle()->getNamespace() !== NS_FILE ) { |
|
136 | + if ($this->contextInteractor->getTitle()->getNamespace() !== NS_FILE) { |
|
137 | 137 | $text .= $this->getRenderedHtmlReferenceList(); |
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - private function getCustomizedRenderedHtmlReferenceList( $customOptions ) { |
|
141 | + private function getCustomizedRenderedHtmlReferenceList($customOptions) { |
|
142 | 142 | |
143 | - $this->searchForReferenceListHeaderTocId( $customOptions ); |
|
143 | + $this->searchForReferenceListHeaderTocId($customOptions); |
|
144 | 144 | |
145 | 145 | // Reset options |
146 | - $this->referenceListOutputRenderer->setReferenceListHeader( '' ); |
|
147 | - $this->referenceListOutputRenderer->setReferenceListType( $this->defaultOptions['listtype'] ); |
|
148 | - $this->referenceListOutputRenderer->setNumberOfReferenceListColumns( $this->defaultOptions['columns'] ); |
|
149 | - $this->referenceListOutputRenderer->setBrowseLinkToCitationResourceVisibility( $this->defaultOptions['browse'] ); |
|
146 | + $this->referenceListOutputRenderer->setReferenceListHeader(''); |
|
147 | + $this->referenceListOutputRenderer->setReferenceListType($this->defaultOptions['listtype']); |
|
148 | + $this->referenceListOutputRenderer->setNumberOfReferenceListColumns($this->defaultOptions['columns']); |
|
149 | + $this->referenceListOutputRenderer->setBrowseLinkToCitationResourceVisibility($this->defaultOptions['browse']); |
|
150 | 150 | |
151 | - $customOptions = explode( 'data-', $customOptions[1] ); |
|
151 | + $customOptions = explode('data-', $customOptions[1]); |
|
152 | 152 | |
153 | 153 | $references = ''; |
154 | 154 | $fingerprint = ''; |
155 | 155 | |
156 | - foreach ( $customOptions as $options ) { |
|
156 | + foreach ($customOptions as $options) { |
|
157 | 157 | |
158 | - if ( strpos( $options, '=' ) === false ) { |
|
158 | + if (strpos($options, '=') === false) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | - $options = explode( '=', trim( str_replace( '"', '', $options ) ) ); |
|
163 | - $this->doFilterValidOption( $options, $references, $fingerprint ); |
|
162 | + $options = explode('=', trim(str_replace('"', '', $options))); |
|
163 | + $this->doFilterValidOption($options, $references, $fingerprint); |
|
164 | 164 | } |
165 | 165 | |
166 | - return $this->getRenderedHtmlReferenceList( $references, $fingerprint ); |
|
166 | + return $this->getRenderedHtmlReferenceList($references, $fingerprint); |
|
167 | 167 | } |
168 | 168 | |
169 | - private function searchForReferenceListHeaderTocId( array $options ) { |
|
169 | + private function searchForReferenceListHeaderTocId(array $options) { |
|
170 | 170 | |
171 | 171 | $headerId = []; |
172 | - $this->referenceListOutputRenderer->setReferenceListHeaderTocId( '' ); |
|
172 | + $this->referenceListOutputRenderer->setReferenceListHeaderTocId(''); |
|
173 | 173 | |
174 | 174 | // We know where to expect the index from preg_* |
175 | - if ( isset( $options[3] ) ) { |
|
176 | - preg_match("/id=\"(.*)\"/", $options[3], $headerId ); |
|
175 | + if (isset($options[3])) { |
|
176 | + preg_match("/id=\"(.*)\"/", $options[3], $headerId); |
|
177 | 177 | } |
178 | 178 | |
179 | - if ( $headerId !== [] ) { |
|
180 | - $this->referenceListOutputRenderer->setReferenceListHeaderTocId( $headerId[1] ); |
|
179 | + if ($headerId !== []) { |
|
180 | + $this->referenceListOutputRenderer->setReferenceListHeaderTocId($headerId[1]); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - private function doFilterValidOption( $options, &$references, &$fingerprint ) { |
|
184 | + private function doFilterValidOption($options, &$references, &$fingerprint) { |
|
185 | 185 | |
186 | 186 | $columns = ''; |
187 | 187 | $header = ''; |
188 | 188 | |
189 | - switch ( $options[0] ) { |
|
189 | + switch ($options[0]) { |
|
190 | 190 | case 'browselinks': |
191 | 191 | $this->referenceListOutputRenderer->setBrowseLinkToCitationResourceVisibility( |
192 | - filter_var( $options[1], FILTER_VALIDATE_BOOLEAN ) |
|
192 | + filter_var($options[1], FILTER_VALIDATE_BOOLEAN) |
|
193 | 193 | ); |
194 | 194 | break; |
195 | 195 | case 'listtype': |
196 | - $this->referenceListOutputRenderer->setReferenceListType( $options[1] ); |
|
196 | + $this->referenceListOutputRenderer->setReferenceListType($options[1]); |
|
197 | 197 | break; |
198 | 198 | case 'columns': |
199 | 199 | $columns = $options[1] < 0 ? 0 : $options[1]; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | break; |
204 | 204 | case 'header': |
205 | 205 | $header = $options[1]; |
206 | - $this->referenceListOutputRenderer->setReferenceListHeader( $header ); |
|
206 | + $this->referenceListOutputRenderer->setReferenceListHeader($header); |
|
207 | 207 | break; |
208 | 208 | case 'references': |
209 | 209 | $references = $options[1]; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $fingerprint = $header . $columns; |
214 | 214 | } |
215 | 215 | |
216 | - private function getRenderedHtmlReferenceList( $references = '', $fingerprint = '' ) { |
|
216 | + private function getRenderedHtmlReferenceList($references = '', $fingerprint = '') { |
|
217 | 217 | |
218 | 218 | $container = []; |
219 | 219 | $oldId = $this->contextInteractor->getOldId(); |
@@ -228,26 +228,26 @@ discard block |
||
228 | 228 | $revId = $oldId != 0 ? $oldId : $this->contextInteractor->getTitle()->getLatestRevID(); |
229 | 229 | |
230 | 230 | // Create an individual hash for when loose references are used |
231 | - $renderedReferenceListHash = md5( $this->getSubject()->getHash() . $references . $fingerprint ); |
|
231 | + $renderedReferenceListHash = md5($this->getSubject()->getHash() . $references . $fingerprint); |
|
232 | 232 | |
233 | - if ( $this->cache->contains( $key ) ) { |
|
234 | - $container = $this->cache->fetch( $key ); |
|
233 | + if ($this->cache->contains($key)) { |
|
234 | + $container = $this->cache->fetch($key); |
|
235 | 235 | |
236 | 236 | // Match against revision, languageCode, and hash |
237 | - if ( isset( $container['revId'] ) && |
|
237 | + if (isset($container['revId']) && |
|
238 | 238 | $container['revId'] == $revId && |
239 | - isset( $container['text'][$lang][$renderedReferenceListHash] ) ) { |
|
239 | + isset($container['text'][$lang][$renderedReferenceListHash])) { |
|
240 | 240 | return $container['text'][$lang][$renderedReferenceListHash]; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | 244 | $renderedReferenceList = $this->referenceListOutputRenderer->doRenderReferenceListFor( |
245 | 245 | $this->getSubject(), |
246 | - json_decode( html_entity_decode( $references ) ) |
|
246 | + json_decode(html_entity_decode($references)) |
|
247 | 247 | ); |
248 | 248 | |
249 | 249 | // Don't cache a history/diff view |
250 | - if ( $oldId != 0 ) { |
|
250 | + if ($oldId != 0) { |
|
251 | 251 | return $renderedReferenceList; |
252 | 252 | } |
253 | 253 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @codeCoverageIgnore |
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | - parent::__construct( 'FindCitableMetadata', 'sci-metadatasearch' ); |
|
25 | + parent::__construct('FindCitableMetadata', 'sci-metadatasearch'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -35,18 +35,18 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @see SpecialPage::execute |
37 | 37 | */ |
38 | - public function execute( $query ) { |
|
38 | + public function execute($query) { |
|
39 | 39 | |
40 | - if ( !$this->userCanExecute( $this->getUser() ) ) { |
|
40 | + if (!$this->userCanExecute($this->getUser())) { |
|
41 | 41 | $this->displayRestrictionError(); |
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $output = $this->getOutput(); |
46 | - $output->setPageTitle( $this->msg( 'findmetadatabyid' )->text() ); |
|
46 | + $output->setPageTitle($this->msg('findmetadatabyid')->text()); |
|
47 | 47 | $this->setHeaders(); |
48 | 48 | |
49 | - $output->addModuleStyles( 'ext.scite.styles' ); |
|
49 | + $output->addModuleStyles('ext.scite.styles'); |
|
50 | 50 | |
51 | 51 | $output->addModules( |
52 | 52 | [ |
@@ -54,25 +54,25 @@ discard block |
||
54 | 54 | ] |
55 | 55 | ); |
56 | 56 | |
57 | - list( $type, $id, $format ) = $this->getRequestParameters( |
|
57 | + list($type, $id, $format) = $this->getRequestParameters( |
|
58 | 58 | $query |
59 | 59 | ); |
60 | 60 | |
61 | - if ( $type === 'pmid' ) { |
|
61 | + if ($type === 'pmid') { |
|
62 | 62 | $type = 'pubmed'; |
63 | 63 | } |
64 | 64 | |
65 | - $this->callPageBuilderFor( $type, $id, $format ); |
|
65 | + $this->callPageBuilderFor($type, $id, $format); |
|
66 | 66 | } |
67 | 67 | |
68 | - private function callPageBuilderFor( $type, $id, $format ) { |
|
68 | + private function callPageBuilderFor($type, $id, $format) { |
|
69 | 69 | |
70 | 70 | $pageBuilder = $this->newPageBuilder(); |
71 | 71 | |
72 | - if ( $format === 'raw' ) { |
|
72 | + if ($format === 'raw') { |
|
73 | 73 | $this->getOutput()->disable(); |
74 | - header( "Content-type: text/plain; charset=utf-8" ); |
|
75 | - header( 'Cache-Control: private, no-cache, must-revalidate' ); |
|
74 | + header("Content-type: text/plain; charset=utf-8"); |
|
75 | + header('Cache-Control: private, no-cache, must-revalidate'); |
|
76 | 76 | |
77 | 77 | $html = $pageBuilder->getRawResponseFor( |
78 | 78 | $type, $id |
@@ -85,25 +85,25 @@ discard block |
||
85 | 85 | $type, $id |
86 | 86 | ); |
87 | 87 | |
88 | - $this->getOutput()->addHTML( $html ); |
|
89 | - $this->addExternalHelpLinkFor( 'sci-specials-citablemetadata-helplink' ); |
|
88 | + $this->getOutput()->addHTML($html); |
|
89 | + $this->addExternalHelpLinkFor('sci-specials-citablemetadata-helplink'); |
|
90 | 90 | } |
91 | 91 | |
92 | - private function getRequestParameters( $query ) { |
|
92 | + private function getRequestParameters($query) { |
|
93 | 93 | |
94 | 94 | $request = $this->getRequest()->getValues(); |
95 | 95 | |
96 | - if ( strpos( $query, '/' ) !== false ) { |
|
97 | - list( $type, $id ) = explode( '/', $query, 2 ); |
|
96 | + if (strpos($query, '/') !== false) { |
|
97 | + list($type, $id) = explode('/', $query, 2); |
|
98 | 98 | $request['type'] = $type; |
99 | 99 | $request['id'] = $id; |
100 | 100 | } |
101 | 101 | |
102 | - $id = isset( $request['id'] ) ? trim( $request['id'] ) : ''; |
|
103 | - $type = isset( $request['type'] ) ? strtolower( $request['type'] ) : ''; |
|
104 | - $format = isset( $request['format'] ) ? strtolower( $request['format'] ) : ''; |
|
102 | + $id = isset($request['id']) ? trim($request['id']) : ''; |
|
103 | + $type = isset($request['type']) ? strtolower($request['type']) : ''; |
|
104 | + $format = isset($request['format']) ? strtolower($request['format']) : ''; |
|
105 | 105 | |
106 | - return [ $type, $id, $format ]; |
|
106 | + return [$type, $id, $format]; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | private function newPageBuilder() { |
@@ -117,21 +117,21 @@ discard block |
||
117 | 117 | ); |
118 | 118 | |
119 | 119 | $httpRequestFactory = new HttpRequestFactory( |
120 | - $applicationFactory->newCacheFactory()->newMediaWikiCompositeCache( $GLOBALS['scigMetadataResponseCacheType'] ) |
|
120 | + $applicationFactory->newCacheFactory()->newMediaWikiCompositeCache($GLOBALS['scigMetadataResponseCacheType']) |
|
121 | 121 | ); |
122 | 122 | |
123 | 123 | $httpRequest = $httpRequestFactory->newCachedCurlRequest(); |
124 | - $httpRequest->setOption( ONOI_HTTP_REQUEST_RESPONSECACHE_TTL, $GLOBALS['scigMetadataResponseCacheLifetime'] ); |
|
125 | - $httpRequest->setOption( ONOI_HTTP_REQUEST_RESPONSECACHE_PREFIX, $GLOBALS['scigCachePrefix'] . ':sci:meta:' ); |
|
124 | + $httpRequest->setOption(ONOI_HTTP_REQUEST_RESPONSECACHE_TTL, $GLOBALS['scigMetadataResponseCacheLifetime']); |
|
125 | + $httpRequest->setOption(ONOI_HTTP_REQUEST_RESPONSECACHE_PREFIX, $GLOBALS['scigCachePrefix'] . ':sci:meta:'); |
|
126 | 126 | |
127 | 127 | $pageBuilder = new PageBuilder( |
128 | 128 | $htmlFormRenderer, |
129 | 129 | $mwCollaboratorFactory->newHtmlColumnListRenderer(), |
130 | - new CitationResourceMatchFinder( $applicationFactory->getStore() ), |
|
131 | - new HttpResponseParserFactory( $httpRequest ) |
|
130 | + new CitationResourceMatchFinder($applicationFactory->getStore()), |
|
131 | + new HttpResponseParserFactory($httpRequest) |
|
132 | 132 | ); |
133 | 133 | |
134 | - $pageBuilder->isReadOnly( MediaWikiServices::getInstance()->getReadOnlyMode()->isReadOnly() ); |
|
134 | + $pageBuilder->isReadOnly(MediaWikiServices::getInstance()->getReadOnlyMode()->isReadOnly()); |
|
135 | 135 | |
136 | 136 | return $pageBuilder; |
137 | 137 | } |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | /** |
140 | 140 | * FIXME MW 1.25 |
141 | 141 | */ |
142 | - private function addExternalHelpLinkFor( $key ) { |
|
142 | + private function addExternalHelpLinkFor($key) { |
|
143 | 143 | |
144 | - if ( !method_exists( $this, 'addHelpLink' ) ) { |
|
144 | + if (!method_exists($this, 'addHelpLink')) { |
|
145 | 145 | return null; |
146 | 146 | } |
147 | 147 | |
148 | - $this->getOutput()->addHelpLink( wfMessage( $key )->escaped(), true ); |
|
148 | + $this->getOutput()->addHelpLink(wfMessage($key)->escaped(), true); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param CitationResourceMatchFinder $citationResourceMatchFinder |
51 | 51 | * @param HttpResponseParserFactory $httpResponseParserFactory |
52 | 52 | */ |
53 | - public function __construct( HtmlFormRenderer $htmlFormRenderer, HtmlColumnListRenderer $htmlColumnListRenderer, CitationResourceMatchFinder $citationResourceMatchFinder, HttpResponseParserFactory $httpResponseParserFactory ) { |
|
53 | + public function __construct(HtmlFormRenderer $htmlFormRenderer, HtmlColumnListRenderer $htmlColumnListRenderer, CitationResourceMatchFinder $citationResourceMatchFinder, HttpResponseParserFactory $httpResponseParserFactory) { |
|
54 | 54 | $this->htmlFormRenderer = $htmlFormRenderer; |
55 | 55 | $this->htmlColumnListRenderer = $htmlColumnListRenderer; |
56 | 56 | $this->citationResourceMatchFinder = $citationResourceMatchFinder; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param boolean $isReadOnly |
64 | 64 | */ |
65 | - public function isReadOnly( $isReadOnly ) { |
|
65 | + public function isReadOnly($isReadOnly) { |
|
66 | 66 | $this->isReadOnly = (bool)$isReadOnly; |
67 | 67 | } |
68 | 68 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - public function getRawResponseFor( $type, $id ) { |
|
77 | + public function getRawResponseFor($type, $id) { |
|
78 | 78 | |
79 | 79 | $responseParser = $this->httpResponseParserFactory->newResponseParserForType( |
80 | 80 | $type |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $responseParser |
85 | 85 | ); |
86 | 86 | |
87 | - return $htmlResponseParserRenderer->getRawResponse( $id ); |
|
87 | + return $htmlResponseParserRenderer->getRawResponse($id); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return string |
97 | 97 | */ |
98 | - public function getHtmlFor( $type, $id ) { |
|
98 | + public function getHtmlFor($type, $id) { |
|
99 | 99 | |
100 | 100 | $text = ''; |
101 | 101 | $success = true; |
102 | 102 | $log = ''; |
103 | 103 | $matches = ''; |
104 | 104 | |
105 | - if ( $type !== '' && $id !== '' ) { |
|
105 | + if ($type !== '' && $id !== '') { |
|
106 | 106 | |
107 | 107 | $responseParser = $this->httpResponseParserFactory->newResponseParserForType( |
108 | 108 | $type |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $this->isReadOnly |
117 | 117 | ); |
118 | 118 | |
119 | - $text = $htmlResponseParserRenderer->renderTextFor( $id ); |
|
119 | + $text = $htmlResponseParserRenderer->renderTextFor($id); |
|
120 | 120 | |
121 | 121 | $matches = $this->tryToFindCitationResourceMatches( |
122 | 122 | $responseParser->getFilteredRecord() |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | ); |
132 | 132 | } |
133 | 133 | |
134 | - return $this->doRenderHtml( $type, $id, $success, $text, $log, $matches ); |
|
134 | + return $this->doRenderHtml($type, $id, $success, $text, $log, $matches); |
|
135 | 135 | } |
136 | 136 | |
137 | - private function doRenderHtml( $type, $id, $success, $text, $log, $matches ) { |
|
137 | + private function doRenderHtml($type, $id, $success, $text, $log, $matches) { |
|
138 | 138 | |
139 | 139 | $htmlFormRenderer = $this->htmlFormRenderer; |
140 | 140 | $messageBuilder = $this->htmlFormRenderer->getMessageBuilder(); |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | ]; |
150 | 150 | |
151 | 151 | |
152 | - if ( $matches !== '' ) { |
|
152 | + if ($matches !== '') { |
|
153 | 153 | $htmlFormRenderer->addParagraph( |
154 | 154 | '<div class="smw-callout smw-callout-info">' . |
155 | - $messageBuilder->getMessage( 'sci-metadata-search-has-match', $matches )->text() . |
|
155 | + $messageBuilder->getMessage('sci-metadata-search-has-match', $matches)->text() . |
|
156 | 156 | '</div>' |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
160 | - $html = $htmlFormRenderer->setName( 'sci-metadata-search-form' ) |
|
160 | + $html = $htmlFormRenderer->setName('sci-metadata-search-form') |
|
161 | 161 | ->withFieldset() |
162 | - ->setMethod( 'get' ) |
|
163 | - ->addParagraph( $messageBuilder->getMessage( 'sci-metadata-search-intro' )->parse() ) |
|
164 | - ->addParagraph( $this->getTypeIdIntroText( $messageBuilder ) ) |
|
162 | + ->setMethod('get') |
|
163 | + ->addParagraph($messageBuilder->getMessage('sci-metadata-search-intro')->parse()) |
|
164 | + ->addParagraph($this->getTypeIdIntroText($messageBuilder)) |
|
165 | 165 | ->addHorizontalRule() |
166 | 166 | ->addOptionSelectList( |
167 | - $messageBuilder->getMessage( 'sci-metadata-search-select-label' )->text(), |
|
167 | + $messageBuilder->getMessage('sci-metadata-search-select-label')->text(), |
|
168 | 168 | 'type', |
169 | 169 | $type, |
170 | 170 | $types ) |
@@ -175,96 +175,96 @@ discard block |
||
175 | 175 | 'id', |
176 | 176 | 40 ) |
177 | 177 | ->addNonBreakingSpace() |
178 | - ->addSubmitButton( $messageBuilder->getMessage( 'sci-metadata-search-form-submit' )->text() ) |
|
178 | + ->addSubmitButton($messageBuilder->getMessage('sci-metadata-search-form-submit')->text()) |
|
179 | 179 | ->addNonBreakingSpace() |
180 | - ->addCheckbox( 'Raw', 'format', 'raw' ) |
|
180 | + ->addCheckbox('Raw', 'format', 'raw') |
|
181 | 181 | ->getForm(); |
182 | 182 | |
183 | - if ( $text !== '' && $success ) { |
|
183 | + if ($text !== '' && $success) { |
|
184 | 184 | $htmlFormRenderer |
185 | - ->addHeader( 'h2', $messageBuilder->getMessage( 'sci-metadata-search-header-result' )->text() ) |
|
186 | - ->addParagraph( $text ); |
|
185 | + ->addHeader('h2', $messageBuilder->getMessage('sci-metadata-search-header-result')->text()) |
|
186 | + ->addParagraph($text); |
|
187 | 187 | } |
188 | 188 | |
189 | - if ( $log !== '' ) { |
|
189 | + if ($log !== '') { |
|
190 | 190 | $htmlFormRenderer |
191 | - ->setName( 'metadata-match' ) |
|
192 | - ->addHeader( 'h2', $messageBuilder->getMessage( 'sci-metadata-search-header-log' )->text() ) |
|
193 | - ->addParagraph( $log ); |
|
191 | + ->setName('metadata-match') |
|
192 | + ->addHeader('h2', $messageBuilder->getMessage('sci-metadata-search-header-log')->text()) |
|
193 | + ->addParagraph($log); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | return $html . $htmlFormRenderer->getForm(); |
197 | 197 | } |
198 | 198 | |
199 | - private function prepareLog( $messages, $matches, $usesCache ) { |
|
199 | + private function prepareLog($messages, $matches, $usesCache) { |
|
200 | 200 | |
201 | 201 | $messageBuilder = $this->htmlFormRenderer->getMessageBuilder(); |
202 | 202 | |
203 | 203 | $log = []; |
204 | 204 | |
205 | - foreach ( $messages as $m ) { |
|
205 | + foreach ($messages as $m) { |
|
206 | 206 | |
207 | - if ( call_user_func_array( 'wfMessage', $m )->exists() ) { |
|
208 | - $m = call_user_func_array( 'wfMessage', $m )->parse(); |
|
207 | + if (call_user_func_array('wfMessage', $m)->exists()) { |
|
208 | + $m = call_user_func_array('wfMessage', $m)->parse(); |
|
209 | 209 | } else { |
210 | - $m = current( $m ); |
|
210 | + $m = current($m); |
|
211 | 211 | } |
212 | 212 | |
213 | - $log[] = $m; |
|
213 | + $log[] = $m; |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( $usesCache ) { |
|
217 | - $log[] = $messageBuilder->getMessage( 'sci-metadata-search-cached' )->text(); |
|
216 | + if ($usesCache) { |
|
217 | + $log[] = $messageBuilder->getMessage('sci-metadata-search-cached')->text(); |
|
218 | 218 | } |
219 | 219 | |
220 | - if ( $this->isReadOnly ) { |
|
221 | - $log[] = $messageBuilder->getMessage( 'sci-metadata-search-read-only' )->text(); |
|
220 | + if ($this->isReadOnly) { |
|
221 | + $log[] = $messageBuilder->getMessage('sci-metadata-search-read-only')->text(); |
|
222 | 222 | } |
223 | 223 | |
224 | - if ( $log === [] ) { |
|
224 | + if ($log === []) { |
|
225 | 225 | return ''; |
226 | 226 | } |
227 | 227 | |
228 | - $this->htmlColumnListRenderer->addContentsByNoIndex( $log ); |
|
229 | - $this->htmlColumnListRenderer->setNumberOfColumns( 1 ); |
|
228 | + $this->htmlColumnListRenderer->addContentsByNoIndex($log); |
|
229 | + $this->htmlColumnListRenderer->setNumberOfColumns(1); |
|
230 | 230 | |
231 | 231 | return $this->htmlColumnListRenderer->getHtml(); |
232 | 232 | } |
233 | 233 | |
234 | - private function getTypeIdIntroText( $messageBuilder ) { |
|
234 | + private function getTypeIdIntroText($messageBuilder) { |
|
235 | 235 | |
236 | 236 | $explain = []; |
237 | 237 | |
238 | - foreach ( [ 'doi', 'oclc', 'pubmed', 'ol', 'viaf' ] as $value ) { |
|
239 | - $explain[] = $messageBuilder->getMessage( 'sci-metadata-search-intro-'. $value )->parse(); |
|
238 | + foreach (['doi', 'oclc', 'pubmed', 'ol', 'viaf'] as $value) { |
|
239 | + $explain[] = $messageBuilder->getMessage('sci-metadata-search-intro-' . $value)->parse(); |
|
240 | 240 | } |
241 | 241 | |
242 | - $this->htmlColumnListRenderer->setColumnListClass( 'scite-metadata-search-types' ); |
|
243 | - $this->htmlColumnListRenderer->addContentsByNoIndex( $explain ); |
|
244 | - $this->htmlColumnListRenderer->setNumberOfColumns( 2 ); |
|
242 | + $this->htmlColumnListRenderer->setColumnListClass('scite-metadata-search-types'); |
|
243 | + $this->htmlColumnListRenderer->addContentsByNoIndex($explain); |
|
244 | + $this->htmlColumnListRenderer->setNumberOfColumns(2); |
|
245 | 245 | |
246 | 246 | return $this->htmlColumnListRenderer->getHtml(); |
247 | 247 | } |
248 | 248 | |
249 | - private function tryToFindCitationResourceMatches( BibliographicFilteredRecord $bibliographicFilteredRecord ) { |
|
249 | + private function tryToFindCitationResourceMatches(BibliographicFilteredRecord $bibliographicFilteredRecord) { |
|
250 | 250 | |
251 | 251 | $html = []; |
252 | 252 | |
253 | - foreach ( [ 'doi', 'oclc', 'viaf', 'olid', 'pubmed', 'pmc' ] as $type ) { |
|
253 | + foreach (['doi', 'oclc', 'viaf', 'olid', 'pubmed', 'pmc'] as $type) { |
|
254 | 254 | $subjects = $this->citationResourceMatchFinder->findMatchForResourceIdentifierTypeToValue( |
255 | 255 | $type, |
256 | - $bibliographicFilteredRecord->getSearchMatchSetValueFor( $type ) |
|
256 | + $bibliographicFilteredRecord->getSearchMatchSetValueFor($type) |
|
257 | 257 | ); |
258 | 258 | |
259 | - if ( $subjects !== [] ) { |
|
259 | + if ($subjects !== []) { |
|
260 | 260 | $html = array_merge( |
261 | 261 | $html, |
262 | - $this->citationResourceMatchFinder->findCitationResourceLinks( $subjects, '', strtoupper( $type ) ) |
|
262 | + $this->citationResourceMatchFinder->findCitationResourceLinks($subjects, '', strtoupper($type)) |
|
263 | 263 | ); |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | - return $html !== [] ? '<strong>' . implode( ', ', $html ) . '</strong>' : ''; |
|
267 | + return $html !== [] ? '<strong>' . implode(', ', $html) . '</strong>' : ''; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | } |