r972: Rebranding from Iris Studios to Blue Static
[bugdar.git] / global.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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 if (!defined('NO_TEMPLATES') OR (defined('NO_TEMPLATES') AND constant('NO_TEMPLATES') == true))
44 {
45 // ###################################################################
46 // do style vars
47 if (($raw = @file_get_contents('./templates/stylevars.txt')) !== false)
48 {
49 // remove comments
50 $raw = preg_replace('#/\*(.*?)\*/#s', '', $raw);
51 $raw = trim($raw);
52
53 // create individual vars
54 $varsraw = explode(';', $raw);
55 foreach ($varsraw AS $var)
56 {
57 if (($var = trim($var)) == '')
58 {
59 continue;
60 }
61
62 // split into varname - value pair
63 $temp = explode(':', $var);
64
65 // clean up varnames
66 $varname = trim($temp[0]);
67 $varname = preg_replace('#[^a-z0-9]#i', '_', $varname);
68
69 // clean up values
70 $value = trim($temp[1]);
71 $value = preg_replace('#[^a-z0-9%\-\.\#]#i', '', $value);
72
73 // put it in the array
74 $stylevar["$varname"] = $value;
75 }
76 }
77 else
78 {
79 trigger_error('StyleVars file (./templates/stylevars.txt) could not be loaded', E_USER_WARNING);
80 }
81
82 // ###################################################################
83 // cache templates
84 $globaltemplates = array(
85 'doctype',
86 'header',
87 'headinclude',
88 'footer',
89 'selectoption',
90 'selectoptgroup',
91 'std_error',
92 'std_redirect',
93 'std_message',
94 'bugfield_input_text',
95 'bugfield_input_checkbox',
96 'bugfield_select_single_option',
97 'bugfield_select_single',
98 'username_display',
99 'help_link'
100 );
101
102 $start = microtime();
103
104 $template->cache(array_merge($globaltemplates, (array)$fetchtemplates));
105
106 $bugsys->debug('time for tpl cache: ' . $funct->fetch_microtime_diff($start));
107
108 eval('$header = "' . $template->fetch('header') . '";');
109 eval('$doctype = "' . $template->fetch('doctype') . '";');
110 eval('$headinclude = "' . $template->fetch('headinclude') . '";');
111 eval('$footer = "' . $template->fetch('footer') . '";');
112 }
113
114 // ###################################################################
115
116 // ###################################################################
117 // initialize template variables
118 $show = array();
119
120 // ###################################################################
121 // create error reporter
122 require_once('./includes/class_message_reporter.php');
123 $message = new Message_Reporter();
124 $bugsys->message =& $message;
125
126 /*=====================================================================*\
127 || ###################################################################
128 || # $HeadURL$
129 || # $Id$
130 || ###################################################################
131 \*=====================================================================*/
132 ?>