Javascript libs caching
[fa-stable.git] / includes / page / header.inc
1 <?php
2
3 function help_url($title, $app)
4 {
5
6         global $help_page_url, $help_base_url, $applications, $help_page_title;
7
8         if (isset($help_page_url))
9         {
10                 return $help_base_url.$help_page_url;
11         }
12
13         $help_page_url = '';
14         if (isset($help_page_title))
15         {
16                 $help_page_url = $help_page_title;
17         }
18         elseif ($title==_("Main Menu"))
19         {
20                 $help_page_url = $applications[$app];
21         }
22         else
23         {
24                 $help_page_url = $title;
25         }
26
27         return $help_base_url.urlencode(str_replace(' ', '', ucwords($help_page_url)));
28 }
29
30 function page_header($title, $no_menu=false, $is_index=false, $onload="", $js="")
31 {
32         // titles and screen header
33         global $db_connections, $path_to_root, $def_app, $applications,
34                 $help_base_url, $help_page_url, $use_popup_windows,
35                 $js_lib, $js_static, $js_path, $js_userlib, $comp_path;
36
37         if (isset($_GET['ajax'])) return;
38
39         $theme = user_theme();
40         $local_path_to_root = $path_to_root;
41
42         if ($help_base_url != null && $use_popup_windows && $js == '')
43         {
44                 if (!function_exists('get_js_open_window'))
45                 {
46                         include_once($path_to_root.'/includes/ui/ui_view.inc');
47                 }
48                 $js = get_js_open_window(900, 500);
49         }
50
51         add_js_user_num(); // add user native numeric input functions
52         // javascript includes collect
53         add_js_source($js);
54         $js ='';
55         foreach($js_static as $jsfile) {
56           $js .= '<script language="javascript" type="text/javascript" src="'.
57                 $js_path . $jsfile . '"></script>';
58         }
59         foreach($js_userlib as $jsfile) {
60           $js .= '<script language="javascript" type="text/javascript" src="'.
61             $jsfile . '"></script>';
62         }
63         foreach($js_lib as $text) {
64           $js .= $text;
65         }
66         if (!isset($no_menu))
67         {
68                 $no_menu = false;
69         }
70         if (!isset($_SESSION["sel_app"]))
71                 session_register("sel_app");
72         if (isset($_SESSION["App"]) && is_object($_SESSION["App"]) && isset($_SESSION["App"]->selected_application) &&
73                 $_SESSION["App"]->selected_application != "")
74                 $sel_app = $_SESSION["App"]->selected_application;
75         elseif (isset($_SESSION["sel_app"]) && $_SESSION["sel_app"] != "")
76                 $sel_app = $_SESSION["sel_app"];
77         else
78                 $sel_app = $def_app;
79         $_SESSION["sel_app"] = $sel_app;
80
81         echo "<html dir='" . $_SESSION['language']->dir . "' >";
82         echo "<head><title>$title</title>";
83         $encoding = $_SESSION['language']->encoding;
84         $local_stylesheet = $_SESSION['language']->get_stylesheet();
85         echo "<meta http-equiv='Content-type' content='text/html'; charset='$encoding'>";
86         echo "<link href='$local_path_to_root/themes/$theme/default.css' rel='stylesheet' type='text/css' /> \n";
87         if (file_exists($local_path_to_root. "/".$local_stylesheet))
88                 echo "<link href='$local_path_to_root/$local_stylesheet' rel='stylesheet' type='text/css' /> \n";
89         if ($js != "")
90                 echo $js;
91         echo "</head> \n";
92         if ($onload == "")
93                 echo "<body>";
94         else
95                 echo "<body onload=\"$onload\">";
96         echo "<script language='javascript' src='".
97           $path_to_root. "/js/inserts.js' type='text/javascript'></script>\n";
98         echo "<table class='callout_main' border='0' cellpadding='0' cellspacing='0'>\n";
99         echo "<tr>\n";
100         echo "<td colspan='2' rowspan='2'>\n";
101
102         echo "<table class='main_page' border='0' cellpadding='0' cellspacing='0'>\n";
103         echo "<tr>\n";
104         echo "<td>\n";
105         echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
106         echo "<tr>\n";
107         echo "<td class='quick_menu'>\n";
108         if (!$no_menu)
109         {
110                 echo "<table cellpadding=0 cellspacing=0 width='100%'><tr><td>";
111                 echo "<div class=tabs>";
112                 foreach($applications as $app => $name)
113                 {
114                         echo "<a ".($sel_app == $app ? "class='selected' " : "").
115                         "href='$local_path_to_root/index.php?application=".$app.
116                                 SID ."'>" .$name . "</a>";
117                 }
118                 echo "</div>";
119
120                 echo "</td></tr></table>";
121
122                 echo "<table class=logoutBar>";
123                 echo "<tr><td class=headingtext3>" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . " | " . $_SERVER['SERVER_NAME'] . " | " . $_SESSION["wa_current_user"]->name . "</td>";
124                 if ($help_base_url != null)
125                 {
126
127                         echo "<td align=right ><a target = '_blank' onclick=" .'"'."javascript:openWindow(this.href,this.target); return false;".'" '. "href='". help_url($title, $sel_app)."'>" . _("Help") . "</a></td>";
128                 }
129                 echo "<td class=logoutBarRight><a href='$local_path_to_root/access/logout.php?'>" . _("Logout") . "</a>";
130                 echo "</td></tr></table>";
131         }
132
133         echo "</td></tr></table>";
134
135         if ($title && !$no_menu && !$is_index)
136         {
137                 echo "<center><table width='100%'><tr><td width='100%' class='titletext'>$title</td></tr></table></center>";
138         }
139
140         if (!$is_index)
141                 echo "<br>";
142 }
143
144 ?>