diff --git a/admin_settings.php b/admin_settings.php index 6c9fed4d..f5583e56 100644 --- a/admin_settings.php +++ b/admin_settings.php @@ -267,14 +267,31 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') { )); } - $integritycheck = ''; + $integritycheck = []; foreach ($integrity->available as $id => $check) { - $displayid = $id + 1; - $result = $integrity->$check(); - $checkdesc = $lng['integrity_check'][$check]; - eval("\$integritycheck.=\"" . \Froxlor\UI\Template::getTemplate("settings/integritycheck_row") . "\";"); + $integritycheck[] = [ + 'displayid' => $id + 1, + 'result' => $integrity->$check(), + 'checkdesc' => $lng['integrity_check'][$check] + ]; } - eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/integritycheck") . "\";"); + + $integrity_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.integrity.php'; + $collection = [ + 'data' => $integritycheck, + 'pagination' => [] + ]; + + UI::twigBuffer('user/table.html.twig', [ + 'listing' => \Froxlor\UI\Listing::formatFromArray($collection, $integrity_list_data['integrity_list']), + 'actions_links' => [[ + 'href' => $linker->getLink(['section' => 'settings', 'page' => $page, 'action' => 'fix']), + 'label' => $lng['admin']['integrityfix'], + 'icon' => 'fa-solid fa-screwdriver-wrench', + 'class' => 'btn-warning' + ]] + ]); + UI::twigOutputBuffer(); } elseif ($page == 'importexport' && $userinfo['change_serversettings'] == '1') { // check for json-stuff if (!extension_loaded('json')) { diff --git a/api_keys.php b/api_keys.php index 6d30636b..9dcafaaa 100644 --- a/api_keys.php +++ b/api_keys.php @@ -165,26 +165,25 @@ $keys_stmt = Database::prepare($keys_stmt_query); Database::pexecute($keys_stmt, $qry_params); $all_keys = $keys_stmt->fetchAll(PDO::FETCH_ASSOC); -if (count($all_keys) == 0) { - $count = 0; - $message = $lng['apikeys']['no_api_keys']; - $sortcode = ""; - $searchcode = ""; - $pagingcode = ""; - eval("\$apikeys.=\"" . \Froxlor\UI\Template::getTemplate("api_keys/keys_error", true) . "\";"); -} - $apikeys_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.apikeys.php'; $collection = [ 'data' => $all_keys, 'pagination' => [] ]; -UI::twigBuffer('user/table.html.twig', [ +$tpl = 'user/table.html.twig'; +if (!empty($success_message)) { + $tpl = 'user/table-note.html.twig'; +} + +UI::twigBuffer($tpl, [ 'listing' => \Froxlor\UI\Listing::formatFromArray($collection, $apikeys_list_data['apikeys_list']), 'actions_links' => (int)$userinfo['api_allowed'] == 1 ? [[ 'href' => $linker->getLink(['section' => 'index', 'page' => $page, 'action' => 'add']), 'label' => $lng['apikeys']['key_add'] - ]] : null + ]] : null, + // alert-box + 'type' => 'success', + 'alert_msg' => $success_message ]); UI::twigOutputBuffer(); diff --git a/lib/Froxlor/UI/Callbacks/Style.php b/lib/Froxlor/UI/Callbacks/Style.php index ee9d7ba3..d34b521e 100644 --- a/lib/Froxlor/UI/Callbacks/Style.php +++ b/lib/Froxlor/UI/Callbacks/Style.php @@ -29,6 +29,11 @@ class Style return $attributes['fields']['deactivated'] ? 'bg-danger' : ''; } + public static function resultIntegrityBad(array $attributes): string + { + return $attributes['fields']['result'] ? '' : 'bg-warning'; + } + public static function invalidApiKey(array $attributes): string { // check whether the api key is not valid anymore diff --git a/lib/tablelisting/admin/tablelisting.admins.php b/lib/tablelisting/admin/tablelisting.admins.php index a4004d8a..e0d9e832 100644 --- a/lib/tablelisting/admin/tablelisting.admins.php +++ b/lib/tablelisting/admin/tablelisting.admins.php @@ -93,7 +93,7 @@ return [ ], ], ], - 'callback' => [ + 'format_callback' => [ [Style::class, 'deactivated'], [Style::class, 'diskspaceWarning'], [Style::class, 'trafficWarning'] diff --git a/lib/tablelisting/admin/tablelisting.integrity.php b/lib/tablelisting/admin/tablelisting.integrity.php new file mode 100644 index 00000000..d0e028ba --- /dev/null +++ b/lib/tablelisting/admin/tablelisting.integrity.php @@ -0,0 +1,50 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Tabellisting + * + */ + +use Froxlor\UI\Callbacks\Text; +use Froxlor\UI\Callbacks\Style; +use Froxlor\UI\Listing; + +return [ + 'integrity_list' => [ + 'title' => $lng['admin']['integritycheck'], + 'icon' => 'fa-solid fa-circle-check', + 'columns' => [ + 'displayid' => [ + 'label' => $lng['admin']['integrityid'], + 'field' => 'displayid' + ], + 'checkdesc' => [ + 'label' => $lng['admin']['integrityname'], + 'field' => 'checkdesc' + ], + 'result' => [ + 'label' => $lng['admin']['integrityresult'], + 'field' => 'result', + 'callback' => [Text::class, 'boolean'] + ] + ], + 'visible_columns' => Listing::getVisibleColumnsForListing('integrity_list', [ + 'displayid', + 'checkdesc', + 'result' + ]), + 'format_callback' => [ + [Style::class, 'resultIntegrityBad'] + ] + ] +]; diff --git a/lib/tablelisting/tablelisting.apikeys.php b/lib/tablelisting/tablelisting.apikeys.php index 9c72cfc6..f35e342a 100644 --- a/lib/tablelisting/tablelisting.apikeys.php +++ b/lib/tablelisting/tablelisting.apikeys.php @@ -62,6 +62,7 @@ return [ 'icon' => 'fa fa-eye', 'title' => $lng['apikeys']['clicktoview'], 'href' => [ + 'section' => 'index', 'page' => 'apikeys', 'action' => '#', 'id' => ':id' @@ -72,13 +73,14 @@ return [ 'title' => $lng['panel']['delete'], 'class' => 'text-danger', 'href' => [ + 'section' => 'index', 'page' => 'apikeys', 'action' => 'delete', 'id' => ':id' ], ], ], - 'callback' => [ + 'format_callback' => [ [Style::class, 'invalidApiKey'] ] ]