Ich hab mir erlaubt einen etwas anderen Minikalender auszuprobieren, dessen Code
ZarPrime im TP Forum gepostet hatte und hab dort kurz mal angefragt.
Gegenüber dem alten Kalender zeigt er auch die aktuellen Events an und wenn man dann die Uposathatage in der Jahreseriegnisliste eingetragen hat, würden auch diese dann "blau" aufscheinen. Läßt sich sicher auch grafisch was machen.
Hab den "Original-Code" (bin nicht sicher, ob es nicht noch einen gibt, der die Tage und Daten in der jeweiligen Sprache anzeigen würde) hier:
/******************************************************************************************
* 'Mini' Calendar in phpblock - *
* *
* Program Parameters/Switches can be specified to change what is displayed and how. *
* If highlighting is turned on, only the types of entries which are selected to *
* be shown will be highlighted (and have to be shown to guests for guests to see *
* highlights). If option of linking the day numbers to calendar event posting form *
* is chosen ($date_links_to_posting = true), SMF permissions are in effect and only *
* those allowed to post events to the calendar will have this link in effect. For *
* $date_links_to_posting = false, and for those not permitted to post events, day *
* numbers will link to the full SMF Calendar page. Additionally, if option to show *
* a separate 'Post Event' button is chosen ($show_post_event_button = true), it will *
* only show for those permitted to post events to the calendar. *
* *
* Look for 'NON-ENGLISH' to see section for changing language. This is actually more *
* correctly referred to as 'language other than server default' as this Calendar will *
* use the server's default LOCALE language for Month and Day names unless overides *
* are specified in the code section labeled 'NON-ENGLISH LABELS, MONTH & DAY NAMES', *
* below. *
* *
* Once a given day is highlighted, the highlight will not be supplanted. That means *
* you may want to modify the order in which highlights are applied in order to set *
* desired 'precedence' (i.e. if b-days highlights are applied first, once a given *
* day is highlighted with b-day color, it will not be changed to be highlighted *
* with event color if an event occurs on the same day; you need to choose an order *
* of precedence and sequence the highlighting accordingly by changing the sequence *
* of sections in the $order_hilites array. Highlighting will be done in the given *
* order. *
* *
* Also, if you want the individual B-day/Event/Holiday sections to be ordered in a *
* different sequence, you need to change the sequence of entries in the $order_lists *
* array. *
* *
* Examples of highlighting can be seen in the section 'Highlight colors & backgrounds' *
* below. As given, highlighting is done by applying the admin specified calendar *
* entry color to the date, bolded, on the default background. Commented example given *
* of using bold white on a background box of the admin specified calendar entry color. *
******************************************************************************************/
global $scripturl, $modSettings, $options, $context, $user_info, $sourcedir, $txt;
// Program Paramters/Switches Section
// use forum's date/time
// include user's time offset to forum date/time
$now = mktime() + (($user_info['time_offset'] + $modSettings['time_offset']) * 3600);
// Order to do highlightling - earlier have precedence
$order_hilites = array('Birthdays', 'Events', 'Holidays');
// Order to show calendar entry lists
$order_lists = array('Birthdays', 'Events', 'Holidays');
// Alignment of calendar entry lists
$align_list_entries = 'left';
// Use 'bordercolor' class for 'gridlines' (table background)
$bordercolor_gridlines = true; // Will 'show through' between table cells to act as 'grid lines'
$gridlines_thickness = 2; // Pixel thickness for table "cellspacing" - only used w/ $bordercolor_gridlines = true;
// Letters to show on calendar for names of each of the days
$day_name_length = 2;
// Selection for first day of the week: 0-Sunday; 1-Monday
$first_day = !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0;
// Show B-Day list at all / to guests
$show_bdays = true;
$show_bdays_to_guests = true;
// Show Event list at all / to guests
$show_events = true;
$show_events_to_guests = true;
// Show Holiday list at all / to guests
$show_hdays = true;
$show_hdays_to_guests = true;
// If true, calendar date numbers link to calendar event posting form
// if not, links to full calendar page
$date_links_to_posting = true;
// Adds 'Post Event' button to bottom of block
$show_post_event_button = true;
// Highlight events, b-days, holidays (only if they're selected to show at all)
$show_hilites = true;
// Colors for saturday & sunday
$color_sunday = '#D00000'; // comment out to use default text colors -
$color_saturday = '#D00000'; // can use hex codes with leading '#'
// Style to use for 'Today' highlight (color & background)
// example:
// 'color:#ff0000; background-color:#ffffff;';
$style_today = 'color:steelblue; font-weight:bold;';
// and / or
// Class to use for 'Today' highlight
$class_today = 'tborder';
// Default class to use when no other class specified
$class_default = 'windowbg';
// Class to use for column top day names
$class_day_names = ''; // Ex.: titlebg, catbg, catbg2, catbg3, windowbg, windowbg2, windowbg3
// Class for 'cells' holding text labels on calendar entry lists
$list_label_class = 'bordercolor'; // Ex.: titlebg, catbg, catbg2, catbg3, windowbg, windowbg2, windowbg3
// Class for 'cells' holding calendar entry lists
// use regular variable for all same class
// use two-member array to alternate between the two
// examples:
// $list_entry_class = 'windowbg';
// $list_entry_class = array('windowbg2','windowbg3');
$list_entry_class = '';
// Highlight style (colors & backgrounds & font)
// example:
// 'font-weight:bold; color:#ff0000; background-color:#ffffff;';
// and / or
// Highlight class (a existing class name)
// example:
// 'myclassname';
$hilite_bday_style = 'font-weight:bold;';
$hilite_bday_class = 'birthday'; // default style
$hilite_hday_style = 'font-weight:bold;';
$hilite_hday_class = 'holiday'; // default style
$hilite_event_style = 'font-weight:bold;';
$hilite_event_class = 'event'; // default style
// Choose to show 'look-behind' for the various entry types
$show_bdays_past = false;
$show_events_past = false;
$show_hdays_past = false;
// For any of the above chosen, days prior to today to display -
// use '0' (zero) to use beginning of current month
$past_look_behind_period = 0;
// Non-English Labels, Month and Day Names
// To use Month and Day names other than the default on your server,
// remove the two asterisk '*******' lines (the first starts with '/***'
// and the second ends '***/') and supply the List Section Labels and the
// Month and Day names to use per instructions below.
$list_label_bdays = 'Birthdays'; // Change to labels in language of choice
$list_label_events = 'Events';
$list_label_hdays = 'Holidays';
// $list_label_bdays = 'Cumpleaños';
// $list_label_events = 'Fiestas';
// $list_label_hdays = 'Festivos';
// specify all the day names in desired language
// The Startday is set according the Firstday in the Member profile
$day_names = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// $day_names = array('Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado');
// setup the day_names array according the Memberprofile
$i = $first_day;
while(!empty($i))
{
$fd = array_shift($day_names);
array_push($day_names, $fd);
$i--;
}
// specify the month names in desired language
$month_nam = array();
$month_nam['01'] = 'January';
$month_nam['02'] = 'February';
$month_nam['03'] = 'March';
$month_nam['04'] = 'April';
$month_nam['05'] = 'May';
$month_nam['06'] = 'June';
$month_nam['07'] = 'July';
$month_nam['08'] = 'August';
$month_nam['09'] = 'September';
$month_nam['10'] = 'October';
$month_nam['11'] = 'November';
$month_nam['12'] = 'December';
// $month_nam['01'] = 'Enero';
// $month_nam['02'] = 'Febrero';
// $month_nam['03'] = 'Marzo';
// $month_nam['04'] = 'Abril';
// $month_nam['05'] = 'Mayo';
// $month_nam['06'] = 'Junio';
// $month_nam['07'] = 'Julio';
// $month_nam['08'] = 'Agosto';
// $month_nam['09'] = 'Septiembre';
// $month_nam['10'] = 'Octubre';
// $month_nam['11'] = 'Noviembre';
// $month_nam['12'] = 'Diciembre';
$month_name = $month_nam[date('m',$now)];
//NAMES (end)
// Program Paramters/Switches Section - End
// (modify below at your own risk!!!)
if (empty($class_default))
$class_default = 'windowbg';
if (empty($hilite_bday_style))
$hilite_bday_class = $class_default;
if (empty($hilite_hday_class))
$hilite_hday_class = $class_default;
if (empty($hilite_event_class))
$hilite_event_class = $class_default;
$table_bkgrd = 'class="'.$class_default.'" cellspacing="1" cellpadding="1" style="margin:0 auto; text-align:center;"';
if ($bordercolor_gridlines)
$table_bkgrd = 'class="information" cellspacing="'.$gridlines_thickness.'" cellpadding="1" style="margin:0 auto; text-align:center;"';
$today = strftime('%d', $now);
$year = date('Y',$now);
$month = date('n',$now);
$nowdate = strftime('%Y-%m-%d', $now);
$month_href = $scripturl . '?action=calendar;year='.$year.';month='.$month;
require_once($sourcedir . '/Subs-Calendar.php');
$low_date_base = strftime('%Y-%m-%d', $now - 24 * 3600);
$high_date_base = strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600);
$low_date = ($show_bdays_past || $show_events_past || $show_hdays_past) ? ( ($past_look_behind_period == 0) ? date('Y',$now).'-'.date('m',$now).'-01' : strftime('%Y-%m-%d', $now - (($past_look_behind_period + 1) * 24 * 3600)) ) : $low_date_base;
$high_date = $high_date_base;
$low_date_ts = strtotime($low_date);
if ($show_bdays)
{
$bdays = $show_bdays_past ? getBirthdayRange($low_date, $high_date) : getBirthdayRange($low_date_base, $high_date);
ksort($bdays);
}
if ($show_events)
{
$events = $show_events_past ? getEventRange($low_date, $high_date, false) : getEventRange($low_date_base, $high_date, false);
ksort($events);
}
if ($show_hdays)
{
$holidays = $show_hdays_past ? getHolidayRange($low_date, $high_date) : getHolidayRange($low_date_base, $high_date);
ksort($holidays);
}
$stub = '<a class="smalltext" style="'.$style_today.'padding: 0px 2px 0px 2px;"';
// Highlighted 'Today' Box
if ($date_links_to_posting && allowedTo('calendar_post'))
$days = array($today => array(NULL, $class_today, $stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.date('j',$now).'</a>'));
else
$days = array($today => array(NULL, $class_today, $stub.' href="'.htmlspecialchars($month_href).'" target="_self">'.date('j',$now).'</a>'));
// HIGHLIGHTING (start)
if ($show_hilites)
{
foreach($order_hilites as $hilite_to_do)
{
$flag = strtoupper(substr($hilite_to_do,0,1));
// B-Day Highlighting
if ($flag == 'B')
{
if ($show_bdays)
{
if ($show_bdays_to_guests || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_bday_style .'padding: 0px 2px 0px 2px;"';
foreach($bdays as $startdate => $value)
{
if(!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
if ($date_links_to_posting && allowedTo('calendar_post'))
$days[substr($startdate,8)] = array(NULL, $hilite_bday_class, $stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self"><span class="'.$hilite_bday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_bday_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_bday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}
// Event Highlighting
if ($flag == 'E')
{
if ($show_events)
{
if ($show_events_to_guests || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_event_style .'padding: 0px 2px 0px 2px;"';
foreach($events as $startdate => $value)
{
if(!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
if ($date_links_to_posting && allowedTo('calendar_post'))
$days[substr($startdate,8)] = array(NULL, $hilite_event_class, $stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self"><span class="'.$hilite_event_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_event_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_event_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}
// Holiday Highlighting
if ($flag == 'H')
{
if ($show_hdays)
{
if ($show_hdays_to_guests || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_hday_style .'padding: 0px 2px 0px 2px;"';
foreach($holidays as $startdate => $value)
{
if (!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
if ($date_links_to_posting && allowedTo('calendar_post'))
$days[substr($startdate,8)] = array(NULL, $hilite_hday_class, $stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self"><span class="'.$hilite_hday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_hday_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_hday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}
}
}
// HIGHLIGHTING (end)
$first_of_month = gmmktime(0,0,0,$month,1,$year);
list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));
if (!isset($month_nam['12']))
{
$day_names = array(); // generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) // January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); // %A means full textual day name
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
}
$weekday = ($weekday + 7 - $first_day) % 7; // adjust for $first_day
$title = htmlentities(ucfirst($month_name)).' '.$year; // note that some locales don't capitalize month and day names
$calendar = '<table '.$table_bkgrd.'>'.'<caption >'.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).'</caption><tr>';
if (empty($class_day_names))
$class_day_names = $class_default;
if($day_name_length)
{ #if the day names should be shown ($day_name_length > 0)
foreach($day_names as $d)
$calendar .= '<th class="'.$class_day_names.' smalltext" align="center" valign="middle" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= '</tr><tr style="text-align:right;">';
}
if($weekday > 0)
$calendar .= '<td class="'.$class_default.'" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++)
{
if($weekday == 7)
{
$weekday = 0; #start a new week
$calendar .= '</tr><tr style="text-align:right;">';
}
$daynow = sprintf('%02d',$day);
$col_width = ' width="14%"';
if (((($weekday+$first_day) % 7) == 0) || ((($weekday+$first_day) % 7) == 0))
$col_width = ' width="15%"';
if(isset($days[$daynow]) && is_array($days[$daynow]))
{
@list($link, $classes, $content) = $days[$daynow];
if(is_null($content))
$content = $daynow;
$calendar .= '<td'.$col_width.' align="center" valign="middle" '.($classes ? ' class="'.htmlspecialchars($classes).'" style="padding: 0px 0px 0px 0px;font-size: x-small;">' : '>').($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= '<td'.$col_width.' class="'.$class_default.'" align="center" valign="middle" style="padding: 0px 0px 0px 0px;font-size: x-small;"><a class="smalltext"';
if (((($weekday+$first_day) % 7) == 0) && isset($color_sunday))
$calendar .= ' style="color:'.$color_sunday.';"';
if (((($weekday+$first_day) % 7) == 6) && isset($color_saturday))
$calendar .= ' style="color:'.$color_saturday.';"';
if ($date_links_to_posting && allowedTo('calendar_post'))
$calendar .= ' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$day.'" target="_self">'.$day.'</a></td>';
else
$calendar .= ' href="'.htmlspecialchars($month_href).'" target="_self">'.$day.'</a></td>';
}
}
if($weekday != 7)
$calendar .= '<td class="'.$class_default.'" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
echo $calendar.'</tr>';
foreach($order_lists as $list_to_do)
{
$flag = strtoupper(substr($list_to_do,0,1));
if (!isset($align_list_entries))
$align_list_entries = 'center';
elseif ($align_list_entries <> 'left')
$align_list_entries = 'center';
if (empty($list_label_class))
$list_label_class = $class_default;
if (empty($list_entry_class))
$list_entry_class = $class_default;
// BIRTHDAY SECTION
if(($flag == 'B') && $show_bdays)
{
if($show_bdays_to_guests || !$user_info['is_guest'])
{
if (!empty($bdays))
{
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_bdays.'</td></tr>';
$ctr = 0;
foreach($bdays as $startdate => $bday_date)
{
if (($startdate >= strftime('%Y-%m-%d', $low_date_ts)) && ($startdate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
foreach ($bday_date as $member)
{
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$birthdate = strtotime($startdate);
$text_start = !isset($month_nam['12']) ? date("M j",$birthdate) : substr($month_nam[strftime('%m', $birthdate)],0,3) . date(" j",$birthdate);
echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . ':</strong></a> ';
echo '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" title="' . $txt['profile_of'] . ' ' . $member['name'] . '">' . '<span class="'.$hilite_bday_class.'">' . ( ($nowdate == $startdate) ? '<b>' : '') . $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '') . ( ($nowdate == $startdate) ? '</b>' : '') . '</span>' . '</a>';
echo '</td></tr>';
}
}
}
}
}
}
// EVENTS SECTION
if(($flag == 'E') && $show_events)
{
if($show_events_to_guests || !$user_info['is_guest'])
{
if (!empty($events))
{
$events_printed = array();
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_events.'</td></tr>';
$ctr = 0;
foreach ($events as $startdate => $evt_date)
{
if (($startdate >= strftime('%Y-%m-%d', $low_date_ts)) && ($startdate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
foreach ($evt_date as $event)
{
if (!in_array($event['id'],$events_printed))
{
$events_printed[] = $event['id'];
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$evt_start = strtotime($event['start_date']);
$evt_end = strtotime($event['end_date']);
$text_start = !isset($month_nam['12']) ? date("M j",$evt_start) : substr($month_nam[strftime('%m', $evt_start)],0,3) . date(" j",$evt_start);
$text_end = ($event['start_date'] == $event['end_date'] ? '' : '-'. (substr($event['start_date'],5,2) == substr($event['end_date'],5,2) ? date("j",$evt_end) : (!isset($month_nam['12']) ? date("M j",$evt_end) : substr($month_nam[strftime('%m', $evt_start)],0,3) . date(" j",$evt_start))));
$link = $event['topic'] == 0 ? '<span class="'.$hilite_event_class.'">'. $event['title'] .'</span>' : '<a href="' . $scripturl . '?topic=' . $event['topic'] . '.0' . '"><span class="'.$hilite_event_class.'">' . $event['title'] . '</span></a>';
echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . $text_end . ':</strong></a> ';
echo ( ($nowdate >= $event['start_date']) && ($event['end_date'] >= $nowdate) ) ? '<b>'.$link.'</b>' : $link;
echo '</td></tr>';
}
}
}
}
}
}
}
// HOLIDAY SECTION
if(($flag == 'H') && $show_hdays)
{
if($show_hdays_to_guests || !$user_info['is_guest'])
{
if (!empty($holidays))
{
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_hdays.'</td></tr>';
$ctr = 0;
foreach ($holidays as $hDate => $hday)
{
if (($hDate >= strftime('%Y-%m-%d', $low_date_ts)) && ($hDate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
$eventdate = strtotime(date("Y").substr($hDate, 4));
foreach ($hday as $holiday)
{
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$text_start = !isset($month_nam['12']) ? date("M j",$eventdate) : substr($month_nam[strftime('%m', $eventdate)],0,3) . date(" j",$eventdate);
echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . ':</strong></a> ';
echo '<span class="'.$hilite_hday_class.'">'.$holiday.'</span>';
echo '</td></tr>';
}
}
}
}
}
}
}
if ($show_post_event_button)
{
if (allowedTo('calendar_post'))
{
echo '<tr><td colspan="7" class="'.$class_default.'" align="center" valign="middle">';
echo '<hr/ >';
echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month, ';year=', $year, ';sesc=', $context['session_id'], '">','<br />', create_button('calendarpe.gif', 'calendar_post_event', 'calendar_post_event', 'align="middle"'), '</a>';
echo '</td></tr>';
}
}
echo '</table>';
und da er etwas flashig war, hab ich ihn etwas angepasst und abgespeckt (die Highlightfarben sind "System"- und die müßte man im index.css ändern, wenn man das möchte). Das ist der Code, der heute für den Kalender hier zur Probe steht.
/******************************************************************************************
* 'Mini' Calendar in phpblock - *
* *
* Program Parameters/Switches can be specified to change what is displayed and how. *
* If highlighting is turned on, only the types of entries which are selected to *
* be shown will be highlighted (and have to be shown to guests for guests to see *
* highlights). If option of linking the day numbers to calendar event posting form *
* is chosen ($date_links_to_posting = true), SMF permissions are in effect and only *
* those allowed to post events to the calendar will have this link in effect. For *
* $date_links_to_posting = false, and for those not permitted to post events, day *
* numbers will link to the full SMF Calendar page. Additionally, if option to show *
* a separate 'Post Event' button is chosen ($show_post_event_button = true), it will *
* only show for those permitted to post events to the calendar. *
* *
* Look for 'NON-ENGLISH' to see section for changing language. This is actually more *
* correctly referred to as 'language other than server default' as this Calendar will *
* use the server's default LOCALE language for Month and Day names unless overides *
* are specified in the code section labeled 'NON-ENGLISH LABELS, MONTH & DAY NAMES', *
* below. *
* *
* Once a given day is highlighted, the highlight will not be supplanted. That means *
* you may want to modify the order in which highlights are applied in order to set *
* desired 'precedence' (i.e. if b-days highlights are applied first, once a given *
* day is highlighted with b-day color, it will not be changed to be highlighted *
* with event color if an event occurs on the same day; you need to choose an order *
* of precedence and sequence the highlighting accordingly by changing the sequence *
* of sections in the $order_hilites array. Highlighting will be done in the given *
* order. *
* *
* Also, if you want the individual B-day/Event/Holiday sections to be ordered in a *
* different sequence, you need to change the sequence of entries in the $order_lists *
* array. *
* *
* Examples of highlighting can be seen in the section 'Highlight colors & backgrounds' *
* below. As given, highlighting is done by applying the admin specified calendar *
* entry color to the date, bolded, on the default background. Commented example given *
* of using bold white on a background box of the admin specified calendar entry color. *
******************************************************************************************/
global $scripturl, $modSettings, $options, $context, $user_info, $sourcedir, $txt;
// Program Paramters/Switches Section
// use forum's date/time
// include user's time offset to forum date/time
$now = mktime() + (($user_info['time_offset'] + $modSettings['time_offset']) * 3600);
// Order to do highlightling - earlier have precedence
$order_hilites = array('Birthdays', 'Events', 'Holidays');
// Order to show calendar entry lists
$order_lists = array('Birthdays', 'Events', 'Holidays');
// Alignment of calendar entry lists
$align_list_entries = 'left';
// Use 'bordercolor' class for 'gridlines' (table background)
$bordercolor_gridlines = true; // Will 'show through' between table cells to act as 'grid lines'
$gridlines_thickness = 2; // Pixel thickness for table "cellspacing" - only used w/ $bordercolor_gridlines = true;
// Letters to show on calendar for names of each of the days
$day_name_length = 2;
// Selection for first day of the week: 0-Sunday; 1-Monday
$first_day = !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0;
// Show B-Day list at all / to guests
$show_bdays = true;
$show_bdays_to_guests = true;
// Show Event list at all / to guests
$show_events = true;
$show_events_to_guests = true;
// Show Holiday list at all / to guests
$show_hdays = true;
$show_hdays_to_guests = true;
// If true, calendar date numbers link to calendar event posting form
// if not, links to full calendar page
$date_links_to_posting = true;
// Adds 'Post Event' button to bottom of block
$show_post_event_button = true;
// Highlight events, b-days, holidays (only if they're selected to show at all)
$show_hilites = true;
// Colors for saturday & sunday
$color_sunday = '#B8704D'; // comment out to use default text colors -
$color_saturday = '#B8704D'; // can use hex codes with leading '#'
// Style to use for 'Today' highlight (color & background)
// example:
// 'color:#000000; background-color:#FFFFFF;';
$style_today = 'color:#B8704D; font-weight:bold; background-color:#D1D1D1;';
// and / or
// Class to use for 'Today' highlight
$class_today = 'tborder';
// Default class to use when no other class specified
$class_default = 'windowbg';
// Class to use for column top day names
$class_day_names = ''; // Ex.: titlebg, catbg, catbg2, catbg3, windowbg, windowbg2, windowbg3
// Class for 'cells' holding text labels on calendar entry lists
$list_label_class = 'bordercolor'; // Ex.: titlebg, catbg, catbg2, catbg3, windowbg, windowbg2, windowbg3
// Class for 'cells' holding calendar entry lists
// use regular variable for all same class
// use two-member array to alternate between the two
// examples:
// $list_entry_class = 'windowbg';
// $list_entry_class = array('windowbg2','windowbg3');
$list_entry_class = '';
// Highlight style (colors & backgrounds & font)
// example:
// 'font-weight:bold; color:#ff0000; background-color:#ffffff;';
// and / or
// Highlight class (a existing class name)
// example:
// 'myclassname';
$hilite_bday_style = 'font-weight:bold;';
$hilite_bday_class = 'birthday'; // default style
$hilite_hday_style = 'font-weight:bold;';
$hilite_hday_class = 'holiday'; // default style
$hilite_event_style = 'font-weight:bold;';
$hilite_event_class = 'event'; // default style
// Choose to show 'look-behind' for the various entry types
$show_bdays_past = false;
$show_events_past = false;
$show_hdays_past = false;
// For any of the above chosen, days prior to today to display -
// use '0' (zero) to use beginning of current month
$past_look_behind_period = 0;
// Non-English Labels, Month and Day Names
// To use Month and Day names other than the default on your server,
// remove the two asterisk '*******' lines (the first starts with '/***'
// and the second ends '***/') and supply the List Section Labels and the
// Month and Day names to use per instructions below.
$list_label_bdays = 'Birthdays'; // Change to labels in language of choice
$list_label_events = 'Events';
$list_label_hdays = 'Holidays';
// $list_label_bdays = 'Cumpleaños';
// $list_label_events = 'Fiestas';
// $list_label_hdays = 'Festivos';
// specify all the day names in desired language
// The Startday is set according the Firstday in the Member profile
$day_names = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// $day_names = array('Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado');
// setup the day_names array according the Memberprofile
$i = $first_day;
while(!empty($i))
{
$fd = array_shift($day_names);
array_push($day_names, $fd);
$i--;
}
// specify the month names in desired language
$month_nam = array();
$month_nam['01'] = 'January';
$month_nam['02'] = 'February';
$month_nam['03'] = 'March';
$month_nam['04'] = 'April';
$month_nam['05'] = 'May';
$month_nam['06'] = 'June';
$month_nam['07'] = 'July';
$month_nam['08'] = 'August';
$month_nam['09'] = 'September';
$month_nam['10'] = 'October';
$month_nam['11'] = 'November';
$month_nam['12'] = 'December';
// $month_nam['01'] = 'Enero';
// $month_nam['02'] = 'Febrero';
// $month_nam['03'] = 'Marzo';
// $month_nam['04'] = 'Abril';
// $month_nam['05'] = 'Mayo';
// $month_nam['06'] = 'Junio';
// $month_nam['07'] = 'Julio';
// $month_nam['08'] = 'Agosto';
// $month_nam['09'] = 'Septiembre';
// $month_nam['10'] = 'Octubre';
// $month_nam['11'] = 'Noviembre';
// $month_nam['12'] = 'Diciembre';
$month_name = $month_nam[date('m',$now)];
//NAMES (end)
// Program Paramters/Switches Section - End
// (modify below at your own risk!!!)
if (empty($class_default))
$class_default = 'windowbg';
if (empty($hilite_bday_style))
$hilite_bday_class = $class_default;
if (empty($hilite_hday_class))
$hilite_hday_class = $class_default;
if (empty($hilite_event_class))
$hilite_event_class = $class_default;
$table_bkgrd = 'class="'.$class_default.'" cellspacing="1" cellpadding="1" style="margin:0 auto; text-align:center;"';
if ($bordercolor_gridlines)
$table_bkgrd = 'cellspacing="'.$gridlines_thickness.'" cellpadding="1" style="margin:0 auto; text-align:center;"';
$today = strftime('%d', $now);
$year = date('Y',$now);
$month = date('n',$now);
$nowdate = strftime('%Y-%m-%d', $now);
$month_href = $scripturl . '?action=calendar;year='.$year.';month='.$month;
require_once($sourcedir . '/Subs-Calendar.php');
$low_date_base = strftime('%Y-%m-%d', $now - 24 * 3600);
$high_date_base = strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600);
$low_date = ($show_bdays_past || $show_events_past || $show_hdays_past) ? ( ($past_look_behind_period == 0) ? date('Y',$now).'-'.date('m',$now).'-01' : strftime('%Y-%m-%d', $now - (($past_look_behind_period + 1) * 24 * 3600)) ) : $low_date_base;
$high_date = $high_date_base;
$low_date_ts = strtotime($low_date);
if ($show_bdays)
{
$bdays = $show_bdays_past ? getBirthdayRange($low_date, $high_date) : getBirthdayRange($low_date_base, $high_date);
ksort($bdays);
}
if ($show_events)
{
$events = $show_events_past ? getEventRange($low_date, $high_date, false) : getEventRange($low_date_base, $high_date, false);
ksort($events);
}
if ($show_hdays)
{
$holidays = $show_hdays_past ? getHolidayRange($low_date, $high_date) : getHolidayRange($low_date_base, $high_date);
ksort($holidays);
}
$stub = '<a style="'.$style_today.'padding: 0px 2px 0px 2px;"';
// Highlighted 'Today' Box
if ($date_links_to_posting && allowedTo('calendar_post'))
$days = array($today => array(NULL, $class_today, $stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.date('j',$now).'</a>'));
else
$days = array($today => array(NULL, $class_today, $stub.' href="'.htmlspecialchars($month_href).'" target="_self">'.date('j',$now).'</a>'));
// HIGHLIGHTING (start)
if ($show_hilites)
{
foreach($order_hilites as $hilite_to_do)
{
$flag = strtoupper(substr($hilite_to_do,0,1));
// B-Day Highlighting
if ($flag == 'B')
{
if ($show_bdays)
{
if ($show_bdays_to_guests || !$user_info['is_guest'])
{
$stub = '<a style="'. $hilite_bday_style .'padding: 0px 2px 0px 2px;"';
foreach($bdays as $startdate => $value)
{
if(!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
if ($date_links_to_posting && allowedTo('calendar_post'))
$days[substr($startdate,8)] = array(NULL, $hilite_bday_class, $stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self"><span class="'.$hilite_bday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_bday_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_bday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}
// Event Highlighting
if ($flag == 'E')
{
if ($show_events)
{
if ($show_events_to_guests || !$user_info['is_guest'])
{
$stub = '<a style="'. $hilite_event_style .'padding: 0px 2px 0px 2px;"';
foreach($events as $startdate => $value)
{
if(!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
if ($date_links_to_posting && allowedTo('calendar_post'))
$days[substr($startdate,8)] = array(NULL, $hilite_event_class, $stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self"><span class="'.$hilite_event_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_event_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_event_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}
// Holiday Highlighting
if ($flag == 'H')
{
if ($show_hdays)
{
if ($show_hdays_to_guests || !$user_info['is_guest'])
{
$stub = '<a style="'. $hilite_hday_style .'padding: 0px 2px 0px 2px;"';
foreach($holidays as $startdate => $value)
{
if (!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
if ($date_links_to_posting && allowedTo('calendar_post'))
$days[substr($startdate,8)] = array(NULL, $hilite_hday_class, $stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self"><span class="'.$hilite_hday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_hday_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_hday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}
}
}
// HIGHLIGHTING (end)
$first_of_month = gmmktime(0,0,0,$month,1,$year);
list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));
if (!isset($month_nam['12']))
{
$day_names = array(); // generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) // January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); // %A means full textual day name
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
}
$weekday = ($weekday + 7 - $first_day) % 7; // adjust for $first_day
$title = htmlentities(ucfirst($month_name)).' '.$year; // note that some locales don't capitalize month and day names
$calendar = '<table '.$table_bkgrd.'>'.'<caption >'.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).'</caption><tr>';
if (empty($class_day_names))
$class_day_names = $class_default;
if($day_name_length)
{ #if the day names should be shown ($day_name_length > 0)
foreach($day_names as $d)
$calendar .= '<th class="'.$class_day_names.'" align="center" valign="middle" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= '</tr><tr style="text-align:right;">';
}
if($weekday > 0)
$calendar .= '<td class="'.$class_default.'" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++)
{
if($weekday == 7)
{
$weekday = 0; #start a new week
$calendar .= '</tr><tr style="text-align:right;">';
}
$daynow = sprintf('%02d',$day);
$col_width = ' width="14%"';
if (((($weekday+$first_day) % 7) == 0) || ((($weekday+$first_day) % 7) == 0))
$col_width = ' width="15%"';
if(isset($days[$daynow]) && is_array($days[$daynow]))
{
@list($link, $classes, $content) = $days[$daynow];
if(is_null($content))
$content = $daynow;
$calendar .= '<td'.$col_width.' align="center" valign="middle" '.($classes ? ' class="'.htmlspecialchars($classes).'" style="padding: 0px 0px 0px 0px;font-size: x-small;">' : '>').($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= '<td'.$col_width.' class="'.$class_default.'" align="center" valign="middle" style="padding: 0px 0px 0px 0px;font-size: x-small;"><a ';
if (((($weekday+$first_day) % 7) == 0) && isset($color_sunday))
$calendar .= ' style="color:'.$color_sunday.';"';
if (((($weekday+$first_day) % 7) == 6) && isset($color_saturday))
$calendar .= ' style="color:'.$color_saturday.';"';
if ($date_links_to_posting && allowedTo('calendar_post'))
$calendar .= ' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$day.'" target="_self">'.$day.'</a></td>';
else
$calendar .= ' href="'.htmlspecialchars($month_href).'" target="_self">'.$day.'</a></td>';
}
}
if($weekday != 7)
$calendar .= '<td class="'.$class_default.'" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
echo $calendar.'</tr>';
foreach($order_lists as $list_to_do)
{
$flag = strtoupper(substr($list_to_do,0,1));
if (!isset($align_list_entries))
$align_list_entries = 'center';
elseif ($align_list_entries <> 'left')
$align_list_entries = 'center';
if (empty($list_label_class))
$list_label_class = $class_default;
if (empty($list_entry_class))
$list_entry_class = $class_default;
// BIRTHDAY SECTION
if(($flag == 'B') && $show_bdays)
{
if($show_bdays_to_guests || !$user_info['is_guest'])
{
if (!empty($bdays))
{
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" align="center" style="font-weight: bold;">'.$list_label_bdays.'</td></tr>';
$ctr = 0;
foreach($bdays as $startdate => $bday_date)
{
if (($startdate >= strftime('%Y-%m-%d', $low_date_ts)) && ($startdate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
foreach ($bday_date as $member)
{
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$birthdate = strtotime($startdate);
$text_start = !isset($month_nam['12']) ? date("M j",$birthdate) : substr($month_nam[strftime('%m', $birthdate)],0,3) . date(" j",$birthdate);
echo '<tr'.$class_to_use.'><td colspan="7" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . ':</strong></a> ';
echo '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" title="' . $txt['profile_of'] . ' ' . $member['name'] . '">' . '<span class="'.$hilite_bday_class.'">' . ( ($nowdate == $startdate) ? '<b>' : '') . $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '') . ( ($nowdate == $startdate) ? '</b>' : '') . '</span>' . '</a>';
echo '</td></tr>';
}
}
}
}
}
}
// EVENTS SECTION
if(($flag == 'E') && $show_events)
{
if($show_events_to_guests || !$user_info['is_guest'])
{
if (!empty($events))
{
$events_printed = array();
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" align="center" style="font-weight: bold;">'.$list_label_events.'</td></tr>';
$ctr = 0;
foreach ($events as $startdate => $evt_date)
{
if (($startdate >= strftime('%Y-%m-%d', $low_date_ts)) && ($startdate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
foreach ($evt_date as $event)
{
if (!in_array($event['id'],$events_printed))
{
$events_printed[] = $event['id'];
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$evt_start = strtotime($event['start_date']);
$evt_end = strtotime($event['end_date']);
$text_start = !isset($month_nam['12']) ? date("M j",$evt_start) : substr($month_nam[strftime('%m', $evt_start)],0,3) . date(" j",$evt_start);
$text_end = ($event['start_date'] == $event['end_date'] ? '' : '-'. (substr($event['start_date'],5,2) == substr($event['end_date'],5,2) ? date("j",$evt_end) : (!isset($month_nam['12']) ? date("M j",$evt_end) : substr($month_nam[strftime('%m', $evt_start)],0,3) . date(" j",$evt_start))));
$link = $event['topic'] == 0 ? '<span class="'.$hilite_event_class.'">'. $event['title'] .'</span>' : '<a href="' . $scripturl . '?topic=' . $event['topic'] . '.0' . '"><span class="'.$hilite_event_class.'">' . $event['title'] . '</span></a>';
echo '<tr'.$class_to_use.'><td colspan="7" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . $text_end . ':</strong></a> ';
echo ( ($nowdate >= $event['start_date']) && ($event['end_date'] >= $nowdate) ) ? '<b>'.$link.'</b>' : $link;
echo '</td></tr>';
}
}
}
}
}
}
}
// HOLIDAY SECTION
if(($flag == 'H') && $show_hdays)
{
if($show_hdays_to_guests || !$user_info['is_guest'])
{
if (!empty($holidays))
{
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" align="center" style="font-weight: bold;">'.$list_label_hdays.'</td></tr>';
$ctr = 0;
foreach ($holidays as $hDate => $hday)
{
if (($hDate >= strftime('%Y-%m-%d', $low_date_ts)) && ($hDate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
$eventdate = strtotime(date("Y").substr($hDate, 4));
foreach ($hday as $holiday)
{
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$text_start = !isset($month_nam['12']) ? date("M j",$eventdate) : substr($month_nam[strftime('%m', $eventdate)],0,3) . date(" j",$eventdate);
echo '<tr'.$class_to_use.'><td colspan="7" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . ':</strong></a> ';
echo '<span class="'.$hilite_hday_class.'">'.$holiday.'</span>';
echo '</td></tr>';
}
}
}
}
}
}
}
if ($show_post_event_button)
{
if (allowedTo('calendar_post'))
{
echo '<tr><td colspan="7" class="'.$class_default.'" align="center" valign="middle">';
echo '<hr/ >';
echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month, ';year=', $year, ';sesc=', $context['session_id'], '">','<br />', create_button('calendar_post_event', 'calendar_post_event', 'align="middle"'), '</a>';
echo '</td></tr>';
}
}
echo '</table>';
Der alte Minikalender, ich hab ihn noch in einem unbenutzen Block gespeichert, wird mit diesem Code generiert:
global $scripturl, $smcFunc;
$now = mktime();
$today = date('j',$now);
$year = date("Y",$now);
$month = date("n",$now);
$days = array($today => array(NULL, NULL, '<a class="smalltext" style="color: steelblue; font-weight: bold; border: solid 1px black; background-color: white; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));
$day_name_length = 3;
$month_href = $scripturl . '?action=calendar';
$first_day = 1;
$pn = array();
$first_of_month = gmmktime(0,0,0,$month,1,$year);
//remember that mktime will automatically correct if invalid dates are entered
// for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
// this provides a built in "rounding" feature to generate_calendar()
$day_names = array(); //generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) //January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); //%A means full textual day name
list($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m,%Y,%B,%w', $first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; //adjust for $first_day
$title = $smcFunc['htmlspecialchars'](ucfirst($month_name)).' '.$year; //note that some locales don't capitalize month and day names
//Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn);
@list($n, $nl) = each($pn); //previous and next links, if applicable
if($p)
$p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n)
$n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table>'."\n".
'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
//if day_name_length is >3, the full name of the day will be printed
foreach($day_names as $d)
$calendar .= '<th class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if($weekday > 0)
$calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; //initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))
$content = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7)
$calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; //remaining "empty" days
echo $calendar."</tr>\n</table>\n";
Nur das man es findet, bzw. vielleicht Vorlagen für Besseres hat.
Der alte Code produziert einen kleinen html-Fehler und das war eigentlich der Grund, warum ich da dann dazu gekommen bin. Konnte im Code nicht ganz erkennen woran es lag, aber ich denke, daß der Grund ist, das in den Tabelen keine Styles mehr zugelassen werden und da irgendwie ein " in einen Tag hineinrutscht. Im Übrigen ist damit und mit ein paar anderen Ausbesserungen, die Startseite zumindest, wieder oder vielleicht sogar erstmal:
This document was successfully checked as XHTML 1.0 Transitional!