function blank_degrees_select_degree_form
Search API
7.x blank_degrees.module | blank_degrees_select_degree_form() |
6.x blank_degrees.module | blank_degrees_select_degree_form() |
4.x blank_degrees.module | blank_degrees_select_degree_form() |
5.x blank_degrees.module | blank_degrees_select_degree_form() |
This form lets the user select which degree they wish to view.
File
- modules/
blank_degrees/ blank_degrees.module, line 240
Code
function blank_degrees_select_degree_form() {
$form = array();
$m = 0;
$bool_show_continue = TRUE;
// Are we in draft mode?
if ($_SESSION ["fp_draft_mode"] == "yes") {
$GLOBALS ["fp_advising"]["bool_use_draft"] = true;
}
else {
$GLOBALS ["fp_advising"]["bool_use_draft"] = false;
}
if (fp_screen_is_mobile()) {
fp_add_css(fp_get_module_path("blank_degrees") . "/css/mobile.css");
}
@$blank_catalog_year = $_REQUEST ["blank_catalog_year"];
// If we used the word "current" for catalog_year, then find out what the current is.
if (strtolower($blank_catalog_year) == "current") {
$blank_catalog_year = variable_get("current_catalog_year", 2006);
}
if ($blank_catalog_year == "") {
// The user must first select the desired catalog year.
$catalog_year_options = array();
$current_catalog_year = variable_get("current_catalog_year", 2006);
if ($GLOBALS ["fp_advising"]["bool_use_draft"]) {
$current_catalog_year = variable_get("current_draft_catalog_year", 2006);
}
$earliest_catalog_year = variable_get("earliest_catalog_year", 2006);
for ($t = $current_catalog_year; $t >= $earliest_catalog_year; $t--) {
$catalog_year_options [$t] = "$t-" . ($t + 1);
}
$form ["blank_catalog_year"] = array(
"type" => "select",
"label" => t("Please begin by selecting a catalog year:"),
"options" => $catalog_year_options,
);
}
else {
// Catalog year WAS specified. So, ask the user to select a degree now.
$form ["blank_catalog_year"] = array(
"type" => "hidden",
"value" => $blank_catalog_year,
);
$form ["mark" . $m++] = array(
"value" => t("Searching degrees in %year.", array("%year" => $blank_catalog_year . "-" . ($blank_catalog_year + 1))) . "
" . l(t("Change?"), "tools/blank-degrees"),
);
$mobile_markup = "";
$degree_options = array();
$db = get_global_database_handler();
if ($degree_array = $db->get_degrees_in_catalog_year($blank_catalog_year, true, $GLOBALS ["fp_advising"]["bool_use_draft"], FALSE)) {
foreach ($degree_array as $major_code => $value) {
if (trim($value ["title"]) == "") {
continue;
}
$degree_id = $value ["degree_id"];
$title = $value ["title"];
if ($value ["degree_class"] == "G") {
$title = "(" . t("Graduate") . ") " . $title;
}
// if title is too long, shorten it.
$maxlen = 95;
if (strlen($title) > $maxlen) {
$title = substr($title, 0, $maxlen - 3) . "...";
}
$degree_options [$degree_id] = $title;
$mobile_markup .= "<a class='degree-search-degree-row'
href='" . fp_url("blank-degrees/display", "blank_degree_id=$degree_id&blank_catalog_year={$_REQUEST ["blank_catalog_year"]}") . "'>
<div class='degree-search-degree-title'>$title</div>
</a>";
}
}
if (fp_screen_is_mobile()) {
$form ["mark" . $m++] = array(
"value" => $mobile_markup,
);
$bool_show_continue = FALSE;
}
else {
// NOT mobile
$form ["blank_degree_id"] = array(
"label" => t("Please select a degree"),
"type" => "select",
"options" => $degree_options,
);
}
}
if ($bool_show_continue) {
$form ["submit"] = array(
"type" => "submit",
"prefix" => "<hr>",
"value" => t("Continue") . " ->",
);
}
return $form;
}