summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/SettingsInfoProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/SettingsInfoProvider.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/SettingsInfoProvider.php89
1 files changed, 89 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/SettingsInfoProvider.php b/www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/SettingsInfoProvider.php
new file mode 100644
index 00000000..6a7cd76e
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/src/Elastic/Admin/SettingsInfoProvider.php
@@ -0,0 +1,89 @@
+<?php
+
+namespace SMW\Elastic\Admin;
+
+use Html;
+use SMW\Elastic\Connection\Client as ElasticClient;
+use WebRequest;
+
+/**
+ * @license GNU GPL v2+
+ * @since 3.0
+ *
+ * @author mwjames
+ */
+class SettingsInfoProvider extends InfoProviderHandler {
+
+ /**
+ * @since 3.0
+ *
+ * {@inheritDoc}
+ */
+ public function getSupplementTask() {
+ return 'settings';
+ }
+
+ /**
+ * @since 3.0
+ *
+ * {@inheritDoc}
+ */
+ public function getHtml() {
+
+ $link = $this->outputFormatter->createSpecialPageLink(
+ $this->msg( 'smw-admin-supplementary-elastic-settings-title' ),
+ [ 'action' => $this->getTask() ]
+ );
+
+ return Html::rawElement(
+ 'li',
+ [],
+ $this->msg(
+ [
+ 'smw-admin-supplementary-elastic-settings-intro',
+ $link
+ ]
+ )
+ );
+ }
+
+ /**
+ * @since 3.0
+ *
+ * {@inheritDoc}
+ */
+ public function handleRequest( WebRequest $webRequest ) {
+
+ $this->outputFormatter->setPageTitle( 'Elasticsearch settings' );
+
+ $this->outputFormatter->addParentLink(
+ [ 'action' => $this->getParentTask() ],
+ 'smw-admin-supplementary-elastic-title'
+ );
+
+ $this->outputInfo();
+ }
+
+ private function outputInfo() {
+
+ $connection = $this->getStore()->getConnection( 'elastic' );
+
+ $settings = [
+ $connection->getSettings(
+ [
+ 'index' => $connection->getIndexNameByType( ElasticClient::TYPE_DATA )
+ ]
+ ),
+ $connection->getSettings(
+ [
+ 'index' => $connection->getIndexNameByType( ElasticClient::TYPE_LOOKUP )
+ ]
+ )
+ ];
+
+ $this->outputFormatter->addAsPreformattedText(
+ $this->outputFormatter->encodeAsJson( $settings )
+ );
+ }
+
+}