mirror of
https://github.com/e107inc/e107.git
synced 2025-04-22 13:41:52 +02:00
Blog calendar menu was not functioning at all. Fixed. Bootstrap carousel enhancements added.
This commit is contained in:
parent
9c720ef696
commit
e624d32789
e107_plugins/blogcalendar_menu
@ -19,21 +19,21 @@
|
||||
*/
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
|
||||
$cString = 'nq_news_blogacalendar_menu_'.preg_replace('#[^\w]#', '', $parm);
|
||||
$cached = e107::getCache()->retrieve($cString);
|
||||
|
||||
if(false === $cached)
|
||||
{
|
||||
|
||||
require_once(e_PLUGIN."blogcalendar_menu/calendar.php");
|
||||
require_once(e_PLUGIN."blogcalendar_menu/functions.php");
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// initialization + fetch options
|
||||
// ------------------------------
|
||||
$prefix = e_PLUGIN."blogcalendar_menu";
|
||||
$marray = array(BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4,
|
||||
BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8,
|
||||
BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
|
||||
$prefix = e_PLUGIN."blogcalendar_menu";
|
||||
$marray = array(BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4, BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8, BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
|
||||
$pref['blogcal_ws'] = "monday";
|
||||
|
||||
// ----------------------------------------------
|
||||
@ -98,12 +98,20 @@ if(false === $cached)
|
||||
// -------------------------------------------
|
||||
// get links to all newsitems in current month
|
||||
// -------------------------------------------
|
||||
$month_start = mktime(0, 0, 0, $req_month, 1, $req_year);
|
||||
$lastday = date("t", $month_start);
|
||||
$month_end = mktime(23, 59, 59, $req_month, $lastday, $req_year);
|
||||
$start = mktime(0, 0, 0, 1, 1, $req_year);
|
||||
$end = time();
|
||||
$month_start = mktime(0, 0, 0, $req_month, 1, $req_year);
|
||||
$lastday = date("t", $month_start);
|
||||
$month_end = mktime(23, 59, 59, $req_month, $lastday, $req_year);
|
||||
$start = mktime(0, 0, 0, 1, 1, $req_year);
|
||||
$end = time();
|
||||
|
||||
$year_start = mktime(0, 0, 0, 1, 1, $req_year);
|
||||
$year_end = mktime(23, 59, 59, 12, 31, $req_year);
|
||||
|
||||
$sql->db_Select("news", "news_id, news_datestamp", "news_class IN (".USERCLASS_LIST.") AND news_datestamp > ".intval($start)." AND news_datestamp < ".intval($end));
|
||||
|
||||
$links = array();
|
||||
$months = array();
|
||||
|
||||
while ($news = $sql->db_Fetch())
|
||||
{
|
||||
$xmonth = date("n", $news['news_datestamp']);
|
||||
@ -111,14 +119,18 @@ if(false === $cached)
|
||||
{
|
||||
$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 AND $news['news_datestamp'] <= $month_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']);
|
||||
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);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
// if we're listing the current year, add the current month to the list regardless of posts
|
||||
@ -138,19 +150,55 @@ if(false === $cached)
|
||||
|
||||
// close the select item
|
||||
$month_selector .= "</select></div>";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(deftrue('e_BOOTSTRAP'))
|
||||
{
|
||||
$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>';
|
||||
$caption = "<div class='inline-text'>".BLOGCAL_L1." ".$req_year.$month_selector."</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$caption = "<div class='form-inline'>".BLOGCAL_L1." ".$req_year."</div>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------------
|
||||
// create and show calendar
|
||||
// ------------------------
|
||||
/*
|
||||
$menu = "<div style='text-align: center;'><table border='0' cellspacing='7'>";
|
||||
$menu .= "<tr><td>$month_selector";
|
||||
$menu .= "<div style='text-align:center'>".calendar($req_day, $req_month, $req_year, $day_links, $pref['blogcal_ws'])."</div>";
|
||||
$menu .= "<div class='forumheader' style='text-align: center; margin-top:2px;'><span class='smalltext'><a href='$prefix/archive.php'>".BLOGCAL_L2."</a></span></div></td></tr>";
|
||||
$menu .= "</table></div>";
|
||||
$cached = $ns->tablerender(BLOGCAL_L1." ".$req_year, $menu, 'blog_calendar', true);
|
||||
*/
|
||||
$menu = "<div id='blogCalendar' data-interval='false' class='carousel slide blogcalendar-block' style='text-align: center;'><table class='table blogcalendar-table' border='0' cellspacing='7'>";
|
||||
$menu .= "<tr><td class='blogcalendar-month-selector'>"; // .$month_selector;
|
||||
if(!defset('e_BOOTSTRAP')) // BC
|
||||
{
|
||||
$menu .= $month_selector;
|
||||
}
|
||||
|
||||
$menu .= "<div class='blogcalendar-day-selector carousel-inner' style='text-align:center'>";
|
||||
|
||||
foreach($months as $k=>$v)
|
||||
{
|
||||
$menu .= calendar($req_day, $k, $req_year, $links[$k], $pref['blogcal_ws']);
|
||||
}
|
||||
$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>
|
||||
</td></tr>";
|
||||
$menu .= "</table></div>";
|
||||
|
||||
$cached = $ns->tablerender($caption, $menu, 'blog_calendar', true);
|
||||
// echo "day= ".$req_day. " month=".$req_month." year=".$req_year." links=".print_a($day_links)." ws=".$pref['blogcal_ws'];
|
||||
e107::getCache()->set($cString, $menu);
|
||||
|
||||
$cached = e107::getCache()->set($cString, $menu_text);
|
||||
}
|
||||
|
||||
echo $cached;
|
||||
|
@ -17,85 +17,132 @@
|
||||
| Based on code by: Thomas Bouve (crahan@gmx.net) and
|
||||
| and Based on: PHP Calendar by Keith Devens http://www.keithdevens.com/software/php_calendar/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
function calendar($req_day, $req_month, $req_year, $links = NULL, $ws = "sunday") {
|
||||
// get access to the preferences
|
||||
global $pref;
|
||||
function calendar($req_day, $req_month, $req_year, $links = NULL, $ws = "sunday")
|
||||
{
|
||||
|
||||
$pref = e107::getPref();
|
||||
|
||||
// prepare the day array
|
||||
$darray = array(BLOGCAL_D1, BLOGCAL_D2, BLOGCAL_D3, BLOGCAL_D4,
|
||||
BLOGCAL_D5, BLOGCAL_D6, BLOGCAL_D7);
|
||||
$darray = array(BLOGCAL_D1, BLOGCAL_D2, BLOGCAL_D3, BLOGCAL_D4, BLOGCAL_D5, BLOGCAL_D6, BLOGCAL_D7);
|
||||
$marray = array('',BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4, BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8, BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
|
||||
|
||||
// what day does the week start on?
|
||||
switch($ws) {
|
||||
switch($ws)
|
||||
{
|
||||
case "monday":
|
||||
$ws = "1";
|
||||
break;
|
||||
$ws = "1";
|
||||
break;
|
||||
|
||||
case "sunday":
|
||||
array_unshift($darray, array_pop($darray));
|
||||
array_unshift($darray, array_pop($darray));
|
||||
$ws = "0";
|
||||
}
|
||||
|
||||
// what's the padding we should use for the cells?
|
||||
$padding = (isset($pref['blogcal_padding']) && $pref['blogcal_padding']) ? $pref['blogcal_padding']: "2";
|
||||
$padding = (isset($pref['blogcal_padding']) && $pref['blogcal_padding']) ? $pref['blogcal_padding']: "2";
|
||||
|
||||
$date = mktime(0, 0, 0, $req_month, 1, $req_year);
|
||||
$last_day = date('t', $date);
|
||||
$date_info = getdate($date);
|
||||
$day_of_week = $date_info['wday'];
|
||||
if ($ws && $day_of_week == 0) $day_of_week = 7;
|
||||
$date = mktime(0, 0, 0, $req_month, 1, $req_year);
|
||||
$last_day = date('t', $date);
|
||||
$date_info = getdate($date);
|
||||
$day_of_week = $date_info['wday'];
|
||||
|
||||
if ($ws && $day_of_week == 0)
|
||||
{
|
||||
$day_of_week = 7;
|
||||
}
|
||||
|
||||
// print the daynames
|
||||
$calendar = "<table class='fborder'>";
|
||||
$calendar .= '<tr>';
|
||||
foreach($darray as $dheader) {
|
||||
$calendar .= "<td class='forumheader' style='padding: ".$padding."px;'><span class='smalltext'>$dheader</span></td>";
|
||||
$calendar = "<table class='table blogcalendar fborder'>";
|
||||
$calendar .= '<thead><tr>';
|
||||
|
||||
foreach($darray as $dheader)
|
||||
{
|
||||
$calendar .= "<th class='forumheader blogcalendar-day-name'><span class='smalltext'>$dheader</span></th>";
|
||||
}
|
||||
$calendar .= "</tr>";
|
||||
|
||||
$calendar .= "</tr>
|
||||
</thead>
|
||||
<tbody>";
|
||||
$calendar .= '<tr>';
|
||||
|
||||
$day_of_month = 1;
|
||||
$tablerow = 1;
|
||||
|
||||
// take care of the first "empty" days of the month
|
||||
if ($day_of_week-$ws > 0) {
|
||||
$calendar .= "<td colspan='";
|
||||
if ($day_of_week-$ws > 0)
|
||||
{
|
||||
$calendar .= "<td class='muted blogcalendar-day-empty' colspan='";
|
||||
$calendar .= $day_of_week-$ws;
|
||||
$calendar .= "'> </td>";
|
||||
}
|
||||
|
||||
// print the days of the month (take the $ws into account)
|
||||
while ($day_of_month <= $last_day) {
|
||||
if ($day_of_week-$ws == 7) {
|
||||
while ($day_of_month <= $last_day)
|
||||
{
|
||||
if ($day_of_week-$ws == 7)
|
||||
{
|
||||
#start a new week
|
||||
$calendar .= "</tr><tr>";
|
||||
$day_of_week = 0+$ws;
|
||||
$tablerow++;
|
||||
}
|
||||
if ($day_of_month == $req_day) {
|
||||
$day_style = isset($links[$day_of_month]) ? "indent" : "forumheader3";
|
||||
} else {
|
||||
$day_style = isset($links[$day_of_month]) ? "indent" : "forumheader3";
|
||||
|
||||
if ($day_of_month == $req_day)
|
||||
{
|
||||
$day_style = isset($links[$day_of_month]) ? "indent blogcalendar-day-active" : "forumheader3 blogcalendar-day";
|
||||
}
|
||||
$calendar .= "<td class='$day_style' style='padding: ".$padding."px;'><span class='smalltext'>";
|
||||
$calendar .= isset($links[$day_of_month]) ? "<a href='".$links[$day_of_month]."'>":"";
|
||||
else
|
||||
{
|
||||
$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'>";
|
||||
$calendar .= isset($links[$day_of_month]) ? "<a class='blogcalendar-day-link' href='".$links[$day_of_month]."'>":"";
|
||||
$calendar .= $day_of_month;
|
||||
$calendar .= isset($links[$day_of_month]) ? "</a>" : "";
|
||||
$calendar .= "</span></td>";
|
||||
$day_of_month++;
|
||||
$day_of_week++;
|
||||
}
|
||||
if ($day_of_week-$ws != 7) {
|
||||
$calendar .= '<td colspan="' . (7 - $day_of_week+$ws) . '"> </td>';
|
||||
|
||||
if ($day_of_week-$ws != 7)
|
||||
{
|
||||
$calendar .= '<td class="blogcalendar-day-empty" colspan="' . (7 - $day_of_week+$ws) . '"> </td>';
|
||||
}
|
||||
|
||||
$calendar .= "</tr>";
|
||||
if ($tablerow != 6) {
|
||||
$calendar .= "<tr><td style='padding: ".$padding."px;' colspan='6'> </td></tr>";
|
||||
|
||||
if ($tablerow != 5)
|
||||
{
|
||||
$calendar .= "<tr><td class='blogcalendar-day-empty' style='padding: ".$padding."px;' colspan='6'> </td></tr>";
|
||||
}
|
||||
|
||||
$calendar .= "</table>";
|
||||
return $calendar;
|
||||
$calendar .= "</tbody></table>";
|
||||
|
||||
// $calendar .= "tablerow = ".$tablerow;
|
||||
|
||||
if(deftrue('e_BOOTSTRAP'))
|
||||
{
|
||||
$active = date("n") == $req_month ? 'active' : '';
|
||||
$text = "<div class='item {$active}'>";
|
||||
$text .= "<h5>".$marray[$req_month]." ".$req_year."</h5>";
|
||||
$text .= $calendar;
|
||||
$text .= "</div>";
|
||||
}
|
||||
else // BC
|
||||
{
|
||||
$text = $calendar;
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user