diff --git a/admin_phpsettings.php b/admin_phpsettings.php index dc5a6063..f1568b4d 100644 --- a/admin_phpsettings.php +++ b/admin_phpsettings.php @@ -183,25 +183,21 @@ if ($page == 'overview') { if ($action == '') { try { - $json_result = FpmDaemons::getLocal($userinfo)->listing(); + $fpmconf_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.fpmconfigs.php'; + $collection = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\FpmDaemons::class, $userinfo)) + ->withPagination($fpmconf_list_data['fpmconf_list']['columns']); } catch (Exception $e) { \Froxlor\UI\Response::dynamic_error($e->getMessage()); } - $result = json_decode($json_result, true)['data']; - $tablecontent = ''; - $count = 0; - if (isset($result['count']) && $result['count'] > 0) { - foreach ($result['list'] as $row) { - $configs = ""; - foreach ($row['configs'] as $configused) { - $configs .= $configused . "
"; - } - $count++; - eval("\$tablecontent.=\"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmdaemons_overview") . "\";"); - } - } - eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmdaemons") . "\";"); + UI::twigBuffer('user/table.html.twig', [ + 'listing' => \Froxlor\UI\Listing::format($collection, $fpmconf_list_data['fpmconf_list']), + 'actions_links' => [[ + 'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']), + 'label' => $lng['admin']['fpmsettings']['addnew'] + ]] + ]); + UI::twigOutputBuffer(); } if ($action == 'add') { diff --git a/lib/Froxlor/UI/Callbacks/PHPConf.php b/lib/Froxlor/UI/Callbacks/PHPConf.php index f4b657c5..3dec2a78 100644 --- a/lib/Froxlor/UI/Callbacks/PHPConf.php +++ b/lib/Froxlor/UI/Callbacks/PHPConf.php @@ -38,6 +38,15 @@ class PHPConf return $domains; } + public static function configsList(array $attributes) + { + $configs = ""; + foreach ($attributes['fields']['configs'] as $configused) { + $configs .= $configused . "
"; + } + return $configs; + } + public static function isNotDefault(array $attributes) { return $attributes['fields']['id'] != 1; diff --git a/lib/tablelisting/admin/tablelisting.fpmconfigs.php b/lib/tablelisting/admin/tablelisting.fpmconfigs.php new file mode 100644 index 00000000..e9603153 --- /dev/null +++ b/lib/tablelisting/admin/tablelisting.fpmconfigs.php @@ -0,0 +1,81 @@ + (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Tabellisting + * + */ + +use Froxlor\UI\Callbacks\PHPConf; +use Froxlor\UI\Listing; + +return [ + 'fpmconf_list' => [ + 'title' => $lng['menue']['phpsettings']['fpmdaemons'], + 'icon' => 'fa-brands fa-php', + 'columns' => [ + 'description' => [ + 'label' => $lng['admin']['phpsettings']['description'], + 'field' => 'description', + ], + 'configs' => [ + 'label' => $lng['admin']['phpsettings']['activephpconfigs'], + 'field' => 'configs', + 'text' => [PHPConf::class, 'configsList'] + ], + 'reload_cmd' => [ + 'label' => $lng['serversettings']['phpfpm_settings']['reload'], + 'field' => 'reload_cmd' + ], + 'config_dir' => [ + 'label' => $lng['serversettings']['phpfpm_settings']['configdir'], + 'field' => 'config_dir' + ], + 'pm' => [ + 'label' => $lng['serversettings']['phpfpm_settings']['configdir'], + 'field' => 'pm', + ], + ], + 'visible_columns' => Listing::getVisibleColumnsForListing('fpmconf_list', [ + 'description', + 'configs', + 'reload_cmd', + 'config_dir', + 'pm' + ]), + 'actions' => [ + 'edit' => [ + 'icon' => 'fa fa-edit', + 'title' => $lng['panel']['edit'], + 'href' => [ + 'section' => 'phpsettings', + 'page' => 'fpmdaemons', + 'action' => 'edit', + 'id' => ':id' + ], + ], + 'delete' => [ + 'icon' => 'fa fa-trash', + 'title' => $lng['panel']['delete'], + 'class' => 'text-danger', + 'href' => [ + 'section' => 'phpsettings', + 'page' => 'fpmdaemons', + 'action' => 'delete', + 'id' => ':id' + ], + 'visible' => [PHPConf::class, 'isNotDefault'] + ] + ] + ] +];