From 503c287e1a15589420e5961ba4a06c96dc1819dc Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Thu, 4 Jul 2024 13:57:18 +0300 Subject: [PATCH] Adds conferences listing output --- public_html/classes/conference.php | 19 ++++++++++-- public_html/pages/conferences.php | 48 +++++++++++++++++++++++------- public_html/static/all.css | 18 ++++++++++- 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/public_html/classes/conference.php b/public_html/classes/conference.php index 12cac0f..e879933 100644 --- a/public_html/classes/conference.php +++ b/public_html/classes/conference.php @@ -19,12 +19,27 @@ class Conference { } // list of all conferences - public function conferences_all_formatted() { + public function conferencesAllFormatted($from_time,$until_time) { + + // time period drill-down + // FIXME make it similar to the bash version + if (empty($from_time)) { + $from_time = '0000-01-01'; + } + if (empty($until_time)) { + $until_time = '9999-12-31'; + } + + // this is needed for compatibility with the bash version, so we use '%s' placeholders + $from_time = htmlspecialchars(strip_tags($from_time)); + $until_time = htmlspecialchars(strip_tags($until_time)); $sql = $this->queries['conferences_all_formatted']; + $sql = sprintf($sql, $from_time, $until_time); + $query = $this->db->prepare($sql); $query->execute(); - return $query; + return $query->fetchAll(PDO::FETCH_ASSOC); } } diff --git a/public_html/pages/conferences.php b/public_html/pages/conferences.php index 7ea0790..cdf028b 100644 --- a/public_html/pages/conferences.php +++ b/public_html/pages/conferences.php @@ -3,20 +3,25 @@ require_once 'classes/database.php'; require 'classes/conference.php'; +// FIXME add dropdown menus for selecting from-until +$from_time = '0000-01-01'; +$until_time = '9999-12-31'; + // list of all conferences try { $db = new Database($config['jilo_database']); $conference = new Conference($db); - $search = $conference->conferences_all_formatted(); + $search = $conference->conferencesAllFormatted($from_time,$until_time); - if ($search->rowCount() > 0) { + if (!empty($search)) { $conferences = array(); $conferences['records'] = array(); - while ($row = $search->fetch(PDO::FETCH_ASSOC)) { - extract($row); + foreach ($search as $item) { + extract($item); $conference_record = array( + // assign title to the field in the array record 'jitsi_component' => $jitsi_component, 'start' => $start, 'end' => $end, @@ -26,18 +31,41 @@ try { 'name_count' => $name_count, 'conference_host' => $conference_host ); + // populate the result array array_push($conferences['records'], $conference_record); } - - // FIXME format this better - echo json_encode($conferences); - - } else { - echo 'No matching conferences found'; } } catch (Exception $e) { $error = $e->getMessage(); } +echo "Conferences for the time period $from_time - $until_time"; + +if (!empty($conferences['records'])) { + + echo "\t"; + echo "\t\t"; + + // table headers + foreach (array_keys($conferences['records'][0]) as $header) { + echo "\t\t\t"; + } + echo "\t\t"; + + //table rows + foreach ($conferences['records'] as $row) { + echo "\t\t"; + foreach ($row as $column) { + echo "\t\t\t"; + } + echo "\t\t"; + } + + echo "\t
" . htmlspecialchars($header) . "
" . htmlspecialchars($column) . "
"; + +} else { + echo '

No matching conferences found.

'; +} + ?> diff --git a/public_html/static/all.css b/public_html/static/all.css index 8d498e8..efac42a 100644 --- a/public_html/static/all.css +++ b/public_html/static/all.css @@ -62,7 +62,7 @@ } #footer { - position: absolute; + position: fixed; left: 0px; bottom: 0px; height: 30px; @@ -77,3 +77,19 @@ #footer a { color: white; } + +#results table { + width: 100%; + border-collapse: collapse; + margin: 20px 0; +} +#results table, th, td { + border: 1px solid #ddd; +} +#results th, td { + padding: 8px; + text-align: left; +} +#results th { + background-color: #f2f2f2; +}