Changeset - 14764b931639
[Not reviewed]
default
0 3 0
ethanzonca - 15 years ago 2010-10-10 20:16:50

Added initial Cedarville crawler
3 files changed with 44 insertions and 4 deletions:
0 comments (0 inline, 0 general)
inc/class.page.php
Show inline comments
 
@@ -158,27 +158,31 @@ class page
 
            </div>
 

	
 
	  </div>
 
          <div id="content">';
 
  }
 

	
 

	
 

	
 
  public function foot(){
 
    echo '</div> <!-- id="content" -->';
 
    $this->pageGenTime = round(microtime(), 3);
 
    echo '  <div id="footer">
 
          <h5>&copy; '. date('Y').' <a href="http://protofusion.org/~nathang/">Nathan Gelderloos</a><br />
 
            <a href="http://ethanzonca.com">Ethan Zonca</a>
 
          </h5>
 
  	    <div id="leftfoot" style="float:left; margin-top: 1em;">
 
		<a href="feedback.php">Submit Feedback</a>
 
            </div>
 
            <div id="rightfoot"><h5>&copy; '. date('Y').' <a href="http://protofusion.org/~nathang/">Nathan Gelderloos</a><br />
 
              <a href="http://ethanzonca.com">Ethan Zonca</a>
 
            </h5>
 
	  </div>
 
        </div> <!-- id="footer" -->
 
      </div>';
 
    echo $this->trackingcode;
 
    echo '</body></html>';
 
  }
 

	
 
  public function secondsToCompound($seconds) {
 
      $ret = "";
 
      $hours = intval(intval($seconds) / 3600);
 
      $ret .= "$hours:";
 
      $minutes = bcmod((intval($seconds) / 60),60);
 
      $ret .= "$minutes:";
school.d/cedarville.inc
Show inline comments
 
@@ -18,12 +18,48 @@ function cedarville_instructions_html()
 
  SlatePermutate can be a useful tool for scheduling your next semester at <a href="http://cedarville.edu/">Cedarville University</a>.
 
</p>
 
<ol>
 
  <li>Get in touch with your advisor during advising/reading recess.</li>
 
  <li>Look up each class your advisor specified on this course listing page</li>
 
  <li>Enter each class into a SlatePermutate schedule and add each section that is listed that you are willing to take.</li>
 
  <li>Submit your schedule and view all of the different permutations of your schedule which would work with the sections you specified.</li>
 
  <li>Print out your preferred schedule by choosing "print" and selecting a schedule.</li>
 
  <li>Wait until it's your turn to register and grab your preferred sections before they fill up!</li>
 
</ol>
 
EOF;
 
}
 

	
 
/** Parse html at URL into array, first row is row headers */
 
function table_parse($url) {
 
  $arr = array();
 
  $dom = new DOMDocument;
 
  $html = file_get_contents($url);
 
  if(!$html){
 
    return 1;
 
  }
 
  $dom->loadHTML($html);
 
  $dom->preserveWhiteSpace = false;
 
  $tables = $dom->getElementsByTagName('table');
 
  $rows = $tables->item(0)->getElementsByTagName('tr'); // Get first table on page 
 
  foreach ($rows as $rownum => $row) {
 
    $cols = $row->getElementsByTagName('td');
 
    foreach($cols as $colnum => $col){
 
      $arr[$rownum][$colnum] = $col->nodeValue;
 
    }
 
  }
 
  return $arr;
 
}
 

	
 
/** Crawls Cedarville course listings. $season is "fa" or "sp", year is 4-digit year */
 
function cedarville_crawl($season, $year) {
 
  /* Current academic departments. Update as needed. */
 
  $departments = array('be','ba','ca','ed','eg','es','hg','id','ll','ms','mu','ns','ph','py','sm','sw');
 
  $basepath = "http://cedarville.edu/courses/schedule/";
 

	
 
  $season = strtolower($season);
 
  $tables = array();
 
  foreach($departments as $department) {
 
    $tables[$department] = table_parse($basepath . $year . $season . '_' . $department . '_' . 'all.htm');
 
  }
 
  return $tables;
 
}
 

	
styles/general.css
Show inline comments
 
@@ -157,23 +157,23 @@ td.center {
 
  background: #EEE;
 

	
 
  cursor:default;
 
}
 
.green:hover {
 
  background: #68a64a!important;
 
}
 

	
 

	
 
/* General Classes */
 

	
 
.clear {
 
  clear: all;
 
  clear: both;
 
}
 
.noborder {
 
  border: none!important;
 
}
 
.righttext {
 
  text-align: right;
 
}
 
.centeredtext {
 
  text-align: center;
 
}
0 comments (0 inline, 0 general)