r850: Adding email options interface and backbone, though it doesn't send anything...
[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 define('HTML_CHECKED', ' checked="checked"');
25
26 // ###################################################################
27 // initialize template system
28 $bugsys->load('template_fs', 'template', true);
29 $template->set('extension', 'tpl');
30 $template->set('pre_parse_hook', 'isso_pre_parse_hook');
31 $template->set('templatedir', 'templates/');
32
33 // ###################################################################
34 // global template variables
35 $datetime = $datef->format('l, F j, Y g:i A');
36 $year = $datef->format('Y');
37 $version = $bugsys->options['trackerversion'];
38
39 $show['admin'] = (bool)can_perform('canadminpanel');
40 $show['newreport'] = (bool)can_perform('cansubmitbugs');
41 $show['search'] = (bool)can_perform('cansearch');
42
43 // ###################################################################
44 // do style vars
45 if (($raw = @file_get_contents('./templates/stylevars.txt')) !== false)
46 {
47 // remove comments
48 $raw = preg_replace('#/\*(.*?)\*/#s', '', $raw);
49 $raw = trim($raw);
50
51 // create individual vars
52 $varsraw = explode(';', $raw);
53 foreach ($varsraw AS $var)
54 {
55 if (($var = trim($var)) == '')
56 {
57 continue;
58 }
59
60 // split into varname - value pair
61 $temp = explode(':', $var);
62
63 // clean up varnames
64 $varname = trim($temp[0]);
65 $varname = preg_replace('#[^a-z0-9]#i', '_', $varname);
66
67 // clean up values
68 $value = trim($temp[1]);
69 $value = preg_replace('#[^a-z0-9%\-\.\#]#i', '', $value);
70
71 // put it in the array
72 $stylevar["$varname"] = $value;
73 }
74 }
75 else
76 {
77 trigger_error('StyleVars file (./templates/stylevars.txt) could not be loaded', E_USER_WARNING);
78 }
79
80 // ###################################################################
81 // cache templates
82 $globaltemplates = array(
83 'doctype',
84 'header',
85 'headinclude',
86 'footer',
87 'selectoption',
88 'selectoptgroup',
89 'std_error',
90 'std_redirect',
91 'std_message',
92 'bugfield_input_text',
93 'bugfield_input_checkbox',
94 'bugfield_select_single_option',
95 'bugfield_select_single',
96 'username_display',
97 'help_link'
98 );
99
100 $start = microtime();
101
102 $template->cache(array_merge($globaltemplates, (array)$fetchtemplates));
103
104 $bugsys->debug('time for tpl cache: ' . $funct->fetch_microtime_diff($start));
105
106 eval('$header = "' . $template->fetch('header') . '";');
107 eval('$doctype = "' . $template->fetch('doctype') . '";');
108 eval('$headinclude = "' . $template->fetch('headinclude') . '";');
109 eval('$footer = "' . $template->fetch('footer') . '";');
110
111 // ###################################################################
112
113 // ###################################################################
114 // initialize template variables
115 $show = array();
116
117 // ###################################################################
118 // create error reporter
119 require_once('./includes/class_message_reporter.php');
120 $message = new Message_Reporter();
121 $bugsys->message =& $message;
122
123 /*=====================================================================*\
124 || ###################################################################
125 || # $HeadURL$
126 || # $Id$
127 || ###################################################################
128 \*=====================================================================*/
129 ?>