function AdvisingScreen::output_to_browser
Search API
7.x AdvisingScreen.php | AdvisingScreen::output_to_browser() |
6.x AdvisingScreen.php | AdvisingScreen::output_to_browser() |
This method outputs the screen to the browser by performing an include(path-to-theme-file.php). All necessary information must be placed into certain variables before the include happens.
File
- classes/
AdvisingScreen.php, line 272
Class
Code
function output_to_browser()
{
global $user, $current_student_id;
// This method will output the screen to the browser.
// outputs the $page_content variable.
// Figure out our school id.
$school_id = $user->school_id;
if ($current_student_id) {
$school_id = db_get_school_id_for_student_id($current_student_id);
}
else if (isset($this->student) && is_object($this->student)) {
$school_id = $this->student->school_id;
}
else if (isset($this->degree_plan) && is_object($this->degree_plan)) {
$school_id = $this->degree_plan->school_id;
}
$theme_location = fp_theme_location(); // file location of the theme folder
$page_logo_url = variable_get("logo_image_url", "");
if ($page_logo_url == "") {
$page_logo_url = $theme_location . "/images/fp_banner_default.png";
}
$page_content = $this->page_content;
$page_tabs = $this->page_tabs;
$page_has_search = $this->page_has_search;
$page_on_load = $this->page_on_load;
$page_scroll_top = $this->page_scroll_top;
$page_is_popup = $this->page_is_popup;
$page_title = $this->page_title;
$page_body_classes = $this->page_body_classes;
// Are we explicitly setting that this is a popup in the URL?
if (isset($_REQUEST ['window_mode']) && $_REQUEST ['window_mode'] == 'popup') {
$page_is_popup = TRUE;
}
$page_extra_js_files = "";
$page_extra_js_settings = "";
$page_extra_css_files = "";
$page_breadcrumbs = "";
$system_name = variable_get("system_name", "FlightPath");
if ($page_title == "") {
// By default, page title is this...
$page_title = variable_get_for_school("school_initials", "DEMO", $school_id) . " " . $system_name;
}
$page_title = menu_convert_replacement_pattern($page_title);
$page_display_title = $page_title;
if (isset($GLOBALS ["fp_set_show_title"]) && $GLOBALS ["fp_set_show_title"] === FALSE) {
$page_display_title = "";
}
$page_title = strip_tags($page_title);
$page_breadcrumbs = fp_render_breadcrumbs();
if ($this->student && $this->page_display_currently_advising == TRUE && !$page_is_popup) {
$page_student_profile_header = fp_render_student_profile_header();
}
$page_hide_report_error = $this->page_hide_report_error;
// We don't have permission, so do not show the report error link regardless.
if (!user_has_permission('access_popup_report_contact')) {
$page_hide_report_error = TRUE;
}
$print_option = "";
if ($this->bool_print == true) {
$page_body_classes .= " bool-print";
}
if ($page_is_popup) {
$page_body_classes .= " page-is-popup";
}
$page_body_classes .= " school-id-" . $school_id;
if (module_enabled('schools')) {
$page_body_classes .= " school-code-" . schools_get_school_code_for_id($school_id);
}
// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
// flush, forcing browsers to load a new copy of the files, as the
// URL changed.
$page_css_js_query_string = variable_get('css_js_query_string', '0');
// Add extra JS files.
if (is_array($GLOBALS ["fp_extra_js"]) && count($GLOBALS ["fp_extra_js"]) > 0) {
foreach ($GLOBALS ["fp_extra_js"] as $js_file_name) {
$page_extra_js_files .= "<script type='text/javascript' src='$js_file_name?$page_css_js_query_string'></script> \n";
}
}
// Load any extra CSS files which addon modules might have added.
if (isset($GLOBALS ["fp_extra_css"]) && is_array($GLOBALS ["fp_extra_css"]) && count($GLOBALS ["fp_extra_css"]) > 0) {
foreach ($GLOBALS ["fp_extra_css"] as $css_file_name) {
$page_extra_css_files .= "<link rel='stylesheet' type='text/css' href='$css_file_name?$page_css_js_query_string' /> \n";
}
}
// Javascript settings... (I know this would be better as a recursive function. For now,
// you can have up to 3 layers deep. Sorry for it looking so ugly.
$page_extra_js_settings .= "var FlightPath = new Object(); \n";
$page_extra_js_settings .= " FlightPath.settings = new Object(); \n";
foreach ($GLOBALS ["fp_extra_js_settings"] as $key => $val) {
if (is_array($val)) {
$page_extra_js_settings .= "FlightPath.settings.$key = new Array(); \n";
foreach ($val as $k => $v) {
if (is_array($v)) {
$page_extra_js_settings .= "FlightPath.settings.$key" . "['" . "$k'] = new Array(); \n";
foreach ($v as $kk => $vv) {
$page_extra_js_settings .= "FlightPath.settings.$key" . "['" . "$k']['$kk'] = '$vv'; \n";
}
}
else {
$page_extra_js_settings .= "FlightPath.settings.$key" . "['" . "$k'] = '$v'; \n";
}
}
}
else {
$page_extra_js_settings .= "FlightPath.settings.$key = '$val'; \n";
}
}
// Scrolling somewhere? Add it to the page_on_load...
if (trim($page_scroll_top != "")) {
$page_on_load .= " scrollTo(0, $page_scroll_top);";
}
// Add our dialog HTML if the page isn't a popup.
if (!$page_is_popup) {
$page_content .= "
<!-- iframe dialog, for use by javascript later on -->
<div id='fp-iframe-dialog-small' style='display: none;' title=''>
<iframe id='fp-iframe-dialog-small-iframe' class='dialog-iframe' ></iframe>
</div>
<div id='fp-iframe-dialog-large' style='display: none;' title=''>
<iframe id='fp-iframe-dialog-large-iframe' class='dialog-iframe' ></iframe>
</div>
";
}
else {
// The page is in a dialog. In order to cope with a strange bug in Chrome (as of 10-29-2020), we need
// to "nudge" the dialog window 1 pixel, or sometimes the internal iframe will not show up.
// We do this after it loads.
$page_on_load .= "\n\n // From: https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser \n\n";
$page_on_load .= ' var browser = (function() {
var test = function(regexp) {return regexp.test(window.navigator.userAgent)}
switch (true) {
case test(/edg/i): return "Microsoft Edge";
case test(/trident/i): return "Microsoft Internet Explorer";
case test(/firefox|fxios/i): return "Mozilla Firefox";
case test(/opr\//i): return "Opera";
case test(/ucbrowser/i): return "UC Browser";
case test(/samsungbrowser/i): return "Samsung Browser";
case test(/chrome|chromium|crios/i): return "Google Chrome";
case test(/safari/i): return "Apple Safari";
default: return "Other";
}
})();';
$page_on_load .= " if (browser == 'Google Chrome') {
parent.fpNudgeDialog();
}";
}
// Grab the appropriate sidebar & top nav content (if any)
$page_sidebar_left_content = $page_top_nav_content = "";
if (!$page_is_popup) {
$page_sidebar_left_content = fp_render_sidebar_left_content();
$page_top_nav_content = fp_render_top_nav_content();
}
if ($page_sidebar_left_content) {
$page_body_classes .= " has-sidebar-left";
}
if ($page_tabs) {
$page_body_classes .= " has-page-tabs";
}
// We are going to try to include the theme. If it can't be found, we will display a CORE theme, and display a message.
$theme = variable_get("theme", "themes/fp_clean");
$head_template_filename = $theme . "/head.tpl.php";
$page_template_filename = $theme . "/page.tpl.php";
// If there is a special theme file we should be using based on the URL, set it here.
$q = fp_trim(strtolower((string) $_REQUEST ['q']));
if ($q) {
$q = trim(str_replace("/", "-", $q));
if ($q) {
if (file_exists($theme . "/page--" . $q . ".tpl.php")) {
$page_template_filename = $theme . "/page--" . $q . ".tpl.php";
}
}
}
if (!file_exists($page_template_filename)) {
print "<p><b>Theme Error:</b> Tried to load template from: $page_template_filename, but this file could not be found.
<br>This is possibly because either the filename or the directory specified does not exist.
<br>Contact site administrator.</p>";
$page_template_filename = "themes/fp_clean" . "/page.tpl.php";
}
// Are we adding any external CSS files?
$external_css = variable_get("external_css", "");
if ($external_css) {
$temp = explode(",", $external_css);
foreach ($temp as $line) {
if (trim($line) == "") {
continue;
}
$page_extra_css_files .= "<link rel='stylesheet' type='text/css' href='" . trim($line) . "?$page_css_js_query_string' /> \n";
}
}
/////////////////////////
// Output to browser:
include ($head_template_filename);
include ($page_template_filename);
}