Changeset - 490910f07d79
[Not reviewed]
Merge default
2 15 2
Nathan Brink (binki) - 13 years ago 2012-10-19 02:31:27
ohnobinki@ohnopublishing.net
Merge in partially-working half-semester support.
19 files changed with 534 insertions and 75 deletions:
0 comments (0 inline, 0 general)
images/favicon.png
Show inline comments
 
deleted file
 
binary diff not shown
Show images
images/favicon.svg
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 
<!-- Created with Inkscape (http://www.inkscape.org/) -->
 

	
 
<svg
 
   xmlns:dc="http://purl.org/dc/elements/1.1/"
 
   xmlns:cc="http://creativecommons.org/ns#"
 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 
   xmlns:svg="http://www.w3.org/2000/svg"
 
   xmlns="http://www.w3.org/2000/svg"
 
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
 
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
 
   width="64"
 
   height="64"
 
   id="svg3040"
 
   version="1.1"
 
   inkscape:version="0.48.2 r9819"
 
   sodipodi:docname="favicon_untraced.svg"
 
   inkscape:export-filename="C:\Users\binki\Documents\repos\slate_permutate\images\favicon_96.png"
 
   inkscape:export-xdpi="135"
 
   inkscape:export-ydpi="135">
 
  <defs
 
     id="defs3042" />
 
  <sodipodi:namedview
 
     id="base"
 
     pagecolor="#ffffff"
 
     bordercolor="#666666"
 
     borderopacity="1.0"
 
     inkscape:pageopacity="0.0"
 
     inkscape:pageshadow="2"
 
     inkscape:zoom="1"
 
     inkscape:cx="32"
 
     inkscape:cy="40.443748"
 
     inkscape:document-units="px"
 
     inkscape:current-layer="text12334-9-1"
 
     showgrid="false"
 
     inkscape:window-width="1366"
 
     inkscape:window-height="716"
 
     inkscape:window-x="-8"
 
     inkscape:window-y="-8"
 
     inkscape:window-maximized="1" />
 
  <metadata
 
     id="metadata3045">
 
    <rdf:RDF>
 
      <cc:Work
 
         rdf:about="">
 
        <dc:format>image/svg+xml</dc:format>
 
        <dc:type
 
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
 
        <dc:title></dc:title>
 
      </cc:Work>
 
    </rdf:RDF>
 
  </metadata>
 
  <g
 
     inkscape:label="Layer 1"
 
     inkscape:groupmode="layer"
 
     id="layer1"
 
     transform="translate(0,-988.36218)">
 
    <rect
 
       style="fill:#d0ffdc;fill-opacity:1;stroke:none"
 
       id="rect3106"
 
       width="88"
 
       height="84"
 
       x="-8"
 
       y="-5"
 
       transform="translate(0,988.36218)"
 
       ry="0"
 
       rx="0" />
 
    <g
 
       style="font-size:72px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:-4px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
 
       id="text12334-9-1">
 
      <path
 
         d="m 29.646092,1030.586 c -0.223138,-4.6239 -1.784894,-8.0718 -4.685274,-10.3438 -2.90043,-2.272 -5.800835,-4.136 -8.701222,-5.592 -2.900421,-1.4559 -4.462176,-3.2719 -4.685271,-5.4479 0.03749,-1.1039 0.448482,-2.0099 1.232985,-2.718 0.784476,-0.7079 1.717463,-1.0739 2.798963,-1.0979 1.331965,0.019 2.663946,0.3405 3.995948,0.9629 1.331961,0.6226 2.447946,1.4296 3.347958,2.421 l 5.975923,-5.3279 c -1.578008,-2.0175 -3.605981,-3.65243 -6.083923,-4.90496 -2.477989,-1.25244 -5.009954,-1.89743 -7.595901,-1.93497 -3.99296,0.0285 -7.3289138,1.15953 -10.0078713,3.39295 -2.6789692,2.23348 -4.0709499,5.39848 -4.1759463,9.49488 0.2222181,4.2822 1.7777518,7.6297 4.666606,10.0425 2.8888414,2.4129 5.7776896,4.4058 8.6665536,5.9786 2.888833,1.5729 4.444368,3.2404 4.666609,5.0026 -0.02402,1.4175 -0.462014,2.5245 -1.313984,3.321 -0.852008,0.7965 -1.973992,1.2015 -3.365956,1.215 -1.243499,-0.062 -2.590481,-0.4785 -4.04095,-1.251 -1.4504905,-0.7725 -2.6714731,-1.5315 -3.6629509,-2.277 l -4.7519388,7.4879 c 1.6409756,1.3785 3.5789491,2.5635 5.8139262,3.555 2.2349605,0.9915 4.4249295,1.5105 6.5699145,1.557 4.135428,-0.029 7.690378,-1.2135 10.664862,-3.555 2.974433,-2.3415 4.531411,-5.6684 4.67094,-9.9809 z"
 
         style="font-variant:normal;font-weight:900;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#4d4d4d;font-family:Delicious Heavy;-inkscape-font-specification:'Delicious Heavy, Heavy'"
 
         id="path3877" />
 
      <path
 
         d="m 62.93754,1012.5863 c -0.151533,-5.6294 -2.008507,-9.5444 -5.570929,-11.7449 -3.56248,-2.20041 -7.921419,-3.2534 -13.076831,-3.15895 l -11.951846,0 0,45.35945 10.727861,0 0,-15.5518 c 0.565478,0.3255 1.216469,0.5745 1.952975,0.747 0.736473,0.1725 1.405464,0.2595 2.006974,0.261 4.47442,-0.1185 8.215368,-1.6815 11.222855,-4.689 3.007429,-3.0074 4.570407,-6.7484 4.688941,-11.2228 z m -10.727862,-0.072 c 0.02248,2.127 -0.454517,3.8489 -1.430981,5.1659 -0.976509,1.317 -2.587487,1.995 -4.832939,2.034 -0.390011,-0.018 -0.870005,-0.126 -1.439981,-0.324 -0.570008,-0.198 -1.050002,-0.378 -1.439982,-0.54 l 0,-12.1679 1.58398,0 c 2.141954,-0.063 3.923929,0.2971 5.34593,1.08 1.421959,0.783 2.159949,2.367 2.213973,4.752 z"
 
         style="fill:#000000"
 
         id="path3879" />
 
    </g>
 
  </g>
 
</svg>
images/favicon_96.png
Show inline comments
 
deleted file
 
binary diff not shown
Show images
images/favicon_untraced.svg
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 
<!-- Created with Inkscape (http://www.inkscape.org/) -->
 

	
 
<svg
 
   xmlns:dc="http://purl.org/dc/elements/1.1/"
 
   xmlns:cc="http://creativecommons.org/ns#"
 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 
   xmlns:svg="http://www.w3.org/2000/svg"
 
   xmlns="http://www.w3.org/2000/svg"
 
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
 
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
 
   width="64"
 
   height="64"
 
   id="svg3040"
 
   version="1.1"
 
   inkscape:version="0.48.2 r9819"
 
   sodipodi:docname="favicon_untraced.svg"
 
   inkscape:export-filename="C:\Users\binki\Documents\repos\slate_permutate\images\favicon_96.png"
 
   inkscape:export-xdpi="135"
 
   inkscape:export-ydpi="135">
 
  <defs
 
     id="defs3042" />
 
  <sodipodi:namedview
 
     id="base"
 
     pagecolor="#ffffff"
 
     bordercolor="#666666"
 
     borderopacity="1.0"
 
     inkscape:pageopacity="0.0"
 
     inkscape:pageshadow="2"
 
     inkscape:zoom="1"
 
     inkscape:cx="32"
 
     inkscape:cy="40.443748"
 
     inkscape:document-units="px"
 
     inkscape:current-layer="layer1"
 
     showgrid="false"
 
     inkscape:window-width="1366"
 
     inkscape:window-height="716"
 
     inkscape:window-x="-8"
 
     inkscape:window-y="-8"
 
     inkscape:window-maximized="1" />
 
  <metadata
 
     id="metadata3045">
 
    <rdf:RDF>
 
      <cc:Work
 
         rdf:about="">
 
        <dc:format>image/svg+xml</dc:format>
 
        <dc:type
 
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
 
        <dc:title></dc:title>
 
      </cc:Work>
 
    </rdf:RDF>
 
  </metadata>
 
  <g
 
     inkscape:label="Layer 1"
 
     inkscape:groupmode="layer"
 
     id="layer1"
 
     transform="translate(0,-988.36218)">
 
    <rect
 
       style="fill:#d0ffdc;fill-opacity:1;stroke:none"
 
       id="rect3106"
 
       width="88"
 
       height="84"
 
       x="-8"
 
       y="-5"
 
       transform="translate(0,988.36218)"
 
       ry="0"
 
       rx="0" />
 
    <text
 
       xml:space="preserve"
 
       style="font-size:72px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:-4px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
 
       x="-0.59351826"
 
       y="1043.0419"
 
       id="text12334-9-1"
 
       sodipodi:linespacing="125%"
 
       inkscape:export-filename="/home/ethanzonca/Images/slatepermutate-square.png"
 
       inkscape:export-xdpi="413.78741"
 
       inkscape:export-ydpi="413.78741"><tspan
 
         sodipodi:role="line"
 
         id="tspan12336-1-7"
 
         x="-0.59351826"
 
         y="1043.0419"
 
         style="font-size:72px;font-style:normal;font-variant:normal;font-weight:900;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:-4px;writing-mode:lr-tb;text-anchor:start;fill:#4d4d4d;fill-opacity:1;font-family:Delicious Heavy;-inkscape-font-specification:'Delicious Heavy, Heavy'">S<tspan
 
   style="font-size:72px;letter-spacing:-4px;fill:#000000"
 
   id="tspan12338-7-4">P</tspan></tspan></text>
 
  </g>
 
</svg>
inc/admin.inc
Show inline comments
 
@@ -551,12 +551,43 @@ 3';
 
   * Check partial parsing support; give a situation where we
 
   * supposedly don't have eof.
 
   */
 
  $n += assert_equal('csv_partial', school_crawl_csv_parse($csv_partial), array(array('1', '2')));
 
  $n += assert_equal('csv_partial_buffer', $csv_partial, '3');
 

	
 
  $section_meeting_a = new SectionMeeting('mwf', '1900', '1950', NULL, 'lecture', NULL, 1335063574 /* 2012-04-22 (sat) */, 1348282798 /* bit after 2012-09-21 (fri) */);
 
  $n += assert_equal('date_start_get+mon', $section_meeting_a->date_start_get(), 1335207600);
 
  $n += assert_equal('date_end_get+fri', $section_meeting_a->date_end_get(), 1348257000);
 

	
 
  $section_meeting_b = new SectionMeeting('mwf', '1900', '1950', NULL, 'lecture', NULL, 1335495574 /* 2012-04-27 (thur) */, 1348109998 /* bit after 2012-09-19 (wed) */);
 
  $n += assert_equal('date_start_get+thur', $section_meeting_b->date_start_get(), 1335553200);
 
  $n += assert_equal('date_end_get+wed', $section_meeting_b->date_end_get(), 1348084200);
 

	
 
  /* The two section meetings above should overlap */
 
  $n += assert_equal('section_meeting_collide', $section_meeting_a->conflictsWith($section_meeting_b), TRUE);
 

	
 
  /*
 
   * A third section meeting has the same time of day but starts the
 
   * day after secftion_meeting_b:
 
   */
 
  $section_meeting_c = new SectionMeeting('mwf', '1900', '1950', NULL, 'lecture', NULL, 1348109998 /* bit after 2012-09-19 (wed) */, 1354406400 /* bit after 2012-12-01 (wed) */);
 
  $n += assert_equal('section_meeting_collide_a', $section_meeting_a->conflictsWith($section_meeting_c), TRUE);
 
  $n += assert_equal('section_meeting_no_collide_b', $section_meeting_b->conflictsWith($section_meeting_c), FALSE);
 

	
 
  /*
 
   * If a section meeting doesn't specify an absolute start/end time,
 
   * it must always conflict.
 
   */
 
  $section_meeting_d = new SectionMeeting('mwf', '1900', '1950');
 
  $n += assert_equal('section_meeting_collide_d_a', $section_meeting_d->conflictsWith($section_meeting_a), TRUE);
 
  $n += assert_equal('section_meeting_collide_a_d', $section_meeting_a->conflictsWith($section_meeting_d), TRUE);
 
  $n += assert_equal('section_meeting_collide_d_b', $section_meeting_d->conflictsWith($section_meeting_b), TRUE);
 
  $n += assert_equal('section_meeting_collide_b_d', $section_meeting_b->conflictsWith($section_meeting_d), TRUE);
 
  $n += assert_equal('section_meeting_collide_d_c', $section_meeting_d->conflictsWith($section_meeting_c), TRUE);
 
  $n += assert_equal('section_meeting_collide_c_b', $section_meeting_c->conflictsWith($section_meeting_d), TRUE);
 

	
 
  return $n;
 
}
 

	
 
/**
 
 * \brief
 
 *   A reimplementation of a standard testsuite utility.
inc/class.page.php
Show inline comments
 
modified file chmod 100755 => 100644
 
@@ -373,13 +373,14 @@ class page
 
	  '    <title>' . $this->pagetitle . ' - ' . $this->base_title[0] . ' - ' . $this->base_title[1] . '</title>'. PHP_EOL .
 
          '    <link rel="stylesheet" href="styles/general.css" type="text/css" media="screen" charset="utf-8" />'.  PHP_EOL .
 
	  '    <link rel="stylesheet" type="text/css" media="print" href="styles/print.css" />'. PHP_EOL .
 
          '    <!--[if IE]>'. PHP_EOL .
 
          '      <link rel="stylesheet" type="text/css" media="screen" charset="utf-8" href="styles/ie.css" />'. PHP_EOL .
 
          '    <![endif]-->'. PHP_EOL .
 
          '    <link rel="shortcut icon" href="images/favicon.png" />'. PHP_EOL
 
          '    <link rel="icon" href="images/favicon.svg" type="image/svg+xml" sizes="any" />' . PHP_EOL
 
      . '    <link rel="apple-touch-icon" href="images/favicon.svg" type="image/svg+xml" sizes="any" />' . PHP_EOL
 
      . '    <style type="text/css">' . PHP_EOL
 
      . $this->cdata_wrap(school_page_css($this->school))
 
      . '    </style>' . PHP_EOL;
 

	
 
    foreach ($this->meta as $key => $value)
 
      echo '    <meta name="' . htmlentities($key, ENT_QUOTES)
inc/class.schedule.php
Show inline comments
 
@@ -186,13 +186,13 @@ class Schedule
 
   *   The instructor of this section/section_meeting.
 
   *
 
   * \return
 
   *   NULL on success, a string on error which is a message for the
 
   *   user and a valid XHTML fragment.
 
   */
 
  function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $instructor = NULL, $location = NULL, $type = 'lecture', $slot = 'default', $credit_hours = -1.0)
 
  function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $instructor = NULL, $location = NULL, $type = 'lecture', $slot = 'default', $credit_hours = -1.0, $date_start = NULL, $date_end = NULL)
 
  {
 
    if (empty($letter) && (empty($time_start) || !strcmp($time_start, 'none')) && (empty($time_end) || !strcmp($time_end, 'none')) && empty($days)
 
	&& empty($synonym) && empty($instructor) && empty($location) && (empty($type) || !strcmp($type, 'lecture'))
 
	&& (empty($slot) || !strcmp($slot, 'default')))
 
      return;
 

	
 
@@ -206,22 +206,31 @@ class Schedule
 

	
 
    if (!empty($credit_hours) && !is_numeric($credit_hours))
 
      {
 
        return 'Invalid credit-hour specification of <tt>' . htmlentities($credit_hours) . '</tt> for ' . htmlentities($course_name) . '-' . htmlentities($letter) . '. Please use a floating point number or do not enter anything if the number of credit hours is not known.';
 
      }
 

	
 
    if (empty($date_start) != empty($date_end)
 
        || !empty($date_start) && !is_numeric($date_start)
 
        || !empty($date_end) && !is_numeric($date_end))
 
      {
 
        return 'Invalid date range specification of <tt>' . htmlentities($date_start, ENT_QUOTES)
 
          . '</tt> through <tt>' . htmlentities($date_end, ENT_QUOTES)
 
          . '</tt>. Was expecting two valid unix timestamps or two empty values.';
 
      }
 

	
 
    foreach ($this->courses as $course)
 
      if (!strcmp($course_name, $course->getName()))
 
	{
 
	  $section = $course->section_get($letter);
 
	  if (!$section)
 
	    {
 
              $section = new Section($letter, array(), $synonym, $credit_hours);
 
	      $course->section_add($section, $slot);
 
	    }
 
	  $section->meeting_add(new SectionMeeting($days, $time_start, $time_end, $location, $type, $instructor));
 
	  $section->meeting_add(new SectionMeeting($days, $time_start, $time_end, $location, $type, $instructor, $date_start, $date_end));
 

	
 
	  return;
 
	}
 

	
 
    error_log('Could not find class when parsing schedule from postData: ' . $course_name);
 
    echo 'Could not find class: ' . $course_name . "<br />\n";
 
@@ -505,13 +514,13 @@ class Schedule
 
	. '    jQuery(\'.cute-time\').cuteTime();' . PHP_EOL
 
	. '  });' . PHP_EOL
 
	. '        </script>' . PHP_EOL;
 

	
 
      echo '        <div id="sharedialog" title="Share Schedule">' . PHP_EOL
 
	. '          <p class="indent"><img alt="[fb]" class="noborder" src="http://facebook.com/favicon.ico" /> <a href="http://www.facebook.com/sharer.php?u=' . urlencode(htmlentities($outputPage->gen_share_url($this->id_get()))) .'&amp;t=My%20Schedule">Share on Facebook</a></p>
 
		     <p class="indent"><img alt="[sp]" class="noborder" src="images/favicon.png" style="margin-right: 5px;"/><span class="clicktoclipboard"><a href="#">Share with URL</a><span class="toclipboard hidden"><p>Copy the share URL below:<br /><em class="centeredtext smallurl">' . htmlentities($outputPage->gen_share_url($this->id_get())) . '</em></p></span></span></p>' . PHP_EOL
 
		     <p class="indent"><img alt="[sp]" class="noborder" src="images/favicon.svg" style="margin-right: 5px; width: 16px; height: 16px;"/><span class="clicktoclipboard"><a href="#">Share with URL</a><span class="toclipboard hidden"><p>Copy the share URL below:<br /><em class="centeredtext smallurl">' . htmlentities($outputPage->gen_share_url($this->id_get())) . '</em></p></span></span></p>' . PHP_EOL
 
	. '        </div>' . PHP_EOL
 
	. '        <p>' . PHP_EOL
 
	. '          <a href="input.php?s='.$this->id.'" class="button">Edit</a>' . PHP_EOL
 
	. '          <span id="printItems"><a href="#" class="button">Print</a></span>' . PHP_EOL
 
	. '          <span id="share"><a href="#" class="button">Share</a></span>' . PHP_EOL;
 

	
inc/class.section.php
Show inline comments
 
@@ -20,14 +20,16 @@
 

	
 
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.section_meeting.inc';
 
   
 
/**
 
 * \brief
 
 *   Represent a Section associated with a Course.
 
 *
 
 * Iterating over a Section yields section_SectionMeeting objects.
 
 */
 
class Section
 
class Section implements IteratorAggregate
 
{
 

	
 
  private $letter;	// Section letter
 
  private $prof;	// Professor, preserved for Section::__wakeup()
 

	
 
  /* meeting times, array of SectionMeeting */
 
@@ -67,12 +69,21 @@ class Section
 
    $this->letter = $letter;
 
    $this->meetings = $section_meetings;
 
    $this->synonym = $synonym;
 
    $this->credit_hours = (float)$credit_hours;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Implements the IteratorAggregate interface.
 
   */
 
  public function getIterator()
 
  {
 
    return new ArrayIterator($this->meetings);
 
  }
 

	
 
  public function getLetter()
 
  {
 
    return $this->letter;
 
  }
 

	
 
  /**
inc/class.section_meeting.inc
Show inline comments
 
<?php /* -*- mode: php; -*- */
 
<?php /* -*- mode: php; indent-tabs-mode: nil; -*- */
 
/*
 
 * Copyright 2010 Nathan Gelderloos, Ethan Zonca, Nathan Phillip Brink
 
 *
 
 * This file is part of SlatePermutate.
 
 *
 
 * SlatePermutate is free software: you can redistribute it and/or modify
 
@@ -32,20 +32,35 @@
 
 * prof/time/location. At Cedarville, a Section refers to a prof and a
 
 * _set_ of time/location pairs. The generalization is to make each
 
 * Section support a list of meeting times/locations.
 
 */
 
class SectionMeeting
 
{
 
  private $date_start;
 
  private $time_start;
 
  private $date_end;
 
  private $time_end;
 
  private $days;
 
  private $location;
 
  private $instructor;
 

	
 
  /**
 
   * \brief
 
   *   Cache some calculations. The timestamp of the first meeting's
 
   *   absolute start time.
 
   */
 
  private $_time_first_meeting_start;
 
  /**
 
   * \brief
 
   *   Cache some calculations. The timestamp of the exact last
 
   *   meeting's end time.
 
   */
 
  private $_time_last_meeting_end;
 

	
 
  /**
 
   * \brief
 
   *   Construct a SectionMeeting.
 
   *
 
   * \param $days
 
   *   A string of single-char day upon which a section meets. Sunday
 
   *   is represented with 'u', Monday with 'm', Tuesday with 't',
 
   *   Wednesday with 'w', Thursday with 'h', Friday with 'f', and
 
@@ -61,28 +76,47 @@ class SectionMeeting
 
   * \param $type
 
   *   The type of meeting this is. For lectures, please use
 
   *   'lecture'. For labs, please use 'lab'. For others, use the
 
   *   school's notation.
 
   * \param $instructor
 
   *   The instructor for this section meeting.
 
   * \param $date_start
 
   *   A timestamp marking some time prior to the first occurence of
 
   *   the section_meeting.
 
   * \param $date_end
 
   *   A timestamp marking some time after the end of the last
 
   *   occurence of this section_meeting.
 
   */
 
  public function __construct($days, $time_start, $time_end, $location = NULL, $type = 'lecture', $instructor = NULL)
 
  public function __construct($days, $time_start, $time_end, $location = NULL, $type = 'lecture', $instructor = NULL, $date_start = NULL, $date_end = NULL)
 
  {
 
    $this->days_set($days);
 

	
 

	
 
    $this->date_start = empty($date_start) ? NULL : (int)$date_start;
 
    $this->time_start = $time_start;
 
    $this->date_end = empty($date_end) ? NULL : (int)$date_end;
 
    $this->time_end = $time_end;
 

	
 
    $this->location = $location;
 

	
 
    $this->type = $type;
 
    $this->instructor = $instructor;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Mark certain cached values as needing to be recalculated.
 
   */
 
  private function _cache_reset()
 
  {
 
    unset($this->_time_first_meeting_start);
 
    unset($this->_time_first_meeting_end);
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Take a days of week string and store it into our $days of week array.
 
   *
 
   * \param $days_str
 
   *   The days of the week in a string format. One char per
 
   *   day. Sun-Sat is represented with 'u', 'm', 't', 'w', 'h', 'f',
 
   *   's'.
 
@@ -91,12 +125,14 @@ class SectionMeeting
 
  {
 
    $this->days = array(0 => FALSE, 1 => FALSE, 2 => FALSE, 3 => FALSE, 4 => FALSE, 5 => FALSE, 6 => FALSE);
 

	
 
    $days_str_strlen = strlen($days_str);
 
    for ($i = 0; $i < $days_str_strlen; $i ++)
 
      $this->days[self::day_atoi($days_str[$i])] = TRUE;
 

	
 
    $this->_cache_reset();
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Convert a day letter to a day numeral.
 
   *
 
@@ -152,12 +188,33 @@ class SectionMeeting
 
  public function getDay($day)
 
  {
 
    return $this->days[self::day_atoi($day)];
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Get a string representing the days of week during which this meeting meets.
 
   */
 
  public function days_get()
 
  {
 
    static $daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f', 5 => 's', 6 => 'u');
 
    static $dayorder_reverse = array(6 => TRUE);
 
    $days = '';
 
    for ($day = 0; $day < 7; $day ++)
 
      if ($this->getDay($day))
 
	{
 
	  if (empty($dayorder_reverse[$day]))
 
	    $days .= $daymap[$day];
 
	  else
 
	    $days = $daymap[$day] . $days;
 
	}
 
    return $days;
 
  }
 

	
 

	
 
  /**
 
   * \return
 
   *   This SectionMeeting's location or NULL if none is defined.
 
   */
 
  public function getLocation()
 
  {
 
    return $this->location;
 
@@ -194,12 +251,141 @@ class SectionMeeting
 
  {
 
    return $this->type;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Return the unix timestamp of the exact time prior of the first
 
   *   section meeting or NULL if unknown.
 
   */
 
  public function date_start_get()
 
  {
 
    static $day_to_real_day = array('u' => 0, 'm' => 1, 't' => 2, 'w' => 3, 'h' => 4, 'f' => 5, 's' => 6);
 

	
 
    if (empty($this->_time_first_meeting_start))
 
      {
 
        if (empty($this->date_start))
 
          return NULL;
 

	
 
        /*
 
         * For now, just assume UTC. Otherwise, we'd need a handle to
 
         * the school and for each school to specify its timezone. Not
 
         * a bad idea, but even if the school has a timezone
 
         * associated with it (which it will someday soon...), this is
 
         * more efficient.
 
         */
 
        $hour = substr($this->getStartTime(), 0, 2);
 
        $minute = substr($this->getStartTime(), 2, 2);
 

	
 
        /*
 
         * This is the dirty part. Find the first instance of this
 
         * section_meeting's day of week and convert that to a day of
 
         * month for gmmktime() call below. Assumes that a day is at
 
         * least 12 hours long (there are 23 and 25 hours days near
 
         * daylight saving changes, so there _are_ issues with
 
         * assuming 24 hours).
 
         */
 

	
 
        /* Search out the first day... */
 
        $earliest_day = -1;
 
        $earliest_day_time = 0;
 
        $days_of_week = $this->days_get();
 
        for ($i = 0; $i < strlen($days_of_week); $i ++)
 
          {
 
            /* Find the first occurence of the currently tested day after $this->date_start */
 
            $day_of_week_sought = $day_to_real_day[$days_of_week[$i]];
 
            $day_of_week_time = $this->date_start - 12 * 60*60;
 
            do
 
              {
 
                $day_of_week = gmdate('w', $day_of_week_time);
 
                $day_of_week_time += 12 * 60*60;
 
              }
 
            while ($day_of_week != $day_of_week_sought);
 

	
 
            /* Find exact time of this meeting on that day */
 
            $day_of_week_time = gmmktime($hour, $minute, 0,
 
                                         gmdate('n', $day_of_week_time),
 
                                         gmdate('j', $day_of_week_time),
 
                                         gmdate('Y', $day_of_week_time));
 

	
 
            if ($earliest_day == -1
 
                || $day_of_week_time < $earliest_day_time)
 
              {
 
                $earliest_day = $i;
 
                $earliest_day_time = $day_of_week_time;
 
              }
 
          }
 

	
 
        $this->_time_first_meeting_start = $earliest_day_time;
 
      }
 

	
 
    return $this->_time_first_meeting_start;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Return the unix timestamp of the exact time at which the the
 
   *   last section meeting stops or NULL if unknown.
 
   *
 
   * This is implemented in mirror to start_date_get(). Refer to that
 
   * function for rationale and comments.
 
   */
 
  public function date_end_get()
 
  {
 
    static $day_to_real_day = array('u' => 0, 'm' => 1, 't' => 2, 'w' => 3, 'h' => 4, 'f' => 5, 's' => 6);
 

	
 
    if (empty($this->_time_last_meeting_end))
 
      {
 
	if (empty($this->date_end))
 
	  return NULL;
 

	
 
        /* Assume UTC */
 
        $hour = substr($this->getEndTime(), 0, 2);
 
        $minute = substr($this->getEndTime(), 2, 2);
 

	
 
        /* Find last meeting time */
 

	
 
        /* Search out the last day of week... */
 
        $latest_day = -1;
 
        $latest_day_time = 0;
 
        $days_of_week = $this->days_get();
 
        for ($i = 0; $i < strlen($days_of_week); $i ++)
 
          {
 
            /* Find last occurence of the currently tested day before $this->date_end */
 
            $day_of_week_sought = $day_to_real_day[$days_of_week[$i]];
 
            $day_of_week_time = $this->date_end + 12 * 60*60;
 
            $day_of_week = '';
 
            do
 
              {
 
                $day_of_week = gmdate('w', $day_of_week_time);
 
                $day_of_week_time -= 12 * 60*60;
 
              }
 
            while ($day_of_week != $day_of_week_sought);
 

	
 
            /* Find exact time this meeting ends on that day */
 
            $day_of_week_time = gmmktime($hour, $minute, 0,
 
                                         gmdate('n', $day_of_week_time),
 
                                         gmdate('j', $day_of_week_time),
 
                                         gmdate('Y', $day_of_week_time));
 

	
 
            if ($latest_day == -1
 
                || $day_of_week_time > $latest_day_time)
 
              {
 
                $latest_day = $i;
 
                $latest_day_time = $day_of_week_time;
 
              }
 
          }
 

	
 
        $this->_time_last_meeting_end = $latest_day_time;
 
      }
 

	
 
    return $this->_time_last_meeting_end;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Check if this section conflicts with the given section.
 
   *
 
   * \param $that
 
   *   The other section for which I should check for conflicts.
 
   * \return
 
   *   TRUE if there is a conflict, FALSE otherwise.
 
@@ -207,15 +393,21 @@ class SectionMeeting
 
  public function conflictsWith(SectionMeeting $that)
 
  {
 
    /*
 
     * The two sections meetings can't conflict if the start/end times
 
     * don't overlap. Also, use >= or <= here so that one can say ``I
 
     * have gym from 10 through 11 and then latin from 11 though 12''.
 
     *
 
     * They also can't conflict if the unix timestamps of the first
 
     * and last meetings indicate that the sections are from different
 
     * parts of the semester.
 
     */	
 
    if ($this->getStartTime() >= $that->getEndTime()
 
	|| $this->getEndTime() <= $that->getStartTime())
 
	|| $this->getEndTime() <= $that->getStartTime()
 
	|| $this->date_start_get() >= ($that_end = $that->date_end_get()) && $that_end !== NULL
 
	|| ($this_end = $this->date_end_get()) <= $that->date_start_get() && $this_end !== NULL)
 
      {
 
	return FALSE;
 
      }
 

	
 
    /*
 
     * Now we know that the sections meetings overlap in start/end
 
@@ -246,13 +438,15 @@ class SectionMeeting
 
   */
 
  public function to_json_array()
 
  {
 
    static $daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f', 5 => 's', 6 => 'u');
 

	
 
    $json_array = array(
 
			'time_start' => $this->time_start,
 
      'date_start' => empty($this->date_start) ? NULL : $this->date_start,
 
      			'time_start' => $this->time_start,
 
      'date_end' => empty($this->date_end) ? NULL : $this->date_end,
 
			'time_end' => $this->time_end,
 
			'days' => array(),
 
			'location' => $this->location,
 
			'instructor' => $this->instructor,
 
			'type' => $this->type,
 
			);
 
@@ -271,17 +465,20 @@ class SectionMeeting
 
   *   The JSON array to parse.
 
   * \return
 
   *   A shiny, new SectionMeeting.
 
   */
 
  public static function from_json_array(array $json_array)
 
  {
 
    $json_array += array('date_start' => NULL, 'date_end' => NULL);
 
    $days = '';
 
    foreach ($json_array['days'] as $day => $meets)
 
      if ($meets)
 
	$days .= $day;
 
    return new SectionMeeting($days, $json_array['time_start'], $json_array['time_end'], $json_array['location'], $json_array['type'], $json_array['instructor']);
 
    return new SectionMeeting($days, $json_array['time_start'], $json_array['time_end'],
 
			      $json_array['location'], $json_array['type'], $json_array['instructor'],
 
			      $json_array['date_start'], $json_array['date_end']);
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Upgrade this section_meeting to support Sunday and Saturday.
 
   */
inc/class.semester.inc
Show inline comments
 
@@ -92,12 +92,17 @@ class Semester
 
  public function class_add(Course $class)
 
  {
 
    $class_parts = Course::parse($class->getName());
 
    if (!isset($class_parts['course']))
 
      throw new ErrorException('I was given a class with an invalid name: `' . $class->getName() . '\'');
 

	
 
    foreach ($class as $course_slot)
 
      foreach ($course_slot as $section)
 
        foreach ($section as $meeting)
 
          $this->time_set_section_meeting($meeting);
 

	
 
    if (!isset($this->departments[$class_parts['department']]))
 
      $this->departments[$class_parts['department']] = array();
 
    $department =& $this->departments[$class_parts['department']];
 

	
 
    $department[$class_parts['course']] = $class;
 
  }
 
@@ -218,12 +223,15 @@ class Semester
 
   *   does not have the concept of course slots. Ask binki for help
 
   *   figuring this out. Course slots are a sort of
 
   *   inverse/complement to section_meetings.
 
   */
 
  public function section_add($dept, $class, Section $section, $title = NULL, $course_slot_id = 'default')
 
  {
 
    foreach ($section as $meeting)
 
      $this->time_set_section_meeting($meeting);
 

	
 
    $dept = strtoupper($dept);
 
    $class = strtoupper($class);
 

	
 
    if (!isset($this->departments[$dept])
 
	|| !isset($this->departments[$dept][$class]))
 
      {
 
@@ -267,12 +275,14 @@ class Semester
 
   * \param $credit_hours
 
   *   The number of credit hours of the associated course or a
 
   *   negative value if unknown.
 
   */
 
  public function section_meeting_add($dept, $course, $title, $section, $synonym, SectionMeeting $section_meeting, $course_slot_id = 'default', $credit_hours = -1.0)
 
  {
 
    $this->time_set_section_meeting($section_meeting);
 

	
 
    $dept = strtoupper($dept);
 
    $course = strtoupper($course);
 

	
 
    if (empty($this->departments[$dept][$course]))
 
      $course_obj = NULL;
 
    else
 
@@ -417,12 +427,29 @@ class Semester
 

	
 
    return $this->time_start;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Consider a section_meeting's start and end dates and make
 
   *   appropriate time_start_set_test() and time_end_set_test()
 
   *   calls.
 
   */
 
  public function time_set_section_meeting(SectionMeeting $meeting)
 
  {
 
    $date_start = $meeting->date_start_get();
 
    if (!empty($date_start))
 
      $this->time_start_set_test($date_start);
 

	
 
    $date_end = $meeting->date_end_get();
 
    if (!empty($date_end))
 
      $this->time_end_set_test($date_end);
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Get a semester's year.
 
   */
 
  public function year_get()
 
  {
 
    return $this->year;
 
  }
inc/school.crawl.inc
Show inline comments
 
@@ -590,18 +590,21 @@ function school_crawl_url($orig_url, $ur
 
{
 
  /*
 
   * This accounts for both if the $url is already an absolute, fully
 
   * qualified URL. It falls back to the original URL if it fails to
 
   * match.
 
   */
 
  foreach (array($url, $orig_url) as $aurl)
 
  foreach (array($orig_url, $url) as $aurl)
 
    if (preg_match(';^(https?)://([^/]+)(/.*)$;', $aurl, $matches))
 
      {
 
	$new_url['schema'] = $matches[1];
 
	$new_url['hostname'] = $matches[2];
 
	$new_url['path'] = $matches[3];
 
	if (!empty($matches[1]))
 
	  $new_url['schema'] = $matches[1];
 
	if (!empty($matches[2]))
 
	  $new_url['hostname'] = $matches[2];
 
	if (!empty($matches[3]))
 
	  $new_url['path'] = $matches[3];
 
      }
 

	
 
  /* check if we have an absolute relative path */
 
  if (!strncmp($url, '/', 1))
 
    $new_url['path'] = $url;
 

	
input.php
Show inline comments
 
modified file chmod 100755 => 100644
 
@@ -151,13 +151,15 @@ elseif ($errors_fix)
 
				    'h' => !empty($section['days'][3]), 'f' => !empty($section['days'][4]),
 
				    's' => !empty($section['days'][5])))
 
		. ', ' . json_encode($section['professor']) . ', '
 
		. json_encode($section['location']) . ', '
 
		. json_encode($section['type']) . ', '
 
		. json_encode($section['slot']) . ', '
 
		. json_encode(isset($section['credit_hours']) ? $section['credit_hours'] : -1) . ');' . PHP_EOL;
 
		. json_encode(isset($section['credit_hours']) ? $section['credit_hours'] : -1) . ', '
 
		. json_encode(empty($section['date_start']) ? NULL : $section['date_start']) . ', '
 
		. json_encode(empty($section['date_end']) ? NULL : $section['date_end']) . ');' . PHP_EOL;
 
	  $my_hc .= PHP_EOL;
 
	}
 
  }
 
else
 
  {
 
    $default_courses = school_default_courses($school);
 
@@ -387,12 +389,14 @@ function input_course_js(Course $course,
 
				'w' => $meeting->getDay(2), 'h' => $meeting->getDay(3), 'f' => $meeting->getDay(4),
 
				's' => $meeting->getDay(5))) . ', '
 
	    . json_encode($meeting->instructor_get()) . ', '
 
	    . json_encode($meeting->getLocation()) . ', '
 
	    . json_encode($meeting->type_get()) . ', '
 
	    . json_encode($course_slot->id_get()) . ', '
 
	    . json_encode($section->credit_hours_get()) . ');' . PHP_EOL;
 
	    . json_encode($section->credit_hours_get()) .', '
 
	    . json_encode($meeting->date_start_get()) . ', '
 
	    . json_encode($meeting->date_end_get()) . ');' . PHP_EOL;
 
	}
 
    }
 

	
 
  return $js;
 
}
process.php
Show inline comments
 
@@ -215,16 +215,19 @@ if(!$DEBUG)
 
		$allClasses->addCourse($course['name'], $course['title']);
 

	
 
				foreach($course as $section)
 
				  /* Skip the section name, which isn't a section */
 
					if(is_array($section))
 
					  {
 
					    if (empty($section['slot']))
 
					      $section['slot'] = 'default';
 
					    $section += array(
 
					      'slot' => 'default',
 
					      'date_start' => NULL,
 
					      'date_end' => NULL,
 
					    );
 

	
 
					    $error_string = $allClasses->addSection($course['name'], $section['letter'], $section['start'], $section['end'], arrayToDays(empty($section['days']) ? array() : $section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type'], $section['slot'], $section['credit_hours']);
 
					    $error_string = $allClasses->addSection($course['name'], $section['letter'], $section['start'], $section['end'], arrayToDays(empty($section['days']) ? array() : $section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type'], $section['slot'], $section['credit_hours'], $section['date_start'], $section['date_end']);
 
					    if ($error_string !== NULL)
 
					      $errors[] = $error_string;
 
					  }
 
			}
 
		}
 

	
school.d/calvin.crawl.inc
Show inline comments
 
@@ -397,33 +397,27 @@ function calvin_crawl_semester(array $sc
 
	  $time_end = school_crawl_time_format(strptime($meeting_info_matches[7], '%I:%M%p'));
 
	  $meeting_place = $meeting_info_matches[8];
 

	
 
	  foreach (array('date_start', 'date_end', 'meeting_type', 'days', 'time_start', 'time_end', 'meeting_place', 'meeting_type') as $var)
 
	    school_crawl_logf($school_crawl_log, 10, "%s:%s", $var, ${$var});
 

	
 
	  $semester->section_meeting_add($section_id['department'], $section_id['course'], $title, $section_id['section'], $synonym,
 
					 new SectionMeeting($days, $time_start, $time_end, $meeting_place, $meeting_type, $faculty_name), 'default', $credits);
 

	
 
	  /*
 
	   * Try to update semester's longetivity stats to help the
 
	   * school_semester_guess() function:
 
	   */
 
	  $date_start_time = strptime($date_start, '%m/%d/%Y');
 
	  $date_end_time = strptime($date_end, '%m/%d/%Y');
 
	  if ($date_start_time !== FALSE)
 
	    $date_start_time = school_crawl_gmmktime($date_start_time, -5 * 60*60);
 
	  else
 
	    $date_start_time = NULL;
 
	  if ($date_end_time !== FALSE)
 
	    $date_end_time = school_crawl_gmmktime($date_end_time, -5 * 60*60) + 24*60*60;
 
	  else
 
	    $date_end_time = NULL;
 

	
 
	  if ($date_start_time !== FALSE)
 
	    {
 
	      $date_start_time = school_crawl_gmmktime($date_start_time, -5 * 60*60);
 
	      $semester->time_start_pool_add($date_start_time);
 
	  $semester->section_meeting_add($section_id['department'], $section_id['course'], $title, $section_id['section'], $synonym,
 
					 new SectionMeeting($days, $time_start, $time_end, $meeting_place, $meeting_type, $faculty_name, $date_start_time, $date_end_time), 'default', $credits);
 

	
 
	    }
 
	  if ($date_end_time !== FALSE)
 
	    {
 
	      $date_end_time = school_crawl_gmmktime($date_end_time, -5 * 60*60);
 
	      $semester->time_end_pool_add($date_end_time);
 
	    }
 
	}
 
	}
 

	
 
      if (!preg_match(';Page ([0-9]+) of ([0-9]+)\</td\>$;m', $html, $pages))
 
	{
 
	  school_crawl_logf($school_crawl_log, 0, 'Unable to determine the number of pages in this Calvin resultset');
 
	  break;
school.d/ccbcmd.crawl.inc
Show inline comments
 
@@ -289,24 +289,24 @@ function ccbcmd_crawl_semester($school, 
 
		    $time_start_text, $time_end_text);
 
	    continue;
 
	  }
 

	
 
	$days = school_crawl_days_str_format($school_crawl_log, $children->item($section_offsets['days'])->textContent);
 

	
 
	$section_dates = $children->item($section_offsets['dates'])->textContent;
 
	$date_start = $date_end = NULL;
 
	if (preg_match(';^([0-9]+)/([0-9]+)-([0-9]+)/([0-9]+)$;', $section_dates, $section_dates_matches))
 
	  {
 
	    $date_start = gmmktime(0, 0, 0, $section_dates_matches[1], $section_dates_matches[2], $semester->year_get());
 
	    $date_end = gmmktime(0, 0, 0, $section_dates_matches[3], $section_dates_matches[4], $semester->year_get());
 
	  }
 

	
 
	$section->meeting_add(new SectionMeeting($days, school_crawl_time_format($time_start), school_crawl_time_format($time_end),
 
						 $children->item($section_offsets['location'])->textContent,
 
						 'lecture',
 
						 $instructor));
 

	
 
	/* check if a semester's date range should be increased */
 
	$section_dates = $children->item($section_offsets['dates'])->textContent;
 
	if (preg_match(';^([0-9]+)/([0-9]+)-([0-9]+)/([0-9]+)$;', $section_dates, $section_dates_matches))
 
	  {
 
	    $semester->time_start_set_test(gmmktime(0, 0, 0, $section_dates_matches[1], $section_dates_matches[2], $semester->year_get()));
 
	    $semester->time_end_set_test(gmmktime(0, 0, 0, $section_dates_matches[3], $section_dates_matches[4], $semester->year_get()));
 
	  }
 
						 $instructor, $date_start, $date_end));
 
      }
 
    }
 

	
 
  return 0;
 
}
 

	
school.d/cedarville.crawl.inc
Show inline comments
 
@@ -288,34 +288,31 @@ function cedarville_crawl_semester(array
 
	      $time_end = school_crawl_time_format(strptime($meeting_matches[5] . 'M', '%I:%M%p'));
 
	      $room = $meeting_matches[2];
 

	
 
	      $type = school_crawl_meeting_type($meeting_matches[1]);
 

	
 
	      /* check for daterange information -- i.e., if the first regex successfully matched: */
 
	      $date_start = $date_end = NULL;
 
	      if (count($meeting_matches) > 7)
 
		{
 
		  $date_start = school_crawl_gmmktime(strptime($meeting_matches[6], '%m/%d/%y'), CEDARVILLE_TIMEZONE_OFFSET);
 
		  $date_end = school_crawl_gmmktime(strptime($meeting_matches[7], '%m/%d/%y'), CEDARVILLE_TIMEZONE_OFFSET);
 
		  if (!empty($date_start) && !empty($date_end))
 
		    {
 
		      $semester->time_start_set_test($date_start);
 
		      $semester->time_end_set_test($date_end);
 
		    }
 
		}
 

	
 
	      /*
 
	       * The tables are made for humans, not computers. If
 
	       * there aren't enough instructors for the number of
 
	       * section meetings, just reuse the first listed
 
	       * instructor:
 
	       */
 
	      if ($meeting_i >= count($instructors))
 
		$instructors[$meeting_i] = $instructors[0];
 

	
 
	      $meetings[] = new SectionMeeting($days, $time_start, $time_end,
 
					       $room, $type, $instructors[$meeting_i]);
 
					       $room, $type, $instructors[$meeting_i],
 
					       $date_start, $date_end);
 

	
 
	      $meeting_i ++;
 
	    }
 

	
 
	  $semester->section_add($section_parts['department'], $section_parts['course'],
 
				 new Section($section_parts['section'], $meetings,
school.d/hope.crawl.inc
Show inline comments
 
@@ -275,22 +275,23 @@ function hope_crawl_semester(array $scho
 
					  $section_csv[$fields['Title']]));
 
	  school_crawl_logf($school_crawl_log, 8, "Course %s-%s-%s has a section meeting with a TBA time, adding dummy course.",
 
			    $subject_id, $course_id, $section_id);
 
	  continue;
 
	}
 

	
 
      $date_start = $date_end = NULL;
 
      if (preg_match(',(\\d\\d)/(\\d\\d)-(\\d\\d)/(\\d\\d),', $section_csv[$fields['Date']], $matches))
 
	{
 
	  list(, $m_start, $d_start, $m_end, $d_end) = $matches;
 
	  if ($m_start && $d_start && $m_end && $d_end)
 
	    {
 
	      $y_start = $y_end = $semester->year_get();
 
	      if ($m_end < $m_start)
 
		$y_end ++;
 
	      $semester->time_start_set_test(gmmktime(0, 0, 0, $m_start, $d_start, $y_start));
 
	      $semester->time_end_set_test(gmmktime(0, 0, 0, $m_end, $d_end, $y_end));
 
	      $date_start = gmmktime(0, 0, 0, $m_start, $d_start, $y_start);
 
	      $date_end = gmmktime(0, 0, 0, $m_end, $d_end, $y_end);
 
	    }
 
	}
 

	
 
      if (trim($section_csv[$fields['U']]))
 
	school_crawl_logf($school_crawl_log, 0, "Section %d has sunday.", $synonym);
 
      $days = school_crawl_days_format($school_crawl_log, array_filter(array_slice($section_csv, $fields['M'], 7), '_hope_crawl_days_filter'));
 
@@ -311,13 +312,14 @@ function hope_crawl_semester(array $scho
 
      if (preg_match('/(^|[^a-z])lab($|o|[^a-z])/i', $title))
 
	$type = 'lab';
 

	
 
      $section_meeting = new SectionMeeting($days, $time_start, $time_end,
 
					    $location,
 
					    $type,
 
					    $instructor);
 
					    $instructor,
 
					    $date_start, $date_end);
 
      $semester->section_meeting_add($subject_id,
 
				     $course_id,
 
				     $title,
 
				     $section_id,
 
				     $synonym,
 
				     $section_meeting,
school.d/umich.crawl.inc
Show inline comments
 
@@ -271,38 +271,37 @@ function umich_crawl_semester(array $sch
 
       * listing of courses. Perform some accumulation here.
 
       */
 
      foreach (array('Instructor') as $key)
 
	if (strlen($curr_value = trim($row[$fields[$key]])))
 
	  $row_accumulation[$key] = $curr_value;
 

	
 
      $semester->section_meeting_add($dept, $course_id, trim($row[$fields['Course Title']]),
 
				     trim($row[$fields['Section']]), $synonym,
 
				     new SectionMeeting($days, $time_start, $time_end,
 
							trim($row[$fields['Location']]),
 
							$meeting_type,
 
							$row_accumulation['Instructor']),
 
				     $meeting_type,
 
				     $credit_hours);
 

	
 
      /*
 
       * If the section so far passed as being a normal section, use
 
       * its start and end dates to help determine the semester's
 
       * respective start and end dates.
 
       * Grab start/stop dates.
 
       */
 
      $date_start = $date_end = NULL;
 
      $date_start_tm = strptime(trim($row[$fields['Start Date']]), '%m/%d/%Y');
 
      $date_end_tm = strptime(trim($row[$fields['End Date']]), '%m/%d/%Y');
 
      if (!empty($date_start_tm) && !empty($date_end_tm))
 
	{
 
	  $date_start = school_crawl_gmmktime($date_start_tm);
 
	  $date_end = school_crawl_gmmktime($date_end_tm);
 
	  if ($date_start > 1000000 && $date_end > 1000000)
 
	  if ($date_start < 1000000 || $date_end < 1000000)
 
	    {
 
	      $semester->time_start_set_test($date_start);
 
	      $semester->time_end_set_test($date_end);
 
	      $date_start = $date_end = NULL;
 
	    }
 
	}
 

	
 
      $semester->section_meeting_add($dept, $course_id, trim($row[$fields['Course Title']]),
 
				     trim($row[$fields['Section']]), $synonym,
 
				     new SectionMeeting($days, $time_start, $time_end,
 
							trim($row[$fields['Location']]),
 
							$meeting_type,
 
							$row_accumulation['Instructor'],
 
							$date_start, $date_end),
 
				     $meeting_type,
 
				     $credit_hours);
 
    }
 
}
 

	
 
/**
 
 * \brief
 
 *   Try to turn a umich-formatted time into something usable.
scripts/scheduleInput.js
Show inline comments
 
@@ -14,15 +14,18 @@
 
 * GNU Affero General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
    //--------------------------------------------------
 
    // General Notes
 
    //--------------------------------------------------
 
/**
 
 * \file
 
 *
 
 * If you are reading this file, you may be interested in contributing
 
 * to slate_permutate. Please see http://ohnopub.net/w/SlatePermutate .
 
 */
 

	
 
/**
 
 * \brief
 
 *   The next course_i value that will be produced when add_class() is
 
 *   called.
 
 *
 
@@ -124,13 +127,13 @@ function addTips()
 
}
 

	
 
/**
 
 * \brief
 
 *   Add a section to a class.
 
 */
 
function add_section_n(cnum, name, synonym, stime, etime, days, instructor, location, type, slot, credit_hours)
 
function add_section_n(cnum, name, synonym, stime, etime, days, instructor, location, type, slot, credit_hours, date_start, date_end)
 
{
 
    var snum = last_section_i ++;
 
    var cssclasses = 'section class' + cnum + ' ' + safe_css_class('slot-' + slot);
 
    var last_tr;
 

	
 
	/*
 
@@ -209,12 +212,14 @@ function add_section_n(cnum, name, synon
 
<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>' +
 
	'<td class="removeCell"><div><button class="gray section-meeting-delete">x</button></div></td><td class="emptyCell">' +
 
	'<input class="section-location-entry" type="hidden" name="postData[' + cnum + '][' + snum + '][location]" />' +
 
	'<input class="section-type-entry" type="hidden" name="postData[' + cnum + '][' + snum + '][type]" />' +
 
		'<input class="section-credit-hours-entry" type="hidden" name="postData[' + cnum + '][' + snum + '][credit_hours]" />' +
 
		'<input class="section-date-start-entry" type="hidden" name="postData[' + cnum + '][' + snum + '][date_start]" />' +
 
		'<input class="section-date-end-entry" type="hidden" name="postData[' + cnum + '][' + snum + '][date_end]" />' +
 
	'</td></tr>';
 

	
 
    /*
 
     * Try to append this section to the last section in its
 
     * associated CourseSlot...
 
     */
 
@@ -241,12 +246,14 @@ function add_section_n(cnum, name, synon
 
    section_tr.find('.section-synonym-entry').val(synonym);
 
    section_tr.find('.section-slot-entry').val(slot);
 
    section_tr.find('.profName').val(instructor);
 
    section_tr.find('.section-location-entry').val(location);
 
    section_tr.find('.section-type-entry').val(type);
 
	section_tr.find('.section-credit-hours-entry').val(credit_hours);
 
	section_tr.find('.section-date-start-entry').val(date_start);
 
	section_tr.find('.section-date-end-entry').val(date_end);
 

	
 
    /* unhide the saturday and sunday columns if they're used by autocomplete data */
 
	if (days.u)
 
		jQuery('#jsrows col.sunday').removeClass('collapsed');
 
    if (days.s)
 
	jQuery('#jsrows col.saturday').removeClass('collapsed');
 
@@ -254,13 +261,13 @@ function add_section_n(cnum, name, synon
 
	credit_hours_change(cnum);
 

	
 
    return last_section_i - 1;
 
}
 
function add_section(cnum)
 
{
 
    var section_i = add_section_n(cnum, '', '', '', '', {}, '', '', '', 'default', -1);
 
    var section_i = add_section_n(cnum, '', '', '', '', {}, '', '', '', 'default', -1, null, null);
 
    if (cnum == slate_permutate_course_free)
 
	course_free_check(cnum);
 
    return section_i;
 
}
 

	
 
/**
 
@@ -289,14 +296,21 @@ function add_sections(cnum, data)
 
    jQuery.each(data.sections, function(i, section)
 
		{
 
		    if (!section.slot)
 
			section.slot = 'default';
 
			if (section.credit_hours === undefined)
 
				section.credit_hours = -1;
 
			if (section.date_start === undefined)
 
			{
 
				section.date_start = null;
 
				section.date_end = null;
 
			}
 

	
 
		    add_section_n(cnum, section.section, section.synonym, section.time_start, section.time_end, section.days, section.instructor, section.location, section.type, section.slot, section.credit_hours);
 
		    add_section_n(cnum, section.section, section.synonym, section.time_start, section.time_end,
 
						  section.days, section.instructor, section.location, section.type, section.slot,
 
						  section.credit_hours, section.date_start, section.date_end);
 
		});
 

	
 
    /*
 
     * Handle course-level interdependencies.
 
     */
 
    if (data.dependencies)
0 comments (0 inline, 0 general)