From: defacer Date: Tue, 20 Apr 2004 11:14:55 +0000 (+0000) Subject: Revision of the calendar tables HTML. Current version outputs a LOT less HTML X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=92668ad2e504ddc0cd0246f0a2cd581b3d1e9f04;p=moodle.git 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? ;) --- diff --git a/calendar/lib.php b/calendar/lib.php index 65b67eb279..9a6ce1ae1a 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -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 .= ''; // Begin table. First row: day names + $content .= '
'; // Begin table + $content .= ''; // 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 .= '\n"; + $content .= ''; } - $content .= ''; // End of day names; prepare for day numbers + $content .= ''; // 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 .= ''."\n"; + $content .= ''."\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 .= '\n"; + if(!empty($class)) { + $class = ' class="'.trim($class).'"'; + } + $content .= ''.$cell."\n"; } // Paddding (the last week may have blank days at the end) for($i = $dayweek; $i <= $display->maxwday; ++$i) { - $content .= ''; + $content .= ''; } $content .= ''; // Last row ends - $content .= '
'.get_string($days[$i % 7], 'calendar')."'.get_string($days[$i % 7], 'calendar').'
  '.$cell."  
'; // Tabular display of days ends + $content .= ''; // Tabular display of days ends return $content; } diff --git a/calendar/view.php b/calendar/view.php index ed2070d780..511642d7d3 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -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 ''; // Begin table. First row: day names + echo '
'; // 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 '\n"; + echo ''; } - echo ''; // End of day names; prepare for day numbers + echo ''; // 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 ''."\n"; + echo ''."\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 ''; + echo ''; } - echo "\n"; // Last row ends + echo "\n\n"; // Last row ends echo "
'.get_string($days[$i % 7], 'calendar')."'.get_string($days[$i % 7], 'calendar').'
  '.$cell; + if(!empty($class)) { + $class = ' class="'.trim($class).'"'; + } + echo ''.$cell; + if(isset($eventsbyday[$day])) { echo ''; foreach($eventsbyday[$day] as $eventindex) { - echo ''; - echo ''; + echo ''; + echo ''; } echo '
·'.$events[$eventindex]->name.'
·'.$events[$eventindex]->name.'
'; } @@ -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 '
  
\n
\n"; // Tabular display of days ends