mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 21:16:07 +00:00
show events in year calendar, get rid of some div.well
This commit is contained in:
parent
fad908cbe0
commit
4443b80631
|
@ -36,21 +36,21 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
getMLText("february"),
|
||||
getMLText("march"),
|
||||
getMLText("april"),
|
||||
getMLText("may"),
|
||||
getMLText("may"),
|
||||
getMLText("june"),
|
||||
getMLText("july"),
|
||||
getMLText("august"),
|
||||
getMLText("september"),
|
||||
getMLText("october"),
|
||||
getMLText("november"),
|
||||
getMLText("july"),
|
||||
getMLText("august"),
|
||||
getMLText("september"),
|
||||
getMLText("october"),
|
||||
getMLText("november"),
|
||||
getMLText("december") );
|
||||
|
||||
|
||||
$this->dayNamesLong = array( getMLText("sunday"),
|
||||
getMLText("monday"),
|
||||
getMLText("tuesday"),
|
||||
getMLText("wednesday"),
|
||||
getMLText("wednesday"),
|
||||
getMLText("thursday"),
|
||||
getMLText("friday"),
|
||||
getMLText("friday"),
|
||||
getMLText("saturday") );
|
||||
/* Set abbreviated weekday names. If no translation is availabe, use
|
||||
* the first three chars from the long name
|
||||
|
@ -58,11 +58,11 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
$this->dayNames = array( getMLText("sunday_abbr", array(), substr($this->dayNamesLong[0], 0, 3)),
|
||||
getMLText("monday_abbr", array(), substr($this->dayNamesLong[1], 0, 3)),
|
||||
getMLText("tuesday_abbr", array(), substr($this->dayNamesLong[2], 0, 3)),
|
||||
getMLText("wednesday_abbr", array(), substr($this->dayNamesLong[3], 0, 3)),
|
||||
getMLText("wednesday_abbr", array(), substr($this->dayNamesLong[3], 0, 3)),
|
||||
getMLText("thursday_abbr", array(), substr($this->dayNamesLong[4], 0, 3)),
|
||||
getMLText("friday_abbr", array(), substr($this->dayNamesLong[5], 0, 3)),
|
||||
getMLText("friday_abbr", array(), substr($this->dayNamesLong[5], 0, 3)),
|
||||
getMLText("saturday_abbr", array(), substr($this->dayNamesLong[6], 0, 3)) );
|
||||
|
||||
|
||||
} /* }}} */
|
||||
|
||||
// Calculate the number of days in a month, taking into account leap years.
|
||||
|
@ -73,11 +73,11 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
$d = $daysInMonth[$month - 1];
|
||||
|
||||
if ($month == 2){
|
||||
|
||||
|
||||
if ($year%4 == 0){
|
||||
|
||||
|
||||
if ($year%100 == 0){
|
||||
|
||||
|
||||
if ($year%400 == 0) $d = 29;
|
||||
}
|
||||
else $d = 29;
|
||||
|
@ -111,7 +111,7 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
$monthName = $this->monthNames[$month - 1];
|
||||
|
||||
$s = "<table class=\"table\">\n";
|
||||
|
||||
|
||||
$s .= "<tr>\n";
|
||||
$s .= "<td style=\"border-top: 0px;\" colspan=\"7\"><a href=\"../out/out.Calendar.php?mode=m&year=".$year."&month=".$month."\">".$monthName."</a></td>\n"; ;
|
||||
$s .= "</tr>\n";
|
||||
|
@ -133,34 +133,49 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
// Make sure we know when today is, so that we can use a different CSS style
|
||||
$today = getdate(time());
|
||||
|
||||
$events = getEventsInInterval(mktime(0,0,0, $month, 1, $year), mktime(23,59,59, $month+1, 0, $year));
|
||||
$eventdays = array();
|
||||
if($events) {
|
||||
for($i=1; $i<$daysInMonth; $i++)
|
||||
$eventdays[$i] = 0;
|
||||
foreach($events as $event) {
|
||||
for($i = date('d', $event['start']); $i <= date('d', $event['stop']); $i++) {
|
||||
$eventdays[$i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while ($d <= $daysInMonth)
|
||||
{
|
||||
$s .= "<tr>\n";
|
||||
|
||||
$s .= "<tr>\n";
|
||||
|
||||
for ($i = 0; $i < 7; $i++){
|
||||
|
||||
$class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "today" : "";
|
||||
$s .= "<td class=\"$class\">";
|
||||
|
||||
|
||||
$class = '';
|
||||
if($eventdays && $eventdays[$d])
|
||||
$class = 'event';
|
||||
$class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "today" : $class;
|
||||
$s .= "<td".($class ? " class=\"$class\"" : "").">";
|
||||
|
||||
if ($d > 0 && $d <= $daysInMonth){
|
||||
|
||||
$s .= "<a href=\"../out/out.Calendar.php?mode=w&year=".$year."&month=".$month."&day=".$d."\">".$d."</a>";
|
||||
}
|
||||
else $s .= " ";
|
||||
|
||||
$s .= "</td>\n";
|
||||
|
||||
$s .= "</td>\n";
|
||||
$d++;
|
||||
}
|
||||
$s .= "</tr>\n";
|
||||
$s .= "</tr>\n";
|
||||
}
|
||||
|
||||
$s .= "</table>\n";
|
||||
|
||||
return $s;
|
||||
return $s;
|
||||
} /* }}} */
|
||||
|
||||
function printYearTable($year) { /* {{{ */
|
||||
print "<table class=\"table-condensed\">\n";
|
||||
print "<table class=\"table\" style=\"max-width: 700px;\">\n";
|
||||
print "<tr>";
|
||||
print "<td valign=\"top\">" . $this->getMonthHTML(1 , $year) ."</td>\n";
|
||||
print "<td valign=\"top\">" . $this->getMonthHTML(2 , $year) ."</td>\n";
|
||||
|
@ -205,7 +220,7 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
if ($mode=="y"){
|
||||
|
||||
$this->contentHeading(getMLText("year_view").": ".$year);
|
||||
|
||||
|
||||
echo "<div class=\"pagination pagination-small\">";
|
||||
echo "<ul>";
|
||||
print "<li><a href=\"../out/out.Calendar.php?mode=y&year=".($year-1)."\"><i style=\"color: black;\" class=\"icon-arrow-left\"></i></a></li>";
|
||||
|
@ -214,17 +229,17 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
echo "</ul>";
|
||||
echo "</div>";
|
||||
|
||||
$this->contentContainerStart();
|
||||
// $this->contentContainerStart();
|
||||
$this->printYearTable($year);
|
||||
$this->contentContainerEnd();
|
||||
// $this->contentContainerEnd();
|
||||
|
||||
}else if ($mode=="m"){
|
||||
|
||||
if (!isset($this->dayNamesLong)) $this->generateCalendarArrays();
|
||||
if (!isset($this->monthNames)) $this->generateCalendarArrays();
|
||||
|
||||
|
||||
$this->contentHeading(getMLText("month_view").": ".$this->monthNames[$month-1]. " ".$year);
|
||||
|
||||
|
||||
echo "<div class=\"pagination pagination-small\">";
|
||||
echo "<ul>";
|
||||
print "<li><a href=\"../out/out.Calendar.php?mode=m&year=".($year)."&month=".($month-1)."\"><i style=\"color: black;\" class=\"icon-arrow-left\"></i></a></li>";
|
||||
|
@ -233,10 +248,10 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
echo "</ul>";
|
||||
echo "</div>";
|
||||
// $this->contentContainerStart();
|
||||
|
||||
|
||||
$days=$this->getDaysInMonth($month, $year);
|
||||
$today = getdate(time());
|
||||
|
||||
|
||||
$events = getEventsInInterval(mktime(0,0,0, $month, 1, $year), mktime(23,59,59, $month, $days, $year));
|
||||
|
||||
echo "<div class=\"row-fluid\">";
|
||||
|
@ -246,9 +261,9 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
$fd = getdate(mktime(12, 0, 0, $month, 1, $year));
|
||||
for($i=0; $i<$fd['wday']-1; $i++)
|
||||
echo "<tr><td colspan=\"2\"> </td></tr>";
|
||||
|
||||
|
||||
for ($i=1; $i<=$days; $i++){
|
||||
|
||||
|
||||
// separate weeks
|
||||
$date = getdate(mktime(12, 0, 0, $month, $i, $year));
|
||||
if (($date["wday"]==$this->firstdayofweek) && ($i!=1)) {
|
||||
|
@ -258,44 +273,44 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
echo "<h4><a href=\"../out/out.Calendar.php?mode=w&year=".($year)."&month=".($month)."&day=".($i)."\">".date('W', mktime(12, 0, 0, $month, $i, $year)).". ".getMLText('calendar_week')."</a></h4>";
|
||||
echo "<div class=\"well\">";
|
||||
}
|
||||
|
||||
|
||||
// highlight today
|
||||
$class = ($year == $today["year"] && $month == $today["mon"] && $i == $today["mday"]) ? "todayHeader" : "header";
|
||||
|
||||
|
||||
echo "<h5>".$i.". - ".$this->dayNamesLong[$date["wday"]]."</h5>";
|
||||
|
||||
|
||||
if ($class=="todayHeader") $class="today";
|
||||
else $class="";
|
||||
|
||||
|
||||
$xdate=mktime(0, 0, 0, $month, $i, $year);
|
||||
foreach ($events as $event){
|
||||
echo "<div>";
|
||||
if (($event["start"]<=$xdate)&&($event["stop"]>=$xdate)){
|
||||
|
||||
|
||||
if (strlen($event['name']) > 25) $event['name'] = substr($event['name'], 0, 22) . "...";
|
||||
print "<i class=\"icon-lightbulb\"></i> <a href=\"../out/out.ViewEvent.php?id=".$event['id']."\">".htmlspecialchars($event['name'])."</a>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo "</div>";
|
||||
echo "</div>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
// $this->contentContainerEnd();
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
if (!isset($this->dayNamesLong)) $this->generateCalendarArrays();
|
||||
if (!isset($this->monthNames)) $this->generateCalendarArrays();
|
||||
|
||||
|
||||
// get the week interval - TODO: $GET
|
||||
$datestart=getdate(mktime(0,0,0,$month,$day,$year));
|
||||
while($datestart["wday"]!=$this->firstdayofweek){
|
||||
$datestart=getdate(mktime(0,0,0,$datestart["mon"],$datestart["mday"]-1,$datestart["year"]));
|
||||
}
|
||||
|
||||
|
||||
$datestop=getdate(mktime(23,59,59,$month,$day,$year));
|
||||
if ($datestop["wday"]==$this->firstdayofweek){
|
||||
$datestop=getdate(mktime(23,59,59,$datestop["mon"],$datestop["mday"]+1,$datestop["year"]));
|
||||
|
@ -304,15 +319,15 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
$datestop=getdate(mktime(23,59,59,$datestop["mon"],$datestop["mday"]+1,$datestop["year"]));
|
||||
}
|
||||
$datestop=getdate(mktime(23,59,59,$datestop["mon"],$datestop["mday"]-1,$datestop["year"]));
|
||||
|
||||
|
||||
$starttime=mktime(0,0,0,$datestart["mon"],$datestart["mday"],$datestart["year"]);
|
||||
$stoptime=mktime(23,59,59,$datestop["mon"],$datestop["mday"],$datestop["year"]);
|
||||
|
||||
|
||||
$today = getdate(time());
|
||||
$events = getEventsInInterval($starttime,$stoptime);
|
||||
|
||||
|
||||
$this->contentHeading(getMLText("week_view").": ".getReadableDate(mktime(12, 0, 0, $month, $day, $year)));
|
||||
|
||||
|
||||
echo "<div class=\"pagination pagination-small\">";
|
||||
echo "<ul>";
|
||||
print "<li><a href=\"../out/out.Calendar.php?mode=w&year=".($year)."&month=".($month)."&day=".($day-7)."\"><i style=\"color: black;\" class=\"icon-arrow-left\"></i></a></li>";
|
||||
|
@ -320,28 +335,28 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
print "<li><a href=\"../out/out.Calendar.php?mode=w&year=".($year)."&month=".($month)."&day=".($day+7)."\"><i style=\"color: black;\" class=\"icon-arrow-right\"></i></a></li>";
|
||||
echo "</ul>";
|
||||
echo "</div>";
|
||||
$this->contentContainerStart();
|
||||
|
||||
echo "<table class='table table-condensed'>\n";
|
||||
|
||||
// $this->contentContainerStart();
|
||||
|
||||
echo "<table class='table _table-condensed' style=\"max-width: 700px;\">\n";
|
||||
|
||||
for ($i=$starttime; $i<$stoptime; $i += 86400){
|
||||
|
||||
|
||||
$date = getdate($i);
|
||||
|
||||
|
||||
// for daylight saving time TODO: could be better
|
||||
if ( ($i!=$starttime) && ($prev_day==$date["mday"]) ){
|
||||
$i += 3600;
|
||||
$date = getdate($i);
|
||||
}
|
||||
|
||||
|
||||
// highlight today
|
||||
$class = ($date["year"] == $today["year"] && $date["mon"] == $today["mon"] && $date["mday"] == $today["mday"]) ? "info" : "";
|
||||
|
||||
|
||||
echo "<tr class=\"".$class."\">";
|
||||
echo "<td colspan=\"3\"><strong>".$this->dayNamesLong[$date["wday"]].", ";
|
||||
echo getReadableDate($i)."</strong></td>";
|
||||
echo "</tr>";
|
||||
|
||||
|
||||
foreach ($events as $event){
|
||||
if (($event["start"]<=$i)&&($event["stop"]>=$i)){
|
||||
echo "<tr>";
|
||||
|
@ -351,15 +366,15 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
print "</td>";
|
||||
echo "<td><a class=\"btn btn-mini\" href=\"../out/out.RemoveEvent.php?id=".$event['id']."\"><i class=\"icon-remove\"></i> ".getMLText('delete')."</a></td>";
|
||||
echo "<td><a class=\"btn btn-mini\" href=\"../out/out.EditEvent.php?id=".$event['id']."\">".getMLText('update')."</a></td>";
|
||||
echo "</tr>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$prev_day=$date["mday"];
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
$this->contentContainerEnd();
|
||||
// $this->contentContainerEnd();
|
||||
}
|
||||
|
||||
$this->contentEnd();
|
||||
|
|
Loading…
Reference in New Issue
Block a user