function get_term_description

6.x misc.inc get_term_description($term_id, $bool_abbreviate = FALSE, $school_id = 0)
4.x misc.inc get_term_description($term_id, $bool_abbreviate = false)
5.x misc.inc get_term_description($term_id, $bool_abbreviate = false)

Convert a term ID into a description. Ex: 20095 = Spring of 2009.

4 calls to get_term_description()
advise_display_history in modules/advise/advise.history.inc
Displays the history tab on screen.
advise_display_popup_change_term in modules/advise/advise.module
This popup allows the advisor to change the advising term.
advise_popup_display_summary in modules/advise/advise.history.inc
Displays the printable advising summary.
fp_render_currently_advising_box in includes/theme.inc
Draws the CurrentlyAdvisingBox which appears at the top of the screen, containing the student's information like name, major, etc.

File

includes/misc.inc, line 868
This file contains misc functions for FlightPath

Code

function get_term_description($term_id, $bool_abbreviate = false) {
  // Describe the term in plain english, for displays.
  // Ex:  "Fall of 2002."
  $rtn = "";

  if (strstr($term_id, "1111")) 
   {
    return "(data unavailable at this time)";
  }

  $year4 = trim(substr($term_id, 0, 4));
  $year2 = trim(substr($term_id, 2, 2));
  $ss = trim(substr($term_id, 4, strlen($term_id) - 4));

  $year4p1 = $year4 + 1;
  $year4m1 = $year4 - 1;

  // left-pad these with 0's if needed.
  $year2p1 = fp_number_pad($year2 + 1, 2);
  $year2m1 = fp_number_pad($year2 - 1, 2);

  // Let's look at the term_idStructure setting and attempt to match
  // what we have been supplied.
  // We expect this structure to look something like:
  // [Y4]60, Spring, Spring of [Y4], Spr '[Y2]
  // [Y4]40, Fall, Fall of [Y4-1], Fall '[Y2-1]

  $temp = $GLOBALS ["fp_system_settings"]["term_id_structure"];
  $structures = explode("\n", $temp);

  foreach ($structures as $structure) {
    // Perform the necessary replacement patterns on the structure.
    $structure = str_replace("[Y4]", $year4, $structure);
    $structure = str_replace("[Y2]", $year2, $structure);
    $structure = str_replace("[Y4-1]", $year4m1, $structure);
    $structure = str_replace("[Y2-1]", $year2m1, $structure);
    $structure = str_replace("[Y4+1]", $year4p1, $structure);
    $structure = str_replace("[Y2+1]", $year2p1, $structure);

    // Now, break up the structure to make it easier to work with.
    $tokens = explode(",", $structure);
    $term_def = trim($tokens [0]);
    $full_description = trim($tokens [2]);
    $abbr_description = trim($tokens [3]);

    // Does our term_id match the termDef?
    if ($term_def == $term_id) {
      if ($bool_abbreviate) {
        return $abbr_description;
      }
      else {
        return $full_description;
      }
    }

  }

  // No descr could be found, so just display the term_id itself.
  if (trim($rtn) == "") {
    $rtn = $term_id;
  }

  return $rtn;
}