Changeset - 3f6590312102
[Not reviewed]
default
0 7 0
Nathan Brink (binki) - 15 years ago 2011-02-05 21:29:32
ohnobinki@ohnopublishing.net
Add Saturday support, but hide it on the input page.
7 files changed with 76 insertions and 26 deletions:
0 comments (0 inline, 0 general)
inc/class.schedule.php
Show inline comments
 
@@ -297,6 +297,25 @@ class Schedule
 

	
 
    if($this->nPermutations > 0)
 
      {
 
	/*
 
	 * Figure out if we have to deal with Saturday and then deal
 
	 * with it.
 
	 */
 
	$max_day_plusone = 5;
 
	$have_saturday = FALSE;
 
	foreach ($this->courses as $course)
 
	  {
 
	    for ($si = 0; $si < $course->getnsections(); $si ++)
 
	      foreach ($course->getSection($si)->getMeetings() as $meeting)
 
		if ($meeting->getDay(5))
 
		  {
 
		    $max_day_plusone = 6;
 
		    $have_saturday = TRUE;
 
		    break;
 
		  }
 
	    if ($have_saturday)
 
	      break;
 
	  }
 

	
 
        echo '<div id="regDialog" title="Registration Codes"><p>Enter these codes into your school\'s online course registration system to register for classes:</p><div id="regDialogList"></div></div>';
 
	echo '<div id="tabs">' . "\n" .
 
@@ -348,18 +367,21 @@ class Schedule
 
	      . "            <td class=\"day\">Tuesday</td>\n"
 
	      . "            <td class=\"day\">Wednesday</td>\n"
 
	      . "            <td class=\"day\">Thursday</td>\n"
 
	      . "            <td class=\"day\">Friday</td>\n"
 
	      . "          </tr>\n";
 
	      . "            <td class=\"day\">Friday</td>\n";
 
	    if ($have_saturday)
 
	      echo "            <td class=\"day\">Saturday</td>\n";
 
	    echo "          </tr>\n";
 

	
 
	    $last_meeting = array();
 
	    $rowspan = array(0, 0, 0, 0, 0);
 
	    $rowspan = array(0, 0, 0, 0, 0, 0);
 
	    for($r = 0; $r < (count($time)-1); $r++)
 
	      {
 

	
 
		echo "          <tr>\n"
 
		  . "            <td class=\"time\">" . $this->prettyTime($time[$r]) . "</td>\n";
 

	
 
		for($dayLoop = 0; $dayLoop < 5; $dayLoop++)
 
		/* currently, 0-5 = monday-saturday */
 
		for($dayLoop = 0; $dayLoop < $max_day_plusone; $dayLoop++)
 
		{
 
		  /* Makes sure there is not a class already in progress */
 
		  if($rowspan[$dayLoop] <= 0)
inc/class.section.php
Show inline comments
 
@@ -188,10 +188,10 @@ class Section
 
    $ret['course'] = strtoupper($course_matches[1]);
 

	
 
    /*
 
     * we accept _either_ alphabetic section _or_ numeric section (the
 
     * latter is for cedarville, particulaly)
 
     * we accept fully alphanumeric section identifiers. ccbcmd uses
 
     * these amazingly.
 
     */
 
    if (!preg_match(';([0-9]+|[a-zA-Z]+);', $section_spec, $section_matches))
 
    if (!preg_match(';([a-zA-Z0-9]+);', $section_spec, $section_matches))
 
      return $ret;
 

	
 
    $ret['section'] = strtoupper($section_matches[1]);
inc/class.section_meeting.inc
Show inline comments
 
@@ -81,7 +81,7 @@ class SectionMeeting
 
   */
 
  private function days_set($days_str)
 
  {
 
    $this->days = array(0 => FALSE, 1 => FALSE, 2 => FALSE, 3 => FALSE, 4 => FALSE);
 
    $this->days = array(0 => FALSE, 1 => FALSE, 2 => FALSE, 3 => FALSE, 4 => FALSE, 5 => FALSE);
 

	
 
    $days_str_strlen = strlen($days_str);
 
    for ($i = 0; $i < $days_str_strlen; $i ++)
 
@@ -96,9 +96,9 @@ class SectionMeeting
 
   */
 
  private static function day_atoi($day_c)
 
  {
 
    static $day_atoi = array('m' => 0, 't' => 1, 'w' => 2, 'h' => 3, 'f' => 4,
 
			     'M' => 0, 'T' => 1, 'W' => 2, 'H' => 3, 'F' => 4,
 
			       0 => 0,   1 => 1,   2 => 2,   3 => 3,   4 => 4);
 
    static $day_atoi = array('m' => 0, 't' => 1, 'w' => 2, 'h' => 3, 'f' => 4, 's' => 5,
 
			     'M' => 0, 'T' => 1, 'W' => 2, 'H' => 3, 'F' => 4, 'S' => 5,
 
			      0  => 0,  1  => 1,  2  => 2,  3  => 3,  4  => 4,  5  => 5);
 

	
 
    return $day_atoi[$day_c];
 
  }
 
@@ -187,7 +187,7 @@ class SectionMeeting
 
     * times. But if they don't both meet on the same day at least
 
     * once, they don't conflict.
 
     */
 
    for ($day = 0; $day < 5; $day ++)
 
    for ($day = 0; $day < 6; $day ++)
 
      {
 
	if ($this->getDay($day) && $that->getDay($day))
 
	  return TRUE;
 
@@ -211,7 +211,7 @@ class SectionMeeting
 
   */
 
  public function to_json_array()
 
  {
 
    static $daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f');
 
    static $daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f', 5 => 's');
 

	
 
    $json_array = array(
 
			'time_start' => $this->time_start,
 
@@ -221,7 +221,7 @@ class SectionMeeting
 
			'type' => $this->type,
 
			);
 

	
 
    for ($day = 0; $day < 5; $day ++)
 
    for ($day = 0; $day < 6; $day ++)
 
      $json_array['days'][$daymap[$day]] = $this->getDay($day);
 

	
 
    return $json_array;
input.php
Show inline comments
 
@@ -114,6 +114,7 @@ if (!empty($_REQUEST['selectschool'])
 
  To get started, enter a course number and add some sections to it.
 
  Then specify each section's letter/number and what times it meets,
 
  add more courses, and click &ldquo;Find a Schedule&rdquo;.
 
  <!--'-->
 
  <?php endif; ?>
 
</p>
 

	
 
@@ -126,6 +127,22 @@ if (!empty($_REQUEST['selectschool'])
 
  <tr>
 
    <td>
 
      <table id="jsrows">
 
	<!-- Allow CSS to apply to entire rows at a time. -->
 
	<colgroup>
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col class="saturday" />
 
	  <col />
 
	  <col />
 
	</colgroup>
 
        <!-- Header -->
 
        <tr>
 
          <td>Class ID</td>
 
@@ -138,6 +155,7 @@ if (!empty($_REQUEST['selectschool'])
 
          <td class="center">W</td>
 
          <td class="center">Th</td>
 
          <td class="center">F</td>
 
	  <td class="center">S</td>
 
          <td class="center"></td>
 
          <td class="center"></td>
 
        </tr>
 
@@ -178,7 +196,8 @@ function input_class_js(Course $class, $
 
	    . htmlentities($section->getSynonym(), ENT_QUOTES) . '\', \''
 
	    . $meeting->getStartTime() . '\', \''
 
	    . $meeting->getEndTime() . '\', '
 
	    . json_encode(array('m' => $meeting->getDay(0), 't' => $meeting->getDay(1), 'w' => $meeting->getDay(2), 'h' => $meeting->getDay(3), 'f' => $meeting->getDay(4))) . ', \''
 
	    . json_encode(array('m' => $meeting->getDay(0), 't' => $meeting->getDay(1), 'w' => $meeting->getDay(2), 'h' => $meeting->getDay(3), 'f' => $meeting->getDay(4),
 
				's' => $meeting->getDay(5))) . ', \''
 
	    . htmlentities($section->getProf(), ENT_QUOTES) . '\', \''
 
	    . htmlentities($meeting->getLocation(), ENT_QUOTES) . '\',\''
 
	    . htmlentities($meeting->type_get(), ENT_QUOTES) . "');\n";
process.php
Show inline comments
 
@@ -24,30 +24,31 @@ include_once 'inc/class.schedule.php';
 
include_once('inc/class.course.inc');
 
include_once 'inc/class.section.php';
 

	
 
// Converts a 5-element day array into a string.
 
// Converts a 6-element day array into a string.
 
// Supports multiple modes, prettiness, and searching for different indicators
 
function arrayToDays($array, $mode = 'num', $pretty = false, $key = 1) {
 
	$outString = '';
 
	switch($mode)
 
	  {
 
		case 'short':
 
			$days = array('Mon','Tue','Wed','Thur','Fri');
 
			$days = array('Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat');
 
			break;
 
		case 'long':
 
			$days = array('Monday','Tuesday','Wednesday','Thursday','Friday');
 
			$days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
 
			break;
 
		case 'num':
 
			$days = array('1','2','3','4','5');
 
			break;
 
	  case 'alpha':
 
	    $days = array('m', 't', 'w', 'h', 'f');
 
	    $days = array('m', 't', 'w', 'h', 'f', 's');
 
	    break;
 
		default:
 
			$outString = 'Invalid mode passed to arrayToDays()!';
 
			return $outString;
 
	}
 
	if(count($array) > 1){
 
		for($i=0; $i<=4; $i++)	{
 
		for($i = 0; $i < 6; $i ++)
 
		{
 
			if(isset($array[$i]) && $array[$i] == $key){
 
				$outString .= $days[$i];
 
				if($pretty)
 
@@ -60,7 +61,7 @@ function arrayToDays($array, $mode = 'nu
 
		}
 
	}
 
	else {
 
		for($i=0; $i<=4; $i++)
 
		for($i=0; $i < 6; $i++)
 
			if(isset($array[$i]))
 
				$outString = $days[$i];
 
	}
 
@@ -138,8 +139,9 @@ if(!$DEBUG)
 
				foreach($class as $section)
 
				  /* Skip the section name, which isn't a section */
 
					if(is_array($section))
 
					{
 
					  {error_log(print_r($section['days'], TRUE));
 
					  $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type']);
 
					  error_log(arrayToDays($section['days'], 'alpha'));
 
					}
 
			}
 
		}
scripts/scheduleInput.js
Show inline comments
 
@@ -192,11 +192,12 @@ function genSectionHtml_n(cnum, name, sy
 
		    }
 

	
 
		result = result + '</select></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][0]" value="1" ' + (days.m ? 'checked="checked"' : '') + ' /></td> \
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][0]" value="1" ' + (days.m ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][1]" value="1" ' + (days.t ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][2]" value="1" ' + (days.w ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][3]" value="1" ' + (days.h ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][4]" value="1" ' + (days.f ? 'checked="checked"' : '') + ' /></td>';
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][4]" value="1" ' + (days.f ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][5]" value="1" ' + (days.s ? 'checked="checked"' : '') + ' /></td>';
 
		result = result + '<td class="removeCell"><div class="deleteSection"><input type="button" value="x" class="gray" /></div></td><td class="emptyCell">' 
 
		    + '<input type="hidden" name="postData[' + cnum + '][' + snum + '][location]" value="' + location + '" />'
 
		    + '<input type="hidden" name="postData[' + cnum + '][' + snum + '][type]" value="' + type + '" />'
 
@@ -253,7 +254,7 @@ function add_section_n(cnum, name, synon
 
}
 
function add_section(cnum)
 
{
 
    return add_section_n(cnum, '', '', '', '', {'m':false, 't':false, 'w':false, 'h':false, 'f':false}, '', '', '');
 
    return add_section_n(cnum, '', '', '', '', {m: false, t: false, w: false, h: false, f: false, s: false}, '', '', '');
 
}
 

	
 
/**
 
@@ -282,7 +283,7 @@ function add_sections(cnum, data)
 
	function add_class_n(name)
 
	{
 
		sectionsOfClass[classNum] = 0; // Initialize at 0
 
		jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + ' pclass' + classNum + '"><td class="nameTip"><input type="text" id="input-course-' + classNum + '" class="classRequired defText className'+classNum+' className" title="Class Name" name="postData[' + classNum + '][name]" value="' + name + '" /></td><td colspan="9"></td><td class="tdInput"><div class="addSection"><input type="button" value="+" class="gray" /></div></td><td class="tdInput"><div class="deleteClass"><input type="button" value="Remove" class="gray" /></div></td></tr>');
 
		jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + ' pclass' + classNum + '"><td class="nameTip"><input type="text" id="input-course-' + classNum + '" class="classRequired defText className'+classNum+' className" title="Class Name" name="postData[' + classNum + '][name]" value="' + name + '" /></td><td colspan="10"></td><td class="tdInput"><div class="addSection"><input type="button" value="+" class="gray" /></div></td><td class="tdInput"><div class="deleteClass"><input type="button" value="Remove" class="gray" /></div></td></tr>');
 

	
 
		var class_elem = jQuery('.className' + classNum);
 
		class_elem.autocomplete({ source: "auto.php" });
styles/general.css
Show inline comments
 
@@ -200,6 +200,12 @@ td.center {
 
  background: #68a64a!important;
 
}
 

	
 
/* For now, hide Saturday on the input page even though it works perfectly fine */
 
.saturday
 
{
 
  /* http://www.w3.org/TR/CSS/tables.html#columns */
 
  visibility: collapse;
 
}
 

	
 
/* General Classes */
 

	
0 comments (0 inline, 0 general)