From 9038afc47a45fffbaeb19e38d09e02ef9ee20fc4 Mon Sep 17 00:00:00 2001 From: Luana Date: Sun, 25 Jun 2023 20:49:19 -0300 Subject: [PATCH] another build_selector use case --- ext/pools/main.php | 8 ++++---- ext/pools/theme.php | 17 ++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ext/pools/main.php b/ext/pools/main.php index ed065923..52e2e323 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -466,13 +466,13 @@ class Pools extends Extension { global $config, $database, $user; if ($config->get_bool(PoolsConfig::ADDER_ON_VIEW_IMAGE) && !$user->is_anonymous()) { + $pools = []; if ($user->can(Permissions::POOLS_ADMIN)) { - $rows = $database->get_all("SELECT * FROM pools"); + $pools = $database->get_pairs("SELECT id,title FROM pools ORDER BY title"); } else { - $rows = $database->get_all("SELECT * FROM pools WHERE user_id=:id", ["id" => $user->id]); + $pools = $database->get_pairs("SELECT id,title FROM pools ORDER BY title WHERE user_id=:id", ["id" => $user->id]); } - if (count($rows) > 0) { - $pools = array_map([Pool::class, "makePool"], $rows); + if (count($pools) > 0) { $event->add_part($this->theme->get_adder_html($event->image, $pools)); } } diff --git a/ext/pools/theme.php b/ext/pools/theme.php index d5815a1f..ea85d724 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -40,18 +40,13 @@ class PoolsTheme extends Themelet public function get_adder_html(Image $image, array $pools): string { - $h = ""; - foreach ($pools as $pool) { - $h .= ""; - } + $selector = $this->build_selector("pool_id", $pools); return "\n" . make_form(make_link("pool/add_post")) . " - - - - - "; + $selector + + + + "; } /**