r639: Adding pre-parse hook so that the userland help system will work
[bugdar.git] / global.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 require_once('./includes/init.php');
14
15 // ###################################################################
16 // initialize template system
17 $bugsys->load('template_fs');
18 $template->extension = 'tpl';
19 $template->pre_parse_hook = 'isso_pre_parse_hook';
20 $template->templatedir = $bugsys->fetch_sourcepath('templates/');
21
22 // ###################################################################
23 // global template variables
24 $datetime = $datef->format('l, F j, Y g:i A');
25 $year = $datef->format('Y');
26 $version = $bugsys->options['trackerversion'];
27
28 $show['admin'] = (bool)can_perform('canadminpanel');
29 $show['newreport'] = (bool)can_perform('cansubmitbugs');
30 $show['search'] = (bool)can_perform('cansearch');
31
32 // ###################################################################
33 // do style vars
34 if (($raw = @file_get_contents('./templates/stylevars.txt')) !== false)
35 {
36 // remove comments
37 $raw = preg_replace('#/\*(.*?)\*/#s', '', $raw);
38 $raw = trim($raw);
39
40 // create individual vars
41 $varsraw = explode(';', $raw);
42 foreach ($varsraw AS $var)
43 {
44 if (($var = trim($var)) == '')
45 {
46 continue;
47 }
48
49 // split into varname - value pair
50 $temp = explode(':', $var);
51
52 // clean up varnames
53 $varname = trim($temp[0]);
54 $varname = preg_replace('#[^a-z0-9]#i', '_', $varname);
55
56 // clean up values
57 $value = trim($temp[1]);
58 $value = preg_replace('#[^a-z0-9%\-\.\#]#i', '', $value);
59
60 // put it in the array
61 $stylevar["$varname"] = $value;
62 }
63 }
64 else
65 {
66 trigger_error('StyleVars file (./templates/stylevars.txt) could not be loaded', E_USER_WARNING);
67 }
68
69 // ###################################################################
70 // cache templates
71 $globaltemplates = array(
72 'doctype',
73 'header',
74 'headinclude',
75 'footer',
76 'selectoption',
77 'selectoptgroup',
78 'std_error',
79 'std_redirect',
80 'std_message',
81 'bugfield_input_text',
82 'bugfield_input_checkbox',
83 'bugfield_select_single_option',
84 'bugfield_select_single',
85 'username_display'
86 );
87
88 $start = microtime();
89
90 $template->cache(array_merge($globaltemplates, (array)$fetchtemplates));
91
92 $bugsys->debug('time for tpl cache: ' . $funct->fetch_microtime_diff($start));
93
94 eval('$header = "' . $template->fetch('header') . '";');
95 eval('$doctype = "' . $template->fetch('doctype') . '";');
96 eval('$headinclude = "' . $template->fetch('headinclude') . '";');
97 eval('$footer = "' . $template->fetch('footer') . '";');
98
99 // ###################################################################
100
101 // ###################################################################
102 // initialize template variables
103 $show = array();
104
105 // ###################################################################
106 // create error reporter
107 require_once('./includes/class_message_reporter.php');
108 $message = new Message_Reporter();
109 $bugsys->message =& $message;
110
111 /*=====================================================================*\
112 || ###################################################################
113 || # $HeadURL$
114 || # $Id$
115 || ###################################################################
116 \*=====================================================================*/
117 ?>