Skip to content

Commit

Permalink
Merge branch 'master' into DropdownIconSplitButtonRelAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
osnard authored Nov 28, 2023
2 parents a84b845 + ef1f667 commit 3bac878
Show file tree
Hide file tree
Showing 142 changed files with 686 additions and 551 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Provides common user interface elements and customizeable stylings.

Add `"mwstake/mediawiki-component-commonuserinterface": "~3.0"` to the `require` section of your `composer.json` file.

Since 3.0 explicit initialization is required. This can be archived by
Since 3.0 explicit initialization is required. This can be achived by
- either adding `"callback": "mwsInitComponents"` to your `extension.json`/`skin.json`
- or calling `mwsInitComponents();` within you extensions/skins custom `callback` method

Expand Down
11 changes: 9 additions & 2 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
return;
}

define( 'MWSTAKE_MEDIAWIKI_COMPONENT_COMMONUSERINTERFACE_VERSION', '3.1.1' );
define( 'MWSTAKE_MEDIAWIKI_COMPONENT_COMMONUSERINTERFACE_VERSION', '3.2.4' );

MWStake\MediaWiki\ComponentLoader\Bootstrapper::getInstance()
->register( 'commonuserinterface', function () {
->register( 'commonuserinterface', static function () {
$lessVars = \MWStake\MediaWiki\Component\CommonUserInterface\LessVars::getInstance();

// Provide the list of values
Expand Down Expand Up @@ -213,6 +213,13 @@
'skinAfterContent' => [],
];

/** Allows to add component filter for rendering components */
$GLOBALS['mwsgCommonUIComponentFilters'] = [
'default' => [
'class' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\ComponentFilter\\DefaultFilter'
]
];

$GLOBALS['mwsgCommonUISkinSlotsEnabled'] = [ 'siteNoticeAfter', 'skinAfterContent' ];

$GLOBALS['wgServiceWiringFiles'][] = __DIR__ . '/includes/ServiceWiring.php';
Expand Down
19 changes: 13 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
"license": "GPL-3.0-only",
"authors": [
{
"name": "BlueSpice",
"email": "[email protected]"
"name": "HalloWelt! GmbH",
"email": "[email protected]",
"homepage": "http://www.hallowelt.com"
}
],
"require": {
"composer/installers": "~1.0|~2",
"mwstake/mediawiki-componentloader": "~1"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "1.0.0",
"jakub-onderka/php-console-highlighter": "0.4.0",
"mediawiki/mediawiki-codesniffer": "29.0.0",
"mediawiki/minus-x": "1.0.0",
"mediawiki/mediawiki-codesniffer": "39.0.0",
"mediawiki/minus-x": "1.1.1",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"php-parallel-lint/php-parallel-lint": "1.3.2",
"phpunit/phpunit": "^8.5"
},
"autoload": {
Expand All @@ -40,5 +42,10 @@
"minus-x fix .",
"phpcbf"
]
},
"config": {
"allow-plugins": {
"composer/installers": true
}
}
}
29 changes: 19 additions & 10 deletions includes/ServiceWiring.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use MediaWiki\MediaWikiServices;
use MWStake\MediaWiki\Component\CommonUserInterface\ComponentFilterFactory;
use MWStake\MediaWiki\Component\CommonUserInterface\ComponentManager;
use MWStake\MediaWiki\Component\CommonUserInterface\ComponentRendererFactory;
use MWStake\MediaWiki\Component\CommonUserInterface\GenericComponentRenderer;
Expand All @@ -13,26 +14,27 @@
use MWStake\MediaWiki\Component\CommonUserInterface\TreeDataGenerator;

return [
'MWStakeCommonUISkinSlotRendererFactory' => function ( MediaWikiServices $services ) {
'MWStakeCommonUISkinSlotRendererFactory' => static function ( MediaWikiServices $services ) {
return new SkinSlotRendererFactory(
$GLOBALS['mwsgCommonUISkinSlotRenderers'],
$services->getObjectFactory()
);
},

'MWStakeCommonUIComponentManager' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIComponentManager' => static function ( MediaWikiServices $services ) {
$componentManager = ComponentManager::singleton(
RequestContext::getMain(),
$GLOBALS['mwsgCommonUISkinSlots'],
$GLOBALS['mwsgCommonUISkinSlotsEnabled'],
$services->get( 'MWStakeCommonUIComponentFilterFactory' ),
$services->getObjectFactory(),
$services->getHookContainer()
);

return $componentManager;
},

'MWStakeCommonUIComponentRendererFactory' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIComponentRendererFactory' => static function ( MediaWikiServices $services ) {
return new ComponentRendererFactory(
$GLOBALS['mwsgCommonUIComponentRendererRegistry'],
$GLOBALS['mwsgCommonUIComponentRegistry'],
Expand All @@ -41,24 +43,24 @@
);
},

'MWStakeCommonUIRendererDataTreeBuilder' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIRendererDataTreeBuilder' => static function ( MediaWikiServices $services ) {
return new RendererDataTreeBuilder(
$services->getService( 'MWStakeCommonUIComponentRendererFactory' )
);
},

