r767: Linking to ISSO2 is done
[bugdar.git] / global.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 require_once('./includes/init.php');
23
24 // ###################################################################
25 // initialize template system
26 $bugsys->load('template_fs', 'template', true);
27 $template->set('extension', 'tpl');
28 $template->set('pre_parse_hook', 'isso_pre_parse_hook');
29 $template->set('templatedir', 'templates/');
30
31 // ###################################################################
32 // global template variables
33 $datetime = $datef->format('l, F j, Y g:i A');
34 $year = $datef->format('Y');
35 $version = $bugsys->options['trackerversion'];
36
37 $show['admin'] = (bool)can_perform('canadminpanel');
38 $show['newreport'] = (bool)can_perform('cansubmitbugs');
39 $show['search'] = (bool)can_perform('cansearch');
40
41 // ###################################################################
42 // do style vars
43 if (($raw = @file_get_contents('./templates/stylevars.txt')) !== false)
44 {
45 // remove comments
46 $raw = preg_replace('#/\*(.*?)\*/#s', '', $raw);
47 $raw = trim($raw);
48
49 // create individual vars
50 $varsraw = explode(';', $raw);
51 foreach ($varsraw AS $var)
52 {
53 if (($var = trim($var)) == '')
54 {
55 continue;
56 }
57
58 // split into varname - value pair
59 $temp = explode(':', $var);
60
61 // clean up varnames
62 $varname = trim($temp[0]);
63 $varname = preg_replace('#[^a-z0-9]#i', '_', $varname);
64
65 // clean up values
66 $value = trim($temp[1]);
67 $value = preg_replace('#[^a-z0-9%\-\.\#]#i', '', $value);
68
69 // put it in the array
70 $stylevar["$varname"] = $value;
71 }
72 }
73 else
74 {
75 trigger_error('StyleVars file (./templates/stylevars.txt) could not be loaded', E_USER_WARNING);
76 }
77
78 // ###################################################################
79 // cache templates
80 $globaltemplates = array(
81 'doctype',
82 'header',
83 'headinclude',
84 'footer',
85 'selectoption',
86 'selectoptgroup',
87 'std_error',
88 'std_redirect',
89 'std_message',
90 'bugfield_input_text',
91 'bugfield_input_checkbox',
92 'bugfield_select_single_option',
93 'bugfield_select_single',
94 'username_display',
95 'help_link'
96 );
97
98 $start = microtime();
99
100 $template->cache(array_merge($globaltemplates, (array)$fetchtemplates));
101
102 $bugsys->debug('time for tpl cache: ' . $funct->fetch_microtime_diff($start));
103
104 eval('$header = "' . $template->fetch('header') . '";');
105 eval('$doctype = "' . $template->fetch('doctype') . '";');
106 eval('$headinclude = "' . $template->fetch('headinclude') . '";');
107 eval('$footer = "' . $template->fetch('footer') . '";');
108
109 // ###################################################################
110
111 // ###################################################################
112 // initialize template variables
113 $show = array();
114
115 // ###################################################################
116 // create error reporter
117 require_once('./includes/class_message_reporter.php');
118 $message = new Message_Reporter();
119 $bugsys->message =& $message;
120
121 /*=====================================================================*\
122 || ###################################################################
123 || # $HeadURL$
124 || # $Id$
125 || ###################################################################
126 \*=====================================================================*/
127 ?>