Javascript libs caching
[fa-stable.git] / includes / main.inc
1 <?php
2
3     include_once($path_to_root . "/includes/db/connect_db.inc");
4
5     include_once($path_to_root . "/includes/reserved.inc");
6     include_once($path_to_root . "/includes/errors.inc");
7     include_once($path_to_root . "/includes/types.inc");
8     include_once($path_to_root . "/includes/systypes.inc");
9     include_once($path_to_root . "/includes/references.inc");
10     include_once($path_to_root . "/includes/prefs/sysprefs.inc");
11     include_once($path_to_root . "/includes/db/comments_db.inc");
12     include_once($path_to_root . "/includes/db/sql_functions.inc");
13
14     include_once($path_to_root . "/admin/db/users_db.inc");
15     include_once($path_to_root . "/includes/ui/ui_view.inc");
16         
17     function page($title, $no_menu=false, $is_index=false, $onload="", $js="")
18     {
19
20         global $path_to_root, $js_lib;
21
22         $hide_menu = $no_menu;
23
24         include($path_to_root . "/includes/page/header.inc");
25
26         page_header($title, $no_menu, $is_index, $onload, $js);
27     }
28
29     function end_page($no_menu=false, $is_index=false)
30     {
31         global $path_to_root;
32
33         $hide_menu = $no_menu;
34
35         include($path_to_root . "/includes/page/footer.inc");
36
37         page_footer($no_menu, $is_index);
38     }
39
40     function flush_dir($path) {
41         $dir = opendir($path);
42         while(false !== ($fname = readdir($dir))) {
43                 if($fname=='.' || $fname=='..') continue;
44                 if(is_dir($path.'/'.$fname)) {
45                     flush_dir($path.'/'.$fname);
46                     rmdir($path.'/'.$fname);
47                 } else
48                     unlink($path.'/'.$fname);
49         }
50     }
51
52     function cache_js_file($fpath, $text) 
53     {
54
55     // FIX compress text ...
56
57     $file = fopen($fpath, 'w');
58     if (!$file) return false;
59     if (!fwrite($file, $text)) return false;
60     return fclose($file);
61
62     }
63
64     function add_js_file($filename) 
65     {
66           global $js_static;
67
68           $search = array_search($filename, $js_static);
69           if ($search === false || $search === null) // php>4.2.0 returns null
70                 $js_static[] = $filename;       
71     }
72
73     function add_js_ufile($filename) 
74     {
75           global $js_userlib;
76
77           $search = array_search($filename, $js_userlib);
78           if ($search === false || $search === null) // php>4.2.0 returns null
79                 $js_userlib[] = $filename;
80     }
81
82     function add_js_source($text) 
83     {
84           global $js_lib;
85           
86           $search = array_search($text, $js_lib);
87           if ($search === false || $search === null) // php>4.2.0 returns null
88                 $js_lib[] = $text;
89     }
90
91 ?>