Download plugins/CorePluginsAdmin/Commands/ListPlugins.php from Leon4gr45/matomo: direct link, hf CLI and curl.
- Browser
- Download file 3.43 kB
-
https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/plugins/CorePluginsAdmin/Commands/ListPlugins.php
- Command line
-
hf download hf://spaces/Leon4gr45/matomo/plugins/CorePluginsAdmin/Commands/ListPlugins.php
-
curl -L -o ListPlugins.php https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/plugins/CorePluginsAdmin/Commands/ListPlugins.php
3.43 kB
| /** | |
| * Matomo - free/libre analytics platform | |
| * | |
| * @link https://matomo.org | |
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | |
| */ | |
| namespace Piwik\Plugins\CorePluginsAdmin\Commands; | |
| use Piwik\Plugin\ConsoleCommand; | |
| use Piwik\Plugin\Manager; | |
| /** | |
| * plugin:list console command. | |
| */ | |
| class ListPlugins extends ConsoleCommand | |
| { | |
| protected function configure() | |
| { | |
| $this->setName('plugin:list'); | |
| $this->setDescription('List installed plugins.'); | |
| $this->addOptionalValueOption('filter-plugin', null, 'If given, prints only plugins that contain this term.'); | |
| $this->addNoValueOption('json', null, 'If given, outputs JSON formatted data.'); | |
| } | |
| protected function doExecute(): int | |
| { | |
| $pluginManager = Manager::getInstance(); | |
| $plugins = $pluginManager->getInstalledPluginsName(); | |
| $pluginFilter = $this->getInput()->getOption('filter-plugin'); | |
| if (!empty($pluginFilter)) { | |
| $plugins = array_filter($plugins, function ($pluginName) use ($pluginFilter) { | |
| return strpos($pluginName, $pluginFilter) !== false; | |
| }); | |
| } | |
| $verbose = $this->getOutput()->isVerbose(); | |
| $plugins = array_map(function ($plugin) use ($pluginManager, $verbose) { | |
| $pluginInformation = array( | |
| "plugin" => $plugin, | |
| "core" => $pluginManager->isPluginBundledWithCore($plugin), | |
| "activated" => !$pluginManager->isPluginInFilesystem($plugin) ? null : $pluginManager->isPluginActivated($plugin), | |
| ); | |
| if ($verbose) { | |
| $pluginInformation["version"] = $pluginManager->getVersion($plugin); | |
| } | |
| return $pluginInformation; | |
| }, $plugins); | |
| if ($this->getInput()->getOption('json')) { | |
| $plugins = array_map(function ($plugin) { | |
| $plugin["comment"] = !isset($plugin["activated"]) ? 'Plugin not found in filesystem.' : ''; | |
| if (isset($plugin["version"]) && !isset($plugin["activated"])) { | |
| $plugin["version"] = ''; | |
| } | |
| return $plugin; | |
| }, $plugins); | |
| // write JSON output | |
| $this->getOutput()->write(json_encode($plugins)); | |
| } else { | |
| // Decorate the plugin information | |
| $plugins = array_map(function ($plugin) { | |
| $plugin["plugin"] = self::wrapInTag('info', $plugin["plugin"]); | |
| $plugin["core"] = $plugin["core"] ? 'Core' : 'Optional'; | |
| if (isset($plugin["version"]) && !isset($plugin["activated"])) { | |
| $plugin["version"] = ''; | |
| } | |
| $plugin["activated"] = !isset($plugin["activated"]) ? self::wrapInTag('error', 'Not found') : ($plugin["activated"] ? 'Activated' : self::wrapInTag('comment', 'Not activated')); | |
| return $plugin; | |
| }, $plugins); | |
| // Sort Core plugins first | |
| uasort($plugins, function ($a, $b) { | |
| return strcmp($a["core"], $b["core"]); | |
| }); | |
| if (!$verbose) { | |
| $this->renderTable(['Plugin', 'Core or optional?', 'Status'], $plugins); | |
| } else { | |
| $this->renderTable(['Plugin', 'Core or optional?', 'Status', 'Version'], $plugins); | |
| } | |
| } | |
| return self::SUCCESS; | |
| } | |
| } | |