Changeset - 6583b0529782
[Not reviewed]
default
0 4 0
Nathan Brink (binki) - 15 years ago 2011-03-26 11:57:37
ohnobinki@ohnopublishing.net
Fix the school_crawl_days_format() school crawler support function to log errors through school_crawl_logf() instead of error_log().
4 files changed with 13 insertions and 9 deletions:
0 comments (0 inline, 0 general)
inc/school.crawl.inc
Show inline comments
 
@@ -146,25 +146,27 @@ function school_crawl_mktime(array $tm)
 
 *   slate_permutate's internal (weird) representation of a set of
 
 *   weekdays.
 
 *
 
 * This function is intended to make it easy for one to take the
 
 * output of an explode() call. For example, to decode $days_str =
 
 * 'Monday, Tuesday, Friday', one would do
 
 * school_crawl_days_format(explode(', ', $days_str));
 
 * school_crawl_days_format($school_crawl_log, explode(', ', $days_str));
 
 *
 
 * \param $school_crawl_log
 
 *   A school_crawl_log handle to report errors to.
 
 * \param $days
 
 *   An array of day names. These may be common abbreviations or
 
 *   truncations (any truncations must be two chars long for
 
 *   simplicity. One-char representations are supported, however, but
 
 *   use 'm', 't', 'w', 'h', 'f' to distinguish Thursday and
 
 *   Tuesday. 'r' may also be used for Thursday.). Case does not
 
 *   matter. 's' is for Saturday, based on CCBCMD.
 
 * \return
 
 *   slate_permutate's strange internal days representation.
 
 */
 
function school_crawl_days_format($days)
 
function school_crawl_days_format(array $school_crawl_log, $days)
 
{
 
  static $daymap_1 = array('m' => 'm', 't' => 't', 'w' => 'w', 'h' => 'h', 'r' => 'h', 'f' => 'f', 's' => 's');
 
  static $daymap_2 = array('th' => 'h');
 

	
 
  $my_days = array();
 
  foreach ($days as $day)
 
@@ -183,14 +185,14 @@ function school_crawl_days_format($days)
 
	  else
 
	    $day = substr($day, 0, 1);
 
	}
 
      if (isset($daymap_1[$day]))
 
	$my_days[$daymap_1[$day]] = TRUE;
 
      else
 
	error_log('school_crawl_days_format() got invalid day specifier:'
 
		  . ' `' . $day_orig . '\' => `' . $day . '\'');
 
	school_crawl_logf($school_crawl_log, 5, "school_crawl_days_format() got invalid day specifier: `%s' => `%s'.",
 
			  $day_orig, $day);
 
    }
 

	
 
  $day_str = '';
 
  foreach ($my_days as $day_val => $junk)
 
    $day_str .= $day_val;
 

	
 
@@ -198,24 +200,26 @@ function school_crawl_days_format($days)
 
}
 

	
 
/**
 
 * \brief
 
 *   Take a string of day initials and format it.
 
 *
 
 * \param $school_crawl_log
 
 *   The school_crawl_log handle to write errors out to.
 
 * \param $days_str
 
 *   Example input: 'mwf', 'TR'.
 
 * \return
 
 *   Same as school_crawl_days_format()
 
 */
 
function school_crawl_days_str_format($days_str)
 
function school_crawl_days_str_format(array $school_crawl_log, $days_str)
 
{
 
  $day_initials = array();
 
  for ($i = 0; $i < strlen($days_str); $i ++)
 
    $day_initials[] = $days_str[$i];
 

	
 
  return school_crawl_days_format($day_initials);
 
  return school_crawl_days_format($school_crawl_log, $day_initials);
 
}
 

	
 
/**
 
 * \brief
 
 *   Try to guess a more standardized section_meeting type.
 
 *
school.d/calvin.crawl.inc
Show inline comments
 
@@ -340,13 +340,13 @@ function calvin_crawl(array &$semesters,
 
	    }
 
	  $date_start = $meeting_info_matches[1];
 
	  $date_end = $meeting_info_matches[2];
 
	  /* e.g., 'Lecture', 'Practicum' */
 
	  $meeting_type = strtolower(trim($meeting_info_matches[3]));
 

	
 
	  $days = school_crawl_days_format(explode(', ', $meeting_info_matches[5]));
 
	  $days = school_crawl_days_format($school_crawl_log, explode(', ', $meeting_info_matches[5]));
 
	  $time_start = school_crawl_time_format(strptime($meeting_info_matches[6], '%I:%M%p'));
 
	  $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});
school.d/ccbcmd.crawl.inc
Show inline comments
 
@@ -225,13 +225,13 @@ function ccbcmd_crawl(array &$semesters,
 
	  {
 
	    school_crawl_logf($school_crawl_log, 0, "Error parsing start or end time: start: ``%s'' end: ``%s''.",
 
		    $time_start_text, $time_end_text);
 
	    return 1;
 
	  }
 

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

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

	
 
	/* check if a semester's date range should be increased */
school.d/cedarville.crawl.inc
Show inline comments
 
@@ -226,13 +226,13 @@ function cedarville_crawl(array &$semest
 
		  school_crawl_logf($school_crawl_log, 6, "Error parsing meeting time. Given `%s'. Skipping %s.", $meetings_str, implode('-', $section_parts));
 
		  break;
 
		}
 
	      /* prepare for parsing the next meeting time */
 
	      $meetings_str = substr($meetings_str, strlen($meeting_matches[0]));
 

	
 
	      $days = school_crawl_days_str_format($meeting_matches[3]);
 
	      $days = school_crawl_days_str_format($school_crawl_log, $meeting_matches[3]);
 
	      $time_start = school_crawl_time_format(strptime($meeting_matches[4] . 'M', '%I:%M%p'));
 
	      $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]);
 

	
0 comments (0 inline, 0 general)