diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/NodesInfoProvider.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/NodesInfoProvider.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/NodesInfoProvider.php b/www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/NodesInfoProvider.php new file mode 100644 index 00000000..ac3f6007 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/NodesInfoProvider.php @@ -0,0 +1,78 @@ +<?php + +namespace SMW\Elastic\Admin; + +use Html; +use WebRequest; + +/** + * @license GNU GPL v2+ + * @since 3.0 + * + * @author mwjames + */ +class NodesInfoProvider extends InfoProviderHandler { + + /** + * @since 3.0 + * + * @return string + */ + public function getSupplementTask() { + return 'nodes'; + } + + /** + * @since 3.0 + * + * {@inheritDoc} + */ + public function getHtml() { + + $link = $this->outputFormatter->createSpecialPageLink( + $this->msg( 'smw-admin-supplementary-elastic-nodes-title' ), + [ 'action' => $this->getTask() ] + ); + + return Html::rawElement( + 'li', + [], + $this->msg( + [ + 'smw-admin-supplementary-elastic-nodes-intro', + $link + ] + ) + ); + } + + /** + * @since 3.0 + * + * {@inheritDoc} + */ + public function handleRequest( WebRequest $webRequest ) { + + $this->outputFormatter->setPageTitle( 'Elasticsearch nodes' ); + + $this->outputFormatter->addParentLink( + [ 'action' => $this->getParentTask() ], + 'smw-admin-supplementary-elastic-title' + ); + + $this->outputInfo(); + } + + private function outputInfo() { + + $connection = $this->getStore()->getConnection( 'elastic' ); + + $nodes = $connection->stats( 'nodes' ); + ksort( $nodes ); + + $this->outputFormatter->addAsPreformattedText( + $this->outputFormatter->encodeAsJson( $nodes ) + ); + } + +} |