jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/404654 )
Change subject: New registratrion for WikiAdmin modules ...................................................................... New registratrion for WikiAdmin modules * new interface IAdminTool * new admin tool registration WikiAdmin extension will not be part of BlueSpice 3. Extensions can be registered as admin-tool for later use with this modification. patch set 2: changes in AddAdminTools for link definition Change-Id: If8858dc3837de73ec5935b21518f77b7bac787c8 --- M extension.json M includes/ServiceWiring.php A src/AdminToolRegistry.php A src/Hook/SkinTemplateOutputPageBeforeExec/AddAdminTools.php A src/IAdminTool.php M src/Services.php A src/SkinData.php 7 files changed, 147 insertions(+), 4 deletions(-) Approvals: Robert Vogel: Looks good to me, approved jenkins-bot: Verified diff --git a/extension.json b/extension.json index f458e35..96a0277 100644 --- a/extension.json +++ b/extension.json @@ -27,7 +27,8 @@ }, "EntityRegistry": {}, "GraphicalListRegistry": {}, - "ExtendedSiteToolsRegistry": {} + "ExtendedSiteToolRegistry": {}, + "AdminToolRegistry": {} } }, "ExtensionFunctions": [ @@ -450,7 +451,10 @@ "UserGetRights": "BsCoreHooks::onUserGetRights", "userCan": "BsCoreHooks::onUserCan", "UploadVerification": "BsCoreHooks::onUploadVerification", - "SkinTemplateOutputPageBeforeExec": "BsCoreHooks::onSkinTemplateOutputPageBeforeExec", + "SkinTemplateOutputPageBeforeExec": [ + "BsCoreHooks::onSkinTemplateOutputPageBeforeExec", + "\\BlueSpice\\Hook\\SkinTemplateOutputPageBeforeExec\\AddAdminTools::callback" + ], "SkinAfterContent": "BsCoreHooks::onSkinAfterContent", "ParserFirstCallInit": "BsCoreHooks::onParserFirstCallInit", "ExtensionTypes": "BsCoreHooks::onExtensionTypes", diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index cc15ae4..397ffa1 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -57,4 +57,9 @@ $services->getConfigFactory()->makeConfig( 'bsg' ) ); }, + + 'BSAdminToolRegistry' => function ( MediaWikiServices $services ) { + $attribute = \ExtensionRegistry::getInstance()->getAttribute( 'BlueSpiceFoundationAdminToolRegistry' ); + return new \BlueSpice\AdminToolRegistry( $attribute ); + } ]; diff --git a/src/AdminToolRegistry.php b/src/AdminToolRegistry.php new file mode 100644 index 0000000..ec48572 --- /dev/null +++ b/src/AdminToolRegistry.php @@ -0,0 +1,27 @@ +<?php + +namespace BlueSpice; + +class AdminToolRegistry { + protected $classes = []; + + public function __construct( $classes ) { + $this->classes = $classes; + } + + /** + * @return IAdminTool[] + */ + public function getAll() { + $adminTools = []; + foreach( $this->classes as $toolId => $callback ) { + $tool = new $callback(); + if( $tool instanceof IAdminTool === false ) { + throw new MWException( "Class for tool '$toolId' does not implement IAdminTool" ); + } + $adminTools[$toolId] = $tool; + } + + return $adminTools; + } +} \ No newline at end of file diff --git a/src/Hook/SkinTemplateOutputPageBeforeExec/AddAdminTools.php b/src/Hook/SkinTemplateOutputPageBeforeExec/AddAdminTools.php new file mode 100644 index 0000000..7969fd8 --- /dev/null +++ b/src/Hook/SkinTemplateOutputPageBeforeExec/AddAdminTools.php @@ -0,0 +1,36 @@ +<?php + +namespace BlueSpice\Hook\SkinTemplateOutputPageBeforeExec; + +use BlueSpice\Hook\SkinTemplateOutputPageBeforeExec; +use BlueSpice\SkinData; + +class AddAdminTools extends SkinTemplateOutputPageBeforeExec { + protected function doProcess() { + $registry = $this->getServices()->getBSAdminToolRegistry(); + $adminTools = $registry->getAll(); + + foreach( $adminTools as $toolId => $tool ) { + $this->template->data[SkinData::ADMIN_LINKS][$toolId] + = $this->makeLinkDesc( $tool ); + } + } + + /** + * + * @param \BlueSpice\IAdminTool $tool + * @return array + */ + protected function makeLinkDesc( $tool ) { + $link = [ + 'title' => $tool->getDescription(), + 'text' => $tool->getName(), + 'href' => $tool->getURL(), + 'classes' => $tool->getClasses(), + 'data' => $tool->getDataAttributes(), + + ]; + return $link; + } + +} \ No newline at end of file diff --git a/src/IAdminTool.php b/src/IAdminTool.php new file mode 100644 index 0000000..eafd8f7 --- /dev/null +++ b/src/IAdminTool.php @@ -0,0 +1,37 @@ +<?php + +namespace BlueSpice; + +interface IAdminTool { + + /** + * @return string + */ + public function getURL(); + + /** + * @return \Message + */ + public function getDescription(); + + /** + * @return \Message + */ + public function getName(); + + /** + * @return string + */ + public function getClasses(); + + /** + * @return array + */ + public function getDataAttributes(); + + /** + * @return array + */ + public function getPermissions(); + +} diff --git a/src/Services.php b/src/Services.php index 5ce168e..f7c3688 100644 --- a/src/Services.php +++ b/src/Services.php @@ -2,8 +2,6 @@ namespace BlueSpice; -use MediaWiki\MediaWikiServices; - class Services extends ServicesDecorator { /** @@ -69,4 +67,12 @@ public function getBSEntityFactory() { return $this->decoratedServices->getService( 'BSEntityFactory' ); } + + /** + * + * @return AdminToolRegistry + */ + public function getBSAdminToolRegistry() { + return $this->decoratedServices->getService( 'BSAdminToolRegistry' ); + } } \ No newline at end of file diff --git a/src/SkinData.php b/src/SkinData.php new file mode 100644 index 0000000..9108206 --- /dev/null +++ b/src/SkinData.php @@ -0,0 +1,28 @@ +<?php + +namespace BlueSpice; + +/** + * Data fields for BlueSpice skin + */ +class SkinData { + + const FEATURED_ACTIONS = 'bs_featured_actions'; + + const SITE_NAV = 'bs_navigation_main'; + + const GLOBAL_ACTIONS_PANEL = 'bs_global_actions_panel'; + const ADMIN_LINKS = 'bs_admin_links'; + const GLOBAL_ACTIONS = 'bs_global_actions'; + + const SITE_TOOLS = 'bs_sitetools_main'; + const PAGE_SETTINGS_PANEL = 'bs_page_settings_panel'; + const PAGE_SETTINGS = 'bs_page_settings'; + const PAGE_INFOS_PANEL = 'bs_page_infos_panel'; + const PAGE_INFOS = 'bs_page_infos'; + const PAGE_DOCUMENTS_PANEL = 'bs_page_documents_panel'; + const PAGE_DOCUMENTS = 'bs_page_documents'; + const PAGE_TOOLS_PANEL = 'bs_page_tools_panel'; + const PAGE_TOOLS = 'bs_page_tools'; + +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/404654 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If8858dc3837de73ec5935b21518f77b7bac787c8 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation Gerrit-Branch: master Gerrit-Owner: Dvogel hallowelt <daniel.vo...@hallowelt.com> Gerrit-Reviewer: Ljonka <l.verhovs...@gmail.com> Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz> Gerrit-Reviewer: Pwirth <wi...@hallowelt.biz> Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits