[ticket/122] Correctly display days in calendar

Due to changes in handling the time the HTML is incorrectly created and
thus causes a <tr> for every day. This results in every day being on a new
line. Additionally, the calendar module is now HTML5 valid.

B3P-122
This commit is contained in:
Marc Alexander
2013-03-03 18:05:20 +01:00
parent c3f7197eea
commit b69511de36
2 changed files with 49 additions and 33 deletions

View File

@@ -58,6 +58,11 @@ class portal_calendar_module
*/ */
private $mini_cal_fdow; private $mini_cal_fdow;
/**
* User datetime object
*/
private $time;
/** /**
* constants * constants
*/ */
@@ -89,8 +94,8 @@ class portal_calendar_module
} }
// initialise some variables // initialise some variables
$time = $user->create_datetime(); $this->time = $user->create_datetime();
$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset()); $now = phpbb_gmgetdate($this->time->getTimestamp() + $this->time->getOffset());
$today_timestamp = $now[0]; $today_timestamp = $now[0];
$mini_cal_today = date('Ymd', $today_timestamp - date('Z')); $mini_cal_today = date('Ymd', $today_timestamp - date('Z'));
$this->stamp = $today_timestamp; $this->stamp = $today_timestamp;
@@ -105,8 +110,8 @@ class portal_calendar_module
// output our general calendar bits // output our general calendar bits
$down = $this->mini_cal_month - 1; $down = $this->mini_cal_month - 1;
$up = $this->mini_cal_month + 1; $up = $this->mini_cal_month + 1;
$prev_month = '<a href="' . append_sid("{$phpbb_root_path}portal.$phpEx", "m$module_id=$down#minical$module_id") . '"><img src="' . $portal_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="&lt;&lt;" /></a>'; $prev_month = '<a href="' . append_sid("{$phpbb_root_path}app.$phpEx", "controller=portal&amp;m$module_id=$down#minical$module_id") . '"><img src="' . $portal_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="&lt;&lt;" /></a>';
$next_month = '<a href="' . append_sid("{$phpbb_root_path}portal.$phpEx", "m$module_id=$up#minical$module_id") . '"><img src="' . $portal_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt="&gt;&gt;" /></a>'; $next_month = '<a href="' . append_sid("{$phpbb_root_path}app.$phpEx", "controller=portal&amp;m$module_id=$up#minical$module_id") . '"><img src="' . $portal_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt="&gt;&gt;" /></a>';
$template->assign_block_vars('minical', array( $template->assign_block_vars('minical', array(
'S_SUNDAY_FIRST' => ($config['board3_sunday_first_' . $module_id]) ? true : false, 'S_SUNDAY_FIRST' => ($config['board3_sunday_first_' . $module_id]) ? true : false,
@@ -169,6 +174,15 @@ class portal_calendar_module
} }
} }
// fill table with empty strings
while ($mini_cal_count <= self::DAYS_PER_WEEK)
{
$template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array(
'MINI_CAL_DAY' => ' ')
);
$mini_cal_count++;
}
/* /*
* Let's start displaying the events * Let's start displaying the events
* make sure we only display events in the future * make sure we only display events in the future
@@ -577,7 +591,7 @@ class portal_calendar_module
**/ **/
private function makeTimestamp($date) private function makeTimestamp($date)
{ {
$this->stamp = (empty($this->stamp)) ? strtotime($date) : $this->stamp; $this->stamp = strtotime($date);
return ($this->stamp); return ($this->stamp);
} }
@@ -592,7 +606,9 @@ class portal_calendar_module
// last or first day of some months need to be treated in a special way // last or first day of some months need to be treated in a special way
if (!empty($this->mini_cal_month)) if (!empty($this->mini_cal_month))
{ {
$today_timestamp = time() + $user->timezone + $user->dst; $time = $user->create_datetime();
$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
$today_timestamp = $now[0];
$cur_month = date("n", $today_timestamp); $cur_month = date("n", $today_timestamp);
$correct_month = $cur_month + $this->mini_cal_month; $correct_month = $cur_month + $this->mini_cal_month;

View File

@@ -2,11 +2,11 @@
<!-- IF minical.MODULE_ID eq $MODULE_ID --> <!-- IF minical.MODULE_ID eq $MODULE_ID -->
<a id="minical{minical.MODULE_ID}" style="float: right;"></a> <a id="minical{minical.MODULE_ID}" style="float: right;"></a>
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R} {$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R}
<table width="100%" cellspacing="1"> <table style="width: 100%;">
<tr> <tr>
<td align="left" colspan="2"><!-- IF S_CONTENT_DIRECTION eq 'rtl' -->{minical.U_NEXT_MONTH}<!-- ELSE -->{minical.U_PREV_MONTH}<!-- ENDIF --></td> <td style="text-align: left;" colspan="2"><!-- IF S_CONTENT_DIRECTION eq 'rtl' -->{minical.U_NEXT_MONTH}<!-- ELSE -->{minical.U_PREV_MONTH}<!-- ENDIF --></td>
<td colspan="3" align="center"><span class="genmed">{minical.L_MINI_CAL_MONTH}</span></td> <td colspan="3" style="text-align: center;"><span class="genmed">{minical.L_MINI_CAL_MONTH}</span></td>
<td align="right" colspan="2"><!-- IF S_CONTENT_DIRECTION eq 'rtl' -->{minical.U_PREV_MONTH}<!-- ELSE -->{minical.U_NEXT_MONTH}<!-- ENDIF --></td> <td style="text-align: right;" colspan="2"><!-- IF S_CONTENT_DIRECTION eq 'rtl' -->{minical.U_PREV_MONTH}<!-- ELSE -->{minical.U_NEXT_MONTH}<!-- ENDIF --></td>
</tr> </tr>
<tr> <tr>
<!-- IF minical.S_SUNDAY_FIRST --> <!-- IF minical.S_SUNDAY_FIRST -->
@@ -26,7 +26,7 @@
<!-- IF minical.mini_cal_row.MODULE_ID eq $MODULE_ID --> <!-- IF minical.mini_cal_row.MODULE_ID eq $MODULE_ID -->
<tr> <tr>
<!-- BEGIN mini_cal_days --> <!-- BEGIN mini_cal_days -->
<td class="row1" align="center"><span class="gensmall">{minical.mini_cal_row.mini_cal_days.MINI_CAL_DAY}</span></td> <td style="width: 14%; text-align: center;"><span class="gensmall">{minical.mini_cal_row.mini_cal_days.MINI_CAL_DAY}</span></td>
<!-- END mini_cal_days --> <!-- END mini_cal_days -->
</tr> </tr>
<!-- ENDIF --> <!-- ENDIF -->