From 7d459cf508f32647aeb97b16bdcf9c28c2ccd829 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Sat, 27 Jul 2024 12:29:28 +0300 Subject: [PATCH] Implements front page widgets --- public_html/pages/front.php | 135 +++++++------------------------ public_html/templates/widget.php | 31 ++++--- 2 files changed, 47 insertions(+), 119 deletions(-) diff --git a/public_html/pages/front.php b/public_html/pages/front.php index 5fb6015..01a0cab 100644 --- a/public_html/pages/front.php +++ b/public_html/pages/front.php @@ -64,63 +64,24 @@ try { exit(); } -// display the result -echo ""; -echo "
Conferences for the last 2 days
"; - -echo "
"; - +// prepare the widget +$widget['name'] = 'LastDays'; +$widget['title'] = 'Conferences for the last 2 days'; if ($time_range_specified) { - echo "

time period: $from_time - $until_time

"; -} - -//// filters - time selection and sorting dropdowns -//include 'templates/results-filter.php'; - -// results table -echo "
\n"; - -if (!empty($conferences['records'])) { - - echo "\t\n"; - - echo "\t\t\n"; - echo "\t\t\t\n"; - - // table headers - foreach (array_keys($conferences['records'][0]) as $header) { - echo "\t\t\t\t\n"; - } - echo "\t\t\t\n"; - echo "\t\t\n"; - - echo "\t\t\n"; - - //table rows - foreach ($conferences['records'] as $row) { - echo "\t\t\t\n"; - // sometimes $column is empty, we make it '' then - foreach ($row as $key => $column) { - if ($key === 'conference ID' && $column === $conference_id) { - echo "\t\t\t\t\n"; - } elseif ($key === 'conference name') { - echo "\t\t\t\t\n"; - } else { - echo "\t\t\t\t\n"; - } - } - echo "\t\t\t\n"; - } - - echo "\t\t\n"; - echo "\t
" . htmlspecialchars($header) . "
" . htmlspecialchars($column ?? '') . "" . htmlspecialchars($column ?? '') . "" . htmlspecialchars($column ?? '') . "
\n"; - + $widget['time_period'] = "

time period: $from_time - $until_time

"; } else { - echo '

No matching conferences found.

'; + $widget['time_period'] = ''; +} +if (!empty($conferences['records'])) { + $widget['full'] = true; + $widget['table_headers'] = array_keys($conferences['records'][0]); + $widget['table_records'] = $conferences['records']; +} else { + $widget['full'] = false; } -echo "\n
\n"; -echo "
"; +// display the widget +include('templates/widget.php'); echo "
"; @@ -179,63 +140,23 @@ try { exit(); } -// display the result -echo ""; -echo "
The last $conference_number conferences
"; - -echo "
"; - +// prepare the widget +$widget['name'] = 'LastConferences'; +$widget['title'] = "The last $conference_number conferences"; if ($time_range_specified) { - echo "
for the time period $from_time - $until_time"; -} - -//// filters - time selection and sorting dropdowns -//include 'templates/results-filter.php'; - -// results table -echo "
\n"; - -if (!empty($conferences['records'])) { - - echo "\t\n"; - - echo "\t\t\n"; - echo "\t\t\t\n"; - - // table headers - foreach (array_keys($conferences['records'][0]) as $header) { - echo "\t\t\t\t\n"; - } - echo "\t\t\t\n"; - echo "\t\t\n"; - - echo "\t\t\n"; - - //table rows - foreach ($conferences['records'] as $row) { - echo "\t\t\t\n"; - // sometimes $column is empty, we make it '' then - foreach ($row as $key => $column) { - if ($key === 'conference ID') { - echo "\t\t\t\t\n"; - } elseif ($key === 'conference name') { - echo "\t\t\t\t\n"; - } else { - echo "\t\t\t\t\n"; - } - } - echo "\t\t\t\n"; - } - - echo "\t\t\n"; - echo "\t
" . htmlspecialchars($header) . "
" . htmlspecialchars($column ?? '') . "" . htmlspecialchars($column ?? '') . "" . htmlspecialchars($column ?? '') . "
\n"; - + $widget['time_period'] = "

time period: $from_time - $until_time

"; } else { - echo '

No matching conferences found.

'; + $widget['time_period'] = ''; +} +if (!empty($conferences['records'])) { + $widget['full'] = true; + $widget['table_headers'] = array_keys($conferences['records'][0]); + $widget['table_records'] = $conferences['records']; +} else { + $widget['full'] = false; } -echo "\n
\n"; - -echo "
"; +// display the widget +include('templates/widget.php'); ?> diff --git a/public_html/templates/widget.php b/public_html/templates/widget.php index b018cf5..b967379 100644 --- a/public_html/templates/widget.php +++ b/public_html/templates/widget.php @@ -1,30 +1,37 @@ - +
-
+
+ - + - + - + - $column) { - if ($key === 'conference ID' && $column === $conference_id) { ?> - - - - + $column) { + if ($key === 'conference ID') { ?> + + + + + + - +
"">""
+ +

No matching records found.

+