PHP-Code:
<?php
defined( '_VALID_MOS' ) or die( 'Restricted access' );
class HTML_easycalendar {
/**
* Show month view
*
* @param array $rows
* @param int $month
* @param int $year
*/
function showMonth($rows, $month, $year){
global $option, $mainframe, $Itemid;
mosCommonHTML::loadOverlib();
$mainframe->addCustomHeadTag('<link href="'.$mainframe->getCfg('live_site') . '/components/com_easycalendar/easycalendar.css" rel="stylesheet" type="text/css"/>');
$starttime = strtotime($year . '-' . $month . '-01 12:00:00');
$endtime = strtotime($year . '-' . $month . '-'. date('t', $starttime) . ' 12:00:00');
$firstday = date('w', $starttime);
$firstday = $firstday == 0 ? 7 : $firstday; //correct, monday as start day
$lastday = date('w', $endtime);
$lastday = $lastday == 0 ? 7 : $lastday; //correct, monday as start day
if($firstday != 1){
$first = $starttime - (($firstday - 1) * (60*60*24));
} else {
$first = $starttime;
}
if($lastday != 7){
$last = $endtime + ((7 - $lastday) * (60*60*24));
} else {
$last = $endtime;
}
if($month == 10){
$last = $last - (60*60*24);
}
$mainframe->setPageTitle(sprintf(EC_VIEW_MONTH, strftime('%B', $starttime), $year));
echo '<div class="componentheading">' . sprintf(EC_VIEW_MONTH, strftime('%B', $starttime), $year) . '</div>';
$p_month = $month - 1;
$p_year = $year;
if($p_month < 1){
$p_year--;
$p_month = 12;
}
$n_month = $month + 1;
$n_year = $year;
if($n_month > 12){
$n_year++;
$n_month = 1;
}
echo '<br><a href="' . sefRelToAbs('index.php?option=' . $option . '&month=' . $p_month . '&year=' . $p_year) . '" title="' . EC_PREV_MONTH . '"><img src="components/com_easycalendar/icons/22x22_back.png" border="0" alt="' . EC_PREV_MONTH . '" /></a>';
echo ' ';
echo '<a href="' . sefRelToAbs('index.php?option=' . $option . '&month=' . $n_month . '&year=' . $n_year) . '" title="' . EC_NEXT_MONTH . '"><img src="components/com_easycalendar/icons/22x22_forward.png" border="0" alt="' . EC_NEXT_MONTH . '" /></a><br><br>Fahre mit der Maus über einen Termin, um mehr Informationen anzeigen zu lassen.';
echo '<div class="heading">' . strftime('%a', $first) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (1 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (2 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (3 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (4 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (5 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (6 * 60*60*24)) . '</div>';
for($i=$first;$i<$last+(60*60*24);$i=$i+(60*60*24)){
// echo date('d-m-Y H:i:s', $i) . '|' . $i . '<br />';
if(date('w', $i) == 1){ //first day
echo '<br clear="all" />';
}
echo '<div class="day">';
echo '<span class="heading' . (date('m', $i) == $month ? ' active' : '') . '">' . date('j', $i) . '</span>';
if(isset($rows[date('Y-m-d', $i)])){
if(isset($rows[date('Y-m-d', $i)]['allday'])){ //list all allday events
for($j=0,$n=count($rows[date('Y-m-d', $i)]['allday']);$j<$n;$j++){
$row = $rows[date('Y-m-d', $i)]['allday'][$j];
$row->description = str_replace(array("\n", "\r"), '', $row->description);
$row->description = addslashes($row->description);
$link = sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid);
echo '<span class="event allday cat' . $row->cid . '">' . mosToolTip($row->description, $row->name, '', null, substr($row->name, 0, 12), $link) . '</span>';
}
}
if(isset($rows[date('Y-m-d', $i)]['regular'])){ //list all regular events
for($j=0,$n=count($rows[date('Y-m-d', $i)]['regular']);$j<$n;$j++){
$row = $rows[date('Y-m-d', $i)]['regular'][$j];
$row->description = str_replace(array("\n", "\r"), '', $row->description);
$row->description = addslashes($row->description);
$link = sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid);
echo '<span class="event regular cat' . $row->cid . '">' . mosToolTip($row->description, $row->name, '', null, substr($row->starttime, 0, 5) . ' ' . substr($row->name, 0, 8), $link) . '</span>';
}
}
}
echo '</div>';
}
}
/**
* Show upcoming events
*
* @param array $rows
*/
function showUpcoming($rows){
global $option, $Itemid, $mainframe;
$mainframe->setPageTitle(EC_VIEW_UPCOMING);
$mainframe->appendPathWay(EC_VIEW_UPCOMING);
echo '<div class="componentheading">' . EC_VIEW_UPCOMING . '</div>';
echo '<table width="100%" cellpadding="0" cellspacing="0">';
echo '<tr>';
echo '<th class="sectiontableheader">'. EC_EVENT_NAME . '</th>';
echo '<th class="sectiontableheader">'. EC_EVENT_DATE . '</th>';
echo '<th class="sectiontableheader">'. EC_EVENT_TIME . '</th>';
echo '<th class="sectiontableheader">'. EC_EVENT_CATEGORY . '</th>';
echo '</tr>';
for($i=0,$n=count($rows);$i<$n;$i++){
$row = $rows[$i];
$link = sefRelToAbs('index.php?option=' . $option . '&task=view&id=' . $row->id . '&Itemid=' . $Itemid);
echo '<tr>';
echo '<td><a href="' . $link . '">' . $row->name . '</a></td>';
echo '<td>' . ($row->startdate == $row->enddate ? mosFormatDate($row->startdate . ' ' . $row->starttime, EC_DATE_FORMAT) : mosFormatDate($row->startdate . ' ' . $row->starttime, EC_DATE_FORMAT) . ' - ' . mosFormatDate($row->enddate . ' ' . $row->endtime, EC_DATE_FORMAT)) . '</td>';
echo '<td>' . ($row->starttime == $row->endtime ? EC_ALL_DAY : mosFormatDate($row->startdate . ' ' . $row->starttime, EC_TIME_FORMAT) . ' - ' . mosFormatDate($row->enddate . ' ' . $row->endtime, EC_TIME_FORMAT)) . '</td>';
echo '<td>' . $row->category . '</td>';
echo '</tr>';
}
echo '</table>';
}
/**
* View event details
*
* @param dbEvent $row
*/
function viewEvent($row, $params){
global $option, $Itemid, $mainframe;
$mainframe->setPageTitle(sprintf(EC_VIEW_EVENT, $row->name));
$mainframe->appendPathWay(sprintf(EC_VIEW_EVENT, $row->name));
echo '<div class="componentheading">' . sprintf(EC_VIEW_EVENT, $row->name) . '</div>';
.... (nicht relevante codeinfos) ...
mosHTML::BackButton($params);
}
/**
* Show copyright notices
*/
function showCopyright(){
global $mainframe;
}
}
?>
Code der easycalendar.css ist zu finden unter:
PHP-Code:
echo '<div class="heading">' . strftime('%a', $first) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (1 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (2 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (3 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (4 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (5 * 60*60*24)) . '</div>';
echo '<div class="heading">' . strftime('%a', $first + (6 * 60*60*24)) . '</div>';
Denn wenn ich die einfach weglasse, werden die Wochentage über dem Kalender nicht angzeigt, dafür stimmt dann das design... Sollten ja aber eigentlich trotzdem angezeigt werden...
Lesezeichen