mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
new layout
This commit is contained in:
@@ -8,8 +8,21 @@ class Contestcalendar extends CI_Controller {
|
||||
|
||||
$data['page_title'] = "Contest Calendar";
|
||||
|
||||
// get the raw data and parse it
|
||||
$rssRawData = $this->getRssData();
|
||||
$data['rss'] = $this->parseRSS($rssRawData);
|
||||
$parsed = $this->parseRSS($rssRawData);
|
||||
|
||||
// and give it to the view
|
||||
$data['contestsToday'] = $this->contestsToday($parsed);
|
||||
$data['contestsNextWeekend'] = $this->contestsNextWeekend($parsed);
|
||||
$data['contestsNextWeek'] = $this->contestsNextWeek($parsed);
|
||||
|
||||
// Get Date format
|
||||
if($this->session->userdata('user_date_format')) {
|
||||
$data['custom_date_format'] = $this->session->userdata('user_date_format');
|
||||
} else {
|
||||
$data['custom_date_format'] = $this->config->item('qso_date_format');
|
||||
}
|
||||
|
||||
$footerData['scripts'] = [
|
||||
'assets/js/sections/dxcalendar.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/dxcalendar.js"))
|
||||
@@ -37,8 +50,8 @@ class Contestcalendar extends CI_Controller {
|
||||
// write the start time to the array. the whole time range is in the 'description' tag of the rssRawData
|
||||
$description = (string) $item->description;
|
||||
$timeRange = $this->parseTimeRange($description);
|
||||
$contest['start'] = $timeRange['start']->format('Y-m-d H:i:s');
|
||||
$contest['end'] = $timeRange['end']->format('Y-m-d H:i:s');
|
||||
$contest['start'] = $timeRange['start'];
|
||||
$contest['end'] = $timeRange['end'];
|
||||
|
||||
// and write the link to the array
|
||||
$contest['link'] = (string) $item->link;
|
||||
@@ -112,5 +125,57 @@ class Contestcalendar extends CI_Controller {
|
||||
|
||||
return $rssRawData;
|
||||
}
|
||||
|
||||
private function contestsToday($rss) {
|
||||
$contestsToday = array();
|
||||
|
||||
$today = date('Y-m-d');
|
||||
|
||||
foreach ($rss as $contest) {
|
||||
$start = date('Y-m-d', strtotime($contest['start']->format('Y-m-d')));
|
||||
if ($start === $today) {
|
||||
$contestsToday[] = $contest;
|
||||
}
|
||||
}
|
||||
|
||||
return $contestsToday;
|
||||
}
|
||||
|
||||
private function contestsNextWeekend($rss) {
|
||||
$contestsNextWeekend = array();
|
||||
|
||||
$today = date('Y-m-d');
|
||||
|
||||
$nextFriday = date('Y-m-d', strtotime('next friday', strtotime($today)));
|
||||
$nextSunday = date('Y-m-d', strtotime('next sunday', strtotime($today)));
|
||||
|
||||
foreach ($rss as $contest) {
|
||||
$start = date('Y-m-d', strtotime($contest['start']->format('Y-m-d')));
|
||||
|
||||
if ($start >= $nextFriday && $start <= $nextSunday) {
|
||||
$contestsNextWeekend[] = $contest;
|
||||
}
|
||||
}
|
||||
|
||||
return $contestsNextWeekend;
|
||||
}
|
||||
|
||||
private function contestsNextWeek($rss) {
|
||||
$contestsNextWeek = array();
|
||||
|
||||
$today = date('Y-m-d');
|
||||
|
||||
$nextMonday = date('Y-m-d', strtotime('next monday', strtotime($today)));
|
||||
|
||||
foreach ($rss as $contest) {
|
||||
$start = date('Y-m-d', strtotime($contest['start']->format('Y-m-d')));
|
||||
|
||||
if ($start >= $nextMonday) {
|
||||
$contestsNextWeek[] = $contest;
|
||||
}
|
||||
}
|
||||
|
||||
return $contestsNextWeek;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +1,71 @@
|
||||
<div class="container">
|
||||
<br>
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
<h2><?= $page_title; ?></h2>
|
||||
<p>This data is from <a target="_blank" href="https://www.contestcalendar.com/">https://www.contestcalendar.com/</a></p>
|
||||
|
||||
<table style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed dxcalendar">
|
||||
<?php
|
||||
function generateTableRows($contests, $custom_date_format) {
|
||||
foreach ($contests as $contest) {
|
||||
echo '<tr>';
|
||||
echo "<td>{$contest['title']}</td>";
|
||||
echo "<td>{$contest['start']->format($custom_date_format)}</td>";
|
||||
echo "<td>{$contest['start']->format('H:i')}</td>";
|
||||
echo "<td>{$contest['end']->format($custom_date_format.' H:i')}</td>";
|
||||
echo "<td><a class='btn btn-secondary btn-sm' href='{$contest['link']}' target='_blank'>Show Details</a></td>";
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h4 class="mb-3">Today</h4>
|
||||
<table style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Contest</th>
|
||||
<th>Date</th>
|
||||
<th>Start</th>
|
||||
<th>End</th>
|
||||
<th>Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php generateTableRows($contestsToday, $custom_date_format); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h4 class="mb-3">Weekend</h4>
|
||||
<table style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Contest</th>
|
||||
<th>Date</th>
|
||||
<th>Start</th>
|
||||
<th>End</th>
|
||||
<th>Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php generateTableRows($contestsNextWeekend, $custom_date_format); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="mb-3">Next Week</h4>
|
||||
<table style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Contest</th>
|
||||
<th>Date</th>
|
||||
<th>Start</th>
|
||||
<th>End</th>
|
||||
<th>Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($rss as $contest) {
|
||||
echo '<tr>';
|
||||
echo "<td>" . $contest['title'] . "</td>";
|
||||
echo "<td>" . $contest['start'] . "</td>";
|
||||
echo "<td>" . $contest['end'] . "</td>";
|
||||
echo "<td><a href='" . $contest['link'] . "' target=_blank>" . $contest['link'] . "</a></td>";
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
<?php generateTableRows($contestsNextWeek, $custom_date_format); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
Reference in New Issue
Block a user