summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-05-25 09:13:28 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-05-25 09:13:28 +0200
commit543bddc03fbf9dc90429d4d77dd11affaea4f356 (patch)
treeff7507a0e963d7affbfc42639b723ef8702126c8 /includes
parent0d3a225b3203b8a8fe0ad24138c09a4f1f738f54 (diff)
downloadgigologadmin-543bddc03fbf9dc90429d4d77dd11affaea4f356.tar.gz
gigologadmin-543bddc03fbf9dc90429d4d77dd11affaea4f356.tar.bz2
gigologadmin-543bddc03fbf9dc90429d4d77dd11affaea4f356.zip
Use select_field helper for city/venue filter.
Diffstat (limited to 'includes')
-rw-r--r--includes/admin/views/giglog_admin_page.php49
1 files changed, 16 insertions, 33 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
index 7de52ce..8ae30c3 100644
--- a/includes/admin/views/giglog_admin_page.php
+++ b/includes/admin/views/giglog_admin_page.php
@@ -70,45 +70,28 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
}
- static function get_filters(): string
+ static function get_filters() : string
{
- $cities = array_merge(["ALL"], GiglogAdmin_Venue::all_cities());
- $cty = filter_input( INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS );
- $selected_city =
- filter_input(INPUT_POST, "selectcity", FILTER_SANITIZE_SPECIAL_CHARS)
- || $cities[0];
-
- $select = '<form method="POST" action="">FILTER DATA: <select name="selectcity">';
-
- foreach ( $cities AS $city ) {
- $select .= '<option value="' . $city . '"' . selected($city,$cty ) . '>';
- $select .= $city . '</option>';
- }
+ $cty = filter_input(INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS);
- $select .= '</select>';
+ $select = '<form method="POST" action="">FILTER DATA:';
+ $select .= \EternalTerror\ViewHelpers\select_field(
+ "selectcity",
+ array_map(fn($city) => [$city, $city], GiglogAdmin_Venue::all_cities()),
+ $cty,
+ "Select city...");
- if ( $cty && $cty!= "ALL" ) {
+ if ( !empty($cty) ) {
//second drop down for venue
- $venues = GiglogAdmin_Venue::venues_in_city($cty);
-
- $venue_list = array_merge(
- [0, "ALL"],
+ $select .= \EternalTerror\ViewHelpers\select_field(
+ "selectvenue",
array_map(
- function($v) { return [$v->id(), $v->name()]; },
- $venues));
-
- $selected_venue = filter_input(INPUT_POST, "selectvenue", FILTER_SANITIZE_SPECIAL_CHARS)
- || $venue_list[0];
-
- $select .= '<select name="selectvenue">';
-
- foreach ( $venue_list as $venue ) {
- $select .= '<option value="' . $venue[0] . '"' . selected($venue, $selected_venue) . '>';
- $select .= $venue[1] . '</option>';
- }
- $select .= '</select>';
-
+ fn($venue) => [$venue->id(), $venue->name()],
+ GiglogAdmin_Venue::venues_in_city($cty)
+ ),
+ filter_input(INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS),
+ "Select venue...");
}
//option to select own concerts only
$select .= '<input class="ownconc" type="checkbox" value="1"';