1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 05:37:32 +02:00

Blog calendar menu now navigates through years as well.

This commit is contained in:
Cameron
2013-04-26 18:19:54 -07:00
parent f7f1866da5
commit ab2f3691d8
4 changed files with 29 additions and 14 deletions

View File

@@ -107,7 +107,9 @@ $year_selector .= "</select>\n</div>";
// create the archive display // create the archive display
// -------------------------- // --------------------------
$newline = 0; $newline = 0;
$archive = "<div style='text-align:center'><table border='0' cellspacing='7'><tr>"; $archive = "<div style='text-align:center'>
<table class='table' border='0' cellspacing='7'>
<tr>";
$archive .= "<td colspan='{$months_per_row}'>{$year_selector}</td></tr><tr>"; $archive .= "<td colspan='{$months_per_row}'>{$year_selector}</td></tr><tr>";
for($i = 1; $i <= 12; $i++) for($i = 1; $i <= 12; $i++)
{ {

View File

@@ -101,7 +101,7 @@ if(false === $cached)
$month_start = mktime(0, 0, 0, $req_month, 1, $req_year); $month_start = mktime(0, 0, 0, $req_month, 1, $req_year);
$lastday = date("t", $month_start); $lastday = date("t", $month_start);
$month_end = mktime(23, 59, 59, $req_month, $lastday, $req_year); $month_end = mktime(23, 59, 59, $req_month, $lastday, $req_year);
$start = mktime(0, 0, 0, 1, 1, $req_year); $start = mktime(0, 0, 0, 1, 1, 1980);
$end = time(); $end = time();
$year_start = mktime(0, 0, 0, 1, 1, $req_year); $year_start = mktime(0, 0, 0, 1, 1, $req_year);
@@ -115,22 +115,23 @@ if(false === $cached)
while ($news = $sql->db_Fetch()) while ($news = $sql->db_Fetch())
{ {
$xmonth = date("n", $news['news_datestamp']); $xmonth = date("n", $news['news_datestamp']);
$xyear = date("Y", $news['news_datestamp']);
if (!isset($month_links[$xmonth]) || !$month_links[$xmonth]) if (!isset($month_links[$xmonth]) || !$month_links[$xmonth])
{ {
$month_links[$xmonth] = e107::getUrl()->create('news/list/month', 'idv='.formatDate($req_year, $xmonth));//e_BASE."news.php?month.".formatDate($req_year, $xmonth); $month_links[$xmonth] = e107::getUrl()->create('news/list/month', 'idv='.formatDate($req_year, $xmonth));//e_BASE."news.php?month.".formatDate($req_year, $xmonth);
} }
if(($news['news_datestamp'] >= $month_start && $news['news_datestamp'] <= $month_end) || (deftrue('e_BOOTSTRAP') && $news['news_datestamp'] >= $year_start && $news['news_datestamp'] <= $year_end)) // if(($news['news_datestamp'] >= $month_start && $news['news_datestamp'] <= $month_end) || (deftrue('e_BOOTSTRAP') && $news['news_datestamp'] >= $year_start && $news['news_datestamp'] <= $year_end))
{ {
$xday = date("j", $news['news_datestamp']); $xday = date("j", $news['news_datestamp']);
if (!isset($day_links[$xday]) || !$day_links[$xday]) if (!isset($day_links[$xday]) || !$day_links[$xday])
{ {
$links[$xmonth][$xday] = e107::getUrl()->create('news/list/day', 'id='.formatDate($req_year, $xmonth, $xday));//e_BASE."news.php?day.".formatDate($req_year, $req_month, $xday); $links[$xyear][$xmonth][$xday] = e107::getUrl()->create('news/list/day', 'id='.formatDate($req_year, $xmonth, $xday));//e_BASE."news.php?day.".formatDate($req_year, $req_month, $xday);
$day_links[$xday] = e107::getUrl()->create('news/list/day', 'id='.formatDate($req_year, $xmonth, $xday));//e_BASE."news.php?day.".formatDate($req_year, $req_month, $xday); $day_links[$xday] = e107::getUrl()->create('news/list/day', 'id='.formatDate($req_year, $xmonth, $xday));//e_BASE."news.php?day.".formatDate($req_year, $req_month, $xday);
} }
} }
$months[$xmonth] = 1; $months[$xyear][$xmonth] = 1;
} }
// if we're listing the current year, add the current month to the list regardless of posts // if we're listing the current year, add the current month to the list regardless of posts
@@ -158,7 +159,7 @@ if(false === $cached)
{ {
$month_selector = '<div class="btn-group pull-right"><a class="btn btn-mini " href="#blogCalendar" data-slide="prev"></a> $month_selector = '<div class="btn-group pull-right"><a class="btn btn-mini " href="#blogCalendar" data-slide="prev"></a>
<a class="btn btn-mini" href="#blogCalendar" data-slide="next"></a></div>'; <a class="btn btn-mini" href="#blogCalendar" data-slide="next"></a></div>';
$caption = "<div class='inline-text'>".BLOGCAL_L1." ".$req_year.$month_selector."</div>"; $caption = "<div class='inline-text'>".BLOGCAL_L1." ".$month_selector."</div>";
} }
else else
{ {
@@ -186,9 +187,13 @@ if(false === $cached)
$menu .= "<div class='blogcalendar-day-selector carousel-inner' style='text-align:center'>"; $menu .= "<div class='blogcalendar-day-selector carousel-inner' style='text-align:center'>";
foreach($months as $k=>$v)
foreach($months as $year=>$val)
{ {
$menu .= calendar($req_day, $k, $req_year, $links[$k], $pref['blogcal_ws']); foreach($val as $month=>$v)
{
$menu .= calendar($req_day, $month, $year, $links[$year][$month], $pref['blogcal_ws']);
}
} }
$menu .= "</div>"; $menu .= "</div>";
$menu .= "<div class='forumheader blogcalendar-archive-link' style='text-align: center; margin-top:2px;'><span class='smalltext'><a class='blogcalendar-archive-link btn btn-small' href='$prefix/archive.php'>".BLOGCAL_L2."</a></span></div> $menu .= "<div class='forumheader blogcalendar-archive-link' style='text-align: center; margin-top:2px;'><span class='smalltext'><a class='blogcalendar-archive-link btn btn-small' href='$prefix/archive.php'>".BLOGCAL_L2."</a></span></div>

View File

@@ -105,15 +105,23 @@ function calendar($req_day, $req_month, $req_year, $links = NULL, $ws = "sunday"
$day_style = isset($links[$day_of_month]) ? "indent blogcalendar-day-active " : "forumheader3 blogcalendar-day"; $day_style = isset($links[$day_of_month]) ? "indent blogcalendar-day-active " : "forumheader3 blogcalendar-day";
} }
$calendar .= "<td class='$day_style' ><span class='smalltext blogcalendar-day-link'>"; $label_style = isset($links[$day_of_month]) ? 'label label-info' : ''; //TODO A pref in admin to choose between info, danger, etc.
$calendar .= "<td class='$day_style' >";
$calendar .= isset($links[$day_of_month]) ? "<a class='blogcalendar-day-link' href='".$links[$day_of_month]."'>":""; $calendar .= isset($links[$day_of_month]) ? "<a class='blogcalendar-day-link' href='".$links[$day_of_month]."'>":"";
$calendar .= "<span class='smalltext blogcalendar-day-link {$label_style}'>";
$calendar .= $day_of_month; $calendar .= $day_of_month;
$calendar .= "</span>";
$calendar .= isset($links[$day_of_month]) ? "</a>" : ""; $calendar .= isset($links[$day_of_month]) ? "</a>" : "";
$calendar .= "</span></td>";
$calendar .= "</td>";
$day_of_month++; $day_of_month++;
$day_of_week++; $day_of_week++;
} }
if ($day_of_week-$ws != 7) if ($day_of_week-$ws != 7)
{ {
$calendar .= '<td class="blogcalendar-day-empty" colspan="' . (7 - $day_of_week+$ws) . '">&nbsp;</td>'; $calendar .= '<td class="blogcalendar-day-empty" colspan="' . (7 - $day_of_week+$ws) . '">&nbsp;</td>';
@@ -121,9 +129,9 @@ function calendar($req_day, $req_month, $req_year, $links = NULL, $ws = "sunday"
$calendar .= "</tr>"; $calendar .= "</tr>";
if ($tablerow != 5) if ($tablerow != 6)
{ {
$calendar .= "<tr><td class='blogcalendar-day-empty' style='padding: ".$padding."px;' colspan='6'>&nbsp;</td></tr>"; $calendar .= "<tr><td class='blogcalendar-day-empty' colspan='7'>&nbsp;</td></tr>";
} }
$calendar .= "</tbody></table>"; $calendar .= "</tbody></table>";

View File

@@ -8,7 +8,7 @@
* *
*/ */
define("BLOGCAL_L1", "News for "); define("BLOGCAL_L1", "News by month");
define("BLOGCAL_L2", "Archive"); define("BLOGCAL_L2", "Archive");
define("BLOGCAL_D1", "Mo"); define("BLOGCAL_D1", "Mo");