-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
910 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"linkTargetSitelinkSiteId": "enwiki" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,25 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: '#^Call to method addHTML\(\) on an unknown class OutputPage\.$#' | ||
identifier: class.notFound | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
|
||
- | ||
message: '#^Call to method addModuleStyles\(\) on an unknown class OutputPage\.$#' | ||
identifier: class.notFound | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
|
||
- | ||
message: '#^Call to method getNamespace\(\) on an unknown class Title\.$#' | ||
identifier: class.notFound | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
|
||
- | ||
message: '#^Call to static method element\(\) on an unknown class Html\.$#' | ||
identifier: class.notFound | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
|
||
- | ||
message: '#^Constant WB_NS_ITEM not found\.$#' | ||
identifier: constant.notFound | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
|
||
- | ||
message: '#^Parameter \$output of method ProfessionalWiki\\WikibaseFacetedSearch\\EntryPoints\\WikibaseFacetedSearchHooks\:\:onSpecialSearchResultsAppend\(\) has invalid type OutputPage\.$#' | ||
identifier: class.notFound | ||
message: '#^Parameter \#1 \$configArray of method ProfessionalWiki\\WikibaseFacetedSearch\\Persistence\\ConfigDeserializer\:\:newConfig\(\) expects array\<string, mixed\>, array\<mixed, mixed\> given\.$#' | ||
identifier: argument.type | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
path: src/Persistence/ConfigDeserializer.php | ||
|
||
- | ||
message: '#^Parameter \$specialSearch of method ProfessionalWiki\\WikibaseFacetedSearch\\EntryPoints\\WikibaseFacetedSearchHooks\:\:onShowSearchHitTitle\(\) has invalid type SpecialSearch\.$#' | ||
identifier: class.notFound | ||
message: '#^Parameter \$linkTargetSitelinkSiteId of class ProfessionalWiki\\WikibaseFacetedSearch\\Application\\Config constructor expects string\|null, mixed given\.$#' | ||
identifier: argument.type | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
path: src/Persistence/ConfigDeserializer.php | ||
|
||
- | ||
message: '#^Parameter \$specialSearch of method ProfessionalWiki\\WikibaseFacetedSearch\\EntryPoints\\WikibaseFacetedSearchHooks\:\:onSpecialSearchResultsAppend\(\) has invalid type SpecialSearch\.$#' | ||
identifier: class.notFound | ||
message: '#^Cannot cast mixed to string\.$#' | ||
identifier: cast.string | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
|
||
- | ||
message: '#^Parameter \$title of method ProfessionalWiki\\WikibaseFacetedSearch\\EntryPoints\\WikibaseFacetedSearchHooks\:\:onShowSearchHitTitle\(\) has invalid type Title\.$#' | ||
identifier: class.notFound | ||
count: 1 | ||
path: src/EntryPoints/WikibaseFacetedSearchHooks.php | ||
path: src/WikibaseFacetedSearchExtension.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"linkTargetSitelinkSiteId": { | ||
"type": [ | ||
"string", | ||
"null" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare( strict_types = 1 ); | ||
|
||
namespace ProfessionalWiki\WikibaseFacetedSearch\Application; | ||
|
||
class Config { | ||
|
||
public function __construct( | ||
public readonly ?string $linkTargetSitelinkSiteId = null | ||
) { | ||
} | ||
|
||
public function combine( Config $config ): self { | ||
return new Config( | ||
$config->linkTargetSitelinkSiteId ?? $this->linkTargetSitelinkSiteId | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare( strict_types = 1 ); | ||
|
||
namespace ProfessionalWiki\WikibaseFacetedSearch\EntryPoints; | ||
|
||
use Message; | ||
use ProfessionalWiki\WikibaseFacetedSearch\WikibaseFacetedSearchExtension; | ||
use SpecialPage; | ||
use Title; | ||
|
||
class SpecialWikibaseFacetedSearchConfig extends SpecialPage { | ||
|
||
public function __construct() { | ||
parent::__construct( 'WikibaseFacetedSearchConfig' ); | ||
} | ||
|
||
public function execute( $subPage ): void { | ||
parent::execute( $subPage ); | ||
|
||
$title = Title::newFromText( WikibaseFacetedSearchExtension::CONFIG_PAGE_TITLE, NS_MEDIAWIKI ); | ||
|
||
if ( $title instanceof Title ) { | ||
$this->getOutput()->redirect( $title->getFullURL() ); | ||
} | ||
} | ||
|
||
public function getGroupName(): string { | ||
return 'wikibase'; | ||
} | ||
|
||
public function getDescription(): Message { | ||
return $this->msg( 'special-wikibase-faceted-search-config' ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare( strict_types = 1 ); | ||
|
||
namespace ProfessionalWiki\WikibaseFacetedSearch\Persistence; | ||
|
||
use ProfessionalWiki\WikibaseFacetedSearch\Application\Config; | ||
|
||
/** | ||
* Combines these config sources, with the latter overriding the former: | ||
* * Defaults | ||
* * $baseConfig (LocalSettings.php) | ||
* * ConfigLookup (MediaWiki:WikibaseFacetedSearch) | ||
*/ | ||
class CombiningConfigLookup implements ConfigLookup { | ||
|
||
public function __construct( | ||
private readonly string $baseConfig, | ||
private readonly ConfigDeserializer $deserializer, | ||
private readonly ConfigLookup $configLookup, | ||
private readonly bool $enableWikiConfig | ||
) { | ||
} | ||
|
||
public function getConfig(): Config { | ||
$config = $this->createDefaultConfig()->combine( | ||
$this->deserializer->deserialize( $this->baseConfig ) | ||
); | ||
|
||
if ( !$this->enableWikiConfig ) { | ||
return $config; | ||
} | ||
|
||
return $config->combine( $this->configLookup->getConfig() ); | ||
} | ||
|
||
private function createDefaultConfig(): Config { | ||
return new Config(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare( strict_types = 1 ); | ||
|
||
namespace ProfessionalWiki\WikibaseFacetedSearch\Persistence; | ||
|
||
use ProfessionalWiki\WikibaseFacetedSearch\Application\Config; | ||
|
||
class ConfigDeserializer { | ||
|
||
public function __construct( | ||
private readonly ConfigJsonValidator $validator | ||
) { | ||
} | ||
|
||
public function deserialize( string $configJson ): Config { | ||
if ( $this->validator->validate( $configJson ) ) { | ||
$configArray = json_decode( $configJson, true ); | ||
|
||
if ( is_array( $configArray ) ) { | ||
return $this->newConfig( $configArray ); | ||
} | ||
} | ||
|
||
return new Config(); | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $configArray | ||
*/ | ||
private function newConfig( array $configArray ): Config { | ||
return new Config( | ||
linkTargetSitelinkSiteId: $configArray['linkTargetSitelinkSiteId'] ?? null, | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.