Add info about current plugin state

This commit is contained in:
Dmitriy Simushev 2014-11-28 15:18:48 +00:00
parent 2bdfebc428
commit 097ec6ef1a
2 changed files with 35 additions and 0 deletions

View File

@ -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');
}
}

View File

@ -15,6 +15,7 @@
<th>{{l10n "Name"}}</th>
<th>{{l10n "Version"}}</th>
<th>{{l10n "Dependencies"}}</th>
<th>{{l10n "State"}}</th>
<th>{{l10n "Edit"}}</th>
</tr>
</thead>
@ -27,6 +28,9 @@
<td class="notlast">
{{#each dependencies}}{{#unless @first}}, {{/unless}}{{@key}}({{this}}){{/each}}
</td>
<td class="notlast">
{{state}}
</td>
<td>
{{#if enabled}}
{{#if canBeDisabled}}