// If the month and year are not passed in, use today's date as a starting point.
$curPage = array( 'month' => isset($_REQUEST['month']) ? (int) $_REQUEST['month'] : $today['month'],
'year' => isset($_REQUEST['year']) ? (int) $_REQUEST['year'] : $today['year']
);
// Get information about the first day of this month.
$firstDayOfMonth = array(
'dayOfWeek' => (int) strftime('%w', mktime(0, 0, 0, $curPage['month'], 1, $curPage['year'])),
'weekNum' => (int) strftime('%U', mktime(0, 0, 0, $curPage['month'], 1, $curPage['year']))
);
Sonrasına ekle:
// Get information about the first day of tprevious month.
$firstDayOfPrevMonth = array(
'dayOfWeek' => (int) strftime('%w', mktime(0, 0, 0, $curPagePrev['month'], 1, $curPagePrev['year'])),
'weekNum' => (int) strftime('%U', mktime(0, 0, 0, $curPagePrev['month'], 1, $curPagePrev['year']))
);
// Get information about the first day of tprevious month.
$firstDayOfNextMonth = array(
'dayOfWeek' => (int) strftime('%w', mktime(0, 0, 0, $curPageNext['month'], 1, $curPageNext['year'])),
'weekNum' => (int) strftime('%U', mktime(0, 0, 0, $curPageNext['month'], 1, $curPageNext['year']))
);
Bul:
// Find the last day of the month.
$nLastDay = (int) strftime('%d', mktime(0, 0, 0, $curPage['month'] == 12 ? 1 : $curPage['month'] + 1, 0, $curPage['month'] == 12 ? $curPage['year'] + 1 : $curPage['year']));
// The number of days the first row is shifted to the right for the starting day.
$nShift = $firstDayOfMonth['dayOfWeek'];
// The number of days the first row is shifted to the right for the starting day.
$nShiftPrev = $firstDayOfPrevMonth['dayOfWeek'];
$nShift = $firstDayOfMonth['dayOfWeek'];
$nShiftNext = $firstDayOfNextMonth['dayOfWeek'];
// Number of rows required to fit the prev month.
$nRowsPrev = floor(($nLastDayPrev + $nShiftPrev) / 7);
if (($nLastDayPrev + $nShiftPrev) % 7)
$nRowsPrev++;
// Number of rows required to fit the next month.
$nRowsNext = floor(($nLastDayNext + $nShiftNext) / 7);
if (($nLastDayNext + $nShiftNext) % 7)
$nRowsNext++;
// Start off the week - and don't let it go above 52, since that's the number of weeks in a year.
$context['weeks'][$nRow] = array(
'days' => array(),
'number' => $firstDayOfMonth['weekNum'] + $nRow + $nWeekAdjust
);
// Handle the dreaded "week 53", it can happen, but only once in a blue moon
if ($context['weeks'][$nRow]['number'] == 53 && $nShift != 4)
$context['weeks'][$nRow]['number'] = 1;
Değiştir:
// This is the week number assigned as a key to limit results to a certain week.
$number = $firstDayOfMonth['weekNum'] + $nRow + $nWeekAdjust;
// Start off the week - and don't let it go above 52, since that's the number of weeks in a year.
$context['weeks'][$number] = array(
'days' => array(),
'number' => $firstDayOfMonth['weekNum'] + $nRow + $nWeekAdjust,
'week' => $scripturl . '?action=calendar;year=' . $curPage['year'] . ';month=' . $curPage['month'] . ';week=' . $number,
);
// Handle the dreaded "week 53", it can happen, but only once in a blue moon
if ($context['weeks'][$number]['number'] == 53 && $nShift != 4)
$context['weeks'][$number]['number'] = 1;
// Iterate through each week.
$context['prevMonthWeeks'] = array();
for ($nRowPrev = 0; $nRowPrev < $nRowsPrev; $nRowPrev++)
{
// This is the week number assigned as a key to limit results to a certain week.
$number = $firstDayOfPrevMonth['weekNum'] + $nRowPrev + $nWeekAdjust + ($curPage['month'] == 1 ? -1 : 0);;
// Start off the week - and don't let it go above 52, since that's the number of weeks in a year.
$context['prevMonthWeeks'][$number] = array(
'days' => array(),
'number' => $firstDayOfPrevMonth['weekNum'] + $nRowPrev + $nWeekAdjust,
'week' => $scripturl . '?action=calendar;year=' . $curPagePrev['year'] . ';month=' . $curPagePrev['month'] . ';week=' . $number,
);
// Handle the dreaded "week 53", it can happen, but only once in a blue moon
if ($context['prevMonthWeeks'][$number]['number'] == 53 && $nShiftPrev != 4)
$context['prevMonthWeeks'][$number]['number'] = 1;
// And figure out all the days.
for ($nCol = 0; $nCol < 7; $nCol++)
{
$nDay = ($nRowPrev * 7) + $nCol - $nShiftPrev + 1;
$context['nextMonthWeeks'] = array();
for ($nRowNext = 0; $nRowNext < $nRowsNext; $nRowNext++)
{
// This is the week number assigned as a key to limit results to a certain week.
$number = $firstDayOfNextMonth['weekNum'] + $nRowNext + $nWeekAdjust + ($curPage['month'] == 12 ? 1 : 0);
// Start off the week - and don't let it go above 52, since that's the number of weeks in a year.
$context['nextMonthWeeks'][$number] = array(
'days' => array(),
'number' => $firstDayOfNextMonth['weekNum'] + $nRowNext + $nWeekAdjust,
'week' => $scripturl . '?action=calendar;year=' . $curPageNext['year'] . ';month=' . $curPageNext['month'] . ';week=' . $number,
);
// Handle the dreaded "week 53", it can happen, but only once in a blue moon
if ($context['nextMonthWeeks'][$number]['number'] == 53 && $nShiftNext != 4)
$context['nextMonthWeeks'][$number]['number'] = 1;
// And figure out all the days.
for ($nCol = 0; $nCol < 7; $nCol++)
{
$nDay = ($nRowNext * 7) + $nCol - $nShiftNext + 1;
// Show each day of the week.
foreach ($context['week_days'] as $day)
echo '
<td class="titlebg2" width="14%" align="left">', substr($txt['days'][$day], 0, 1), '</td>';
echo '
</tr>';
/* Each week in weeks contains the following:
days (a list of days), number (week # in the year.) */
foreach ($context['prevMonthWeeks'] as $week)
{
echo '
<tr>
<td class="titlebg2"><a href="', $week['week'], '">»</a></td>';
/* Every day has the following:
day (# in month), is_today (is this day *today*?), is_first_day (first day of the week?),
holidays, events, birthdays. (last three are lists.) */
foreach ($week['days'] as $day)
{
// If this is today, make it a different color and show a border.
echo '
<td valign="top" align="right" style="height: auto; padding: 2px;" class="', $day['is_today'] ? 'calendar_today' : (empty($day['day']) ? 'windowbg3' : 'windowbg'), '">';
// Skip it if it should be blank - it's not a day if it has no number.
if (!empty($day['day']))
echo
$day['day'];
foreach ($context['weeks'] as $week)
{
echo '
<tr>';
Değiştir:
foreach ($context['weeks'] as $week)
{
// This is used to highlight the current week.
$currentWeek = isset($_REQUEST['week']) && $_REQUEST['week'] == $week['number'];
// If this is today, make it a different color and show a border.
echo '
<td valign="top" style="height: 100px; padding: 2px;" class="', $day['is_today'] ? 'calendar_today' : 'windowbg' , '">';
// Skip it if it should be blank - it's not a day if it has no number.
if (!empty($day['day']))
{
// Should the day number be a link?
if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
echo '
<a href="', $scripturl, '?action=calendar;sa=post;month=', $context['current_month'], ';year=', $context['current_year'], ';day=', $day['day'], ';sesc=', $context['session_id'], '">', $day['day'], '</a>';
else
echo '
', $day['day'];
// Is this the first day of the week? (and are we showing week numbers?)
if ($day['is_first_day'])
echo '<span class="smalltext"> - ', $txt['calendar51'], ' ', $week['number'], '</span>';
// Are there any holidays?
if (!empty($day['holidays']))
echo '
<div class="smalltext" style="color: #', $modSettings['cal_holidaycolor'], ';">', $txt['calendar5'], ' ', implode([/swf2][swf3], $day['holidays']), '</div>';
// Show any birthdays...
if (!empty($day['birthdays']))
{
echo '
<div class="smalltext">
<span style="color: #', $modSettings['cal_bdaycolor'], ';">', $txt['calendar3'], '</span> ';
/* Each of the birthdays has:
id, name (person), age (if they have one set?), and is_last. (last in list?) */
foreach ($day['birthdays'] as $member)
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '[/swf2][swf3]</a>', $member['is_last'] ? '' : [/swf2][swf3];
echo '
</div>';
}
// Any special posted events?
if (!empty($day['events']))
{
echo '
<div class="smalltext">
<span style="color: #', $modSettings['cal_eventcolor'], ';">', $txt['calendar4'], '</span>';
/* The events are made up of:
title, href, is_last, can_edit (are they allowed to?), and modify_href. */
foreach ($day['events'] as $event)
{
// If they can edit the event, show a star they can click on....
if ($event['can_edit'])
echo '
<a href="', $event['modify_href'], '" style="color: #FF0000;">*</a> ';
// If this is today, make it a different color and show a border.
echo '
<td valign="top" align="right" style="height: auto; padding: 2px;" class="', $day['is_today'] ? 'calendar_today' : (empty($day['day']) ? 'windowbg3' : ($currentWeek ? 'windowbg2' : 'windowbg')), '">';
// Skip it if it should be blank - it's not a day if it has no number.
if (!empty($day['day']))
echo
$day['day'];
// Show each day of the week.
foreach ($context['week_days'] as $day)
echo '
<td class="titlebg2" width="14%" align="center">', substr($txt['days'][$day], 0, 1), '</td>';
echo '
</tr>';
/* Each week in weeks contains the following:
days (a list of days), number (week # in the year.) */
foreach ($context['nextMonthWeeks'] as $week)
{
echo '
<tr>
<td class="titlebg2"><a href="', $week['week'], '">»</a></td>';
/* Every day has the following:
day (# in month), is_today (is this day *today*?), is_first_day (first day of the week?),
holidays, events, birthdays. (last three are lists.) */
foreach ($week['days'] as $day)
{
// If this is today, make it a different color and show a border.
echo '
<td valign="top" align="right" style="height: auto; padding: 2px;" class="', $day['is_today'] ? 'calendar_today' : ((empty($day['day']) || isset($_REQUEST['week']) && $week['week'] == $_REQUEST['week']) ? 'windowbg3' : 'windowbg'), '">';
// Skip it if it should be blank - it's not a day if it has no number.
if (!empty($day['day']))
echo
$day['day'];
// Are there any holidays?
if (!empty($day['holidays']))
echo '
<div class="smalltext" style="color: #', $modSettings['cal_holidaycolor'], ';">', $txt['calendar5'], ' ', implode([/swf2][swf3], $day['holidays']), '</div>';
// Show any birthdays...
if (!empty($day['birthdays']))
{
echo '
<div class="smalltext">
<span style="color: #', $modSettings['cal_bdaycolor'], ';">', $txt['calendar3'], '</span> ';
/* Each of the birthdays has:
id, name (person), age (if they have one set?), and is_last. (last in list?) */
foreach ($day['birthdays'] as $member)
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '[/swf2][swf3]</a>', $member['is_last'] ? '' : [/swf2][swf3];
echo '
</div>';
}
// Any special posted events?
if (!empty($day['events']))
{
echo '
<div class="smalltext">
<span style="color: #', $modSettings['cal_eventcolor'], ';">', $txt['calendar4'], '</span>';
/* The events are made up of:
title, href, is_last, can_edit (are they allowed to?), and modify_href. */
foreach ($day['events'] as $event)
{
// If they can edit the event, show a star they can click on....
if ($event['can_edit'])
echo '
<a href="', $event['modify_href'], '" style="color: #FF0000;">*</a> ';
// This is used to set the offset between days depending if a week starts on sunday or monday
$weekOffset++;
if ($weekOffset == 7)
$weekOffset = 0;
}
}
else
{
echo '
<tr>';
// Show each day of the week.
foreach ($context['week_days'] as $day)
echo '
<td class="titlebg2" width="14%" align="center">', $txt['days'][$day], '</td>';
echo '
</tr>';
/* Each week in weeks contains the following:
days (a list of days), number (week # in the year.) */
foreach ($context['weeks'] as $week)
{
echo '
<tr>';
/* Every day has the following:
day (# in month), is_today (is this day *today*?), is_first_day (first day of the week?),
holidays, events, birthdays. (last three are lists.) */
foreach ($week['days'] as $day)
{
// If this is today, make it a different color and show a border.
echo '
<td valign="top" style="height: 100px; padding: 2px;" class="', $day['is_today'] ? 'calendar_today' : (empty($day['day']) ? 'windowbg3' : 'windowbg'), '">';
// Skip it if it should be blank - it's not a day if it has no number.
if (!empty($day['day']))
{
// Should the day number be a link?
if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
echo '
<a href="', $scripturl, '?action=calendar;sa=post;month=', $context['current_month'], ';year=', $context['current_year'], ';day=', $day['day'], ';sesc=', $context['session_id'], '">', $day['day'], '</a>';
else
echo '
', $day['day'];
// Is this the first day of the week? (and are we showing week numbers?)
if ($day['is_first_day'])
echo '
<span class="smalltext"> - ', $txt['calendar51'], ' ', $week['number'], '</span>';
// Are there any holidays?
if (!empty($day['holidays']))
echo '
<div class="smalltext" style="color: #', $modSettings['cal_holidaycolor'], ';">
', $txt['calendar5'], ' ', implode([/swf2][swf3], $day['holidays']), '
</div>';
// Show any birthdays...
if (!empty($day['birthdays']))
{
echo '
<div class="smalltext">
<span style="color: #', $modSettings['cal_bdaycolor'], ';">', $txt['calendar3'], '</span> ';
/* Each of the birthdays has:
id, name (person), age (if they have one set?), and is_last. (last in list?) */
foreach ($day['birthdays'] as $member)
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '[/swf2][swf3]</a>', $member['is_last'] ? '' : [/swf2][swf3];
echo '
</div>';
}
// Any special posted events?
if (!empty($day['events']))
{
echo '
<div class="smalltext">
<span style="color: #', $modSettings['cal_eventcolor'], ';">', $txt['calendar4'], '</span>';
/* The events are made up of:
title, href, is_last, can_edit (are they allowed to?), and modify_href. */
foreach ($day['events'] as $event)
{
// If they can edit the event, show a star they can click on....
if ($event['can_edit'])
echo '
<a href="', $event['modify_href'], '" style="color: #FF0000;">*</a> ';