@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return array |
29 | 29 | */ |
30 | - public function newSciteParserFunctionDefinition( NamespaceExaminer $namespaceExaminer, Options $options ) { |
|
30 | + public function newSciteParserFunctionDefinition(NamespaceExaminer $namespaceExaminer, Options $options) { |
|
31 | 31 | |
32 | - $sciteParserFunctionDefinition = function( $parser ) use( $namespaceExaminer, $options ) { |
|
32 | + $sciteParserFunctionDefinition = function($parser) use($namespaceExaminer, $options) { |
|
33 | 33 | |
34 | 34 | $parserData = ApplicationFactory::getInstance()->newParserData( |
35 | 35 | $parser->getTitle(), |
@@ -52,20 +52,20 @@ discard block |
||
52 | 52 | $namespaceExaminer, |
53 | 53 | $citationTextTemplateRenderer, |
54 | 54 | $mediaWikiNsContentMapper, |
55 | - new BibtexProcessor( new BibtexParser(), new BibtexAuthorListParser() ) |
|
55 | + new BibtexProcessor(new BibtexParser(), new BibtexAuthorListParser()) |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | $sciteParserFunction->setStrictParserValidationState( |
59 | - $options->get( 'enabledStrictParserValidation' ) |
|
59 | + $options->get('enabledStrictParserValidation') |
|
60 | 60 | ); |
61 | 61 | |
62 | 62 | return $sciteParserFunction->doProcess( |
63 | - ParameterProcessorFactory::newFromArray( func_get_args() ), |
|
63 | + ParameterProcessorFactory::newFromArray(func_get_args()), |
|
64 | 64 | new PreTextFormatter() |
65 | 65 | ); |
66 | 66 | }; |
67 | 67 | |
68 | - return [ 'scite', $sciteParserFunctionDefinition, 0 ]; |
|
68 | + return ['scite', $sciteParserFunctionDefinition, 0]; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function newReferenceListParserFunctionDefinition() { |
79 | 79 | |
80 | - $referenceListParserFunctionDefinition = function( $parser ) { |
|
80 | + $referenceListParserFunctionDefinition = function($parser) { |
|
81 | 81 | |
82 | 82 | $parserData = ApplicationFactory::getInstance()->newParserData( |
83 | 83 | $parser->getTitle(), |
84 | 84 | $parser->getOutput() |
85 | 85 | ); |
86 | 86 | |
87 | - $referenceListParserFunction = new ReferenceListParserFunction( $parserData ); |
|
87 | + $referenceListParserFunction = new ReferenceListParserFunction($parserData); |
|
88 | 88 | |
89 | 89 | return $referenceListParserFunction->doProcess( |
90 | - ParameterProcessorFactory::newFromArray( func_get_args() ) |
|
90 | + ParameterProcessorFactory::newFromArray(func_get_args()) |
|
91 | 91 | ); |
92 | 92 | }; |
93 | 93 | |
94 | - return [ 'referencelist', $referenceListParserFunctionDefinition, 0 ]; |
|
94 | + return ['referencelist', $referenceListParserFunctionDefinition, 0]; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param string $cachePrefix |
28 | 28 | */ |
29 | - public function setCachePrefix( $cachePrefix ) { |
|
29 | + public function setCachePrefix($cachePrefix) { |
|
30 | 30 | $this->cachePrefix = $cachePrefix; |
31 | 31 | } |
32 | 32 | |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return string |
39 | 39 | */ |
40 | - public function getCacheKeyForCitationReference( $hash ) { |
|
41 | - return $this->cachePrefix . ':sci:ref:' . md5( $hash . self::VERSION ); |
|
40 | + public function getCacheKeyForCitationReference($hash) { |
|
41 | + return $this->cachePrefix . ':sci:ref:' . md5($hash . self::VERSION); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public function getCacheKeyForReferenceList( $hash ) { |
|
52 | - return $this->cachePrefix . ':sci:reflist:' . md5( $hash . self::VERSION ); |
|
51 | + public function getCacheKeyForReferenceList($hash) { |
|
52 | + return $this->cachePrefix . ':sci:reflist:' . md5($hash . self::VERSION); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param MediaWikiNsContentReader $mediaWikiNsContentReader |
41 | 41 | */ |
42 | - public function __construct( MediaWikiNsContentReader $mediaWikiNsContentReader ) { |
|
42 | + public function __construct(MediaWikiNsContentReader $mediaWikiNsContentReader) { |
|
43 | 43 | $this->mediaWikiNsContentReader = $mediaWikiNsContentReader; |
44 | 44 | } |
45 | 45 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return string |
61 | 61 | */ |
62 | - public function findPropertyForId( $id ) { |
|
62 | + public function findPropertyForId($id) { |
|
63 | 63 | |
64 | - $id = strtolower( trim( $id ) ); |
|
64 | + $id = strtolower(trim($id)); |
|
65 | 65 | |
66 | - if ( self::$identifierToPropertyMap === [] ) { |
|
66 | + if (self::$identifierToPropertyMap === []) { |
|
67 | 67 | |
68 | 68 | // Fixed by definition due to usage of |
69 | 69 | // pre-defined properties |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | 'reference' => SCI_PROP_CITE_KEY, |
78 | 78 | 'citation text' => SCI_PROP_CITE_TEXT, |
79 | 79 | 'sortkey' => '_SKEY' |
80 | - ] + $this->parseContentFor( "sci-property-definition" ); |
|
80 | + ] + $this->parseContentFor("sci-property-definition"); |
|
81 | 81 | } |
82 | 82 | |
83 | - return isset( self::$identifierToPropertyMap[$id] ) ? self::$identifierToPropertyMap[$id] : null; |
|
83 | + return isset(self::$identifierToPropertyMap[$id]) ? self::$identifierToPropertyMap[$id] : null; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -90,48 +90,48 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public function findTemplateForType( $type ) { |
|
93 | + public function findTemplateForType($type) { |
|
94 | 94 | |
95 | - $type = strtolower( trim( $type ) ); |
|
95 | + $type = strtolower(trim($type)); |
|
96 | 96 | |
97 | - if ( self::$typeToTemplateMap === [] ) { |
|
98 | - self::$typeToTemplateMap = $this->parseContentFor( "sci-template-definition" ); |
|
97 | + if (self::$typeToTemplateMap === []) { |
|
98 | + self::$typeToTemplateMap = $this->parseContentFor("sci-template-definition"); |
|
99 | 99 | } |
100 | 100 | |
101 | - return isset( self::$typeToTemplateMap[$type] ) ? self::$typeToTemplateMap[$type] : null; |
|
101 | + return isset(self::$typeToTemplateMap[$type]) ? self::$typeToTemplateMap[$type] : null; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @param string $name |
106 | 106 | */ |
107 | - private function parseContentFor( $name ) { |
|
107 | + private function parseContentFor($name) { |
|
108 | 108 | |
109 | - if ( self::$skipMessageCache ) { |
|
109 | + if (self::$skipMessageCache) { |
|
110 | 110 | $this->mediaWikiNsContentReader->skipMessageCache(); |
111 | 111 | } |
112 | 112 | |
113 | - $contents = (string)$this->mediaWikiNsContentReader->read( $name ); |
|
113 | + $contents = (string)$this->mediaWikiNsContentReader->read($name); |
|
114 | 114 | |
115 | - if ( $contents === '' ) { |
|
115 | + if ($contents === '') { |
|
116 | 116 | return []; |
117 | 117 | } |
118 | 118 | |
119 | - $contentMap = array_map( 'trim', preg_split( "([\n][\s]?)", $contents ) ); |
|
119 | + $contentMap = array_map('trim', preg_split("([\n][\s]?)", $contents)); |
|
120 | 120 | $list = []; |
121 | 121 | |
122 | 122 | // Check whether the first line is infact an explanation |
123 | - if ( strpos( $contentMap[0], '|' ) === false ) { |
|
124 | - array_shift( $contentMap ); |
|
123 | + if (strpos($contentMap[0], '|') === false) { |
|
124 | + array_shift($contentMap); |
|
125 | 125 | } |
126 | 126 | |
127 | - foreach ( $contentMap as $map ) { |
|
127 | + foreach ($contentMap as $map) { |
|
128 | 128 | |
129 | - if ( strpos( $map, '|' ) === false ) { |
|
129 | + if (strpos($map, '|') === false) { |
|
130 | 130 | continue; |
131 | 131 | } |
132 | 132 | |
133 | - list( $id, $value ) = explode( '|', $map, 2 ); |
|
134 | - $list[str_replace( '_', ' ', strtolower( trim( $id ) ) )] = $value; |
|
133 | + list($id, $value) = explode('|', $map, 2); |
|
134 | + $list[str_replace('_', ' ', strtolower(trim($id)))] = $value; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return $list; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param MediaWikiNsContentMapper $mediaWikiNsContentMapper |
75 | 75 | * @param BibtexProcessor $bibtexProcessor |
76 | 76 | */ |
77 | - public function __construct( ParserData $parserData, NamespaceExaminer $namespaceExaminer, CitationTextTemplateRenderer $citationTextTemplateRenderer, MediaWikiNsContentMapper $mediaWikiNsContentMapper, BibtexProcessor $bibtexProcessor ) { |
|
77 | + public function __construct(ParserData $parserData, NamespaceExaminer $namespaceExaminer, CitationTextTemplateRenderer $citationTextTemplateRenderer, MediaWikiNsContentMapper $mediaWikiNsContentMapper, BibtexProcessor $bibtexProcessor) { |
|
78 | 78 | $this->parserData = $parserData; |
79 | 79 | $this->namespaceExaminer = $namespaceExaminer; |
80 | 80 | $this->citationTextTemplateRenderer = $citationTextTemplateRenderer; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param boolean $strictParserValidationState |
90 | 90 | */ |
91 | - public function setStrictParserValidationState ( $strictParserValidationState ) { |
|
91 | + public function setStrictParserValidationState($strictParserValidationState) { |
|
92 | 92 | $this->strictParserValidationState = (bool)$strictParserValidationState; |
93 | 93 | } |
94 | 94 | |
@@ -143,28 +143,28 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param ParserParameterProcessor $parserParameterProcessor |
145 | 145 | */ |
146 | - public function doProcess( ParserParameterProcessor $parserParameterProcessor, PreTextFormatter $preTextFormatter = null ) { |
|
146 | + public function doProcess(ParserParameterProcessor $parserParameterProcessor, PreTextFormatter $preTextFormatter = null) { |
|
147 | 147 | |
148 | - if ( !$this->namespaceExaminer->isSemanticEnabled( $this->parserData->getTitle()->getNamespace() ) ) { |
|
149 | - return $this->createErrorMessageFor( 'sci-scite-parser-not-enabled-namespace' ); |
|
148 | + if (!$this->namespaceExaminer->isSemanticEnabled($this->parserData->getTitle()->getNamespace())) { |
|
149 | + return $this->createErrorMessageFor('sci-scite-parser-not-enabled-namespace'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | // Hopefully the bibtex processor will add all required parameters and values |
153 | - if ( $parserParameterProcessor->hasParameter( 'bibtex' ) ) { |
|
154 | - $this->bibtexProcessor->doProcess( $parserParameterProcessor ); |
|
153 | + if ($parserParameterProcessor->hasParameter('bibtex')) { |
|
154 | + $this->bibtexProcessor->doProcess($parserParameterProcessor); |
|
155 | 155 | } |
156 | 156 | |
157 | - $reference = str_replace( '_', ' ', (string)$parserParameterProcessor->getFirstParameter() ); |
|
157 | + $reference = str_replace('_', ' ', (string)$parserParameterProcessor->getFirstParameter()); |
|
158 | 158 | $type = ''; |
159 | 159 | |
160 | 160 | // Explicit reference precedes |
161 | - if ( $parserParameterProcessor->hasParameter( 'reference' ) ) { |
|
162 | - $reference = $parserParameterProcessor->getParameterValuesFor( 'reference' ); |
|
163 | - $reference = end( $reference ); |
|
161 | + if ($parserParameterProcessor->hasParameter('reference')) { |
|
162 | + $reference = $parserParameterProcessor->getParameterValuesFor('reference'); |
|
163 | + $reference = end($reference); |
|
164 | 164 | } |
165 | 165 | |
166 | - if ( $reference === '' ) { |
|
167 | - return $this->createErrorMessageFor( 'sci-scite-parser-no-reference' ); |
|
166 | + if ($reference === '') { |
|
167 | + return $this->createErrorMessageFor('sci-scite-parser-no-reference'); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // Fixed identifier |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | $reference |
174 | 174 | ); |
175 | 175 | |
176 | - if ( $parserParameterProcessor->hasParameter( 'type' ) ) { |
|
177 | - $type = $parserParameterProcessor->getParameterValuesFor( 'type' ); |
|
178 | - sort( $type ); |
|
179 | - $type = end( $type ); |
|
176 | + if ($parserParameterProcessor->hasParameter('type')) { |
|
177 | + $type = $parserParameterProcessor->getParameterValuesFor('type'); |
|
178 | + sort($type); |
|
179 | + $type = end($type); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $returnText = $this->tryToMatchCitationTextByPrecept( |
@@ -197,125 +197,125 @@ discard block |
||
197 | 197 | // placed next to each other, have the first occurrence to mark its |
198 | 198 | // existence explicitly by outputting an empty paragraph and so avoid a |
199 | 199 | // <br> element. |
200 | - if ( $returnText === '' && $this->parserData->getOutput()->getExtensionData( 'sci-parserfunction' ) === null ) { |
|
201 | - $this->parserData->getOutput()->setExtensionData( 'sci-parserfunction', true ); |
|
200 | + if ($returnText === '' && $this->parserData->getOutput()->getExtensionData('sci-parserfunction') === null) { |
|
201 | + $this->parserData->getOutput()->setExtensionData('sci-parserfunction', true); |
|
202 | 202 | $returnText = '<p></p>'; |
203 | 203 | } |
204 | 204 | |
205 | - if ( $parserParameterProcessor->hasParameter( '@show' ) && $preTextFormatter !== null ) { |
|
206 | - $returnText = $preTextFormatter->getFormattedSciteFuncFrom( $parserParameterProcessor->getRaw() ) . $returnText; |
|
205 | + if ($parserParameterProcessor->hasParameter('@show') && $preTextFormatter !== null) { |
|
206 | + $returnText = $preTextFormatter->getFormattedSciteFuncFrom($parserParameterProcessor->getRaw()) . $returnText; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | return $returnText; //array( '', 'noparse' => true, 'isHTML' => true ); |
210 | 210 | } |
211 | 211 | |
212 | - private function tryToMatchCitationTextByPrecept( ParserParameterProcessor $parserParameterProcessor, $reference, $type = '' ) { |
|
212 | + private function tryToMatchCitationTextByPrecept(ParserParameterProcessor $parserParameterProcessor, $reference, $type = '') { |
|
213 | 213 | |
214 | 214 | $template = ''; |
215 | 215 | |
216 | - if ( $this->strictParserValidationState && $type === '' ) { |
|
216 | + if ($this->strictParserValidationState && $type === '') { |
|
217 | 217 | |
218 | 218 | $parserParameterProcessor->addParameter( |
219 | 219 | DIProperty::TYPE_ERROR, |
220 | 220 | PropertyRegistry::SCI_CITE |
221 | 221 | ); |
222 | 222 | |
223 | - return $this->createErrorMessageFor( 'sci-scite-parser-no-type', $reference ); |
|
223 | + return $this->createErrorMessageFor('sci-scite-parser-no-type', $reference); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | // An injected text trumps a template |
227 | - if ( $parserParameterProcessor->hasParameter( 'citation text' ) ) { |
|
227 | + if ($parserParameterProcessor->hasParameter('citation text')) { |
|
228 | 228 | return ''; |
229 | 229 | } |
230 | 230 | |
231 | 231 | // An explicit template precedes the assignment found for the type |
232 | - if ( $parserParameterProcessor->hasParameter( 'template' ) ) { |
|
233 | - $template = $parserParameterProcessor->getParameterValuesFor( 'template' ); |
|
234 | - $template = trim( end( $template ) ); |
|
235 | - } elseif ( $this->mediaWikiNsContentMapper->findTemplateForType( $type ) !== null ) { |
|
236 | - $template = $this->mediaWikiNsContentMapper->findTemplateForType( $type ); |
|
232 | + if ($parserParameterProcessor->hasParameter('template')) { |
|
233 | + $template = $parserParameterProcessor->getParameterValuesFor('template'); |
|
234 | + $template = trim(end($template)); |
|
235 | + } elseif ($this->mediaWikiNsContentMapper->findTemplateForType($type) !== null) { |
|
236 | + $template = $this->mediaWikiNsContentMapper->findTemplateForType($type); |
|
237 | 237 | } |
238 | 238 | |
239 | - if ( $template !== '' ) { |
|
240 | - $this->citationTextTemplateRenderer->packFieldsForTemplate( $template ); |
|
239 | + if ($template !== '') { |
|
240 | + $this->citationTextTemplateRenderer->packFieldsForTemplate($template); |
|
241 | 241 | |
242 | 242 | // Fixed identifier |
243 | 243 | $parserParameterProcessor->addParameter( |
244 | 244 | 'citation text', |
245 | - $this->citationTextTemplateRenderer->renderFor( $parserParameterProcessor->toArray() ) |
|
245 | + $this->citationTextTemplateRenderer->renderFor($parserParameterProcessor->toArray()) |
|
246 | 246 | ); |
247 | - } elseif ( $this->strictParserValidationState ) { |
|
247 | + } elseif ($this->strictParserValidationState) { |
|
248 | 248 | |
249 | 249 | $parserParameterProcessor->addParameter( |
250 | 250 | DIProperty::TYPE_ERROR, |
251 | 251 | PropertyRegistry::SCI_CITE_TEXT |
252 | 252 | ); |
253 | 253 | |
254 | - return $this->createErrorMessageFor( 'sci-scite-parser-no-citation-text', $reference, $type ); |
|
254 | + return $this->createErrorMessageFor('sci-scite-parser-no-citation-text', $reference, $type); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | return ''; |
258 | 258 | } |
259 | 259 | |
260 | - private function addPropertyValuesFor( ParserParameterProcessor $parserParameterProcessor, $reference ) { |
|
260 | + private function addPropertyValuesFor(ParserParameterProcessor $parserParameterProcessor, $reference) { |
|
261 | 261 | |
262 | - $subobject = new Subobject( $this->parserData->getTitle() ); |
|
263 | - $subobject->setEmptyContainerForId( '_SCITE' . md5( $reference ) ); |
|
262 | + $subobject = new Subobject($this->parserData->getTitle()); |
|
263 | + $subobject->setEmptyContainerForId('_SCITE' . md5($reference)); |
|
264 | 264 | |
265 | 265 | $subject = $this->parserData->getSemanticData()->getSubject(); |
266 | 266 | |
267 | - foreach ( $parserParameterProcessor->toArray() as $key => $values ) { |
|
267 | + foreach ($parserParameterProcessor->toArray() as $key => $values) { |
|
268 | 268 | |
269 | - if ( $key === DIProperty::TYPE_ERROR ) { |
|
269 | + if ($key === DIProperty::TYPE_ERROR) { |
|
270 | 270 | |
271 | - $value = new DIProperty( end( $values ) ); |
|
271 | + $value = new DIProperty(end($values)); |
|
272 | 272 | |
273 | 273 | $subobject->getSemanticData()->addPropertyObjectValue( |
274 | - new DIProperty( DIProperty::TYPE_ERROR ), |
|
274 | + new DIProperty(DIProperty::TYPE_ERROR), |
|
275 | 275 | $value->getDiWikiPage() |
276 | 276 | ); |
277 | 277 | |
278 | 278 | continue; |
279 | 279 | } |
280 | 280 | |
281 | - $property = $this->mediaWikiNsContentMapper->findPropertyForId( $key ); |
|
281 | + $property = $this->mediaWikiNsContentMapper->findPropertyForId($key); |
|
282 | 282 | |
283 | 283 | // No mapping, no annotation |
284 | - if ( $property === null ) { |
|
284 | + if ($property === null) { |
|
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | |
288 | - foreach ( $values as $value ) { |
|
288 | + foreach ($values as $value) { |
|
289 | 289 | |
290 | 290 | $dataValue = $this->dataValueFactory->newPropertyValue( |
291 | 291 | $property, |
292 | - trim( $value ), |
|
292 | + trim($value), |
|
293 | 293 | false, |
294 | 294 | $subject |
295 | 295 | ); |
296 | 296 | |
297 | - $subobject->addDataValue( $dataValue ); |
|
297 | + $subobject->addDataValue($dataValue); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | - if ( $subobject->getSemanticData()->isEmpty() ) { |
|
301 | + if ($subobject->getSemanticData()->isEmpty()) { |
|
302 | 302 | return; |
303 | 303 | } |
304 | 304 | |
305 | 305 | $this->parserData->getSemanticData()->addPropertyObjectValue( |
306 | - new DIProperty( PropertyRegistry::SCI_CITE ), |
|
306 | + new DIProperty(PropertyRegistry::SCI_CITE), |
|
307 | 307 | $subobject->getContainer() |
308 | 308 | ); |
309 | 309 | |
310 | - $this->parserData->getSubject()->setContextReference( 'scitep:' . uniqid() ); |
|
310 | + $this->parserData->getSubject()->setContextReference('scitep:' . uniqid()); |
|
311 | 311 | $this->parserData->pushSemanticDataToParserOutput(); |
312 | 312 | } |
313 | 313 | |
314 | - private function createErrorMessageFor( $messageKey, $arg1 = '', $arg2 = '' ) { |
|
314 | + private function createErrorMessageFor($messageKey, $arg1 = '', $arg2 = '') { |
|
315 | 315 | return \Html::rawElement( |
316 | 316 | 'div', |
317 | - [ 'class' => 'smw-callout smw-callout-error' ], |
|
318 | - wfMessage( $messageKey, $arg1, $arg2 )->inContentLanguage()->text() |
|
317 | + ['class' => 'smw-callout smw-callout-error'], |
|
318 | + wfMessage($messageKey, $arg1, $arg2)->inContentLanguage()->text() |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 |
@@ -11,10 +11,10 @@ |
||
11 | 11 | |
12 | 12 | /** English (English) */ |
13 | 13 | $specialPageAliases['en'] = [ |
14 | - 'FindCitableMetadata' => [ 'FindCitableMetadata', 'FindMetadataById' ] |
|
14 | + 'FindCitableMetadata' => ['FindCitableMetadata', 'FindMetadataById'] |
|
15 | 15 | ]; |
16 | 16 | |
17 | 17 | /** German (Deutsch) */ |
18 | 18 | $specialPageAliases['de'] = [ |
19 | - 'FindCitableMetadata' => [ 'Metadatensuche_nach_Identifizierungskennung' ] |
|
19 | + 'FindCitableMetadata' => ['Metadatensuche_nach_Identifizierungskennung'] |
|
20 | 20 | ]; |
@@ -9,15 +9,15 @@ |
||
9 | 9 | * English (English) |
10 | 10 | */ |
11 | 11 | $magicWords['en'] = [ |
12 | - 'scite' => [ 0, 'scite' ], |
|
13 | - 'referencelist' => [ 0, 'referencelist' ], |
|
14 | - 'SCI_NOREFERENCELIST' => [ 0, '__NOREFERENCELIST__' ] |
|
12 | + 'scite' => [0, 'scite'], |
|
13 | + 'referencelist' => [0, 'referencelist'], |
|
14 | + 'SCI_NOREFERENCELIST' => [0, '__NOREFERENCELIST__'] |
|
15 | 15 | ]; |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * German (Deutsch) |
19 | 19 | */ |
20 | 20 | $magicWords['de'] = [ |
21 | - 'referencelist' => [ 0, 'referenzierungen' ], |
|
22 | - 'SCI_NOREFERENCELIST' => [ 0, '__KEINE_REFERENZIERUNGEN__', '__KEINEREFERENZIERUNGEN__' ] |
|
21 | + 'referencelist' => [0, 'referenzierungen'], |
|
22 | + 'SCI_NOREFERENCELIST' => [0, '__KEINE_REFERENZIERUNGEN__', '__KEINEREFERENZIERUNGEN__'] |
|
23 | 23 | ]; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param Cache $cache |
40 | 40 | * @param Options $options |
41 | 41 | */ |
42 | - public function __construct( Store $store, Cache $cache, Options $options ) { |
|
42 | + public function __construct(Store $store, Cache $cache, Options $options) { |
|
43 | 43 | $this->options = $options; |
44 | 44 | |
45 | 45 | $this->addCallbackHandlers( |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * @param string $key |
58 | 58 | * @param mixed $value |
59 | 59 | */ |
60 | - public function setOption( $key, $value ) { |
|
61 | - $this->options->set( $key, $value ); |
|
60 | + public function setOption($key, $value) { |
|
61 | + $this->options->set($key, $value); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return boolean |
70 | 70 | */ |
71 | - public function isRegistered( $name ) { |
|
72 | - return \MediaWiki\MediaWikiServices::getInstance()->getHookContainer()->isRegistered( $name ); |
|
71 | + public function isRegistered($name) { |
|
72 | + return \MediaWiki\MediaWikiServices::getInstance()->getHookContainer()->isRegistered($name); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function clear() { |
79 | 79 | |
80 | - if ( !defined( 'MW_PHPUNIT_TEST' ) ) { |
|
80 | + if (!defined('MW_PHPUNIT_TEST')) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | - foreach ( $this->handlers as $name => $callback ) { |
|
85 | - \MediaWiki\MediaWikiServices::getInstance()->getHookContainer()->clear( $name ); |
|
84 | + foreach ($this->handlers as $name => $callback) { |
|
85 | + \MediaWiki\MediaWikiServices::getInstance()->getHookContainer()->clear($name); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return Callable|false |
95 | 95 | */ |
96 | - public function getHandlerFor( $name ) { |
|
97 | - return isset( $this->handlers[$name] ) ? $this->handlers[$name] : false; |
|
96 | + public function getHandlerFor($name) { |
|
97 | + return isset($this->handlers[$name]) ? $this->handlers[$name] : false; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | // return; |
107 | 107 | //} |
108 | 108 | |
109 | - foreach ( $this->handlers as $name => $callback ) { |
|
110 | - \MediaWiki\MediaWikiServices::getInstance()->getHookContainer()->register( $name, $callback ); |
|
109 | + foreach ($this->handlers as $name => $callback) { |
|
110 | + \MediaWiki\MediaWikiServices::getInstance()->getHookContainer()->register($name, $callback); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @param array &$config |
118 | 118 | */ |
119 | - public static function onBeforeConfigCompletion( &$config ) { |
|
119 | + public static function onBeforeConfigCompletion(&$config) { |
|
120 | 120 | |
121 | - if ( !isset( $config['smwgFulltextSearchPropertyExemptionList'] ) ) { |
|
121 | + if (!isset($config['smwgFulltextSearchPropertyExemptionList'])) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Exclude those properties from indexing |
126 | 126 | $config['smwgFulltextSearchPropertyExemptionList'] = array_merge( |
127 | 127 | $config['smwgFulltextSearchPropertyExemptionList'], |
128 | - [ PropertyRegistry::SCI_CITE ] |
|
128 | + [PropertyRegistry::SCI_CITE] |
|
129 | 129 | ); |
130 | 130 | } |
131 | 131 | |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public static function initExtension() { |
136 | 136 | |
137 | - $GLOBALS['wgHooks']['SMW::Config::BeforeCompletion'][] = function( &$config ) { |
|
137 | + $GLOBALS['wgHooks']['SMW::Config::BeforeCompletion'][] = function(&$config) { |
|
138 | 138 | |
139 | 139 | $exemptionlist = [ |
140 | 140 | PropertyRegistry::SCI_CITE |
141 | 141 | ]; |
142 | 142 | |
143 | 143 | // Exclude listed properties from indexing |
144 | - if ( isset( $config['smwgFulltextSearchPropertyExemptionList'] ) ) { |
|
144 | + if (isset($config['smwgFulltextSearchPropertyExemptionList'])) { |
|
145 | 145 | $config['smwgFulltextSearchPropertyExemptionList'] = array_merge( |
146 | 146 | $config['smwgFulltextSearchPropertyExemptionList'], |
147 | 147 | $exemptionlist |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | // selected object would trigger an automatic change without the necessary |
153 | 153 | // human intervention and can therefore produce unwanted query updates |
154 | 154 | |
155 | - if ( isset( $config['smwgQueryDependencyPropertyExemptionList'] ) ) { |
|
155 | + if (isset($config['smwgQueryDependencyPropertyExemptionList'])) { |
|
156 | 156 | $config['smwgQueryDependencyPropertyExemptionList'] = array_merge( |
157 | 157 | $config['smwgQueryDependencyPropertyExemptionList'], |
158 | 158 | $exemptionlist |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | '_sci_olid' |
182 | 182 | ]; |
183 | 183 | |
184 | - foreach ( $types as $type ) { |
|
184 | + foreach ($types as $type) { |
|
185 | 185 | $dataTypeRegistry->registerDatatype( |
186 | 186 | $type, |
187 | 187 | '\SCI\DataValues\ResourceIdentifierStringValue', |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | }; |
195 | 195 | |
196 | 196 | // SMW 3.1+ |
197 | - if ( method_exists( $dataTypeRegistry, 'registerCallable' ) ) { |
|
198 | - $dataTypeRegistry->registerCallable( '_sci_ref', 'sci.citationreferencepositionjournal', $callback ); |
|
197 | + if (method_exists($dataTypeRegistry, 'registerCallable')) { |
|
198 | + $dataTypeRegistry->registerCallable('_sci_ref', 'sci.citationreferencepositionjournal', $callback); |
|
199 | 199 | } else { |
200 | 200 | $dataTypeRegistry->registerExtraneousFunction( |
201 | 201 | '\SCI\CitationReferencePositionJournal', |
@@ -206,40 +206,40 @@ discard block |
||
206 | 206 | return true; |
207 | 207 | } |
208 | 208 | |
209 | - private function addCallbackHandlers( $store, $cache, $options ) { |
|
209 | + private function addCallbackHandlers($store, $cache, $options) { |
|
210 | 210 | |
211 | 211 | $propertyRegistry = new PropertyRegistry(); |
212 | 212 | $namespaceExaminer = ApplicationFactory::getInstance()->getNamespaceExaminer(); |
213 | 213 | |
214 | 214 | $cacheKeyProvider = new CacheKeyProvider(); |
215 | - $cacheKeyProvider->setCachePrefix( $options->get( 'cachePrefix' ) ); |
|
215 | + $cacheKeyProvider->setCachePrefix($options->get('cachePrefix')); |
|
216 | 216 | |
217 | 217 | $this->citationReferencePositionJournal = new CitationReferencePositionJournal( |
218 | 218 | $cache, |
219 | 219 | $cacheKeyProvider |
220 | 220 | ); |
221 | 221 | |
222 | - $referenceBacklinksLookup = new ReferenceBacklinksLookup( $store ); |
|
222 | + $referenceBacklinksLookup = new ReferenceBacklinksLookup($store); |
|
223 | 223 | |
224 | 224 | /** |
225 | 225 | * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::Property::initProperties |
226 | 226 | */ |
227 | - $this->handlers['SMW::Property::initProperties'] = function ( $corePropertyRegistry ) use ( $propertyRegistry ) { |
|
228 | - return $propertyRegistry->registerTo( $corePropertyRegistry ); |
|
227 | + $this->handlers['SMW::Property::initProperties'] = function($corePropertyRegistry) use ($propertyRegistry) { |
|
228 | + return $propertyRegistry->registerTo($corePropertyRegistry); |
|
229 | 229 | }; |
230 | 230 | |
231 | 231 | /** |
232 | 232 | * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::DataType::initTypes |
233 | 233 | */ |
234 | - $this->handlers['SMW::DataType::initTypes'] = [ $this, 'onDataTypeInit' ]; |
|
234 | + $this->handlers['SMW::DataType::initTypes'] = [$this, 'onDataTypeInit']; |
|
235 | 235 | |
236 | 236 | /** |
237 | 237 | * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::Browse::AfterIncomingPropertiesLookupComplete |
238 | 238 | */ |
239 | - $this->handlers['SMW::Browse::AfterIncomingPropertiesLookupComplete'] = function ( $store, $semanticData, $requestOptions ) use ( $referenceBacklinksLookup ) { |
|
239 | + $this->handlers['SMW::Browse::AfterIncomingPropertiesLookupComplete'] = function($store, $semanticData, $requestOptions) use ($referenceBacklinksLookup) { |
|
240 | 240 | |
241 | - $referenceBacklinksLookup->setRequestOptions( $requestOptions ); |
|
242 | - $referenceBacklinksLookup->setStore( $store ); |
|
241 | + $referenceBacklinksLookup->setRequestOptions($requestOptions); |
|
242 | + $referenceBacklinksLookup->setStore($store); |
|
243 | 243 | |
244 | 244 | $referenceBacklinksLookup->addReferenceBacklinksTo( |
245 | 245 | $semanticData |
@@ -248,22 +248,22 @@ discard block |
||
248 | 248 | return true; |
249 | 249 | }; |
250 | 250 | |
251 | - $this->handlers['SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate'] = function ( $property, $subject, &$html ) use ( $referenceBacklinksLookup ) { |
|
252 | - return $referenceBacklinksLookup->getSpecialPropertySearchFurtherLink( $property, $subject, $html ); |
|
251 | + $this->handlers['SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate'] = function($property, $subject, &$html) use ($referenceBacklinksLookup) { |
|
252 | + return $referenceBacklinksLookup->getSpecialPropertySearchFurtherLink($property, $subject, $html); |
|
253 | 253 | }; |
254 | 254 | |
255 | 255 | /** |
256 | 256 | * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::Parser::BeforeMagicWordsFinder |
257 | 257 | */ |
258 | - $this->handlers['SMW::Parser::BeforeMagicWordsFinder'] = function( array &$magicWords ) { |
|
259 | - $magicWords = array_merge( $magicWords, [ 'SCI_NOREFERENCELIST' ] ); |
|
258 | + $this->handlers['SMW::Parser::BeforeMagicWordsFinder'] = function(array &$magicWords) { |
|
259 | + $magicWords = array_merge($magicWords, ['SCI_NOREFERENCELIST']); |
|
260 | 260 | return true; |
261 | 261 | }; |
262 | 262 | |
263 | 263 | /** |
264 | 264 | * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::SQLStore::AddCustomFixedPropertyTables |
265 | 265 | */ |
266 | - $this->handlers['SMW::SQLStore::AddCustomFixedPropertyTables'] = function( array &$customFixedProperties ) use( $propertyRegistry ) { |
|
266 | + $this->handlers['SMW::SQLStore::AddCustomFixedPropertyTables'] = function(array &$customFixedProperties) use($propertyRegistry) { |
|
267 | 267 | |
268 | 268 | $properties = [ |
269 | 269 | $propertyRegistry::SCI_CITE_KEY, |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | $propertyRegistry::SCI_OLID |
279 | 279 | ]; |
280 | 280 | |
281 | - foreach ( $properties as $property ) { |
|
282 | - $customFixedProperties[$property] = str_replace( '__', '_', $property ); |
|
281 | + foreach ($properties as $property) { |
|
282 | + $customFixedProperties[$property] = str_replace('__', '_', $property); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | return true; |
@@ -288,13 +288,13 @@ discard block |
||
288 | 288 | /** |
289 | 289 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay |
290 | 290 | */ |
291 | - $this->handlers['BeforePageDisplay'] = function ( &$outputPage, &$skin ) use( $namespaceExaminer ) { |
|
291 | + $this->handlers['BeforePageDisplay'] = function(&$outputPage, &$skin) use($namespaceExaminer) { |
|
292 | 292 | |
293 | - if ( !$namespaceExaminer->isSemanticEnabled( $outputPage->getTitle()->getNamespace() ) ) { |
|
293 | + if (!$namespaceExaminer->isSemanticEnabled($outputPage->getTitle()->getNamespace())) { |
|
294 | 294 | return true; |
295 | 295 | } |
296 | 296 | |
297 | - $outputPage->addModuleStyles( 'ext.scite.styles' ); |
|
297 | + $outputPage->addModuleStyles('ext.scite.styles'); |
|
298 | 298 | |
299 | 299 | $outputPage->addModules( |
300 | 300 | [ |
@@ -312,15 +312,15 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput |
314 | 314 | */ |
315 | - $this->handlers['OutputPageParserOutput'] = function( &$outputPage, $parserOutput ) { |
|
316 | - $outputPage->smwmagicwords = $parserOutput->getExtensionData( 'smwmagicwords' ); |
|
315 | + $this->handlers['OutputPageParserOutput'] = function(&$outputPage, $parserOutput) { |
|
316 | + $outputPage->smwmagicwords = $parserOutput->getExtensionData('smwmagicwords'); |
|
317 | 317 | return true; |
318 | 318 | }; |
319 | 319 | |
320 | 320 | /** |
321 | 321 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageBeforeHTML |
322 | 322 | */ |
323 | - $this->handlers['OutputPageBeforeHTML'] = function( &$outputPage, &$text ) use ( $store, $namespaceExaminer, $cache, $cacheKeyProvider, $options ) { |
|
323 | + $this->handlers['OutputPageBeforeHTML'] = function(&$outputPage, &$text) use ($store, $namespaceExaminer, $cache, $cacheKeyProvider, $options) { |
|
324 | 324 | |
325 | 325 | $referenceListFactory = new ReferenceListFactory( |
326 | 326 | $store, |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | ); |
330 | 330 | |
331 | 331 | $cachedReferenceListOutputRenderer = $referenceListFactory->newCachedReferenceListOutputRenderer( |
332 | - new MediaWikiContextInteractor( $outputPage->getContext() ), |
|
332 | + new MediaWikiContextInteractor($outputPage->getContext()), |
|
333 | 333 | $cache, |
334 | 334 | $cacheKeyProvider, |
335 | 335 | $options |
336 | 336 | ); |
337 | 337 | |
338 | - $cachedReferenceListOutputRenderer->addReferenceListToText( $text ); |
|
338 | + $cachedReferenceListOutputRenderer->addReferenceListToText($text); |
|
339 | 339 | |
340 | 340 | return true; |
341 | 341 | }; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | /** |
344 | 344 | * @see https://www.semantic-mediawiki.org/wiki/Hooks#SMWStore::updateDataBefore |
345 | 345 | */ |
346 | - $this->handlers['SMWStore::updateDataBefore'] = function ( $store, $semanticData ) use ( $cache, $cacheKeyProvider ) { |
|
346 | + $this->handlers['SMWStore::updateDataBefore'] = function($store, $semanticData) use ($cache, $cacheKeyProvider) { |
|
347 | 347 | |
348 | 348 | $hash = $semanticData->getSubject()->getHash(); |
349 | 349 | |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | // more because as long as a CiteRef exists, CitationReferencePositionJournal |
352 | 352 | // is able recompute and update the entries but with no CiteRef left |
353 | 353 | // the last entry will remain and needs to be purged at this point |
354 | - if ( !$this->citationReferencePositionJournal->hasCitationReference( $semanticData ) ) { |
|
354 | + if (!$this->citationReferencePositionJournal->hasCitationReference($semanticData)) { |
|
355 | 355 | $cache->delete( |
356 | - $cacheKeyProvider->getCacheKeyForCitationReference( $hash ) |
|
356 | + $cacheKeyProvider->getCacheKeyForCitationReference($hash) |
|
357 | 357 | ); |
358 | 358 | } |
359 | 359 | |
360 | 360 | $cache->delete( |
361 | - $cacheKeyProvider->getCacheKeyForReferenceList( $hash ) |
|
361 | + $cacheKeyProvider->getCacheKeyForReferenceList($hash) |
|
362 | 362 | ); |
363 | 363 | |
364 | 364 | return true; |
@@ -367,16 +367,16 @@ discard block |
||
367 | 367 | /** |
368 | 368 | * @see https://www.semantic-mediawiki.org/wiki/Hooks#SMW::SQLStore::AfterDeleteSubjectComplete |
369 | 369 | */ |
370 | - $this->handlers['SMW::SQLStore::AfterDeleteSubjectComplete'] = function ( $store, $title ) use ( $cache, $cacheKeyProvider ) { |
|
370 | + $this->handlers['SMW::SQLStore::AfterDeleteSubjectComplete'] = function($store, $title) use ($cache, $cacheKeyProvider) { |
|
371 | 371 | |
372 | - $hash = DIWikiPage::newFromTitle( $title )->getHash(); |
|
372 | + $hash = DIWikiPage::newFromTitle($title)->getHash(); |
|
373 | 373 | |
374 | 374 | $cache->delete( |
375 | - $cacheKeyProvider->getCacheKeyForCitationReference( $hash ) |
|
375 | + $cacheKeyProvider->getCacheKeyForCitationReference($hash) |
|
376 | 376 | ); |
377 | 377 | |
378 | 378 | $cache->delete( |
379 | - $cacheKeyProvider->getCacheKeyForReferenceList( $hash ) |
|
379 | + $cacheKeyProvider->getCacheKeyForReferenceList($hash) |
|
380 | 380 | ); |
381 | 381 | |
382 | 382 | return true; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | /** |
386 | 386 | * @see https://www.semantic-mediawiki.org/wiki/Hooks#SMW::SQLStore::AfterDataUpdateComplete |
387 | 387 | */ |
388 | - $this->handlers['SMW::SQLStore::AfterDataUpdateComplete'] = function ( $store, $semanticData, $compositePropertyTableDiffIterator ) use ( $referenceBacklinksLookup, $options ) { |
|
388 | + $this->handlers['SMW::SQLStore::AfterDataUpdateComplete'] = function($store, $semanticData, $compositePropertyTableDiffIterator) use ($referenceBacklinksLookup, $options) { |
|
389 | 389 | |
390 | - $referenceBacklinksLookup->setStore( $store ); |
|
390 | + $referenceBacklinksLookup->setStore($store); |
|
391 | 391 | |
392 | 392 | $citationTextChangeUpdateJobDispatcher = new CitationTextChangeUpdateJobDispatcher( |
393 | 393 | $store, |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | ); |
396 | 396 | |
397 | 397 | $citationTextChangeUpdateJobDispatcher->setEnabledUpdateJobState( |
398 | - $options->get( 'enabledCitationTextChangeUpdateJob' ) |
|
398 | + $options->get('enabledCitationTextChangeUpdateJob') |
|
399 | 399 | ); |
400 | 400 | |
401 | 401 | $citationTextChangeUpdateJobDispatcher->dispatchUpdateJobFor( |
@@ -409,12 +409,12 @@ discard block |
||
409 | 409 | /** |
410 | 410 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars |
411 | 411 | */ |
412 | - $this->handlers['ResourceLoaderGetConfigVars'] = function ( &$vars ) use ( $options ) { |
|
412 | + $this->handlers['ResourceLoaderGetConfigVars'] = function(&$vars) use ($options) { |
|
413 | 413 | |
414 | 414 | $vars['ext.scite.config'] = [ |
415 | - 'showTooltipForCitationReference' => $options->get( 'showTooltipForCitationReference' ), |
|
416 | - 'tooltipRequestCacheTTL' => $options->get( 'tooltipRequestCacheTTL' ), |
|
417 | - 'cachePrefix' => $options->get( 'cachePrefix' ) |
|
415 | + 'showTooltipForCitationReference' => $options->get('showTooltipForCitationReference'), |
|
416 | + 'tooltipRequestCacheTTL' => $options->get('tooltipRequestCacheTTL'), |
|
417 | + 'cachePrefix' => $options->get('cachePrefix') |
|
418 | 418 | ]; |
419 | 419 | |
420 | 420 | return true; |
@@ -423,20 +423,20 @@ discard block |
||
423 | 423 | /** |
424 | 424 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit |
425 | 425 | */ |
426 | - $this->handlers['ParserFirstCallInit'] = function ( &$parser ) use ( $namespaceExaminer, $options ) { |
|
426 | + $this->handlers['ParserFirstCallInit'] = function(&$parser) use ($namespaceExaminer, $options) { |
|
427 | 427 | |
428 | 428 | $parserFunctionFactory = new ParserFunctionFactory(); |
429 | 429 | |
430 | - list( $name, $definition, $flag ) = $parserFunctionFactory->newSciteParserFunctionDefinition( |
|
430 | + list($name, $definition, $flag) = $parserFunctionFactory->newSciteParserFunctionDefinition( |
|
431 | 431 | $namespaceExaminer, |
432 | 432 | $options |
433 | 433 | ); |
434 | 434 | |
435 | - $parser->setFunctionHook( $name, $definition, $flag ); |
|
435 | + $parser->setFunctionHook($name, $definition, $flag); |
|
436 | 436 | |
437 | - list( $name, $definition, $flag ) = $parserFunctionFactory->newReferenceListParserFunctionDefinition(); |
|
437 | + list($name, $definition, $flag) = $parserFunctionFactory->newReferenceListParserFunctionDefinition(); |
|
438 | 438 | |
439 | - $parser->setFunctionHook( $name, $definition, $flag ); |
|
439 | + $parser->setFunctionHook($name, $definition, $flag); |
|
440 | 440 | |
441 | 441 | return true; |
442 | 442 | }; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param Store $store |
40 | 40 | */ |
41 | - public function __construct( Store $store ) { |
|
41 | + public function __construct(Store $store) { |
|
42 | 42 | $this->store = $store; |
43 | 43 | $this->dataValueFactory = DataValueFactory::getInstance(); |
44 | 44 | } |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return array |
53 | 53 | */ |
54 | - public function findCitationResourceLinks( array $subjects, $linkClass = '', $caption = '' ) { |
|
54 | + public function findCitationResourceLinks(array $subjects, $linkClass = '', $caption = '') { |
|
55 | 55 | |
56 | 56 | $citationResourceLinks = []; |
57 | 57 | |
58 | - foreach ( $subjects as $subject ) { |
|
58 | + foreach ($subjects as $subject) { |
|
59 | 59 | |
60 | 60 | $dataValue = $this->dataValueFactory->newDataItemValue( |
61 | 61 | $subject, |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return array |
86 | 86 | */ |
87 | - public function findMatchForResourceIdentifierTypeToValue( $type, $id = null ) { |
|
87 | + public function findMatchForResourceIdentifierTypeToValue($type, $id = null) { |
|
88 | 88 | |
89 | - if ( $id === null || $id === '' ) { |
|
89 | + if ($id === null || $id === '') { |
|
90 | 90 | return []; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); |
94 | 94 | |
95 | - $resourceIdentifierStringValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( $type ); |
|
96 | - $resourceIdentifierStringValue->setUserValue( $id ); |
|
95 | + $resourceIdentifierStringValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType($type); |
|
96 | + $resourceIdentifierStringValue->setUserValue($id); |
|
97 | 97 | $id = $resourceIdentifierStringValue->getWikiValue(); |
98 | 98 | |
99 | 99 | $description = new SomeProperty( |
100 | 100 | $resourceIdentifierStringValue->getProperty(), |
101 | - new ValueDescription( new DIBlob( $id ) ) |
|
101 | + new ValueDescription(new DIBlob($id)) |
|
102 | 102 | ); |
103 | 103 | |
104 | 104 | $query = new Query( |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | ); |
109 | 109 | |
110 | 110 | $query->querymode = Query::MODE_INSTANCES; |
111 | - $query->setLimit( 10 ); |
|
111 | + $query->setLimit(10); |
|
112 | 112 | |
113 | - if ( defined( 'SMWQuery::NO_CACHE' ) ) { |
|
114 | - $query->setOption( Query::NO_CACHE, true ); |
|
113 | + if (defined('SMWQuery::NO_CACHE')) { |
|
114 | + $query->setOption(Query::NO_CACHE, true); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) { |
|
118 | - $query->setOption( Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder' ); |
|
117 | + if (defined('SMWQuery::PROC_CONTEXT')) { |
|
118 | + $query->setOption(Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder'); |
|
119 | 119 | } |
120 | 120 | |
121 | - return $this->store->getQueryResult( $query )->getResults(); |
|
121 | + return $this->store->getQueryResult($query)->getResults(); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array |
130 | 130 | */ |
131 | - public function findCitationTextFor( $citationReference ) { |
|
131 | + public function findCitationTextFor($citationReference) { |
|
132 | 132 | |
133 | 133 | $text = ''; |
134 | 134 | $subjects = []; |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | $citationReference |
138 | 138 | ); |
139 | 139 | |
140 | - if ( !$queryResult instanceof QueryResult ) { |
|
141 | - return [ $subjects, $text ]; |
|
140 | + if (!$queryResult instanceof QueryResult) { |
|
141 | + return [$subjects, $text]; |
|
142 | 142 | } |
143 | 143 | |
144 | - while ( $resultArray = $queryResult->getNext() ) { |
|
145 | - foreach ( $resultArray as $result ) { |
|
144 | + while ($resultArray = $queryResult->getNext()) { |
|
145 | + foreach ($resultArray as $result) { |
|
146 | 146 | |
147 | 147 | // Collect all subjects for the same reference because it can happen |
148 | 148 | // that the same reference key is used for different citation |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | // text but return all subjects to make it easier to find them later |
151 | 151 | $subjects[] = $result->getResultSubject(); |
152 | 152 | |
153 | - while ( ( $dataValue = $result->getNextDataValue() ) !== false ) { |
|
153 | + while (($dataValue = $result->getNextDataValue()) !== false) { |
|
154 | 154 | $text = $dataValue->getShortWikiText(); |
155 | 155 | } |
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - return [ $subjects, $text ]; |
|
159 | + return [$subjects, $text]; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -168,20 +168,20 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return QueryResult |
170 | 170 | */ |
171 | - public function findMatchForCitationReference( $citationReference ) { |
|
171 | + public function findMatchForCitationReference($citationReference) { |
|
172 | 172 | |
173 | 173 | $description = new SomeProperty( |
174 | - new DIProperty( PropertyRegistry::SCI_CITE_KEY ), |
|
175 | - new ValueDescription( new DIBlob( $citationReference ) ) |
|
174 | + new DIProperty(PropertyRegistry::SCI_CITE_KEY), |
|
175 | + new ValueDescription(new DIBlob($citationReference)) |
|
176 | 176 | ); |
177 | 177 | |
178 | - $propertyValue = $this->dataValueFactory->newDataValueByType( '__pro' ); |
|
178 | + $propertyValue = $this->dataValueFactory->newDataValueByType('__pro'); |
|
179 | 179 | $propertyValue->setDataItem( |
180 | - new DIProperty( PropertyRegistry::SCI_CITE_TEXT ) |
|
180 | + new DIProperty(PropertyRegistry::SCI_CITE_TEXT) |
|
181 | 181 | ); |
182 | 182 | |
183 | 183 | $description->addPrintRequest( |
184 | - new PrintRequest( PrintRequest::PRINT_PROP, null, $propertyValue ) |
|
184 | + new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue) |
|
185 | 185 | ); |
186 | 186 | |
187 | 187 | $query = new Query( |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | ); |
192 | 192 | |
193 | 193 | $query->querymode = Query::MODE_INSTANCES; |
194 | - $query->setLimit( 10 ); |
|
194 | + $query->setLimit(10); |
|
195 | 195 | |
196 | - if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) { |
|
197 | - $query->setOption( Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder' ); |
|
196 | + if (defined('SMWQuery::PROC_CONTEXT')) { |
|
197 | + $query->setOption(Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder'); |
|
198 | 198 | } |
199 | 199 | |
200 | - return $this->store->getQueryResult( $query ); |
|
200 | + return $this->store->getQueryResult($query); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param Store $store |
42 | 42 | * @param ReferenceBacklinksLookup $referenceBacklinksLookup |
43 | 43 | */ |
44 | - public function __construct( Store $store, ReferenceBacklinksLookup $referenceBacklinksLookup ) { |
|
44 | + public function __construct(Store $store, ReferenceBacklinksLookup $referenceBacklinksLookup) { |
|
45 | 45 | $this->store = $store; |
46 | 46 | $this->referenceBacklinksLookup = $referenceBacklinksLookup; |
47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param boolean $enabledUpdateJobState |
53 | 53 | */ |
54 | - public function setEnabledUpdateJobState( $enabledUpdateJobState ) { |
|
54 | + public function setEnabledUpdateJobState($enabledUpdateJobState) { |
|
55 | 55 | $this->enabledUpdateJobState = $enabledUpdateJobState; |
56 | 56 | } |
57 | 57 | |
@@ -63,21 +63,21 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return boolean |
65 | 65 | */ |
66 | - public function dispatchUpdateJobFor( DIWikiPage $subject, ChangeOp $changeOp ) { |
|
66 | + public function dispatchUpdateJobFor(DIWikiPage $subject, ChangeOp $changeOp) { |
|
67 | 67 | |
68 | - if ( !$this->enabledUpdateJobState ) { |
|
68 | + if (!$this->enabledUpdateJobState) { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $tableName = $this->store->getPropertyTableInfoFetcher()->findTableIdForProperty( |
73 | - new DIProperty( PropertyRegistry::SCI_CITE_TEXT ) |
|
73 | + new DIProperty(PropertyRegistry::SCI_CITE_TEXT) |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $subjectIdList = $this->getSubjectListFrom( |
77 | - $changeOp->getOrderedDiffByTable( $tableName ) |
|
77 | + $changeOp->getOrderedDiffByTable($tableName) |
|
78 | 78 | ); |
79 | 79 | |
80 | - if ( ( $jobList = $this->getDispatchableTargetList( $subjectIdList ) ) === [] ) { |
|
80 | + if (($jobList = $this->getDispatchableTargetList($subjectIdList)) === []) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
@@ -93,30 +93,30 @@ discard block |
||
93 | 93 | return true; |
94 | 94 | } |
95 | 95 | |
96 | - private function getSubjectListFrom( array $orderedDiff ) { |
|
96 | + private function getSubjectListFrom(array $orderedDiff) { |
|
97 | 97 | |
98 | 98 | $subjectIdList = []; |
99 | 99 | |
100 | 100 | // Find out whether a cite text object was altered |
101 | - foreach ( $orderedDiff as $key => $value ) { |
|
101 | + foreach ($orderedDiff as $key => $value) { |
|
102 | 102 | |
103 | - if ( strpos( $key, 'sci_cite_text' ) === false ) { |
|
103 | + if (strpos($key, 'sci_cite_text') === false) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | - if ( !isset( $value['delete'] ) ) { |
|
107 | + if (!isset($value['delete'])) { |
|
108 | 108 | $value['delete'] = []; |
109 | 109 | } |
110 | 110 | |
111 | - foreach ( $value['delete'] as $delete ) { |
|
111 | + foreach ($value['delete'] as $delete) { |
|
112 | 112 | $subjectIdList[] = $delete['s_id']; |
113 | 113 | } |
114 | 114 | |
115 | - if ( !isset( $value['insert'] ) ) { |
|
115 | + if (!isset($value['insert'])) { |
|
116 | 116 | $value['insert'] = []; |
117 | 117 | } |
118 | 118 | |
119 | - foreach ( $value['insert'] as $insert ) { |
|
119 | + foreach ($value['insert'] as $insert) { |
|
120 | 120 | $subjectIdList[] = $insert['s_id']; |
121 | 121 | } |
122 | 122 | } |
@@ -124,25 +124,25 @@ discard block |
||
124 | 124 | return $subjectIdList; |
125 | 125 | } |
126 | 126 | |
127 | - private function getDispatchableTargetList( array $subjectIdList ) { |
|
127 | + private function getDispatchableTargetList(array $subjectIdList) { |
|
128 | 128 | |
129 | - if ( $subjectIdList === [] ) { |
|
129 | + if ($subjectIdList === []) { |
|
130 | 130 | return []; |
131 | 131 | } |
132 | 132 | |
133 | - $hashList = $this->store->getObjectIds()->getDataItemPoolHashListFor( $subjectIdList ); |
|
133 | + $hashList = $this->store->getObjectIds()->getDataItemPoolHashListFor($subjectIdList); |
|
134 | 134 | $referenceBacklinks = []; |
135 | 135 | |
136 | - foreach ( $hashList as $hash ) { |
|
136 | + foreach ($hashList as $hash) { |
|
137 | 137 | $referenceBacklinks += $this->referenceBacklinksLookup->findReferenceBacklinksFor( |
138 | - $this->referenceBacklinksLookup->tryToFindCitationKeyFor( DIWikiPage::doUnserialize( $hash ) ) |
|
138 | + $this->referenceBacklinksLookup->tryToFindCitationKeyFor(DIWikiPage::doUnserialize($hash)) |
|
139 | 139 | ); |
140 | 140 | } |
141 | 141 | |
142 | 142 | $targetBatch = []; |
143 | 143 | |
144 | - foreach ( $referenceBacklinks as $referenceBacklink ) { |
|
145 | - $targetBatch[HashBuilder::getHashIdForDiWikiPage( $referenceBacklink )] = true; |
|
144 | + foreach ($referenceBacklinks as $referenceBacklink) { |
|
145 | + $targetBatch[HashBuilder::getHashIdForDiWikiPage($referenceBacklink)] = true; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | return $targetBatch; |