@@ -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 | }; |