theme.inc

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

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
pretty_print