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