Adds conferences listing output

main
Yasen Pramatarov 2024-07-04 13:57:18 +03:00
parent 7f3b006d4d
commit 503c287e1a
3 changed files with 72 additions and 13 deletions

View File

@ -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);
}
}

View File

@ -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<table id=\"results\">";
echo "\t\t<tr>";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>";
}
echo "\t\t</tr>";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>";
foreach ($row as $column) {
echo "\t\t\t<td>" . htmlspecialchars($column) . "</td>";
}
echo "\t\t</tr>";
}
echo "\t</table>";
} else {
echo '<p>No matching conferences found.</p>';
}
?>

View File

@ -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;
}