'MWStakeCommonUIRendererDataTreeRenderer' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIRendererDataTreeRenderer' => static function ( MediaWikiServices $services ) {
return new RendererDataTreeRenderer(
$services->getService( 'MWStakeCommonUIComponentRendererFactory' )
);
},

'MWStakeCommonUIHtmlIdRegistry' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIHtmlIdRegistry' => static function ( MediaWikiServices $services ) {
$registry = HtmlIdRegistry::singleton();
return $registry;
},

'MWStakeCommonUIGenericComponentRenderer' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIGenericComponentRenderer' => static function ( MediaWikiServices $services ) {
$renderer = new GenericComponentRenderer(
$services->get( 'MWStakeCommonUIComponentManager' ),
$services->get( 'MWStakeCommonUIRendererDataTreeBuilder' ),
Expand All @@ -67,25 +69,32 @@
return $renderer;
},

'MWStakeSkinSlotRegistry' => function ( MediaWikiServices $services ) {
'MWStakeSkinSlotRegistry' => static function ( MediaWikiServices $services ) {
$skinSlotRegistry = SkinSlotRegistry::singleton(
$GLOBALS['mwsgCommonUISkinSlots']
);
return $skinSlotRegistry;
},

'MWStakeLinkFormatter' => function ( MediaWikiServices $services ) {
'MWStakeLinkFormatter' => static function ( MediaWikiServices $services ) {
$linkFormatter = new LinkFormatter(
$services->getMainConfig()->get( 'ExternalLinkTarget' ),
$services->getMainConfig()->get( 'NoFollowLinks' )
);
return $linkFormatter;
},

'MWStakeCommonUITreeDataGenerator' => function ( MediaWikiServices $services ) {
'MWStakeCommonUITreeDataGenerator' => static function ( MediaWikiServices $services ) {
return new TreeDataGenerator(
$GLOBALS['mwsgCommonUIComponentTreeNodeRegistry'],
$services->getObjectFactory()
);
},

'MWStakeCommonUIComponentFilterFactory' => static function ( MediaWikiServices $services ) {
return new ComponentFilterFactory(
$GLOBALS['mwsgCommonUIComponentFilters'],
$services->getObjectFactory()
);
},
];
4 changes: 2 additions & 2 deletions resources/templates/tree-link-node.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<li{{#id}} id="{{.}}"{{/id}} class="mws-tree-item{{class}}" {{#role}} role="{{.}}"{{/role}}>
<div>
{{#expandBtn}}<a class="mws-tree-expander{{class}}" aria-expanded="{{expanded}}" role="button" tabindex="0" aria-label="{{text}}"{{#id}} aria-controlls="{{.}}-children"{{/id}}{{#hasChildren}} aria-haspopup="true"{{/hasChildren}}></a>{{/expandBtn}}<a id="{{labelId}}" class="mws-tree-item-label{{#isNew}} new{{/isNew}}" href="{{href}}"{{#title}} title="{{{.}}}"{{/title}}{{#rel}} rel="{{{.}}}"{{/rel}}{{#target}} target="{{{.}}}"{{/target}}>{{text}}</a>
{{#expandBtn}}<a class="mws-tree-expander{{class}}" aria-expanded="{{expanded}}" role="button" tabindex="0" aria-label="{{text}}"{{#id}} aria-controlls="{{.}}-children"{{/id}}{{#hasChildren}} aria-haspopup="true"{{/hasChildren}}></a>{{/expandBtn}}<a id="{{labelId}}" class="mws-tree-item-label{{#isNew}} new{{/isNew}}" href="{{href}}"{{#title}} title="{{{.}}}"{{/title}}{{#rel}} rel="{{{.}}}"{{/rel}}{{#target}} target="{{{.}}}"{{/target}}>{{{text}}}</a>
</div>
{{#hasChildren}}
<div class="mws-tree-cnt{{#expanded}} show{{/expanded}}" role="tree" aria-labelledby="{{labelId}}" aria-expanded="expanded" tabindex="0">
Expand All @@ -9,4 +9,4 @@
</ul>
</div>
{{/hasChildren}}
</li>
</li>
4 changes: 2 additions & 2 deletions src/AriaAttributesBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static function factory() {
* @param array $data
* @return array
*/
public function build( $data ) : array {
public function build( $data ): array {
$attribs = [];

foreach ( $data as $key => $value ) {
Expand All @@ -35,7 +35,7 @@ public function build( $data ) : array {
* @param array $data
* @return string
*/
public function toString( $data ) : string {
public function toString( $data ): string {
$attribs = $this->build( $data );

return implode( ' ', $attribs );
Expand Down
6 changes: 3 additions & 3 deletions src/Component/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ public function __construct( $options ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->options['id'];
}

/**
* @inheritDoc
*/
public function getClasses() : array {
public function getClasses(): array {
return $this->options['classes'];
}

/**
* @inheritDoc
*/
public function getText() : Message {
public function getText(): Message {
return $this->options['text'];
}
}
4 changes: 2 additions & 2 deletions src/Component/CallbackLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct( $id, $callback ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->id;
}

Expand All @@ -40,7 +40,7 @@ public function getId() : string {
*
* @return string
*/
public function getHtml() : string {
public function getHtml(): string {
return call_user_func_array( $this->callback, [ $this->componentProcessData ] );
}
}
10 changes: 5 additions & 5 deletions src/Component/ComponentBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ abstract class ComponentBase implements IComponent {
*
* @inheritDoc
*/
public function getRequiredRLModules() : array {
public function getRequiredRLModules(): array {
return [];
}

/**
*
* @inheritDoc
*/
public function getRequiredRLStyles() : array {
public function getRequiredRLStyles(): array {
return [];
}

/**
*
* @inheritDoc
*/
public function getSubComponents() : array {
public function getSubComponents(): array {
return [];
}

/**
*
* @inheritDoc
*/
public function shouldRender( IContextSource $context ) : bool {
public function shouldRender( IContextSource $context ): bool {
return true;
}

Expand All @@ -51,7 +51,7 @@ public function shouldRender( IContextSource $context ) : bool {
* Usually this is SkinTemplate's `$tpl->data`
* @return void
*/
public function setComponentData( $data ) : void {
public function setComponentData( $data ): void {
$this->componentProcessData = $data;
}
}
4 changes: 2 additions & 2 deletions src/Component/Literal.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct( $id, $html ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->id;
}

Expand All @@ -40,7 +40,7 @@ public function getId() : string {
*
* @return string
*/
public function getHtml() : string {
public function getHtml(): string {
return $this->html;
}
}
4 changes: 2 additions & 2 deletions src/Component/MessageLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public function __construct( $id, $msg ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->id;
}

/**
*
* @return Message
*/
public function getText() : Message {
public function getText(): Message {
return $this->msg;
}
}
4 changes: 2 additions & 2 deletions src/Component/NullComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public function __construct( $id = 'null-component' ) {
/**
* @return string
*/
public function getId() : string {
public function getId(): string {
return $this->id;
}

/**
* @param IContextSource $context
* @return bool
*/
public function shouldRender( IContextSource $context ) : bool {
public function shouldRender( IContextSource $context ): bool {
return false;
}
}
Loading

0 comments on commit 3bac878

Please sign in to comment.