theme.inc

  1. 7.x includes/theme.inc
  2. 6.x includes/theme.inc
  3. 4.x includes/theme.inc
  4. 5.x includes/theme.inc

File

includes/theme.inc
View source
  1. <?php
  2. /**
  3. * These functions deal mostly with theme-related functions.
  4. * In other words, functions responsible for drawing, rendering, etc, HTML
  5. * to the screen.
  6. */
  7. // TODO: Implement this functioN!
  8. function convert_html_to_bbcode($str) {
  9. depricated_message();
  10. return $str;
  11. }
  12. // TODO: implement this!
  13. function convert_bbcode_to_html($str) {
  14. depricated_message();
  15. return $str;
  16. }
  17. /**
  18. * Format a timestamp using the date command.
  19. * TODO: Make the formats something which can be controlled through the settings.
  20. *
  21. * Available formats:
  22. * - standard
  23. * - short
  24. * - pretty
  25. * - just_date
  26. *
  27. */
  28. function format_date($timestamp = 0, $format = "standard", $custom = "") {
  29. if (!is_numeric($timestamp)) {
  30. $timestamp = 0; // make sure it's numeric.
  31. }
  32. if ($timestamp == 0) {
  33. $timestamp = strtotime("now");
  34. }
  35. $f = "";
  36. if ($format == "standard") {
  37. $f = "n/d/Y h:i:sa";
  38. }
  39. if ($format == "short") {
  40. $f = "n/d/Y - g:ia";
  41. }
  42. if ($format == "pretty") {
  43. $f = "F jS, Y, g:ia";
  44. }
  45. if ($format == "just_date") {
  46. $f = "F jS, Y";
  47. }
  48. if ($custom != "") $f = $custom;
  49. return date($f, $timestamp);
  50. }
  51. /**
  52. * Render a "menu" block of menu items which are all rooted at the menu_root.
  53. * So if the menu root is tools, it might return items whose paths look like:
  54. * tools/fun
  55. * tools/here/there
  56. * So long as the menu type is "MENU_TYPE_NORMAL_ITEM". Other types will be ignored.
  57. *
  58. *
  59. * We want to
  60. */
  61. function fp_render_menu_block($title = "Tools", $menu_root = "tools") {
  62. $rtn = "";
  63. $is_empty = true;
  64. if ($title != "") {
  65. $rtn .= fp_render_curved_line($title);
  66. }
  67. $menu_items = menu_get_items_beginning_with($menu_root);
  68. foreach ($menu_items as $item) {
  69. if ($item["type"] != MENU_TYPE_CALLBACK) {
  70. $rtn .= fp_render_menu_item($item);
  71. $is_empty = false;
  72. }
  73. }
  74. if ($is_empty) {
  75. return "";
  76. }
  77. //pretty_print($menu_items);
  78. return $rtn;
  79. }
  80. /**
  81. * Output the contents of the $page variable to the screen.
  82. * $page is an array containing details about the page, as well as
  83. * its original menu item (router_item) definition.
  84. */
  85. function fp_display_page($page) {
  86. global $current_student_id, $screen;
  87. $page_title = $page["title"];
  88. if (@$GLOBALS["fp_set_title"] != "") {
  89. $page_title = $GLOBALS["fp_set_title"];
  90. }
  91. if (!is_object($screen)) {
  92. $screen = new AdvisingScreen("",null,"not_advising");
  93. }
  94. $screen->page_title = $page_title;
  95. $screen->page_has_search = @$page["router_item"]["page_settings"]["page_has_search"];
  96. // Add some body classes to the page for this student.
  97. $student = $screen->student;
  98. if (!is_object($student)) {
  99. $student = new Student();
  100. $student->student_id = $current_student_id;
  101. $student->load_student_data();
  102. }
  103. if (is_object($student)) {
  104. fp_add_body_class("student-rank-$student->db_rank student-catalog-year-$student->catalog_year");
  105. }
  106. // If we don't have permission to search, then hide the little search.
  107. if (!user_has_permission("display_search_subtab")) {
  108. $screen->page_has_search = FALSE;
  109. }
  110. // mobile screens never have the search box
  111. if (fp_screen_is_mobile()) {
  112. $screen->page_has_search = FALSE;
  113. }
  114. $screen->page_banner_is_link = @$page["router_item"]["page_settings"]["page_banner_is_link"];
  115. $screen->page_hide_report_error = @$page["router_item"]["page_settings"]["page_hide_report_error"];
  116. $screen->page_is_popup = @$page["router_item"]["page_settings"]["page_is_popup"];
  117. if (isset($page["router_item"]["page_settings"]["screen_mode"])) {
  118. $screen->screen_mode = $page["router_item"]["page_settings"]["screen_mode"];
  119. }
  120. if (isset($page["router_item"]["page_settings"]["bool_print"])) {
  121. $screen->bool_print = $page["router_item"]["page_settings"]["bool_print"];
  122. }
  123. if (@$_REQUEST["scroll_top"] != "") {
  124. $screen->page_scroll_top = $_REQUEST["scroll_top"];
  125. }
  126. // If there is a SESSION var for scroll_top, use that instead, then wipe it.
  127. if (@$_SESSION['scroll_top'] != "") {
  128. $screen->page_scroll_top = $_SESSION["scroll_top"];
  129. $_SESSION['scroll_top'] = "";
  130. unset($_SESSION['scroll_top']);
  131. }
  132. // Was this page a tab? And if so, are there any other tabs we need to display? //
  133. if (@$page["router_item"]["type"] == MENU_TYPE_TAB || @$page["router_item"]["tab_parent"] != "") {
  134. // We know we should have at least 1 tab for this page.
  135. $tab_array = fp_build_tab_array($page);
  136. $screen->page_tabs = fp_render_tab_array($tab_array);
  137. }
  138. // Should we override the page_tabs with what is in "fp_set_page_tabs" ?
  139. if (isset($GLOBALS["fp_set_page_tabs"]) && is_array($GLOBALS["fp_set_page_tabs"])) {
  140. //fpm($GLOBALS["fp_set_page_tabs"]);
  141. $screen->page_tabs = fp_render_tab_array($GLOBALS["fp_set_page_tabs"]);
  142. }
  143. // Build up the content //
  144. $content_top = "";
  145. $page_show_title = @$page["router_item"]["page_settings"]["page_show_title"];
  146. if (isset($GLOBALS["fp_set_show_title"])) {
  147. $page_show_title = $GLOBALS["fp_set_show_title"];
  148. }
  149. if ($page_show_title == TRUE) {
  150. $content_top .= "<h2 class='title'>" . $page_title . "</h2>";
  151. }
  152. if (@$page["router_item"]["page_settings"]["display_greeting"] == TRUE) {
  153. $content_top .= fp_render_greeting();
  154. }
  155. $c = 0;
  156. // Are there any "menu_link"s for this? In order words, little links at the top of the page,
  157. // where breadcrumbs might appear.
  158. if (!$screen->bool_print && @is_array($page["router_item"]["page_settings"]["menu_links"])) {
  159. $content_top .= "<ul class='top-menu-links'>";
  160. foreach ($page["router_item"]["page_settings"]["menu_links"] as $item) {
  161. $lclass = "";
  162. if ($c == 0) $lclass='first';
  163. $p = menu_convert_replacement_pattern(@$item["path"]);
  164. $q = menu_convert_replacement_pattern(@$item["query"]);
  165. $t = @$item["text"];
  166. $a = @$item["attributes"];
  167. if (!is_array($a)) $a = array();
  168. // Make sure the current user has access to view this link. Otherwise, do not even
  169. // bother showing it.
  170. $test_item = menu_get_item($p) ;
  171. if (!menu_check_user_access($test_item)) {
  172. continue;
  173. }
  174. $content_top .= "<li class='$lclass'>" . l($t, $p, $q, $a) . "</li>";
  175. $c++;
  176. }
  177. $content_top .= "</ul>";
  178. }
  179. if (!$screen->bool_print) {
  180. // Any sub-tabs we need to render?
  181. if (@$page["router_item"]["type"] == MENU_TYPE_SUB_TAB) {
  182. $sub_tab_array = fp_build_sub_tab_array($page);
  183. $content_top .= fp_render_sub_tab_array($sub_tab_array);
  184. }
  185. // Should we override the page sub-tabs with what is in "fp_set_page_sub_tabs" ?
  186. if (isset($GLOBALS["fp_set_page_sub_tabs"]) && is_array($GLOBALS["fp_set_page_sub_tabs"])) {
  187. $content_top .= fp_render_sub_tab_array($GLOBALS["fp_set_page_sub_tabs"]);
  188. }
  189. }
  190. // If there are "messages" waiting, then let's add them to the top of content.
  191. if (@count($_SESSION["fp_messages"]) > 0) {
  192. $content_top .= "<div class='fp-messages'>";
  193. foreach ($_SESSION["fp_messages"] as $key => $tmsg) {
  194. $type = $tmsg["type"];
  195. $message = $tmsg["msg"];
  196. $content_top .= "<div class='fp-message fp-message-$type'>$message</div>";
  197. }
  198. $content_top .= "</div>";
  199. unset($_SESSION["fp_messages"]);
  200. }
  201. // content_top gets the Currently Advising box.
  202. if (@$page["router_item"]["page_settings"]["display_currently_advising"] == TRUE) {
  203. $content_top .= fp_render_currently_advising_box(false, $screen->bool_blank, $screen->bool_print, NULL, $screen->screen_mode);
  204. }
  205. $screen->page_content = $content_top .= $page["content"];
  206. // If there are CSS files to add, add those.
  207. // Add in the body classes
  208. $screen->page_body_classes .= " " . @$GLOBALS["fp_add_body_classes"];
  209. // Add in our URL (after we sanitize it appropriately)
  210. $class = @$_REQUEST['q'];
  211. $class = str_replace("'", '', $class);
  212. $class = str_replace('"', '', $class);
  213. $class = str_replace('(', '', $class);
  214. $class = str_replace(')', '', $class);
  215. $class = str_replace(';', '', $class);
  216. $class = str_replace('.', '', $class);
  217. $class = str_replace('<', '', $class);
  218. $class = str_replace('>', '', $class);
  219. $class = str_replace('/', '', $class);
  220. $class = str_replace('\\', '', $class);
  221. $class = str_replace('#', '', $class);
  222. $class = str_replace('&', '', $class);
  223. $screen->page_body_classes .= " page-" . str_replace("/", "-", $class);
  224. $screen->output_to_browser();
  225. }
  226. /**
  227. * Sets whether the title should be shown on the page or not.
  228. */
  229. function fp_show_title($bool_show = TRUE) {
  230. $GLOBALS["fp_set_show_title"] = $bool_show;
  231. }
  232. /**
  233. * This function will return the HTML to contruct a collapsible fieldset,
  234. * complete with javascript and style tags.
  235. *
  236. * @param String $content
  237. * @param String $legend
  238. * @param bool $bool_start_closed
  239. * @return String
  240. */
  241. function fp_render_c_fieldset($content, $legend = "Click to expand/collapse", $bool_start_closed = false)
  242. {
  243. // Create a random ID for this fieldset, js, and styles.
  244. $id = md5(rand(9,99999) . time());
  245. $start_js_val = 1;
  246. $fsstate = "open";
  247. $content_style = "";
  248. if ($bool_start_closed) {
  249. $start_js_val = 0;
  250. $fsstate = "closed";
  251. $content_style = "display: none;";
  252. }
  253. $js = "<script type='text/javascript'>
  254. var fieldset_state_$id = $start_js_val;
  255. function toggle_fieldset_$id() {
  256. var content = document.getElementById('content_$id');
  257. var fs = document.getElementById('fs_$id');
  258. if (fieldset_state_$id == 1) {
  259. // Already open. Let's close it.
  260. fieldset_state_$id = 0;
  261. \$(content).slideUp('medium');
  262. fs.className = 'c-fieldset-closed-$id c-fieldset-closed c-fieldset';
  263. }
  264. else {
  265. // Was closed. let's open it.
  266. fieldset_state_$id = 1;
  267. \$(content).slideDown('medium');
  268. fs.className = 'c-fieldset-open-$id c-fieldset-open c-fieldset';
  269. }
  270. }
  271. </script>";
  272. $rtn = "
  273. <fieldset class='c-fieldset-$fsstate-$id c-fieldset-$fsstate c-fieldset' id='fs_$id'>
  274. <legend><a href='javascript: toggle_fieldset_$id();' class='nounderline'>$legend</a></legend>
  275. <div id='content_$id' class='c-fieldset-content' style='$content_style'>
  276. $content
  277. </div>
  278. </fieldset>
  279. $js
  280. <style>
  281. fieldset.c-fieldset-open-$id {
  282. border: 1px solid;
  283. }
  284. fieldset.c-fieldset-closed-$id {
  285. border: 1px solid;
  286. border-bottom-width: 0;
  287. border-left-width: 0;
  288. border-right-width: 0;
  289. }
  290. legend a {
  291. text-decoration: none;
  292. }
  293. </style>
  294. ";
  295. return $rtn;
  296. }
  297. /**
  298. * Create a "sub-tab" array, which looks like a standard tab_array,
  299. * but it contains only this page's sub-tab siblings.
  300. */
  301. function fp_build_sub_tab_array($page) {
  302. global $current_student_id;
  303. $tab_array = array();
  304. $tab_family = $page["router_item"]["tab_family"];
  305. $active_tab_path = $page["path"];
  306. $items = menu_get_items_in_tab_family($tab_family);
  307. foreach ($items as $item) {
  308. // Does the user have access to this subtab?
  309. if (!menu_check_user_access($item)) {
  310. continue;
  311. }
  312. $title = $item["title"];
  313. $path = $item["path"];
  314. $active = FALSE;
  315. $on_click = @$page["page_settings"]["tab_on_click"];
  316. if ($on_click == "") {
  317. // Just a simple link to the path
  318. // Add the current_student_id to the query!
  319. $query = "current_student_id=$current_student_id";
  320. $turl = fp_url($path, $query, TRUE);
  321. $on_click = "window.location=\"" . $turl . "\"";
  322. }
  323. if ($path == $active_tab_path) {
  324. // This is the current page we are on.
  325. $active = TRUE;
  326. $title = $page["title"];
  327. $on_click = "";
  328. }
  329. $tab_array[] = array(
  330. "title" => $item["title"],
  331. "active" => $active,
  332. "on_click" => $on_click,
  333. );
  334. }
  335. return $tab_array;
  336. }
  337. /**
  338. * Looks at the current page array and returns a valid $tab_array
  339. * Meant for the top of the screen.
  340. */
  341. function fp_build_tab_array($page) {
  342. global $current_student_id;
  343. $tab_array = array();
  344. $tab_family = $page["router_item"]["tab_family"];
  345. $active_tab_path = $page["path"];
  346. if ($page["router_item"]["tab_parent"] != "") {
  347. // We want to know the PARENT's tab_family, so we can display the correct tabs at the top of the page.
  348. $tab_parent = $page["router_item"]["tab_parent"];
  349. $item = menu_get_item($tab_parent);
  350. $tab_family = $item["tab_family"];
  351. $active_tab_path = $item["path"];
  352. }
  353. // look for other possible tabs, based on the "tab_family" value
  354. // Also check to make sure the user has access to the tab.
  355. $items = menu_get_items_in_tab_family($tab_family);
  356. foreach ($items as $item) {
  357. // Does the user have access to this tab?
  358. if (!menu_check_user_access($item)) {
  359. continue;
  360. }
  361. $title = $item["title"];
  362. $path = $item["path"];
  363. $active = FALSE;
  364. $on_click = @$page["page_settings"]["tab_on_click"];
  365. if ($on_click == "") {
  366. // Just a simple link to the path
  367. // Include the current_student_id!
  368. $query = "current_student_id=$current_student_id";
  369. $turl = fp_url($path, $query, TRUE);
  370. $on_click = "window.location=\"" . $turl . "\"";
  371. }
  372. if ($path == $active_tab_path) {
  373. // This is the current page we are on.
  374. $active = TRUE;
  375. $title = $page["title"];
  376. $on_click = "";
  377. }
  378. $tab_array[] = array(
  379. "title" => $item["title"],
  380. "active" => $active,
  381. "on_click" => $on_click,
  382. );
  383. }
  384. return $tab_array;
  385. }
  386. /**
  387. * Draws the CurrentlyAdvisingBox which appears at the top of the screen,
  388. * containing the student's information like name, major, etc.
  389. *
  390. * @param bool $bool_hide_catalog_warning
  391. * - If set to TRUE, FP will not display a warning which tells
  392. * the user that they are working under an outdated catalog year.
  393. *
  394. * @return string
  395. */
  396. function fp_render_currently_advising_box($bool_hide_catalog_warning = false, $bool_blank = FALSE, $bool_print = FALSE, $degree_plan = NULL, $screen_mode = "") {
  397. global $current_student_id, $screen, $user, $student;
  398. $rtn = "";
  399. $bool_catalog_warning = FALSE;
  400. $bool_future_catalog_warning = FALSE;
  401. $csid = $current_student_id;
  402. if (is_object($screen) && is_object($screen->degree_plan)) {
  403. $degree_plan = $screen->degree_plan;
  404. }
  405. if (!isset($student) || $student == null || !is_object($student)) {
  406. $student = new Student($csid);
  407. }
  408. if ($degree_plan == null) {
  409. // Degree plan is still null. This probably means we are NOT on an advising screen, so, let's
  410. // use a FlightPath object to init our degree plan, which might actually be a combination of degrees.
  411. // First, we can cheat by seeing if we have anything cached for this student the last time their degree plan
  412. // was loaded. Using this,
  413. // its much faster & memory-friendly than trying to re-init a whole new FlightPath object and DegreePlan object(s).
  414. $bool_got_from_simple_cache = FALSE;
  415. // TODO: Check for _what_if if we are in what if mode?
  416. if (isset($_SESSION["fp_simple_degree_plan_cache_for_student"])) {
  417. if ($_SESSION["fp_simple_degree_plan_cache_for_student"]["cwid"] == $csid) {
  418. // Yes, it's for this student. Load her up.
  419. $degree_plan = new DegreePlan();
  420. $degree_plan->degree_id = $_SESSION["fp_simple_degree_plan_cache_for_student"]["degree_id"];
  421. $degree_plan->combined_degree_ids_array = $_SESSION["fp_simple_degree_plan_cache_for_student"]["combined_degree_ids_array"];
  422. $degree_plan->is_combined_dynamic_degree_plan = $_SESSION["fp_simple_degree_plan_cache_for_student"]["is_combined_dynamic_degree_plan"];
  423. $bool_got_from_simple_cache = TRUE;
  424. }
  425. }
  426. if (!$bool_got_from_simple_cache) {
  427. // didn't get it from the simple cache, so load it all fresh.
  428. $fp = new FlightPath($student);
  429. $fp->init(TRUE);
  430. $degree_plan = $fp->degree_plan;
  431. }
  432. }
  433. $settings = fp_get_system_settings();
  434. $rtn .= "<table class='fp-currently-advising'>";
  435. $for_term = $whatif = $what_if_select = $hypoclass = "";
  436. $advising_term_id = @$GLOBALS["fp_advising"]["advising_term_id"];
  437. if ($advising_term_id != "" && ($screen_mode != "not_advising" && $screen_mode != "detailed")
  438. && user_has_permission("can_advise_students"))
  439. {
  440. // If this is someone who is allowed to change terms. (advisor or above)
  441. $t_term_id = $advising_term_id;
  442. $for_term = " " . t("for") . " ";
  443. $termdesc = get_term_description($t_term_id);
  444. $furl = fp_url("advise/popup-change-term");
  445. // Let's make the change-term link a little more intuitive.
  446. $for_term .= "<span class='currently-advising-box-change-term'><a href='javascript: popupWindow2(\"" . $furl . "\",\"advising_term_id=$t_term_id\");'>$termdesc</a></span>";
  447. /*
  448. $for_term .= "<span style='font-size: 8pt; font-weight:normal;'>
  449. - <a href='javascript: popupWindow2(\"" . $furl . "\",\"advising_term_id=$t_term_id\");' style='color:blue; background-color: white; border: 1px solid black; padding-left: 3px; padding-right: 3px;'>" . t("change") . "<img src='" . fp_theme_location() . "/images/calendar1.jpg' height='13' border='0' style='vertical-align: bottom;'></a>
  450. </span>";
  451. */
  452. }
  453. // TODO: bool_blank? bool_print?
  454. if (@$GLOBALS["fp_advising"]["advising_what_if"] == "yes" && !$bool_blank)
  455. {
  456. $whatif = " (" . t("in \"What If\" mode") . ") ";
  457. $hypoclass = "hypo";
  458. // Set the cat year to whatever our What If cat year was, current if we can't find it.
  459. $what_if_catalog_year = @$GLOBALS["fp_advising"]["what_if_catalog_year"];
  460. if ($what_if_catalog_year != 0 && $what_if_catalog_year != "") {
  461. $student->catalog_year = $what_if_catalog_year;
  462. }
  463. else {
  464. // Only change to current if that is how our settings are set...
  465. if (variable_get("what_if_catalog_year", "current") == "current") {
  466. $student->catalog_year = $settings["current_catalog_year"];
  467. }
  468. }
  469. if ($bool_print != true) {
  470. $what_if_select = "<div class='tenpt'><b>
  471. " . l(t("Change What If Settings"), "what-if", "advising_what_if=yes&what_if_major_code=none&what_if_track_code=none&what_if_track_degree_ids=none&current_student_id=$current_student_id") . "
  472. </b></div>";
  473. }
  474. }
  475. $ca = t("Currently Advising");
  476. if (!user_has_permission("can_advise_students") || $screen_mode == "detailed") {
  477. $ca = t("Student Details");
  478. }
  479. if ($bool_blank == true) {
  480. $ca = t("Viewing Blank Degree Plan");
  481. }
  482. $rtn .= "<tr><td colspan='2' style='padding-bottom: 10px;'>
  483. $what_if_select
  484. <table border='0' width='100%' class='elevenpt blueBorder' cellpadding='0' cellspacing='0' >
  485. <tr>
  486. <td colspan='4' class='blueTitle' align='center' height='20'>
  487. " . fp_render_square_line("$ca$whatif$for_term") . "
  488. </td>
  489. </tr>
  490. ";
  491. // Okay, let's build up the display array.
  492. $display_array = array();
  493. // How to display the catalog_year...
  494. $cat_year = $student->catalog_year . "-" . ($student->catalog_year + 1);
  495. // Should we display a catalog year warning? This is
  496. // something that can be part of a settings table.
  497. if ($student->catalog_year < $settings["earliest_catalog_year"]) {
  498. $cat_year = "<b>$cat_year</b>";
  499. $bool_catalog_warning = true;
  500. }
  501. if ($settings["current_catalog_year"] > $settings["earliest_catalog_year"]) {
  502. // Is the student's catalog set beyond the range that
  503. // FP has data for? If so, show a warning.
  504. if ($student->catalog_year > $settings["current_catalog_year"])
  505. {
  506. $cat_year = "<b>$cat_year</b>";
  507. $bool_future_catalog_warning = true;
  508. }
  509. }
  510. if (!$bool_blank) {
  511. array_push($display_array, t("Name:") . " ~~ " . $student->name);
  512. array_push($display_array, t("CWID:") . " ~~ " . $student->student_id);
  513. }
  514. $db = get_global_database_handler();
  515. ///////////////////////////
  516. $degree_title_div = "";
  517. $s = ""; // plural degrees?
  518. $bool_show_track_selection_link = FALSE;
  519. // We are trying to figure out what to display for the Degree field. If there is only ONE degree plan
  520. // to worry about, then we will display it.
  521. if ($degree_plan == null || $degree_plan->is_combined_dynamic_degree_plan != TRUE) {
  522. // This is an ordinary degree plan.
  523. $use_degree_plan = $degree_plan;
  524. $degree_title = "";
  525. if ($degree_plan != NULL) {
  526. $degree_title = $degree_plan->get_title2(TRUE);
  527. }
  528. /**
  529. * This degree is in fact a track.
  530. */
  531. if (strstr($degree_plan->major_code, "_")) {
  532. $degree_title = $degree_plan->get_title2(TRUE, TRUE);
  533. if ($degree_plan->db_allow_dynamic == 0) {
  534. // This degree is NON-dynamic. Meaning, if we change tracks, we should do it from the perspective
  535. // of the original major code, and how FP 4.x did things.
  536. $temp = explode("_", $degree_plan->major_code);
  537. $m = trim($temp[0]);
  538. // Remove trailing | if its there.
  539. $m = rtrim($m, "|");
  540. $use_degree_plan = $db->get_degree_plan($m, $degree_plan->catalog_year, TRUE); // the original degree plan!
  541. }
  542. }
  543. if ($screen_mode == "detailed") {
  544. $degree_title .= " ($degree_plan->major_code)";
  545. }
  546. if ($use_degree_plan != null && $use_degree_plan->get_available_tracks()) {
  547. $bool_show_track_selection_link = TRUE;
  548. }
  549. $degree_title_div = "<div class='degree-title'>$degree_title</div>";
  550. //array_push($display_array, t("Degree:") . " ~~ " . $degree_title);
  551. }
  552. else {
  553. // This degree plan is made from combining several other degrees. let's trot them out and display them as well.
  554. $t_degree_plan_titles = "";
  555. foreach ($degree_plan->combined_degree_ids_array as $t_degree_id) {
  556. $t_degree_plan = new DegreePlan();
  557. $t_degree_plan->degree_id = $t_degree_id;
  558. $t_degree_plan->load_descriptive_data();
  559. if ($t_degree_plan->get_available_tracks()) {
  560. $bool_show_track_selection_link = TRUE;
  561. }
  562. // Add it to our box...
  563. // If more than one major/minor, etc, combine them into one div
  564. $t_title = $t_degree_plan->get_title2(TRUE);
  565. $t_class = $t_degree_plan->degree_class;
  566. $t_class_details = fp_get_degree_classification_details($t_class);
  567. // If this is actually a track, let's get the track's title instead.
  568. if ($x = $t_degree_plan->get_track_title(TRUE)) {
  569. $t_title = $x;
  570. }
  571. if ($t_class_details["level_num"] == 3) {
  572. $t_title = "<span class='level-3-raquo'>&raquo;</span>" . $t_title;
  573. }
  574. $machine_major_code = fp_get_machine_readable($t_degree_plan->major_code);
  575. if ($t_degree_plan->track_code != "") {
  576. $machine_major_code .= "-" . fp_get_machine_readable($t_degree_plan->track_code);
  577. }
  578. $t_degree_plan_titles .= "<div class='multi-degree-title multi-degree-class-" . $t_class . "
  579. multi-degree-class-level-" . $t_class_details["level_num"] . "
  580. multi-degree-code-$machine_major_code '>
  581. " . $t_title . "</div>";
  582. $s = "s";
  583. }
  584. $degree_title_div = $t_degree_plan_titles;
  585. }
  586. // Now, do we want to add an option to select a track to the degree_title_div?
  587. if ($bool_show_track_selection_link) {
  588. // Are we in what_if mode?
  589. $advising_what_if = @$GLOBALS["fp_advising"]["advising_what_if"];
  590. // We want to add a link to the popup to let the user select other degree tracks.
  591. $op_link = "<a class='degree-op-link-change-degree-options' href='javascript: popupWindow2(\"" . fp_url("advise/popup-change-track", "advising_what_if=$advising_what_if") . "\",\"\");'
  592. style='background: url(" . fp_theme_location() . "/images/popup.gif) no-repeat top left;
  593. padding-left: 20px; text-decoration: none; font-size: 0.8em;'
  594. >Change degree options</a>";
  595. if ($screen_mode == "not_advising" || $screen_mode == "detailed") {
  596. $op_link = "";
  597. }
  598. if (!user_has_permission("can_advise_students")) {
  599. if (@$GLOBALS["fp_advising"]["advising_what_if"] != "yes")
  600. {
  601. // In other words, we do not have permission to advise,
  602. // and we are not in whatIf, so take out the link.
  603. $op_link = "";
  604. }
  605. }
  606. if ($op_link) {
  607. $degree_title_div .= "<div class='degree-op-link' style='text-align: right;'>$op_link</div>";
  608. }
  609. }
  610. // Add our "degrees" section....
  611. array_push($display_array, t("Degree$s:") . " ~~ " . $degree_title_div);
  612. if (!$bool_blank) {
  613. array_push($display_array, t("Rank:") . " ~~ " . $student->rank);
  614. }
  615. array_push($display_array, t("Catalog Year:") . " ~~ " . $cat_year);
  616. if (!$bool_blank) {
  617. array_push($display_array, t("Cumulative:") . " ~~ " . $student->cumulative_hours . " " . t("hrs") . ". &nbsp;" . fp_truncate_decimals($student->gpa, 3) . " " . t("GPA"));
  618. }
  619. // Invoke a hook, letting other modules act on the "display array".
  620. invoke_hook('alter_currently_advising_box', array(&$display_array));
  621. if ($student->student_id != "" || $bool_blank == true)
  622. { // Make sure we have selected a student! (or are viewing a blank plan)
  623. // Now, go through the array and display it.
  624. for ($t = 0; $t < count($display_array); $t = $t + 2)
  625. {
  626. $temp = explode(" ~~ ",$display_array[$t]);
  627. $name1 = trim($temp[0]);
  628. $value1 = trim($temp[1]);
  629. $temp = @explode(" ~~ ",$display_array[$t+1]);
  630. $name2 = @trim($temp[0]);
  631. $value2 = @trim($temp[1]);
  632. if (fp_screen_is_mobile()) {
  633. // Mobile screen. Needs to be more condensed.
  634. $rtn .= "<tr class='$hypoclass'>
  635. <td valign='top'>$value1</td>
  636. <td valign='top'>$value2</td>
  637. </tr>";
  638. }
  639. else {
  640. // Regular desktop screen.
  641. $rtn .= "
  642. <tr class='$hypoclass' >
  643. <td valign='top' width='20%' class='side_padding' style='padding-top: 5px;'>
  644. $name1
  645. </td>
  646. <td width='30%' valign='top' class='side_padding elevenpt' style='padding-top: 5px;'>
  647. $value1
  648. </td>
  649. <td valign='top' align='left' width='20%' class='side_padding elevenpt' style='padding-top: 5px;'>
  650. $name2
  651. </td>
  652. <td align='right' width='30%' valign='top' class='side_padding elevenpt' style='padding-top: 5px;'>
  653. $value2
  654. </td>
  655. </tr> ";
  656. }
  657. }
  658. } else {
  659. // No student has been selected yet!
  660. $rtn .= "<tr height='60'>
  661. <td align='center' class='no-advisee-selected'> " . t("No advisee selected.") . " </td>
  662. </tr>";
  663. $bool_hide_catalog_warning = true;
  664. }
  665. $rtn .= "</table>";
  666. if ($bool_catalog_warning == true && !$bool_hide_catalog_warning)
  667. {
  668. $rtn .= "
  669. <div class='tenpt hypo' style='margin-top: 4px; padding: 2px;'>
  670. <table border='0' cellspacing='0' cellpadding='0'>
  671. <td valign='top'>
  672. <img src='" . fp_theme_location() . "/images/alert_lg.gif' >
  673. </td>
  674. <td valign='middle' class='tenpt' style='padding-left: 8px;'>
  675. <b>" . t("Important Notice:") . " </b>
  676. " . t("FlightPath cannot display degree plans from
  677. catalogs earlier than @earliest.
  678. The above student's catalog year is @current, which means
  679. that the degree plan below may not accurately
  680. display this student's degree requirements.", array("@earliest" => $settings["earliest_catalog_year"] . "-" . ($settings["earliest_catalog_year"] + 1), "@current" => $cat_year)) . "
  681. </td>
  682. </table>
  683. </div>
  684. ";
  685. }
  686. if ($bool_future_catalog_warning == true && !$bool_hide_catalog_warning)
  687. {
  688. $msg = t("This student's catalog year is @cat_year,
  689. and specific curriculum requirements are not yet
  690. available for this year.
  691. To advise this student according to @new_cat
  692. requirements, select the student's major using What If.", array("@cat_year" => $cat_year, "@new_cat" => "{$settings["current_catalog_year"]}-" . ($settings["current_catalog_year"] + 1)));
  693. // If the what_if catalog year is in "student" mode, we can't tell them to use What If, cause it won't work.
  694. if (variable_get("what_if_catalog_year", "current") == "student") {
  695. $msg = t("This student's catalog year is @cat_year,
  696. and specific curriculum requirements are not yet
  697. available for this year.", array("@cat_year" => $cat_year));
  698. }
  699. $rtn .= "
  700. <div class='tenpt hypo' style='margin-top: 4px; padding: 2px;'>
  701. <table border='0' cellspacing='0' cellpadding='0'>
  702. <td valign='top'>
  703. <img src='" . fp_theme_location() . "/images/alert_lg.gif' >
  704. </td>
  705. <td valign='middle' class='tenpt' style='padding-left: 8px;'>
  706. <b>" . t("Important Notice:") . " </b>
  707. $msg
  708. </td>
  709. </table>
  710. </div>
  711. ";
  712. }
  713. $rtn .= "</td></tr>";
  714. $rtn .= "</table>";
  715. return $rtn;
  716. }
  717. /**
  718. * This displays a friendly message to the user, and provides
  719. * a logout link at the top.
  720. */
  721. function fp_render_greeting() {
  722. global $user;
  723. if ($user->id < 1) {
  724. // No one is logged in! Don't display.
  725. return "";
  726. }
  727. $rtn = "";
  728. $today = date("D, F jS, Y", strtotime("today"));
  729. $dname = $user->name;
  730. if ($user->f_name != "" || $user->l_name != "") {
  731. $dname = trim($user->f_name . " " . $user->l_name) . " ($user->name)";
  732. }
  733. $rtn .= "<div class='flightpath-greeting-message'>
  734. Welcome $dname! Today is $today. " . l("Log out?", "logout") . "
  735. </div>";
  736. return $rtn;
  737. }
  738. /**
  739. * Similar to render_tab_array.
  740. */
  741. function fp_render_sub_tab_array($tab_array) {
  742. global $current_student_id;
  743. $rtn = "";
  744. $rtn .= "<div class='sub-tabs'>";
  745. foreach ($tab_array as $tab) {
  746. $title = @$tab["title"];
  747. $on_click = @$tab["on_click"];
  748. $active = @$tab["active"];
  749. $type = @$tab["type"];
  750. $extra_class = "";
  751. if ($active) $extra_class = "gradbutton-active";
  752. if ($type == "link" ) {
  753. // Render as a standard link
  754. $rtn .= "<a href='javascript: $on_click' class='fp-sub-tab-link $extra_class'>$title</a>";
  755. }
  756. else {
  757. // Render as a button
  758. $rtn .= fp_render_button($title, $on_click, true, "", $extra_class);
  759. }
  760. }
  761. $rtn .= "</div>";
  762. return $rtn;
  763. }
  764. /**
  765. * Returns the HTML to draw a pretty button.
  766. *
  767. * @param string $title
  768. * @param string $on_click
  769. * @param bool $bool_padd
  770. * @param string $style
  771. * @return string
  772. */
  773. function fp_render_button($title, $on_click, $bool_padd = true, $style = "", $extra_class = "")
  774. {
  775. // Style is expected to look like:
  776. // style='some:thing;'
  777. // with SINGLE apostrophes! not quotes.
  778. // we want to add on a variable-name-friendly version of the title to extra_class.
  779. $extra_class .= " fp-render-button-" . fp_get_machine_readable(strtolower($title));
  780. $on_mouse = "onmouseover='this.className=\"gradbutton gradbutton_hover hand $extra_class\";'
  781. onmouseout='this.className=\"gradbutton hand $extra_class\";'
  782. onmousedown='this.className=\"gradbutton gradbutton_down hand $extra_class\";'
  783. onmouseup='this.className=\"gradbutton gradbutton_hover hand $extra_class\";'
  784. ";
  785. if (fp_screen_is_mobile()) $on_mouse = ""; // Causes problems for some mobile devices.
  786. if ($bool_padd) {
  787. $padd = "&nbsp;&nbsp;";
  788. }
  789. $rtn = "<span class='gradbutton hand $extra_class' onClick='$on_click' $on_mouse $style >
  790. $padd $title $padd
  791. </span>
  792. ";
  793. return $rtn;
  794. }
  795. function fp_render_mobile_tab_array($tab_array) {
  796. $rtn = "";
  797. $js_vars = "var mobileTabSelections = new Array(); ";
  798. if (count($tab_array) <= 1) return "";
  799. $rtn .= "<table border='0' width='200' cellpadding='0' cellspacing='0' class='fp-mobile-tabs'>
  800. <td>
  801. <b>" . t("Display") . ": </b>";
  802. $rtn .= "<select onChange='executeSelection()' id='mobileTabsSelect'>";
  803. for ($t = 0; $t < count($tab_array); $t++)
  804. {
  805. $title = $tab_array[$t]["title"];
  806. $active = $tab_array[$t]["active"];
  807. $on_click = $tab_array[$t]["on_click"];
  808. if ($title == "")
  809. {
  810. continue;
  811. }
  812. $sel = ($active == true) ? $sel = "selected":"";
  813. $rtn .= "<option $sel value='$t'>$title</option>";
  814. $js_vars .= "mobileTabSelections[$t] = '$on_click'; \n";
  815. }
  816. $rtn .= "</select>
  817. </td></table>";
  818. $rtn .= '
  819. <script type="text/javascript">
  820. ' . $js_vars . '
  821. function executeSelection() {
  822. var sel = document.getElementById("mobileTabsSelect").value;
  823. var statement = mobileTabSelections[sel];
  824. // Lets execute the statement...
  825. eval(statement);
  826. }
  827. </script>
  828. ';
  829. return $rtn;
  830. }
  831. /**
  832. * Given a propperly formatted tab_array, this will return the HTML
  833. * to draw it on a page.
  834. *
  835. * @param array $tab_array
  836. * - Array should have this structure:
  837. * - $tab_array[i]["title"] = The title or caption of the tab. "main", or "Edit", etc.
  838. * - $tab_array[i]["active"] = boolean. True if this is the tab we are currently looking at.
  839. * - $tab_array[i]["on_click"] = This is a valid onClick='blah blah' that is the result of clicking the tab.
  840. *
  841. * @return string
  842. */
  843. function fp_render_tab_array($tab_array)
  844. {
  845. // fix mobile tabs
  846. if (fp_screen_is_mobile()) {
  847. return fp_render_mobile_tab_array($tab_array);
  848. }
  849. $rtn = "";
  850. $rtn .= "<table border='0' width='100%' cellpadding='0' cellspacing='0'>
  851. <tr>
  852. ";
  853. $img_path = fp_theme_location() . "/images";
  854. for ($t = 0; $t < count($tab_array); $t++)
  855. {
  856. $title = @$tab_array[$t]["title"];
  857. $active = @$tab_array[$t]["active"];
  858. $on_click = @$tab_array[$t]["on_click"];
  859. if ($title == "")
  860. {
  861. continue;
  862. }
  863. $padd = "30px;";
  864. if ($t > 0)
  865. {
  866. $padd = "5px;";
  867. }
  868. $rtn .= "<td style='padding-right: $padd'></td>
  869. <td>";
  870. if ($active != TRUE)
  871. { //innactive tabs...
  872. $theclass = "inactive_tab hand";
  873. $overclass = "inactive_tab_over";
  874. if ($on_click == "")
  875. {
  876. $theclass = "inactive_tab";
  877. $overclass = "inactive_tab_over_no_link";
  878. }
  879. $rtn .= "
  880. <table align='left' cellpadding='0' onClick='$on_click' cellspacing='0' class='$theclass' onmouseover='this.className=\"$overclass\";' onmouseout='this.className=\"inactive_tab\";'>
  881. <tr>
  882. <td class='tab_tl_i' align='left' valign='baseline' width='12'></td>
  883. <td class='tab_top_i' valign='baseline' ></td>
  884. <td class='tab_tr_i' valign='baseline' align='right' width='12'></td>
  885. </tr>
  886. <tr>
  887. <td class='tab_left_i' align='left' valign='baseline' width='12'>
  888. <img src='$img_path/tab_left_i.gif' width='12' height='18'>
  889. </td>
  890. <td align='left' nowrap class='tab_center_i'>
  891. <div style='padding-bottom: 3px; margin-top: -2px;' class='tab_text'>$title</div>
  892. </td>
  893. <td class='tab_right_i' align='right' valign='baseline'>
  894. <img src='$img_path/tab_right_i.gif' width='12' height='18'>
  895. </td>
  896. </tr>
  897. </table>
  898. ";
  899. } else {
  900. // active tab...
  901. $rtn .= "
  902. <table align='left' cellpadding='0' cellspacing='0' class='active_tab'>
  903. <tr>
  904. <td class='tab_tl' align='left' valign='baseline' width='12'></td>
  905. <td class='tab_top' valign='baseline'></td>
  906. <td class='tab_tr' valign='baseline' align='right' width='12'></td>
  907. </tr>
  908. <tr>
  909. <td class='tab_left' align='left' valign='baseline' width='12'>
  910. <img src='$img_path/tab_left.gif' width='12' height='18'>
  911. </td>
  912. <td align='left' nowrap class='tab_center'>
  913. <div style='padding-bottom: 3px; margin-top: -2px;' class='tab_text'>$title</div>
  914. </td>
  915. <td class='tab_right' align='right' valign='baseline'>
  916. <img src='$img_path/tab_right.gif' width='12' height='18'>
  917. </td>
  918. </tr>
  919. </table>
  920. ";
  921. }
  922. $rtn .= "</td>";
  923. }
  924. $rtn .= "
  925. </tr>
  926. </table>";
  927. return $rtn;
  928. }
  929. function display_not_found() {
  930. header("HTTP/1.0 404 Not Found", TRUE, 404);
  931. $page = array(
  932. "title" => t("Not Found"),
  933. "content" => "<h2>" . t("Page not found") . "</h2>" . t("Sorry, the requested page could not be found."),
  934. );
  935. fp_display_page($page);
  936. die;
  937. }
  938. function display_access_denied() {
  939. header('HTTP/1.1 403 Forbidden', TRUE, 403);
  940. $page = array(
  941. "title" => t("Access Denied"),
  942. "content" => "<h2>" . t("Access Denied") . "</h2>" . t("Sorry, but you do not have access to the requested page or function."),
  943. );
  944. fp_display_page($page);
  945. die;
  946. }
  947. /**
  948. * Return the theme location
  949. */
  950. function fp_theme_location($bool_include_base_path = TRUE) {
  951. $p = @$GLOBALS["fp_system_settings"]["theme"];
  952. // The theme hasn't been set for some reason
  953. if ($p == "") {
  954. $p = "themes/classic";
  955. }
  956. if ($bool_include_base_path) {
  957. $bp = base_path();
  958. // The following code is to fix a bug where we might end up with // as our location, if our base_path is simply "/", meaning,
  959. // the site is located on a bare domain.
  960. if ($bp != "/") {
  961. $p = base_path() . "/" . $p;
  962. }
  963. else {
  964. $p = "/" . $p;
  965. }
  966. }
  967. return $p;
  968. }
  969. /**
  970. * Will draw a string in a pretty curved box. Used for displaying semester
  971. * titles.
  972. *
  973. * @param string $title
  974. * @return string
  975. */
  976. function fp_render_curved_line($text) {
  977. // Will simply draw a curved title bar containing the $title
  978. // as the text.
  979. $rtn = "
  980. <div class='blueTitle' style='text-align: center; border-radius: 5px; padding: 1px;'>
  981. <span class='tenpt'><b>$text</b></span>
  982. </div>
  983. ";
  984. return $rtn;
  985. }
  986. /**
  987. * Will draw a string in a pretty square box. Used for displaying semester
  988. * titles.
  989. *
  990. * @param string $title
  991. * @return string
  992. */
  993. function fp_render_square_line($text) {
  994. $rtn = "";
  995. $rtn .= "
  996. <table border='0' width='100%' cellpadding='0' cellspacing='0'>
  997. <tr>
  998. <td width='10%' align='left' valign='top'></td>
  999. <td width='80%' align='center' rowspan='2'>
  1000. <span class='tenpt' style='color: white' ><b>$text</b></span>
  1001. </td>
  1002. <td width='10%' align='right' valign='top'></td>
  1003. </tr>
  1004. <tr>
  1005. <td align='left' valign='bottom'></td>
  1006. <td align='right' valign='bottom'></td>
  1007. </tr>
  1008. </table>
  1009. ";
  1010. return $rtn;
  1011. }
  1012. function fp_render_menu_item($item, $bool_check_user_access = TRUE) {
  1013. $rtn = "";
  1014. if ($bool_check_user_access) {
  1015. if (!menu_check_user_access($item)) {
  1016. return "";
  1017. }
  1018. }
  1019. $description = $item["description"];
  1020. $title = $item["title"];
  1021. //$url = $GLOBALS["fp_system_settings"]["base_path"] . "/" . $item["path"];
  1022. $url = fp_url($item["path"], "", TRUE);
  1023. $target = @$item["page_settings"]["target"];
  1024. $menu_icon = @$item["page_settings"]["menu_icon"];
  1025. $extra_class = "";
  1026. if ($menu_icon != "") {
  1027. if (!strstr($menu_icon, 'http')) {
  1028. $base_url = $GLOBALS['fp_system_settings']['base_url'];
  1029. if ($base_url == "/") $base_url = ""; // so that we don't have // as a path, because of the next line.
  1030. if (substr($menu_icon, 0, 1) == '/') {
  1031. // Already starts with a slash, so probably should just use as is.
  1032. // take no action.
  1033. }
  1034. else {
  1035. $menu_icon = $base_url . "/" . $menu_icon;
  1036. }
  1037. }
  1038. $icon_img = "<img src='$menu_icon' border='0' class='fpmn-icon'>";
  1039. }
  1040. else {
  1041. $icon_img = "<span class='fp-menu-item-no-icon'></span>";
  1042. }
  1043. if (!$description) $extra_class = "fp-menu-item-tight";
  1044. $rtn .= "<div class='fp-menu-item $extra_class'>
  1045. <div class='fp-menu-item-link-line'>
  1046. <a href='$url' target='$target'>$icon_img$title</a>
  1047. </div>
  1048. ";
  1049. if ($description) {
  1050. $rtn .= " <div class='fp-menu-item-description'>$description</div>";
  1051. }
  1052. $rtn .= "</div>";
  1053. return $rtn;
  1054. }
  1055. /**
  1056. * Alias of pretty_print($var)
  1057. */
  1058. function ppm($var) {
  1059. pretty_print($var);
  1060. }
  1061. function pretty_print($var) {
  1062. print "<pre>" . print_r($var, true) . "</pre>";
  1063. }

Functions

Namesort descending Description
convert_bbcode_to_html
convert_html_to_bbcode
display_access_denied
display_not_found
format_date Format a timestamp using the date command. TODO: Make the formats something which can be controlled through the settings.
fp_build_sub_tab_array Create a "sub-tab" array, which looks like a standard tab_array, but it contains only this page's sub-tab siblings.
fp_build_tab_array Looks at the current page array and returns a valid $tab_array Meant for the top of the screen.
fp_display_page Output the contents of the $page variable to the screen. $page is an array containing details about the page, as well as its original menu item (router_item) definition.
fp_render_button Returns the HTML to draw a pretty button.
fp_render_currently_advising_box Draws the CurrentlyAdvisingBox which appears at the top of the screen, containing the student's information like name, major, etc.
fp_render_curved_line Will draw a string in a pretty curved box. Used for displaying semester titles.
fp_render_c_fieldset This function will return the HTML to contruct a collapsible fieldset, complete with javascript and style tags.
fp_render_greeting This displays a friendly message to the user, and provides a logout link at the top.
fp_render_menu_block Render a "menu" block of menu items which are all rooted at the menu_root. So if the menu root is tools, it might return items whose paths look like: tools/fun tools/here/there So long as the menu type is "MENU_TYPE_NORMAL_ITEM". …
fp_render_menu_item
fp_render_mobile_tab_array
fp_render_square_line Will draw a string in a pretty square box. Used for displaying semester titles.
fp_render_sub_tab_array Similar to render_tab_array.
fp_render_tab_array Given a propperly formatted tab_array, this will return the HTML to draw it on a page.
fp_show_title Sets whether the title should be shown on the page or not.
fp_theme_location Return the theme location
ppm Alias of pretty_print($var)
pretty_print