diff --git a/class.schedule.php b/class.schedule.php --- a/class.schedule.php +++ b/class.schedule.php @@ -22,8 +22,6 @@ class Schedule private $storage; // Integer array of valid schedules private $title; - private $classContinue = array(-1, -1, -1, -1, -1); - /** * \brief * My global identification number. Not defined until the schedule @@ -262,35 +260,44 @@ class Schedule } $table .= "
| " . ($i+1) . " | \n\t\tMonday | \n\t\tTuesday | \n\t\tWednesday | \n\t\tThursday | \n\t\tFriday | \n\t||
| ' . ($i + 1) . " | \n" + . "Monday | \n" + . "Tuesday | \n" + . "Wednesday | \n" + . "Thursday | \n" + . "Friday | \n" + . "||
| " . $this->prettyTime($time[$r]) . " | "; + $table .= "|||||||
| " . $this->prettyTime($time[$r]) . " | \n"; for($dayLoop = 0; $dayLoop < 5; $dayLoop++) { - for($j = 0; $j < $this->nclasses; $j++) + /* Makes sure there is not a class already in progress */ + if($rowspan[$lastDay] <= 0) + { + for($j = 0; $j < $this->nclasses; $j++) { $class = $this->classStorage[$j]; $section_index = $this->storage[$i][$j]; $section = $class->getSection($section_index); - // Makes sure there is not a class already in progress - if($this->getClassCont($dayLoop) == -1) - { /* iterate through all of a class's meeting times */ $meetings = $section->getMeetings(); @@ -308,57 +315,48 @@ class Schedule if ($current_meeting) { - // Checks if the class continues after the given time - if($current_meeting->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t" . htmlentities($class->getName()) . " " . htmlentities($section->getLetter()) . " | "; - - $this->setClassCont($dayLoop, $j); - $last_meeting[$dayLoop] = $current_meeting; + /* calculate how many rows this section should span */ + for ($my_r = $r; $current_meeting->getEndTime() > $time[$my_r]; $my_r ++) + ; + $rowspan[$dayLoop] = $my_r - $r; + + $single_multi = 'single'; + if ($rowspan[$dayLoop] > 1) + $single_multi = 'multi'; - $filled = TRUE; - } - else - { - $table .= "\n\n\t" . htmlentities($class->getName()) . " " . htmlentities($section->getLetter()) . " | "; - $filled = TRUE; - } + $table .= '' + . htmlentities($class->getName(), ENT_QUOTES) . ' ' + . htmlentities($section->getLetter(), ENT_QUOTES) + . " | \n"; + $filled = TRUE; } - } - else - { - if($j == $this->getClassCont($dayLoop)) - { - if(isset($last_meeting[$dayLoop]) - && $last_meeting[$dayLoop]->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $filled = TRUE; - } - else - { - $table .= "\n\t\t | "; - $this->setClassCont($dayLoop, -1); - $filled = TRUE; - } - } - } - } + } + } - // If the cell was not filled, fill it with an empty cell. + if ($rowspan[$dayLoop] > 0) + { + $filled = TRUE; + $rowspan[$dayLoop] --; + } + + /* If the cell was not filled, fill it with an empty cell. */ if(!$filled) { - $table .= "\n\t\t | "; + $table .= " | \n"; } - $filled = false; + $filled = FALSE; } // End of row - $table .= "\n\t |