Revision of the calendar tables HTML. Current version outputs a LOT less HTML

(mainly class attributes) but requires ALL themes to update their CSS rules.

Coming up next... can you guess? ;)
This commit is contained in:
defacer
2004-04-20 11:14:55 +00:00
parent 2b7591ccbc
commit 92668ad2e5
2 changed files with 29 additions and 22 deletions
+14 -10
View File
@@ -114,17 +114,18 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
// Arguments passed by reference.
calendar_events_by_day($events, $display->tstart, $eventsbyday, $durationbyday, $typesbyday);
$content .= '<table class="calendarmini"><tr>'; // Begin table. First row: day names
$content .= '<table class="calendarmini">'; // Begin table
$content .= '<thead><tr>'; // Header row: day names
// Print out the names of the weekdays
$days = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
for($i = $display->minwday; $i <= $display->maxwday; ++$i) {
// This uses the % operator to get the correct weekday no matter what shift we have
// applied to the $display->minwday : $display->maxwday range from the default 0 : 6
$content .= '<td class="calendarheader">'.get_string($days[$i % 7], 'calendar')."</td>\n";
$content .= '<td>'.get_string($days[$i % 7], 'calendar').'</td>';
}
$content .= '</tr><tr>'; // End of day names; prepare for day numbers
$content .= '</tr></thead><tbody><tr>'; // End of day names; prepare for day numbers
// For the table display. $week is the row; $dayweek is the column.
$week = 1;
@@ -132,7 +133,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
// Paddding (the first week may have blank days in the beginning)
for($i = $display->minwday; $i < $startwday; ++$i) {
$content .= '<td class="calendardaymini">&nbsp;</td>'."\n";
$content .= '<td>&nbsp;</td>'."\n";
}
// Now display all the calendar
@@ -143,16 +144,16 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
$dayweek = $display->minwday;
++$week;
}
// Reset vars
$class = '';
$cell = '';
if($dayweek % 7 == 0 || $dayweek % 7 == 6) {
// Weekend. This is true no matter what the exact range is.
$class = 'cal_day_mini calendarweekend';
$class = 'cal_weekend';
}
else {
// Normal working day.
$class = 'cal_day_mini';
$class = '';
}
// Special visual fx if an event is defined
@@ -210,16 +211,19 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
}
// Just display it
$content .= '<td class="'.$class.'">'.$cell."</td>\n";
if(!empty($class)) {
$class = ' class="'.trim($class).'"';
}
$content .= '<td'.$class.'>'.$cell."</td>\n";
}
// Paddding (the last week may have blank days at the end)
for($i = $dayweek; $i <= $display->maxwday; ++$i) {
$content .= '<td class="calendardaymini">&nbsp;</td>';
$content .= '<td>&nbsp;</td>';
}
$content .= '</tr>'; // Last row ends
$content .= '</table>'; // Tabular display of days ends
$content .= '</tbody></table>'; // Tabular display of days ends
return $content;
}
+15 -12
View File
@@ -414,17 +414,17 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
echo calendar_top_controls('month', array('m' => $m, 'y' => $y));
// Start calendar display
echo '<table class="calendarmonth"><tr>'; // Begin table. First row: day names
echo '<table class="calendarmonth"><thead><tr>'; // Begin table. First row: day names
// Print out the names of the weekdays
$days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
for($i = $display->minwday; $i <= $display->maxwday; ++$i) {
// This uses the % operator to get the correct weekday no matter what shift we have
// applied to the $display->minwday : $display->maxwday range from the default 0 : 6
echo '<td class="calendarheader">'.get_string($days[$i % 7], 'calendar')."</td>\n";
echo '<td class="calendarheader">'.get_string($days[$i % 7], 'calendar').'</td>';
}
echo '</tr><tr>'; // End of day names; prepare for day numbers
echo '</tr></thead><tbody><tr>'; // End of day names; prepare for day numbers
// For the table display. $week is the row; $dayweek is the column.
$week = 1;
@@ -432,7 +432,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
// Paddding (the first week may have blank days in the beginning)
for($i = $display->minwday; $i < $startwday; ++$i) {
echo '<td class="calendardaymonth">&nbsp;</td>'."\n";
echo '<td>&nbsp;</td>'."\n";
}
// Now display all the calendar
@@ -445,15 +445,14 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
}
// Reset vars
$class = '';
$cell = '';
if($dayweek % 7 == 0 || $dayweek % 7 == 6) {
// Weekend. This is true no matter what the exact range is.
$class = 'calendardaymonth calendarweekend';
$class = 'cal_weekend';
}
else {
// Normal working day.
$class = 'calendardaymonth';
$class = '';
}
// Special visual fx if an event is defined
@@ -502,12 +501,16 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
}
// Just display it
echo '<td class="'.$class.'">'.$cell;
if(!empty($class)) {
$class = ' class="'.trim($class).'"';
}
echo '<td'.$class.'>'.$cell;
if(isset($eventsbyday[$day])) {
echo '<table>';
foreach($eventsbyday[$day] as $eventindex) {
echo '<tr><td valign="top"><strong>&middot;</strong></td>';
echo '<td><a href="'.CALENDAR_URL.'view.php?view=event&amp;id='.$events[$eventindex]->id.'">'.$events[$eventindex]->name.'</a></td></tr>';
echo '<tr><td style="vertical-align: top; width: 10px;"><strong>&middot;</strong></td>';
echo '<td style="width: 100%;"><a href="'.CALENDAR_URL.'view.php?view=event&amp;id='.$events[$eventindex]->id.'">'.$events[$eventindex]->name.'</a></td></tr>';
}
echo '</table>';
}
@@ -521,9 +524,9 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
// Paddding (the last week may have blank days at the end)
for($i = $dayweek; $i <= $display->maxwday; ++$i) {
echo '<td class="calendardaymonth">&nbsp;</td>';
echo '<td>&nbsp;</td>';
}
echo "</tr>\n"; // Last row ends
echo "</tr>\n</tbody>\n"; // Last row ends
echo "</table>\n<br />\n"; // Tabular display of days ends