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. /**
  8. * Given an array of table headers (in the format listed below), returns back the HTML to draw it to the screen.
  9. * This makes them clickable, to make the table header sortable. This is meant to be used with queries, by adding
  10. * in an "ORDER BY" clause.
  11. *
  12. * $headers should look like this:
  13. * 0 = array('label' => 'First Name', 'field' => 'field__first_name');
  14. *
  15. * If the label should NOT be clickable, then "field" should be blank or absent.
  16. *
  17. *
  18. */
  19. function theme_table_header_sortable($headers = array(), $element_id = "default") {
  20. // Is there a "current student id" being specified in the URL? If so, let's keep it in our links.
  21. $csid = trim(@$_REQUEST['current_student_id']);
  22. if ($csid) {
  23. $csid = "&current_student_id=$csid";
  24. }
  25. $rtn = "";
  26. $rtn .= "<tr>";
  27. $filter = trim(@$_GET['filter']); // if there is an existing filter we need to preserve.
  28. $filter_line = "";
  29. if ($filter) {
  30. $filter_line = "&filter=" . $filter;
  31. }
  32. foreach ($headers as $header) {
  33. $th_class = fp_get_machine_readable(strtolower($header['label']));
  34. $rtn .= "<th class='header-sortable-$th_class'>";
  35. $label = $header['label'];
  36. $field = @$header['field'];
  37. $init_dir = @$hader['init_dir'];
  38. if (!$field) {
  39. $rtn .= $label;
  40. }
  41. else {
  42. // Convert label to a link. Also, show it as ASC or DESC based on if it is currently selected.
  43. // get the current header sort field and dir....
  44. $current_fsort = @$_GET['fsort'];
  45. $current_fsortdir = @$_GET['fsortdir'];
  46. $opposite_fsortdir = 'ASC';
  47. if ($current_fsortdir == 'ASC') {
  48. $opposite_fsortdir = 'DESC';
  49. }
  50. if ($field == $current_fsort) {
  51. if ($current_fsortdir == 'ASC') {
  52. $label .= " <i class='fa fa-chevron-up'></i>";
  53. }
  54. else {
  55. $label .= " <i class='fa fa-chevron-down'></i>";
  56. }
  57. }
  58. $new_fsortdir = 'ASC';
  59. //if ($default_sort) $new_fsortdir = $default_sort;
  60. // Scenario #1:
  61. // We have never clicked this item before. The link should be for THIS field, and for its "new_fsortdir"
  62. if ($current_fsort != $field) {
  63. $link = l($label, $_GET['q'], "fsort=$field&fsortdir=$new_fsortdir" . $filter_line . $csid);
  64. }
  65. // Scenario #2:
  66. // We have just recently clcked this item. We want to REVERSE the sort direction
  67. if ($current_fsort == $field) {
  68. $link = l($label, $_GET['q'], "fsort=$field&fsortdir=$opposite_fsortdir" . $filter_line . $csid);
  69. }
  70. $rtn .= $link;
  71. } // else
  72. $rtn .= "</th>";
  73. } // foreach header
  74. $rtn .= "</tr>";
  75. return $rtn;
  76. } // theme_table_header_sortable
  77. /**
  78. * Sets our initial sort, if there isn't already one set.
  79. */
  80. function theme_table_header_sortable_set_initial_sort($field, $dir) {
  81. if (@$_GET['fsort'] == '') {
  82. $_GET['fsort'] = $field;
  83. $_GET['fsortdir'] = $dir;
  84. }
  85. }
  86. /**
  87. * Used with the theme_table_header_sortable function (meant to be called AFTER headers have been created.)
  88. *
  89. * The main thing we want to do is confirm that what we are getting from GET is a valid fieldname in the headers array,
  90. * to prevent SQL injection.
  91. */
  92. function theme_table_header_sortable_order_by($headers) {
  93. $rtn = "";
  94. $fsort = @$_GET['fsort'];
  95. $fsortdir = @$_GET['fsortdir'];
  96. if (!$fsort) return '';
  97. if ($fsort) {
  98. // Confirm that this field is in the headers array.
  99. $bool_found_it = FALSE;
  100. foreach ($headers as $header) {
  101. if (isset($header['field']) && $header['field'] == $fsort) {
  102. $bool_found_it = TRUE;
  103. break;
  104. }
  105. }
  106. if (!$bool_found_it) return ""; // couldn't find it!
  107. }
  108. if ($fsortdir != "" && $fsortdir != 'ASC' && $fsortdir != 'DESC') {
  109. $fsortdir = '';
  110. }
  111. return "ORDER BY $fsort $fsortdir";
  112. } // ... sortable_order_by
  113. /**
  114. * Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager/6.x
  115. *
  116. * The purpose of this is to return the HTML to display a "pager", as created from the pager_query() function.
  117. *
  118. * $tags: An array of labels for the controls in the pager.
  119. * $limit: The number of query results to display per page.
  120. * $element: An optional integer to distinguish between multiple pagers on one page.
  121. * $parameters: An associative array of query string parameters to append to the pager links.
  122. * $quantity: The number of pages in the list.
  123. *
  124. */
  125. function theme_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
  126. global $pager_page_array, $pager_total;
  127. // Calculate various markers within this pager piece:
  128. // Middle is used to "center" pages around the current page.
  129. $pager_middle = ceil($quantity / 2);
  130. if (!isset($pager_page_array)) $pager_page_array = array();
  131. if (!isset($pager_page_array[$element])) $pager_page_array[$element] = 0;
  132. if (!isset($pager_total)) $pager_total = array();
  133. if (!isset($pager_total[$element])) $pager_total[$element] = 0;
  134. // current is the page we are currently paged to
  135. $pager_current = $pager_page_array[$element] + 1;
  136. // first is the first page listed by this pager piece (re quantity)
  137. $pager_first = $pager_current - $pager_middle + 1;
  138. // last is the last page listed by this pager piece (re quantity)
  139. $pager_last = $pager_current + $quantity - $pager_middle;
  140. // max is the maximum page number
  141. $pager_max = $pager_total[$element];
  142. // End of marker calculations.
  143. // Prepare for generation loop.
  144. $i = $pager_first;
  145. if ($pager_last > $pager_max) {
  146. // Adjust "center" if at end of query.
  147. $i = $i + ($pager_max - $pager_last);
  148. $pager_last = $pager_max;
  149. }
  150. if ($i <= 0) {
  151. // Adjust "center" if at start of query.
  152. $pager_last = $pager_last + (1 - $i);
  153. $i = 1;
  154. }
  155. // End of generation loop preparation.
  156. $li_first = theme_pager_first(isset($tags[0]) ? $tags[0] : t('« first'), $limit, $element, $parameters);
  157. $li_previous = theme_pager_previous(isset($tags[1]) ? $tags[1] : t('‹ previous'), $limit, $element, 1, $parameters);
  158. $li_next = theme_pager_next(isset($tags[3]) ? $tags[3] : t('next ›'), $limit, $element, 1, $parameters);
  159. $li_last = theme_pager_last(isset($tags[4]) ? $tags[4] : t('last »'), $limit, $element, $parameters);
  160. if ($pager_total[$element] > 1) {
  161. if ($li_first) {
  162. $items[] = array(
  163. 'class' => 'pager-first',
  164. 'data' => $li_first,
  165. );
  166. }
  167. if ($li_previous) {
  168. $items[] = array(
  169. 'class' => 'pager-previous',
  170. 'data' => $li_previous,
  171. );
  172. }
  173. // When there is more than one page, create the pager list.
  174. if ($i != $pager_max) {
  175. if ($i > 1) {
  176. $items[] = array(
  177. 'class' => 'pager-ellipsis',
  178. 'data' => '…',
  179. );
  180. }
  181. // Now generate the actual pager piece.
  182. for (; $i <= $pager_last && $i <= $pager_max; $i++) {
  183. if ($i < $pager_current) {
  184. $items[] = array(
  185. 'class' => 'pager-item',
  186. 'data' => theme_pager_previous($i, $limit, $element, $pager_current - $i, $parameters),
  187. );
  188. }
  189. if ($i == $pager_current) {
  190. $items[] = array(
  191. 'class' => 'pager-current',
  192. 'data' => $i,
  193. );
  194. }
  195. if ($i > $pager_current) {
  196. $items[] = array(
  197. 'class' => 'pager-item',
  198. 'data' => theme_pager_next($i, $limit, $element, $i - $pager_current, $parameters),
  199. );
  200. }
  201. }
  202. if ($i < $pager_max) {
  203. $items[] = array(
  204. 'class' => 'pager-ellipsis',
  205. 'data' => '…',
  206. );
  207. }
  208. }
  209. // End generation.
  210. if ($li_next) {
  211. $items[] = array(
  212. 'class' => 'pager-next',
  213. 'data' => $li_next,
  214. );
  215. }
  216. if ($li_last) {
  217. $items[] = array(
  218. 'class' => 'pager-last',
  219. 'data' => $li_last,
  220. );
  221. }
  222. //return theme('item_list', $items, NULL, 'ul', array(
  223. // 'class' => 'pager',
  224. //));
  225. $rtn = "";
  226. $rtn = "<ul class='pager'>";
  227. foreach ($items as $details) {
  228. $class = @$details['class'];
  229. $data = @$details['data'];
  230. $rtn .= "<li class='$class'>$data</li>";
  231. }
  232. $rtn .= "</ul>";
  233. return "<div class='pager-wrapper pager-wrapper-$element'>$rtn</div>";
  234. }
  235. }
  236. /**
  237. * Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/pager_get_querystring/6.x
  238. */
  239. function pager_get_querystring() {
  240. static $string = NULL;
  241. if (!isset($string)) {
  242. $string = fp_query_string_encode($_REQUEST, array_merge(array(
  243. 'q',
  244. 'page',
  245. 'pass',
  246. ), array_keys($_COOKIE)));
  247. }
  248. return $string;
  249. }
  250. /**
  251. * Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_link/6.x
  252. *
  253. * $text: The link text. Also used to figure out the title attribute of the link, if it is not provided in $attributes['title'];
  254. * in this case, $text must be one of the standard pager link text strings that would be generated by the pager theme functions,
  255. * such as a number or t('« first').
  256. * $page_new: The first result to display on the linked page.
  257. * $element: An optional integer to distinguish between multiple pagers on one page.
  258. * $parameters: An associative array of query string parameters to append to the pager link.
  259. * $attributes: An associative array of HTML attributes to apply to the pager link.
  260. *
  261. */
  262. function theme_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
  263. $page = isset($_GET['page']) ? $_GET['page'] : '';
  264. if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
  265. $parameters['page'] = $new_page;
  266. }
  267. $query = array();
  268. if (count($parameters)) {
  269. $query[] = fp_query_string_encode($parameters, array());
  270. }
  271. $querystring = pager_get_querystring();
  272. if ($querystring != '') {
  273. $query[] = $querystring;
  274. }
  275. // Set each pager link title
  276. if (!isset($attributes['title'])) {
  277. static $titles = NULL;
  278. if (!isset($titles)) {
  279. $titles = array(
  280. t('« first') => t('Go to first page'),
  281. t('‹ previous') => t('Go to previous page'),
  282. t('next ›') => t('Go to next page'),
  283. t('last »') => t('Go to last page'),
  284. );
  285. }
  286. if (isset($titles[$text])) {
  287. $attributes['title'] = $titles[$text];
  288. }
  289. else {
  290. if (is_numeric($text)) {
  291. $attributes['title'] = t('Go to page @number', array(
  292. '@number' => $text,
  293. ));
  294. }
  295. }
  296. }
  297. return l($text, $_GET['q'], count($query) ? implode('&', $query) : '', $attributes);
  298. /*
  299. return l($text, $_GET['q'], array(
  300. 'attributes' => $attributes,
  301. 'query' => count($query) ? implode('&', $query) : NULL,
  302. ));
  303. */
  304. }
  305. /**
  306. * Adapted from: https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_first/6.x
  307. */
  308. function theme_pager_first($text, $limit, $element = 0, $parameters = array()) {
  309. global $pager_page_array;
  310. $output = '';
  311. // If we are anywhere but the first page
  312. if ($pager_page_array[$element] > 0) {
  313. $output = theme_pager_link($text, pager_load_array(0, $element, $pager_page_array), $element, $parameters);
  314. }
  315. return $output;
  316. }
  317. /**
  318. * Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_last/6.x
  319. */
  320. function theme_pager_last($text, $limit, $element = 0, $parameters = array()) {
  321. global $pager_page_array, $pager_total;
  322. $output = '';
  323. // If we are anywhere but the last page
  324. if ($pager_page_array[$element] < $pager_total[$element] - 1) {
  325. $output = theme_pager_link($text, pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), $element, $parameters);
  326. }
  327. return $output;
  328. }
  329. /**
  330. * Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_next/6.x
  331. */
  332. function theme_pager_next($text, $limit, $element = 0, $interval = 1, $parameters = array()) {
  333. global $pager_page_array, $pager_total;
  334. $output = '';
  335. // If we are anywhere but the last page
  336. if ($pager_page_array[$element] < $pager_total[$element] - 1) {
  337. $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
  338. // If the next page is the last page, mark the link as such.
  339. if ($page_new[$element] == $pager_total[$element] - 1) {
  340. $output = theme_pager_last($text, $limit, $element, $parameters);
  341. }
  342. else {
  343. $output = theme_pager_link($text, $page_new, $element, $parameters);
  344. }
  345. }
  346. return $output;
  347. }
  348. /**
  349. * Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_previous/6.x
  350. */
  351. function theme_pager_previous($text, $limit, $element = 0, $interval = 1, $parameters = array()) {
  352. global $pager_page_array;
  353. $output = '';
  354. // If we are anywhere but the first page
  355. if ($pager_page_array[$element] > 0) {
  356. $page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);
  357. // If the previous page is the first page, mark the link as such.
  358. if ($page_new[$element] == 0) {
  359. $output = theme_pager_first($text, $limit, $element, $parameters);
  360. }
  361. else {
  362. $output = theme_pager_link($text, $page_new, $element, $parameters);
  363. }
  364. }
  365. return $output;
  366. }
  367. /**
  368. * Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/pager_load_array/6.x
  369. *
  370. * Copies $old_array to $new_array and sets $new_array[$element] = $value Fills in $new_array[0 .. $element - 1] = 0
  371. *
  372. */
  373. function pager_load_array($value, $element, $old_array) {
  374. $new_array = $old_array;
  375. // Look for empty elements.
  376. for ($i = 0; $i < $element; $i++) {
  377. if (!$new_array[$i]) {
  378. // Load found empty element with 0.
  379. $new_array[$i] = 0;
  380. }
  381. }
  382. // Update the changed element.
  383. $new_array[$element] = (int) $value;
  384. return $new_array;
  385. }
  386. /**
  387. * Format a timestamp using the date command.
  388. * TODO: Make the formats something which can be controlled through the settings.
  389. *
  390. * Available formats:
  391. * - standard
  392. * - short
  393. * - pretty
  394. * - just_date
  395. * - just_time
  396. *
  397. */
  398. function format_date($timestamp = 0, $format = "standard", $custom = "") {
  399. if (!is_numeric($timestamp)) {
  400. $timestamp = 0; // make sure it's numeric.
  401. }
  402. if ($timestamp == 0) {
  403. $timestamp = strtotime("now");
  404. }
  405. $f = "";
  406. if ($format == "standard") {
  407. $f = "n/d/Y h:i:sa";
  408. }
  409. if ($format == "short") {
  410. $f = "n/d/Y - g:ia";
  411. }
  412. if ($format == "pretty") {
  413. $f = "F jS, Y, g:ia";
  414. }
  415. if ($format == 'long_no_year') {
  416. $f = 'l, F jS \a\t g:ia';
  417. }
  418. if ($format == "just_date") {
  419. $f = "F jS, Y";
  420. }
  421. if ($format == 'just_time') {
  422. $f = "g:ia";
  423. }
  424. if ($custom != "") $f = $custom;
  425. return date($f, $timestamp);
  426. }
  427. /**
  428. * Render a "menu" block of menu items which are all rooted at the menu_root.
  429. * So if the menu root is tools, it might return items whose paths look like:
  430. * tools/fun
  431. * tools/here/there
  432. * So long as the menu type is "MENU_TYPE_NORMAL_ITEM" or "MENU_TYPE_DEFAULT_TAB". Other types will be ignored.
  433. *
  434. *
  435. * We want to
  436. */
  437. function fp_render_menu_block($title = "Tools", $menu_root = "tools", $bool_reset = FALSE) {
  438. $rtn = "";
  439. $is_empty = true;
  440. if ($title != "") {
  441. $rtn .= fp_render_section_title($title);
  442. }
  443. $menu_items = menu_get_items_beginning_with($menu_root);
  444. foreach ($menu_items as $item) {
  445. if ($item['path'] === $menu_root) continue; // don't need to duplicate the menu root link itself
  446. if ($item["type"] == MENU_TYPE_NORMAL_ITEM || $item['type'] == MENU_TYPE_DEFAULT_TAB) {
  447. $item = menu_get_item($item['path'], $bool_reset);
  448. $rtn .= fp_render_menu_item($item);
  449. $is_empty = false;
  450. }
  451. }
  452. if ($is_empty) {
  453. return "";
  454. }
  455. //pretty_print($menu_items);
  456. return $rtn;
  457. }
  458. /**
  459. * Output the contents of the $page variable to the screen.
  460. * $page is an array containing details about the page, as well as
  461. * its original menu item (router_item) definition.
  462. */
  463. function fp_display_page($page) {
  464. global $current_student_id, $screen, $user;
  465. $page_title = $page["title"];
  466. if (@$GLOBALS["fp_set_title"] != "") {
  467. $page_title = $GLOBALS["fp_set_title"];
  468. }
  469. if (!is_object($screen)) {
  470. $screen = new AdvisingScreen("",null,"not_advising");
  471. }
  472. $screen->page_title = $page_title;
  473. $screen->page_has_search = @$page["router_item"]["page_settings"]["page_has_search"];
  474. // Add some body classes to the page for this student.
  475. $student = $screen->student;
  476. if (!is_object($student)) {
  477. $student = new Student();
  478. $student->student_id = $current_student_id;
  479. $student->load_student_data();
  480. }
  481. if (is_object($student)) {
  482. fp_add_body_class("student-rank-$student->db_rank student-catalog-year-$student->catalog_year");
  483. }
  484. $screen->page_banner_is_link = @$page["router_item"]["page_settings"]["page_banner_is_link"];
  485. $screen->page_hide_report_error = @$page["router_item"]["page_settings"]["page_hide_report_error"];
  486. $screen->page_is_popup = @$page["router_item"]["page_settings"]["page_is_popup"];
  487. if (isset($page["router_item"]["page_settings"]["screen_mode"])) {
  488. $screen->screen_mode = $page["router_item"]["page_settings"]["screen_mode"];
  489. }
  490. if (isset($page["router_item"]["page_settings"]["bool_print"])) {
  491. $screen->bool_print = $page["router_item"]["page_settings"]["bool_print"];
  492. }
  493. if (@$_REQUEST["scroll_top"] != "") {
  494. $screen->page_scroll_top = $_REQUEST["scroll_top"];
  495. }
  496. // If there is a SESSION var for scroll_top, use that instead, then wipe it.
  497. if (@$_SESSION['scroll_top'] != "") {
  498. $screen->page_scroll_top = $_SESSION["scroll_top"];
  499. $_SESSION['scroll_top'] = "";
  500. unset($_SESSION['scroll_top']);
  501. }
  502. // Was this page a tab? And if so, are there any other tabs we need to display? //
  503. if (@$page["router_item"]["type"] == MENU_TYPE_TAB || @$page["router_item"]["type"] == MENU_TYPE_DEFAULT_TAB || @$page["router_item"]["tab_parent"] != "") {
  504. // We know we should have at least 1 tab for this page.
  505. $tab_array = fp_build_tab_array($page);
  506. $screen->page_tabs = fp_render_tab_array($tab_array);
  507. }
  508. // Should we override the page_tabs with what is in "fp_set_page_tabs" ?
  509. if (isset($GLOBALS["fp_set_page_tabs"]) && is_array($GLOBALS["fp_set_page_tabs"])) {
  510. //fpm($GLOBALS["fp_set_page_tabs"]);
  511. $screen->page_tabs = fp_render_tab_array($GLOBALS["fp_set_page_tabs"]);
  512. }
  513. // Build up the content //
  514. $content_top = "";
  515. $page_show_title = @$page["router_item"]["page_settings"]["page_show_title"];
  516. if (isset($GLOBALS["fp_set_show_title"])) {
  517. $page_show_title = $GLOBALS["fp_set_show_title"];
  518. }
  519. if ($page_show_title == FALSE) {
  520. $page_title = "";
  521. }
  522. $c = 0;
  523. // Are there any "menu_link"s for this? In order words, little links at the top of the page,
  524. // where breadcrumbs might appear.
  525. if (!$screen->bool_print && @is_array($page["router_item"]["page_settings"]["menu_links"])) {
  526. //$content_top .= "<ul class='top-menu-links'>";
  527. $crumbs = array();
  528. foreach ($page["router_item"]["page_settings"]["menu_links"] as $item) {
  529. $lclass = "";
  530. if ($c == 0) $lclass='first';
  531. $p = menu_convert_replacement_pattern(@$item["path"]);
  532. $q = menu_convert_replacement_pattern(@$item["query"]);
  533. $t = @$item["text"];
  534. $a = @$item["attributes"];
  535. if (!is_array($a)) $a = array();
  536. // Make sure the current user has access to view this link. Otherwise, do not even
  537. // bother showing it.
  538. $test_item = menu_get_item($p) ;
  539. if (!menu_check_user_access($test_item)) {
  540. continue;
  541. }
  542. //$content_top .= "<li class='$lclass'>" . l($t, $p, $q, $a) . "</li>";
  543. $crumbs[] = array('text' => $t, 'path' => $p, 'query' => $q, 'attributes' => $a);
  544. $c++;
  545. }
  546. //$content_top .= "</ul>";
  547. // If not already set!
  548. if (!isset($GLOBALS['fp_breadcrumbs'])) {
  549. fp_set_breadcrumbs($crumbs);
  550. }
  551. }
  552. // Any sub-tabs we need to render?
  553. if (@$page["router_item"]["type"] == MENU_TYPE_SUB_TAB) {
  554. $sub_tab_array = fp_build_sub_tab_array($page);
  555. $content_top .= fp_render_sub_tab_array($sub_tab_array);
  556. }
  557. // Should we override the page sub-tabs with what is in "fp_set_page_sub_tabs" ?
  558. if (isset($GLOBALS["fp_set_page_sub_tabs"]) && is_array($GLOBALS["fp_set_page_sub_tabs"])) {
  559. $content_top .= fp_render_sub_tab_array($GLOBALS["fp_set_page_sub_tabs"]);
  560. }
  561. // If there are "messages" waiting, then let's add them to the top of content.
  562. if (isset($_SESSION["fp_messages"]) && is_array($_SESSION["fp_messages"]) && count($_SESSION["fp_messages"]) > 0) {
  563. $content_top .= "<div class='fp-messages'>";
  564. foreach ($_SESSION["fp_messages"] as $key => $tmsg) {
  565. $type = $tmsg["type"];
  566. $message = $tmsg["msg"];
  567. $content_top .= "<div class='fp-message fp-message-$type'>$message</div>";
  568. }
  569. $content_top .= "</div>";
  570. unset($_SESSION["fp_messages"]);
  571. }
  572. // content_top gets the Currently Advising box.
  573. if (@$page["router_item"]["page_settings"]["display_currently_advising"] == TRUE) {
  574. // To do this, we need to make sure the $screen->student object is loaded.
  575. $screen->page_display_currently_advising = TRUE;
  576. if (!$screen->student) {
  577. $screen->student = new Student($current_student_id);
  578. }
  579. }
  580. if (isset($page["router_item"]["page_settings"]["display_currently_advising"])) {
  581. if ($page["router_item"]["page_settings"]["display_currently_advising"] === FALSE) {
  582. // Meaning, we are explicitly saying do NOT show the currently advising box!
  583. $screen->page_display_currently_advising = FALSE;
  584. }
  585. }
  586. $screen->page_content = $content_top .= $page["content"];
  587. if ($user->id > 0) {
  588. // meaning, they are logged in.
  589. $screen->page_content .= fp_render_mobile_hamburger_menu(); // add to the bottom
  590. }
  591. // Add in the body classes
  592. $screen->page_body_classes .= " " . @$GLOBALS["fp_add_body_classes"];
  593. // Add in our URL (after we sanitize it appropriately)
  594. $class = @$_REQUEST['q'];
  595. $class = str_replace("'", '', $class);
  596. $class = str_replace('"', '', $class);
  597. $class = str_replace('(', '', $class);
  598. $class = str_replace(')', '', $class);
  599. $class = str_replace(';', '', $class);
  600. $class = str_replace('.', '', $class);
  601. $class = str_replace('<', '', $class);
  602. $class = str_replace('>', '', $class);
  603. $class = str_replace('/', '-', $class);
  604. $class = str_replace('\\', '', $class);
  605. $class = str_replace('#', '', $class);
  606. $class = str_replace('&', '', $class);
  607. $screen->page_body_classes .= " page--" . str_replace("/", "-", $class);
  608. $screen->output_to_browser();
  609. } // fp_display_page
  610. /**
  611. * This function accepts a "profile items" array by reference, which is presumed to have a "left_side" and a "right_side" already
  612. * defined. We can "push" items onto it, and the item will automatically go to the side with the fewest "items" so as to keep
  613. * it "balanced."
  614. */
  615. function fp_push_and_balance_profile_items(&$profile_items, array $item) {
  616. // We do the -1 to the right_side, because it is already unbalanced by 1 as a default.
  617. $dec = 1;
  618. if (count($profile_items['right_side']) == 0) $dec = 0;
  619. if (count($profile_items['left_side']) <= count($profile_items['right_side']) - $dec) {
  620. $profile_items['left_side'] += $item;
  621. }
  622. else {
  623. $profile_items['right_side'] += $item;
  624. }
  625. // No need to return, since passed by reference.
  626. } // fp_push_and_balance_profile_items
  627. /**
  628. * Returns the HTML for the "profile" header html for a student
  629. */
  630. function fp_render_student_profile_header($bool_mini = TRUE, $extra_profile_items = array()) {
  631. global $current_student_id, $screen, $user, $student;
  632. $csid = $current_student_id;
  633. $school_id = db_get_school_id_for_student_id($current_student_id);
  634. $degree_plan = NULL;
  635. $rtn = "";
  636. if (!isset($extra_profile_items['left_side'])) $extra_profile_items['left_side'] = array();
  637. if (!isset($extra_profile_items['right_side'])) $extra_profile_items['right_side'] = array();
  638. // Call a hook to possibly add more items to our profile items.
  639. invoke_hook("alter_student_profile_items", array($bool_mini, &$extra_profile_items));
  640. if (is_object($screen) && is_object($screen->degree_plan)) {
  641. $degree_plan = $screen->degree_plan;
  642. }
  643. if (!isset($student) || $student == NULL || !is_object($student)) {
  644. $student = new Student($current_student_id);
  645. }
  646. if ($degree_plan == NULL) {
  647. // Degree plan is still null. This probably means we are NOT on an advising screen, so, let's
  648. // use a FlightPath object to init our degree plan, which might actually be a combination of degrees.
  649. // First, we can cheat by seeing if we have anything cached for this student the last time their degree plan
  650. // was loaded. Using this,
  651. // its much faster & memory-friendly than trying to re-init a whole new FlightPath object and DegreePlan object(s).
  652. $bool_got_from_simple_cache = FALSE;
  653. // TODO: Check for _what_if if we are in what if mode?
  654. if (isset($_SESSION["fp_simple_degree_plan_cache_for_student"])) {
  655. if ($_SESSION["fp_simple_degree_plan_cache_for_student"]["cwid"] == $csid) {
  656. // Yes, it's for this student. Load her up.
  657. $degree_plan = new DegreePlan();
  658. $degree_plan->degree_id = $_SESSION["fp_simple_degree_plan_cache_for_student"]["degree_id"];
  659. $degree_plan->combined_degree_ids_array = $_SESSION["fp_simple_degree_plan_cache_for_student"]["combined_degree_ids_array"];
  660. $degree_plan->is_combined_dynamic_degree_plan = $_SESSION["fp_simple_degree_plan_cache_for_student"]["is_combined_dynamic_degree_plan"];
  661. $bool_got_from_simple_cache = TRUE;
  662. }
  663. }
  664. if (!$bool_got_from_simple_cache) {
  665. // didn't get it from the simple cache, so load it all fresh.
  666. $fp = new FlightPath($student);
  667. $fp->init(TRUE);
  668. $degree_plan = $fp->degree_plan;
  669. }
  670. }
  671. $cat_year = $student->catalog_year . "-" . ($student->catalog_year + 1);
  672. $rank = $student->rank;
  673. // Should we display a catalog year warning? This is
  674. // something that can be part of a settings table.
  675. if ($student->catalog_year < intval(variable_get_for_school("earliest_catalog_year", 2006, $school_id))) {
  676. $alert_msg = "";
  677. $alert_msg .= "<b>" . t("Important Notice:") . "</b> " . t("FlightPath cannot display degree plans from catalogs earlier than %earliest.
  678. The student&#039;s catalog year is %current, which means that the degree plan displayed may not accurately
  679. represent this student&#039;s degree requirements.", array("%earliest" => intval(variable_get_for_school("earliest_catalog_year", 2006, $school_id)) . "-" . (intval(variable_get_for_school("earliest_catalog_year", 2006, $school_id)) + 1), "%current" => $cat_year));
  680. $cat_year = "<span class='catalog-year-alert-early'>$cat_year<a href='javascript:fp_alert(\"$alert_msg\");' title='" . t("Important Notice") . "'><i class='fa fa-exclamation-triangle'></i></a></span>";
  681. $bool_catalog_warning = true;
  682. }
  683. if (variable_get_for_school("current_catalog_year",'', $school_id) > intval(variable_get_for_school("earliest_catalog_year", 2006, $school_id))) {
  684. // Is the student's catalog set beyond the range that
  685. // FP has data for? If so, show a warning.
  686. if ($student->catalog_year > variable_get_for_school("current_catalog_year",'', $school_id))
  687. {
  688. $alert_msg = t("This student&#039;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&#039;s major using What If.", array("@cat_year" => $cat_year, "@new_cat" => variable_get_for_school("current_catalog_year",'',$school_id) . "-" . (variable_get_for_school("current_catalog_year",'',$school_id) + 1)));
  693. $cat_year = "<span class='catalog-year-alert-too-far'>$cat_year<a href='javascript:fp_alert(\"$alert_msg\");' title='" . t("Important Notice") . "'><i class='fa fa-exclamation-triangle'></i></a></span>";
  694. $bool_future_catalog_warning = true;
  695. }
  696. }
  697. $db = get_global_database_handler();
  698. ///////////////////////////
  699. $degree_title_div = "";
  700. $s = ""; // plural degrees?
  701. $bool_show_track_selection_link = FALSE;
  702. // We are trying to figure out what to display for the Degree field. If there is only ONE degree plan
  703. // to worry about, then we will display it.
  704. if ($degree_plan == null || $degree_plan->is_combined_dynamic_degree_plan != TRUE) {
  705. // This is an ordinary degree plan.
  706. $use_degree_plan = $degree_plan;
  707. $degree_title = "";
  708. if ($degree_plan != NULL) {
  709. $degree_title = $degree_plan->get_title2(TRUE);
  710. }
  711. /**
  712. * This degree is in fact a track.
  713. */
  714. if (strstr($degree_plan->major_code, "_")) {
  715. $degree_title = $degree_plan->get_title2(TRUE, TRUE);
  716. if ($degree_plan->db_allow_dynamic == 0) {
  717. // This degree is NON-dynamic. Meaning, if we change tracks, we should do it from the perspective
  718. // of the original major code, and how FP 4.x did things.
  719. $temp = explode("_", $degree_plan->major_code);
  720. $m = trim($temp[0]);
  721. // Remove trailing | if its there.
  722. $m = rtrim($m, "|");
  723. $use_degree_plan = $db->get_degree_plan($m, $degree_plan->catalog_year, TRUE); // the original degree plan!
  724. }
  725. }
  726. if ($screen->screen_mode == "detailed") {
  727. $degree_title .= " ($degree_plan->major_code)";
  728. }
  729. if ($use_degree_plan != null && $use_degree_plan->get_available_tracks()) {
  730. $bool_show_track_selection_link = TRUE;
  731. }
  732. $degree_title_div = "<div class='degree-title'>$degree_title</div>";
  733. //array_push($display_array, t("Degree:") . " ~~ " . $degree_title);
  734. }
  735. else {
  736. // This degree plan is made from combining several other degrees. let's trot them out and display them as well.
  737. $t_degree_plan_titles = "";
  738. $dc = 0;
  739. foreach ($degree_plan->combined_degree_ids_array as $t_degree_id) {
  740. $t_degree_plan = new DegreePlan();
  741. $t_degree_plan->degree_id = $t_degree_id;
  742. $t_degree_plan->load_descriptive_data();
  743. if ($t_degree_plan->get_available_tracks()) {
  744. $bool_show_track_selection_link = TRUE;
  745. }
  746. // Add it to our box...
  747. // If more than one major/minor, etc, combine them into one div
  748. $t_title = $t_degree_plan->get_title2(TRUE);
  749. $t_class = $t_degree_plan->degree_class;
  750. $t_class_details = fp_get_degree_classification_details($t_class);
  751. // If this is actually a track, let's get the track's title instead.
  752. if ($x = $t_degree_plan->get_track_title(TRUE)) {
  753. $t_title = $x;
  754. }
  755. if ($t_class_details["level_num"] == 3) {
  756. $t_title = "<span class='level-3-raquo'>&raquo;</span>" . $t_title;
  757. }
  758. $machine_major_code = fp_get_machine_readable($t_degree_plan->major_code);
  759. if ($t_degree_plan->track_code != "") {
  760. $machine_major_code .= "-" . fp_get_machine_readable($t_degree_plan->track_code);
  761. }
  762. $t_degree_plan_titles .= "<span class='multi-degree-title multi-degree-class-" . $t_class . "
  763. multi-degree-class-level-" . $t_class_details["level_num"] . "
  764. multi-degree-code-$machine_major_code multi-degree-num-$dc'>
  765. " . $t_title . "</span><span class='multi-degree-comma'>,</span>";
  766. $dc++;
  767. $s = "s";
  768. }
  769. // Trim the last comma off the end of t_degree_plan_titles
  770. $t_degree_plan_titles = rtrim($t_degree_plan_titles, "<span class='multi-degree-comma'>,</span>");
  771. $degree_title_div = $t_degree_plan_titles;
  772. }
  773. // Now, do we want to add an option to select a track to the degree_title_div?
  774. if ($bool_show_track_selection_link) {
  775. // Are we in what_if mode?
  776. $advising_what_if = @$GLOBALS["fp_advising"]["advising_what_if"];
  777. // We want to add a link to the popup to let the user select other degree tracks.
  778. $op_link = "<a class='degree-op-link-change-degree-options' href='javascript: popupSmallIframeDialog(\"" . fp_url("advise/popup-change-track", "advising_what_if=$advising_what_if") . "\",\"" . t("Select a Degree Option") . "\");'
  779. title='" . t("Change degree options") . "'><i class='fa fa-cog'></i></a>";
  780. if (!$screen || $screen->screen_mode == "not_advising" || $screen->screen_mode == "detailed") {
  781. $op_link = "";
  782. }
  783. if (!user_has_permission("can_advise_students")) {
  784. if (@$GLOBALS["fp_advising"]["advising_what_if"] != "yes")
  785. {
  786. // In other words, we do not have permission to advise,
  787. // and we are not in whatIf, so take out the link.
  788. $op_link = "";
  789. }
  790. }
  791. if ($op_link) {
  792. $degree_title_div .= "<span class='degree-op-link'>$op_link</span>";
  793. }
  794. }
  795. $right_side_top = "<h2>&nbsp; &nbsp; &nbsp; &nbsp;</h2>"; // need spacers on purpose
  796. $whatifclass = "";
  797. if (@$GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
  798. $whatifclass = "student-mini-profile-what-if-mode";
  799. // Set the cat year to whatever our What If cat year was, current if we can't find it.
  800. $what_if_catalog_year = @$GLOBALS["fp_advising"]["what_if_catalog_year"];
  801. if ($what_if_catalog_year != 0 && $what_if_catalog_year != "") {
  802. $student->catalog_year = $what_if_catalog_year;
  803. }
  804. else {
  805. // Only change to current if that is how our settings are set...
  806. if (variable_get_for_school("what_if_catalog_year_mode", "current", $school_id) == "current") {
  807. $student->catalog_year = variable_get_for_school("current_catalog_year",'',$school_id);
  808. }
  809. }
  810. //$what_if_select = "<span class='what-if-change-settings'>" . l("<i class='fa fa-cog'></i> " . t("Change 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") . "</span>";
  811. //$right_side_top = "<h2 class='what-if-notice'>" . t("What If Mode") . "</h2>";
  812. }
  813. // Figure out what the user's image is based on their account.
  814. $image_url = "";
  815. $student_account_user_id = db_get_user_id_from_cwid($student->student_id, 'student');
  816. if ($student_account_user_id) {
  817. $student_account = fp_load_user($student_account_user_id);
  818. if ($student_account) {
  819. $image_url = @$student_account->settings['image_url'];
  820. }
  821. }
  822. $rtn .= "<div class='student-mini-profile $whatifclass'>
  823. ";
  824. if ($image_url) {
  825. $rtn .= "<div class='header-profile-image'>
  826. <img src='$image_url' class='student-profile-image' />
  827. </div> <!-- profile-image -->
  828. ";
  829. }
  830. $school_html = $school_name = "";
  831. if (module_enabled("schools")) {
  832. // If we have schools module enabled, let's find out what school this student belongs to and display it
  833. $defs = schools_get_school_definitions(TRUE);
  834. $temp = @$defs[$student->school_id];
  835. if ($temp) {
  836. $school_html .= "
  837. <div class='profile-detail-line profile-inline-line profile-detail-line-school profile-line-detail-school-$student->school_id'>
  838. <label>" . t("School:") . "</label> <span class='profile-line-content'>" . $temp['name'] . "</span>
  839. </div>
  840. ";
  841. }
  842. }
  843. $rtn .= " <div class='profile-top-details-wrapper profile-top-wrapper-left-side'>
  844. <div class='profile-detail-line profile-detail-line-student-name-cwid'>
  845. <h2>$student->name &nbsp; &nbsp; ($student->student_id)</h2>
  846. </div>
  847. $school_html
  848. <div class='profile-detail-line profile-inline-line profile-detail-line-degree'>
  849. <label>" . t("Degree$s:") . "</label> <span class='profile-line-content'>$degree_title_div</span>
  850. </div>
  851. <div class='profile-detail-line profile-inline-line profile-detail-line-cat-year'>
  852. <label>" . t("Catalog Year:") . "</label> <span class='profile-line-content'>$cat_year</span>
  853. </div>
  854. ";
  855. if (isset($extra_profile_items['left_side'])) {
  856. foreach ($extra_profile_items['left_side'] as $details) {
  857. $label = @$details['label'];
  858. $content = @$details['content'];
  859. $extra_class = @$details['extra_class'];
  860. $mobile_content = @$details['mobile_content']; // displayed in an initially-hidden span, if provided.
  861. if ($mobile_content) {
  862. $mobile_content = "<span style='display:none;' class='mobile-profile-line-content'>$mobile_content</span>";
  863. $extra_class .= " has-mobile-content";
  864. }
  865. $rtn .= "<div class='profile-detail-line profile-inline-line $extra_class'>
  866. <label>$label</label> <span class='profile-line-content'>$content</span>$mobile_content
  867. </div>";
  868. }
  869. }
  870. $rtn .= "</div>
  871. <div class='profile-top-details-wrapper profile-top-wrapper-right-side'>
  872. <div class='profile-detail-line profile-detail-line-empty'>
  873. $right_side_top <!-- need something here so it lines up correctly -->
  874. </div>
  875. <div class='profile-detail-line profile-inline-line profile-detail-line-rank'>
  876. <label>" . t("Classification:") . "</label> <span class='profile-line-content'>$rank</span>
  877. </div>
  878. <div class='profile-detail-line profile-inline-line profile-detail-line-cumu'>
  879. <label>" . t("Cumulative:") . "</label> <span class='profile-line-content'>{$student->cumulative_hours} " . t("hrs") . " / " . fp_truncate_decimals($student->gpa, 3) . " " . t("GPA") . "</span>
  880. </div>
  881. ";
  882. if (isset($extra_profile_items['right_side'])) {
  883. foreach ($extra_profile_items['right_side'] as $details) {
  884. $label = @$details['label'];
  885. $content = @$details['content'];
  886. $extra_class = @$details['extra_class'];
  887. $mobile_content = @$details['mobile_content']; // displayed in an initially-hidden span, if provided.
  888. if ($mobile_content) {
  889. $mobile_content = "<span style='display:none;' class='mobile-profile-line-content'>$mobile_content</span>";
  890. $extra_class .= " has-mobile-content";
  891. }
  892. $rtn .= "<div class='profile-detail-line profile-inline-line $extra_class'>
  893. <label>$label</label> <span class='profile-line-content'>$content</span>$mobile_content
  894. </div>";
  895. }
  896. }
  897. $rtn .= "
  898. </div>
  899. <div class='clear'></div>
  900. </div>
  901. ";
  902. return $rtn;
  903. }
  904. /**
  905. * Return the HTML for breadcrumbs for the current page we are on.
  906. * Will skip any breadcrumbs we do not have permission to access.
  907. */
  908. function fp_render_breadcrumbs() {
  909. $rtn = "";
  910. $c = 0;
  911. if (isset($GLOBALS['fp_breadcrumbs']) && is_array($GLOBALS['fp_breadcrumbs'])) {
  912. $crumbs = $GLOBALS['fp_breadcrumbs'];
  913. $rtn .= "<div id='breadcrumb-inner-wrapper'>
  914. <ul class='breadcrumbs'>";
  915. foreach ($crumbs as $crumb) {
  916. $z_index = 20 - $c;
  917. $text = @$crumb['text'];
  918. $path = @$crumb['path'];
  919. $query = @$crumb['query'];
  920. $attributes = @$crumb['attributes'];
  921. // Do we have permission for this menu item? If not, do not render this breadcrumb.
  922. if ($path != "<front>") {
  923. $item = menu_get_item($path);
  924. if (!menu_check_user_access($item)) {
  925. continue;
  926. }
  927. }
  928. if (!$attributes || !is_array($attributes)) {
  929. $attributes = array();
  930. $attributes['style'] = '';
  931. }
  932. $attributes['style'] .= " z-index: $z_index;";
  933. $link = l($text, $path, $query, $attributes);
  934. $extra_class = "";
  935. if ($c == 0) $extra_class .= "first";
  936. if ($c == count($crumbs) -1) $extra_class .= " last";
  937. $rtn .= "<li class='crumbs $extra_class' style='z-index: $z_index;' >
  938. $link
  939. </li>";
  940. $c++;
  941. }
  942. $rtn .= "</ul>
  943. </div>";
  944. }
  945. return $rtn;
  946. } // fp_render_breadcrumbs
  947. /**
  948. * Returns the HTML for the left sidebar content.
  949. */
  950. function fp_render_sidebar_left_content($bool_for_hamburger_menu = FALSE) {
  951. global $user;
  952. $html = "";
  953. // Our links.... (we will check permissions later based on the path)
  954. $links = array();
  955. if ($_SESSION["fp_logged_in"] != TRUE) {
  956. // user is not logged in. The top-most link should be to log in.
  957. $links[] = array(
  958. 'path' => 'login',
  959. 'icon' => 'fa-sign-in',
  960. 'desc' => t('Login'),
  961. 'class' => 'login',
  962. 'weight' => 0,
  963. );
  964. }
  965. else {
  966. // the user is logged in normally, the top-most link should be the dashboard
  967. $links[] = array(
  968. 'path' => '<front>',
  969. 'icon' => 'fa-home',
  970. 'desc' => t('Dashboard'),
  971. 'class' => 'home',
  972. 'weight' => 0,
  973. );
  974. }
  975. if ($user->is_student) {
  976. $links[] = array(
  977. 'path' => 'student-profile',
  978. 'icon' => 'fa-graduation-cap',
  979. 'desc' => t('My Profile'),
  980. 'class' => 'my-profile',
  981. 'weight' => 10,
  982. );
  983. }
  984. $links[] = array(
  985. 'path' => 'calendar',
  986. 'icon' => 'fa-calendar',
  987. 'desc' => t('Appointments'),
  988. 'class' => 'appointments',
  989. 'weight' => 20,
  990. );
  991. $links[] = array(
  992. 'path' => 'student-search',
  993. 'icon' => 'fa-users',
  994. 'desc' => t('Students'),
  995. 'class' => 'students',
  996. 'weight' => 30,
  997. );
  998. $links[] = array(
  999. 'path' => 'tools/course-search',
  1000. 'icon' => 'fa-book',
  1001. 'desc' => t('Courses'),
  1002. 'class' => 'courses',
  1003. 'weight' => 40,
  1004. );
  1005. $links[] = array(
  1006. 'path' => 'tools/blank-degrees',
  1007. 'icon' => 'fa-university',
  1008. 'desc' => t('Degrees'),
  1009. 'class' => 'degrees',
  1010. 'weight' => 50,
  1011. );
  1012. $links[] = array(
  1013. 'path' => 'stats',
  1014. 'icon' => 'fa-bar-chart',
  1015. 'desc' => t('Analytics'),
  1016. 'class' => 'analytics',
  1017. 'weight' => 60,
  1018. );
  1019. $links[] = array(
  1020. 'path' => 'admin-tools',
  1021. 'icon' => 'fa-bolt',
  1022. 'desc' => t('Admin Tools'),
  1023. 'class' => 'admin-tools',
  1024. 'weight' => 70,
  1025. );
  1026. if ($bool_for_hamburger_menu) {
  1027. // Include a handy log-out on the mobile hamburger menu
  1028. $links[] = array(
  1029. 'path' => 'logout',
  1030. 'icon' => 'fa-sign-out',
  1031. 'desc' => t('Log Out'),
  1032. 'class' => 'logout',
  1033. 'weight' => 999,
  1034. );
  1035. }
  1036. // TODO: hook to allow other modules to add to this list or modify it.
  1037. // Sort links by weight
  1038. $temp = array();
  1039. foreach ($links as $c => $details) {
  1040. $weight = @floatval($details['weight']);
  1041. $temp[] = "$weight ~ $c";
  1042. }
  1043. sort($temp);
  1044. $new_links = array();
  1045. foreach ($temp as $line) {
  1046. $x = explode("~", $line);
  1047. $i = intval($x[1]);
  1048. $new_links[] = $links[$i];
  1049. }
  1050. $links = $new_links;
  1051. // Display
  1052. $html .= "<ul class='sidebar-left-nav'>";
  1053. foreach ($links as $c => $link) {
  1054. $path = $link['path'];
  1055. $icon = $link['icon'];
  1056. $desc = $link['desc'];
  1057. $query = @$link['query'];
  1058. $class = @$link['class'];
  1059. if ($c == 0) $class .= " first";
  1060. if ($c == count($links) - 1) $class .= " last";
  1061. // Do we have permission for this menu item?
  1062. if ($path != "<front>") {
  1063. $item = menu_get_item($path);
  1064. if (!menu_check_user_access($item)) {
  1065. continue;
  1066. }
  1067. }
  1068. // If we are here, we have access!
  1069. $html .= "<a href='" . fp_url($path, $query) . "'>
  1070. <li class='$class'>
  1071. <i class='fa $icon'></i>
  1072. <div class='desc'>$desc</div>
  1073. </li>
  1074. </a>";
  1075. } // foreach
  1076. $html .= "</ul>";
  1077. return $html;
  1078. } // fp_render_sidebar_left_content
  1079. /**
  1080. * This will create the HTML content for the "mobile hamburger" menu, which appears when we press
  1081. * the 3 lines icon or "hamburger" icon on a mobile device.
  1082. */
  1083. function fp_render_mobile_hamburger_menu() {
  1084. $rtn = "";
  1085. $rtn .= "<div id='mobile-hamburger-menu' style='display:none;'>
  1086. <div class='mobile-top-nav'>";
  1087. $rtn .= fp_render_top_nav_content(TRUE);
  1088. $rtn .= " </div>
  1089. <div class='clear'></div>
  1090. <div class='mobile-sidebar-content'>";
  1091. $rtn .= fp_render_sidebar_left_content(TRUE);
  1092. $rtn .= " </div>
  1093. </div>";
  1094. return $rtn;
  1095. }
  1096. /**
  1097. * Returns the HTML for the top navigation content of the screen itself.
  1098. *
  1099. * If the bool_for_hamburger_menu == true, then we are trying to render this for
  1100. * our mobile hamburger menu, so we will alter a little bit.
  1101. *
  1102. */
  1103. function fp_render_top_nav_content($bool_for_hamburger_menu = FALSE) {
  1104. global $user;
  1105. $html = "";
  1106. $name = "";
  1107. if ($user->is_faculty) {
  1108. $name = fp_get_faculty_name($user->cwid);
  1109. }
  1110. else {
  1111. $name = fp_get_student_name($user->cwid);
  1112. }
  1113. $badge = "";
  1114. // If user has new alerts to view, we should show a "badge" on the icon over the alerts icon
  1115. $alert_count_by_type = fp_get_alert_count_by_type();
  1116. if ($alert_count_by_type && is_array($alert_count_by_type) && count($alert_count_by_type) > 0) {
  1117. $unread_total = 0;
  1118. foreach ($alert_count_by_type as $module => $alert_types) {
  1119. if ($alert_types && is_array($alert_types)) {
  1120. foreach ($alert_types as $k => $details) {
  1121. $ur = intval( $details['unread']);
  1122. if ($ur < 0) $ur = 0; // bug that can happen after deletions, it can be in negative numbers.
  1123. $unread_total += $ur;
  1124. }
  1125. }
  1126. }
  1127. if ($unread_total > 0) {
  1128. $badge = "<span class='tub-alert-count'><i class='fa fa-circle'></i></span>";
  1129. }
  1130. }
  1131. if (!$bool_for_hamburger_menu) {
  1132. $html .= "<ul class='top-nav-ul'>";
  1133. // If we have a student selected, then we will display a link to go back to that student.
  1134. if ($user->is_faculty) {
  1135. if (@trim($_SESSION["last_student_selected"]) != '') {
  1136. $csid = trim($_SESSION["last_student_selected"]);
  1137. $sname = trim(fp_get_student_name($csid));
  1138. if ($sname) {
  1139. $sname = htmlentities($sname);
  1140. $cur_stu_link = l("<i class='fa fa-id-card-o'></i>", "student-select","current_student_id=$csid",array("title" => t("Return to @sname", array("@sname" => $sname))));
  1141. $html .= "<li class='current-student-link'>$cur_stu_link</li>";
  1142. }
  1143. }
  1144. }
  1145. if (user_has_permission('view_any_advising_session')) {
  1146. $html .= "<li class='student-search'>" . student_search_render_small_search() . "</li>";
  1147. }
  1148. if (user_has_permission('view_advisee_alerts')) {
  1149. $html .= "<li class='alerts'><span class='tub-icon-element-alert'><a href='" . fp_url('alerts') . "'><i class='fa fa-bell'></i>$badge</a></span></li>";
  1150. }
  1151. $html .= "<li class='user-options last'>";
  1152. $user_menu_links = array(
  1153. 0 => l(t('My Settings'), 'user-settings'),
  1154. 1 => l(t('Log Out'), 'logout'),
  1155. );
  1156. // Call a hook to allow others to modify this.
  1157. invoke_hook('user_menu_links_alter', array(&$user_menu_links));
  1158. $html .= "
  1159. <div class='tub-element tub-float-right-a tub-last-element tub-user-menu tub-icon-element dropdown'>
  1160. <div class='tub-element-wrapper'>
  1161. <a href='javascript:fpToggleUserMenu();' class='tub-link dropdown-trigger'>
  1162. <i class='fa fa-user'></i><span class='tub-caret-down'><i class='fa fa-caret-down'></i></span>
  1163. </a>
  1164. </div>
  1165. <div id='tub-user-pulldown' style='display:none;' >
  1166. $name
  1167. <ul class='user-pulldown'>
  1168. ";
  1169. foreach ($user_menu_links as $link) {
  1170. $html .= "<li>" . $link . "</li>";
  1171. }
  1172. $html .= "
  1173. </ul>
  1174. </div>
  1175. </div>
  1176. </li>
  1177. </ul>
  1178. ";
  1179. // We are also going to have a hidden "hamburger" icon, which gets displayed
  1180. // when we shrink to mobile. It will be invisible by default.
  1181. $html .= "<div class='mobile-hamburger-icon' style='display: none;'>
  1182. <a href='javascript:fpToggleHamburgerMenu();'><i class='fa fa-bars'></i></a>
  1183. </div>";
  1184. }
  1185. else {
  1186. // This IS for our *** hamburger menu **** !
  1187. $cog_class = "cog-only";
  1188. $html .= "<ul class='top-nav-ul'>";
  1189. if (user_has_permission('view_advisee_alerts')) {
  1190. $html .= "<li class='alerts first'><span class='tub-icon-element-alert'><a href='" . fp_url('alerts') . "'><i class='fa fa-bell'></i>$badge</a></span></li>";
  1191. $cog_class = "last";
  1192. }
  1193. $html .= "
  1194. <li class='user-options last $cog_class'>
  1195. <a href='" . fp_url('user-settings') . "'><i class='fa fa-cog'></i></a>
  1196. </li>
  1197. </ul>
  1198. ";
  1199. }
  1200. return $html;
  1201. } // fp_render_top_nav_content
  1202. /**
  1203. * Sets whether the title should be shown on the page or not.
  1204. */
  1205. function fp_show_title($bool_show = TRUE) {
  1206. $GLOBALS["fp_set_show_title"] = $bool_show;
  1207. }
  1208. /**
  1209. * This function will return the HTML to contruct a collapsible fieldset,
  1210. * complete with javascript and style tags.
  1211. *
  1212. * @param String $content
  1213. * @param String $legend
  1214. * @param bool $bool_start_closed
  1215. * @return String
  1216. */
  1217. function fp_render_c_fieldset($content, $legend = "Click to expand/collapse", $bool_start_closed = false, $extra_class = "")
  1218. {
  1219. // Create a random ID for this fieldset, js, and styles.
  1220. $id = md5(rand(9,99999) . time());
  1221. $start_js_val = 1;
  1222. $fsstate = "open";
  1223. $content_style = "";
  1224. if ($bool_start_closed) {
  1225. $start_js_val = 0;
  1226. $fsstate = "closed";
  1227. $content_style = "display: none;";
  1228. }
  1229. $js = "<script type='text/javascript'>
  1230. var fieldset_state_$id = $start_js_val;
  1231. function toggle_fieldset_$id() {
  1232. var content = document.getElementById('content_$id');
  1233. var fs = document.getElementById('fs_$id');
  1234. if (fieldset_state_$id == 1) {
  1235. // Already open. Let's close it.
  1236. fieldset_state_$id = 0;
  1237. \$(content).slideUp('medium');
  1238. fs.className = 'c-fieldset-closed-$id c-fieldset-closed c-fieldset';
  1239. }
  1240. else {
  1241. // Was closed. let's open it.
  1242. fieldset_state_$id = 1;
  1243. \$(content).slideDown('medium');
  1244. fs.className = 'c-fieldset-open-$id c-fieldset-open c-fieldset';
  1245. }
  1246. }
  1247. </script>";
  1248. $rtn = "
  1249. <fieldset class='c-fieldset-$fsstate-$id c-fieldset-$fsstate c-fieldset $extra_class' id='fs_$id'>
  1250. <legend><a href='javascript: toggle_fieldset_$id();' class='nounderline'>$legend</a></legend>
  1251. <div id='content_$id' class='c-fieldset-content' style='$content_style'>
  1252. $content
  1253. </div>
  1254. </fieldset>
  1255. $js
  1256. <style>
  1257. fieldset.c-fieldset-open-$id {
  1258. border: 1px solid;
  1259. }
  1260. fieldset.c-fieldset-closed-$id {
  1261. border: 1px solid;
  1262. border-bottom-width: 0;
  1263. border-left-width: 0;
  1264. border-right-width: 0;
  1265. }
  1266. legend a {
  1267. text-decoration: none;
  1268. }
  1269. </style>
  1270. ";
  1271. return $rtn;
  1272. }
  1273. /**
  1274. * Create a "sub-tab" array, which looks like a standard tab_array,
  1275. * but it contains only this page's sub-tab siblings.
  1276. */
  1277. function fp_build_sub_tab_array($page) {
  1278. global $current_student_id;
  1279. $tab_array = array();
  1280. $tab_family = $page["router_item"]["tab_family"];
  1281. $active_tab_path = $page["path"];
  1282. $items = menu_get_items_in_tab_family($tab_family);
  1283. foreach ($items as $item) {
  1284. // Does the user have access to this subtab?
  1285. if (!menu_check_user_access($item)) {
  1286. continue;
  1287. }
  1288. $title = $item["title"];
  1289. $path = $item["path"];
  1290. $active = FALSE;
  1291. $on_click = @$page["page_settings"]["tab_on_click"];
  1292. if ($on_click == "") {
  1293. // Just a simple link to the path
  1294. // Add the current_student_id to the query!
  1295. $query = "current_student_id=$current_student_id";
  1296. $turl = fp_url($path, $query, TRUE);
  1297. $on_click = "window.location=\"" . $turl . "\"";
  1298. }
  1299. if ($path == $active_tab_path) {
  1300. // This is the current page we are on.
  1301. $active = TRUE;
  1302. $title = $page["title"];
  1303. $on_click = "";
  1304. }
  1305. $tab_array[] = array(
  1306. "title" => $item["title"],
  1307. "active" => $active,
  1308. "on_click" => $on_click,
  1309. );
  1310. }
  1311. return $tab_array;
  1312. }
  1313. /**
  1314. * Looks at the current page array and returns a valid $tab_array
  1315. * Meant for the top of the screen.
  1316. */
  1317. function fp_build_tab_array($page) {
  1318. global $current_student_id;
  1319. $tab_array = array();
  1320. $tab_family = $page["router_item"]["tab_family"];
  1321. $active_tab_path = $page["path"];
  1322. if ($page["router_item"]["tab_parent"] != "") {
  1323. // We want to know the PARENT's tab_family, so we can display the correct tabs at the top of the page.
  1324. $tab_parent = $page["router_item"]["tab_parent"];
  1325. $item = menu_get_item($tab_parent);
  1326. $tab_family = $item["tab_family"];
  1327. $active_tab_path = $item["path"];
  1328. }
  1329. // look for other possible tabs, based on the "tab_family" value
  1330. // Also check to make sure the user has access to the tab.
  1331. $items = menu_get_items_in_tab_family($tab_family);
  1332. foreach ($items as $item) {
  1333. // Does the user have access to this tab?
  1334. if (!menu_check_user_access($item)) {
  1335. continue;
  1336. }
  1337. $title = $tab_title = $item["title"];
  1338. $path = $item["path"];
  1339. if (isset($item["page_settings"]["tab_title"])) {
  1340. $tab_title = $item["page_settings"]["tab_title"];
  1341. }
  1342. if (strstr($path, "%")) {
  1343. // it contains at least one wildcard. So, let's replace the wildcard with
  1344. // the coresponding value from arg(). Ex: content/%/edit (when we are on content/55/view) would == content/55/edit.
  1345. $new_path = "";
  1346. $pieces = explode("/", $path);
  1347. foreach ($pieces as $c => $piece) {
  1348. if ($piece != "%") {
  1349. $new_path .= $piece . "/";
  1350. }
  1351. else {
  1352. // This WAS a wildcard. Replace with arg() value.
  1353. $a = @arg($c);
  1354. $new_path .= $a . "/";
  1355. }
  1356. }
  1357. $new_path = rtrim($new_path, "/"); // get rid of trailing slash.
  1358. $path = $new_path;
  1359. }
  1360. $active = FALSE;
  1361. $on_click = @$page["page_settings"]["tab_on_click"];
  1362. $href = "";
  1363. if ($on_click == "") {
  1364. // Just a simple link to the path
  1365. // Include the current_student_id!
  1366. $query = "current_student_id=$current_student_id";
  1367. $turl = fp_url($path, $query, TRUE);
  1368. //$on_click = "window.location=\"" . $turl . "\"";
  1369. $href = $turl;
  1370. }
  1371. if ($path == $active_tab_path) {
  1372. // This is the current page we are on.
  1373. $active = TRUE;
  1374. $title = $tab_title;
  1375. $on_click = "";
  1376. $href = "";
  1377. }
  1378. $tab_array[] = array(
  1379. "title" => $tab_title,
  1380. "active" => $active,
  1381. "on_click" => $on_click,
  1382. "href" => $href,
  1383. );
  1384. }
  1385. return $tab_array;
  1386. }
  1387. /**
  1388. * Similar to render_tab_array.
  1389. */
  1390. function fp_render_sub_tab_array($tab_array) {
  1391. global $current_student_id;
  1392. $rtn = "";
  1393. $rtn .= "<div class='sub-tabs'>";
  1394. foreach ($tab_array as $tab) {
  1395. $title = @$tab["title"];
  1396. $on_click = @$tab["on_click"];
  1397. $active = @$tab["active"];
  1398. $type = @$tab["type"];
  1399. $extra_class = "";
  1400. if ($active) $extra_class = "gradbutton-active";
  1401. $extra_class .= " sub-tab-title-" . fp_get_machine_readable(strtolower(trim($title)));
  1402. if ($type == "link" ) {
  1403. // Render as a standard link
  1404. $label = @$tab["label"];
  1405. $text = @$tab["text"];
  1406. $link_title = @$tab['link_title'];
  1407. $link_class = @$tab['link_class'];
  1408. $rtn .= "<span class='subtab-link-wrapper $link_class'>";
  1409. if ($label) {
  1410. $rtn .= "<label>$label</label>";
  1411. }
  1412. $rtn .= "<a href='javascript: $on_click' class='fp-sub-tab-link $extra_class' title='$link_title'>$text</a>";
  1413. $rtn .= "</span>";
  1414. }
  1415. else {
  1416. // Render as a button
  1417. $rtn .= fp_render_button($title, $on_click, $extra_class);
  1418. }
  1419. }
  1420. $rtn .= "</div>";
  1421. return $rtn;
  1422. }
  1423. /**
  1424. * Returns the HTML to draw a pretty button.
  1425. *
  1426. */
  1427. function fp_render_button($title, $on_click, $extra_class = "") {
  1428. // we want to add on a variable-name-friendly version of the title to extra_class.
  1429. $extra_class .= " fp-render-button-" . fp_get_machine_readable(strtolower($title));
  1430. $rtn = "<button class='fp-render-button $extra_class' onClick='$on_click'>$title</button>";
  1431. return $rtn;
  1432. }
  1433. function fp_render_mobile_tab_array($tab_array) {
  1434. $rtn = "";
  1435. $js_vars = "var mobileTabSelections = new Array(); ";
  1436. if (count($tab_array) <= 1) return "";
  1437. $rtn .= "<table border='0' width='200' cellpadding='0' cellspacing='0' class='fp-mobile-tabs'>
  1438. <td>
  1439. <b>" . t("Display") . ": </b>";
  1440. $rtn .= "<select onChange='executeSelection()' id='mobileTabsSelect'>";
  1441. for ($t = 0; $t < count($tab_array); $t++)
  1442. {
  1443. $title = $tab_array[$t]["title"];
  1444. $active = $tab_array[$t]["active"];
  1445. $on_click = $tab_array[$t]["on_click"];
  1446. if ($title == "")
  1447. {
  1448. continue;
  1449. }
  1450. $sel = ($active == true) ? $sel = "selected":"";
  1451. $rtn .= "<option $sel value='$t'>$title</option>";
  1452. $js_vars .= "mobileTabSelections[$t] = '$on_click'; \n";
  1453. }
  1454. $rtn .= "</select>
  1455. </td></table>";
  1456. $rtn .= '
  1457. <script type="text/javascript">
  1458. ' . $js_vars . '
  1459. function executeSelection() {
  1460. var sel = document.getElementById("mobileTabsSelect").value;
  1461. var statement = mobileTabSelections[sel];
  1462. // Lets execute the statement...
  1463. eval(statement);
  1464. }
  1465. </script>
  1466. ';
  1467. return $rtn;
  1468. }
  1469. /**
  1470. * Given a propperly formatted tab_array, this will return the HTML
  1471. * to draw it on a page.
  1472. *
  1473. * @param array $tab_array
  1474. * - Array should have this structure:
  1475. * - $tab_array[i]["title"] = The title or caption of the tab. "main", or "Edit", etc.
  1476. * - $tab_array[i]["active"] = boolean. True if this is the tab we are currently looking at.
  1477. * - $tab_array[i]["href"] = This is a complete href for the link we will create.
  1478. * - $tab_array[i]["on_click"] = This is an onClick command for javascript. If this is set, href will be ignored.
  1479. *
  1480. * @return string
  1481. */
  1482. function fp_render_tab_array($tab_array) {
  1483. $rtn = "";
  1484. if (count($tab_array) == 0) return "";
  1485. $img_path = fp_theme_location() . "/images";
  1486. $rtn .= "<ul class='tabs'>";
  1487. for ($t = 0; $t < count($tab_array); $t++)
  1488. {
  1489. $title = @$tab_array[$t]["title"];
  1490. // If the title has a replacement pattern in it, then we need to call a hook to see what it should be set to.
  1491. if (strpos($title, "%") !== 0) {
  1492. $title = menu_convert_replacement_pattern($title);
  1493. }
  1494. $active = @$tab_array[$t]["active"];
  1495. $on_click = @$tab_array[$t]["on_click"];
  1496. $href = @$tab_array[$t]["href"];
  1497. $extra_a = "";
  1498. if ($on_click != "") {
  1499. $href = "javascript:void(0);";
  1500. $extra_a = "onclick='$on_click'";
  1501. }
  1502. if ($title == "")
  1503. {
  1504. continue;
  1505. }
  1506. $extra_class = "inactive";
  1507. if ($active) {
  1508. $extra_class = "active";
  1509. // the active tab is not clickable.
  1510. $href = 'javascript:void(0);';
  1511. $extra_a = '';
  1512. }
  1513. if ($t == 0) $extra_class .= " first";
  1514. if ($t == count($tab_array) - 1) $extra_class .= " last";
  1515. // Also add in a machine-friendly class based on the title and position
  1516. $extra_class .= " tab-count-$t tab-title-" . fp_get_machine_readable(strtolower(trim($title)));
  1517. $rtn .= "<li class='tab $extra_class'><a href='$href' $extra_a>$title</a></li>";
  1518. }
  1519. $rtn .= "</ul>";
  1520. return $rtn;
  1521. }
  1522. function display_not_found() {
  1523. header("HTTP/1.0 404 Not Found", TRUE, 404);
  1524. $page = array(
  1525. "title" => t("Not Found"),
  1526. "content" => "<h2>" . t("Page not found") . "</h2>" . t("Sorry, the requested page could not be found."),
  1527. );
  1528. $location = @$_SERVER["REQUEST_URI"];
  1529. watchdog("page_not_found", "404 - Page not found (" . strip_tags($location) . ")", array(), WATCHDOG_DEBUG);
  1530. fp_display_page($page);
  1531. die;
  1532. }
  1533. function display_access_denied() {
  1534. header('HTTP/1.1 403 Forbidden', TRUE, 403);
  1535. $page = array(
  1536. "title" => t("Access Denied"),
  1537. "content" => "<h2>" . t("Access Denied") . "</h2>" . t("Sorry, but you do not have access to the requested page or function."),
  1538. );
  1539. $location = @$_SERVER["REQUEST_URI"];
  1540. watchdog("access_denied", "403 - Access denied (" . strip_tags($location) . ")", array(), WATCHDOG_DEBUG);
  1541. fp_display_page($page);
  1542. die;
  1543. }
  1544. /**
  1545. * Return the theme location
  1546. */
  1547. function fp_theme_location($bool_include_base_path = TRUE) {
  1548. $p = variable_get("theme",'themes/fp6_clean');
  1549. // The theme hasn't been set for some reason
  1550. if ($p == "") {
  1551. $p = "themes/fp6_clean";
  1552. }
  1553. if ($bool_include_base_path) {
  1554. $bp = base_path();
  1555. // The following code is to fix a bug where we might end up with // as our location, if our base_path is simply "/", meaning,
  1556. // the site is located on a bare domain.
  1557. if ($bp != "/") {
  1558. $p = base_path() . "/" . $p;
  1559. }
  1560. else {
  1561. $p = "/" . $p;
  1562. }
  1563. }
  1564. return $p;
  1565. }
  1566. /**
  1567. * Will draw a string in a pretty curved box. Used for displaying semester
  1568. * titles.
  1569. *
  1570. * @param string $title
  1571. * @return string
  1572. */
  1573. function fp_render_curved_line($text) {
  1574. depricated_message();
  1575. // Will simply draw a curved title bar containing the $title
  1576. // as the text.
  1577. $rtn = "
  1578. <div class='blueTitle' style='text-align: center; border-radius: 5px; padding: 1px;'>
  1579. <span class='tenpt'><b>$text</b></span>
  1580. </div>
  1581. ";
  1582. return $rtn;
  1583. }
  1584. function fp_render_section_title($text, $extra_class = '') {
  1585. $extra_class .= " section-box-text-" . fp_get_machine_readable(strtolower(trim($text)));
  1586. $rtn = "<div class='section-box-title section-box-title-$extra_class'>$text</div>";
  1587. return $rtn;
  1588. }
  1589. /**
  1590. * Will draw a string in a pretty square box. Used for displaying semester
  1591. * titles.
  1592. *
  1593. * @param string $title
  1594. * @return string
  1595. */
  1596. function fp_render_square_line($text) {
  1597. depricated_message("render_square_line");
  1598. $rtn = "";
  1599. $rtn .= "
  1600. <table border='0' width='100%' cellpadding='0' cellspacing='0'>
  1601. <tr>
  1602. <td width='10%' align='left' valign='top'></td>
  1603. <td width='80%' align='center' rowspan='2'>
  1604. <span class='tenpt' style='color: white' ><b>$text</b></span>
  1605. </td>
  1606. <td width='10%' align='right' valign='top'></td>
  1607. </tr>
  1608. <tr>
  1609. <td align='left' valign='bottom'></td>
  1610. <td align='right' valign='bottom'></td>
  1611. </tr>
  1612. </table>
  1613. ";
  1614. return $rtn;
  1615. }
  1616. function fp_render_menu_item($item, $bool_check_user_access = TRUE) {
  1617. $rtn = "";
  1618. if ($bool_check_user_access) {
  1619. if (!menu_check_user_access($item)) {
  1620. return "";
  1621. }
  1622. }
  1623. $description = $item["description"];
  1624. $title = $item["title"];
  1625. $safe_title = htmlentities(trim($title), ENT_QUOTES);
  1626. //$url = $GLOBALS["fp_system_settings"]["base_path"] . "/" . $item["path"];
  1627. $url = fp_url($item["path"], "", TRUE);
  1628. $target = @$item["page_settings"]["target"];
  1629. $menu_icon = @$item["page_settings"]["menu_icon"];
  1630. $extra_class = "";
  1631. if ($menu_icon != "") {
  1632. if (!strstr($menu_icon, 'http')) {
  1633. $base_url = $GLOBALS['fp_system_settings']['base_url'];
  1634. if ($base_url == "/") $base_url = ""; // so that we don't have // as a path, because of the next line.
  1635. if (substr($menu_icon, 0, 1) == '/') {
  1636. // Already starts with a slash, so probably should just use as is.
  1637. // take no action.
  1638. }
  1639. else {
  1640. $menu_icon = $base_url . "/" . $menu_icon;
  1641. }
  1642. }
  1643. $icon_img = "<img src='$menu_icon' border='0' class='fpmn-icon' alt='$safe_title'>";
  1644. }
  1645. else {
  1646. $icon_img = "<span class='fp-menu-item-no-icon'></span>";
  1647. }
  1648. if (!$description) $extra_class = "fp-menu-item-tight";
  1649. $machine_title = strtolower(fp_get_machine_readable($title));
  1650. $machine_path = strtolower(fp_get_machine_readable($item['path']));
  1651. $extra_class .= " fp-menu-item-title-$machine_title fp-menu-item-path-$machine_path ";
  1652. $rtn .= "<div class='fp-menu-item $extra_class'>
  1653. <div class='fp-menu-item-link-line'>
  1654. <a href='$url' target='$target'>$icon_img$title</a>
  1655. </div>
  1656. ";
  1657. if ($description) {
  1658. $rtn .= " <div class='fp-menu-item-description'>$description</div>";
  1659. }
  1660. $rtn .= "</div>";
  1661. return $rtn;
  1662. }
  1663. /**
  1664. * Alias of pretty_print($var)
  1665. */
  1666. function ppm($var, $b = FALSE) {
  1667. return pretty_print($var, $b);
  1668. }
  1669. function pretty_print($var, $bool_return = FALSE) {
  1670. $x = "<pre>" . print_r($var, true) . "</pre>";
  1671. if ($bool_return) return $x;
  1672. print $x;
  1673. }

Functions

Namesort descending Description
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_push_and_balance_profile_items This function accepts a "profile items" array by reference, which is presumed to have a "left_side" and a "right_side" already defined. We can "push" items onto it, and the item will automatically go to the…
fp_render_breadcrumbs Return the HTML for breadcrumbs for the current page we are on. Will skip any breadcrumbs we do not have permission to access.
fp_render_button Returns the HTML to draw a pretty button.
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_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" or…
fp_render_menu_item
fp_render_mobile_hamburger_menu This will create the HTML content for the "mobile hamburger" menu, which appears when we press the 3 lines icon or "hamburger" icon on a mobile device.
fp_render_mobile_tab_array
fp_render_section_title
fp_render_sidebar_left_content Returns the HTML for the left sidebar content.
fp_render_square_line Will draw a string in a pretty square box. Used for displaying semester titles.
fp_render_student_profile_header Returns the HTML for the "profile" header html for a student
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_render_top_nav_content Returns the HTML for the top navigation content of the screen itself.
fp_show_title Sets whether the title should be shown on the page or not.
fp_theme_location Return the theme location
pager_get_querystring Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/pager_ge...
pager_load_array Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/pager_lo...
ppm Alias of pretty_print($var)
pretty_print
theme_pager Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pa...
theme_pager_first Adapted from: https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pa...
theme_pager_last Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pa...
theme_pager_link Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pa...
theme_pager_next Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pa...
theme_pager_previous Adapted from https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pa...
theme_table_header_sortable Given an array of table headers (in the format listed below), returns back the HTML to draw it to the screen. This makes them clickable, to make the table header sortable. This is meant to be used with queries, by adding in an "ORDER BY"…
theme_table_header_sortable_order_by Used with the theme_table_header_sortable function (meant to be called AFTER headers have been created.)
theme_table_header_sortable_set_initial_sort Sets our initial sort, if there isn't already one set.