Menu hotkeys system implementation.
[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 = access_string($applications[$app], true);
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 send_scripts()
31 {
32     global $js_lib, $js_static, $js_path, $js_userlib, $comp_path,
33         $path_to_root, $go_debug;
34
35         add_user_js_data();
36
37         $js ='';
38         foreach($js_static as $jsfile)
39         {
40             $fpath = $comp_path.'/'.user_company().'/js_cache/'.$jsfile;
41             // compress also static files
42                 if (!file_exists($fpath) || $go_debug)
43                         cache_js_file($fpath, file_get_contents($js_path.$jsfile));
44
45                 $js .= '<script language="javascript" type="text/javascript" src="'.
46                         $fpath . '"></script>';
47         }
48         foreach($js_userlib as $jsfile)
49         {
50                 $js .= '<script language="javascript" type="text/javascript" src="'.
51                 $jsfile . '"></script>';
52         }
53
54         foreach($js_lib as $text)
55         {
56                 $js .= $text;
57         }
58     echo $js;
59 }
60
61 function page_header($title, $no_menu=false, $is_index=false, $onload="", $js="")
62 {
63         // titles and screen header
64         global $path_to_root, $def_app, $use_popup_windows, $help_base_url;
65
66         if (in_ajax())
67                 return; // just for speed up
68
69         $theme = user_theme();
70         $local_path_to_root = $path_to_root;
71
72         if ($help_base_url != null && $use_popup_windows && $js == '')
73         {
74                 if (!function_exists('get_js_open_window'))
75                 {
76                         include_once($path_to_root.'/includes/ui/ui_view.inc');
77                 }
78                 add_js_source(get_js_open_window(900, 500));
79         }
80         if ($js!='')
81           add_js_source($js);
82
83         if (!isset($no_menu))
84         {
85                 $no_menu = false;
86         }
87         if (!isset($_SESSION["sel_app"]))
88                 session_register("sel_app");
89         if (isset($_SESSION["App"]) && is_object($_SESSION["App"]) && isset($_SESSION["App"]->selected_application) &&
90                 $_SESSION["App"]->selected_application != "")
91                 $sel_app = $_SESSION["App"]->selected_application;
92         elseif (isset($_SESSION["sel_app"]) && $_SESSION["sel_app"] != "")
93                 $sel_app = $_SESSION["sel_app"];
94         else
95                 $sel_app = $def_app;
96         $_SESSION["sel_app"] = $sel_app;
97         if (isset($_SESSION["App"]) && is_object($_SESSION["App"]))
98                 $_SESSION["App"]->selected_application = $sel_app;
99         $encoding = $_SESSION['language']->encoding;
100
101         if (!headers_sent()){
102                 header("Content-type: text/html; charset='$encoding'");
103         }
104         echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
105         echo "<html dir='" . $_SESSION['language']->dir . "' >\n";
106         echo "<head><title>$title</title>";
107         $local_stylesheet = $_SESSION['language']->get_stylesheet();
108         echo "<meta http-equiv='Content-type' content='text/html; charset=$encoding'>";
109         echo "<link href='$local_path_to_root/themes/$theme/default.css' rel='stylesheet' type='text/css'> \n";
110         if (file_exists($local_path_to_root. "/".$local_stylesheet))
111                 echo "<link href='$local_path_to_root/$local_stylesheet' rel='stylesheet' type='text/css'> \n";
112         send_scripts($js);
113
114         echo "</head> \n";
115         if ($onload == "")
116                 echo "<body>";
117         else
118                 echo "<body onload=\"$onload\">";
119         include_once($local_path_to_root."/themes/".user_theme()."/renderer.php");
120         $rend = new renderer();
121         $rend->menu_header($title, $no_menu, $is_index);
122 }
123
124 ?>