function get_term_description

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

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

21 calls to get_term_description()
advise.history.inc in modules/advise/advise.history.inc
advise.module in modules/advise/advise.module
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_display_view in modules/advise/advise.module
This is the page which actually displays the "view" for the user to see their advising session, or for an advisor to advise them.

... See full list

File

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

Code

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

  if (!$term_id) {
    $term_id = '';
  }

  // If already in our GLOBALS cache, then just return that.
  if (isset($GLOBALS ['fp_cache_get_term_description'][$term_id][intval($bool_abbreviate)][$school_id])) {
    return $GLOBALS ['fp_cache_get_term_description'][$term_id][intval($bool_abbreviate)][$school_id];
  }


  // See if any modules would like to act on the term_id before we proceed.
  invoke_hook("alter_term_id_prior_to_description", array(&$term_id, &$bool_abbreviate, $school_id));


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

  $year4 = intval(trim(substr($term_id, 0, 4)));
  $year2 = intval(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 = @variable_get_for_school("term_id_structure", '', $school_id);
  $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;
  }

  // Save to our GLOBALS cache
  $GLOBALS ['fp_cache_get_term_description'][$term_id][intval($bool_abbreviate)][$school_id] = $rtn;

  return $rtn;
}