Changeset - 30e159e1b597
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 14 years ago 2012-02-15 23:23:08
ohnobinki@ohnopublishing.net
Add support to cedarville's crawler for retreiving friendly subject/department names for the autocomplete user.
1 file changed with 29 insertions and 0 deletions:
0 comments (0 inline, 0 general)
school.d/cedarville.crawl.inc
Show inline comments
 
@@ -320,6 +320,35 @@ function cedarville_crawl_semester(array
 
	  $semester->section_add($section_parts['department'], $section_parts['course'],
 
				 new Section($section_parts['section'], $meetings,
 
					     $synonym, $credit_hours), $title);
 

	
 
	  /*
 
	   * Get the full subject's name from the course's page if we
 
	   * don't have it already.
 
	   */
 
	  if (!$semester->department_name_has($section_parts['department']))
 
	    {
 
	      foreach ($course_table[1]->childNodes as $course_a)
 
		if ($course_a instanceof DOMElement
 
		&& $course_a->tagName == 'a')
 
		  break;
 
	      if ($course_a instanceof DOMElement
 
		  && $course_a->tagName == 'a'
 
		  && strlen($course_href = $course_a->getAttribute('href')))
 
		{
 
		  $course_uri = school_crawl_url($uri, $course_href);
 
		  $course_html = school_crawl_geturi($course_uri, $cookies, $school_crawl_log);
 
		  if (!empty($course_html))
 
		    {
 
		      $course_dom = new DOMDocument();
 
		      $course_dom->loadHTML($course_html);
 
		      if ($subject_td = $course_dom->getElementById('main_0_subjectLink'))
 
			{
 
			  $subject_name = preg_replace('/ *\\[[A-Z]*\\]$/', '', $subject_td->nodeValue);
 
			  $semester->department_name_set($section_parts['department'], $subject_name);
 
			}
 
		    }
 
		}
 
	    }
 
	}
 
    }
 

	
0 comments (0 inline, 0 general)