From 097ec6ef1acbbce260f98931bfc0874fc5077970 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 28 Nov 2014 15:18:48 +0000 Subject: [PATCH] Add info about current plugin state --- .../Mibew/Controller/PluginController.php | 31 +++++++++++++++++++ .../server_side/plugins.handlebars | 4 +++ 2 files changed, 35 insertions(+) diff --git a/src/mibew/libs/classes/Mibew/Controller/PluginController.php b/src/mibew/libs/classes/Mibew/Controller/PluginController.php index e5950829..a5a97be4 100644 --- a/src/mibew/libs/classes/Mibew/Controller/PluginController.php +++ b/src/mibew/libs/classes/Mibew/Controller/PluginController.php @@ -213,9 +213,40 @@ class PluginController extends AbstractController 'canBeDisabled' => $plugin->canBeDisabled(), 'canBeUninstalled' => $plugin->canBeUninstalled(), 'canBeUpdated' => $plugin->canBeUpdated(), + 'state' => $this->getPluginState($plugin), ); } return $plugins; } + + /** + * Gets string representation of the current plugin state. + * + * @param PluginInfo $plugin Plugin to get state for. + * @return string Human readable representation of plugin's state. + */ + protected function getPluginState(PluginInfo $plugin) + { + if (!$plugin->isEnabled()) { + // The plugin is just disabled + return getlocal('disabled'); + } + + if (PluginManager::getInstance()->hasPlugin($plugin->getName())) { + // The plugin is enabled and works well + return getlocal('working'); + } + + // The plugin is enabled but something is wrong. + if ($plugin->needsUpdate()) { + // The plugin is not working because it needs to be updated. + return getlocal('needs update'); + } + + // Actually we do not know why the plugin does not work. The only thing + // that can be said is the plugin was not initialized correctly by some + // reasons. + return getlocal('not initialized'); + } } diff --git a/src/mibew/styles/pages/default/templates_src/server_side/plugins.handlebars b/src/mibew/styles/pages/default/templates_src/server_side/plugins.handlebars index 97552964..d3faf974 100644 --- a/src/mibew/styles/pages/default/templates_src/server_side/plugins.handlebars +++ b/src/mibew/styles/pages/default/templates_src/server_side/plugins.handlebars @@ -15,6 +15,7 @@ {{l10n "Name"}} {{l10n "Version"}} {{l10n "Dependencies"}} + {{l10n "State"}} {{l10n "Edit"}} @@ -27,6 +28,9 @@ {{#each dependencies}}{{#unless @first}}, {{/unless}}{{@key}}({{this}}){{/each}} + + {{state}} + {{#if enabled}} {{#if canBeDisabled}}