From 51d820bd27fb251342c706af249d09369aa5c73d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 11 Jul 2005 00:43:54 +0000 Subject: [PATCH] r311: Added stylevar system. --- global.php | 39 +++++++++++++++++++++++++++ includes/class_message_reporter.php | 6 ++--- templates/stylevars.dsv | 41 +++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 templates/stylevars.dsv diff --git a/global.php b/global.php index 789aa36..926faa9 100755 --- a/global.php +++ b/global.php @@ -24,6 +24,43 @@ $datetime = $datef->format('l, F j, Y g:i A'); $year = $datef->format('Y'); $version = $bugsys->options['trackerversion']; +// ################################################################### +// do style vars +if (($raw = @file_get_contents('./templates/stylevars.dsv')) !== false) +{ + // remove comments + $raw = preg_replace('#/\*(.*?)\*/#s', '', $raw); + $raw = trim($raw); + + // create individual vars + $varsraw = explode(';', $raw); + foreach ($varsraw AS $var) + { + if (($var = trim($var)) == '') + { + continue; + } + + // split into varname - value pair + $temp = explode(':', $var); + + // clean up varnames + $varname = trim($temp[0]); + $varname = preg_replace('#[^a-z0-9]#i', '_', $varname); + + // clean up values + $value = trim($temp[1]); + $value = preg_replace('#[^a-z0-9%\-\.\#]#i', '', $value); + + // put it in the array + $stylevar["$varname"] = $value; + } +} +else +{ + trigger_error('StyleVars file (./templates/stylevars.dsv)', E_USER_WARNING); +} + // ################################################################### // cache templates $globaltemplates = array( @@ -49,6 +86,8 @@ eval('$doctype = "' . $template->fetch('doctype') . '";'); eval('$headinclude = "' . $template->fetch('headinclude') . '";'); eval('$footer = "' . $template->fetch('footer') . '";'); +// ################################################################### + // ################################################################### // initialize template variables $show = array(); diff --git a/includes/class_message_reporter.php b/includes/class_message_reporter.php index afba72c..0e4b03f 100755 --- a/includes/class_message_reporter.php +++ b/includes/class_message_reporter.php @@ -21,7 +21,7 @@ class Message_Reporter function error($text = '') { global $bugsys; - global $doctype, $header, $headinclude, $footer, $focus, $show; + global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; if (is_array($this->phrase) AND empty($this->process)) { @@ -65,7 +65,7 @@ class Message_Reporter function redirect($text = '', $url = '') { global $bugsys; - global $doctype, $header, $headinclude, $footer, $focus, $show; + global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; if (is_array($this->phrase) AND empty($this->process)) { @@ -96,7 +96,7 @@ class Message_Reporter function message($text = '') { global $bugsys; - global $doctype, $header, $headinclude, $footer, $focus, $show; + global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; if (is_array($this->phrase) AND empty($this->process)) { diff --git a/templates/stylevars.dsv b/templates/stylevars.dsv new file mode 100644 index 0000000..3cfd4b8 --- /dev/null +++ b/templates/stylevars.dsv @@ -0,0 +1,41 @@ +/*=====================================================================*\ +|| ################################################################### || +|| # BugTrack [#]version[#] +|| # --------------------------------------------------------------- # || +|| # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # || +|| # This file may not be reproduced in any way without permission. # || +|| # --------------------------------------------------------------- # || +|| # User License Agreement at http://www.iris-studios.com/license/ # || +|| ################################################################### || +\*=====================================================================*/ + +/* +This file is parsed to create PHP variables that +are used in templates with the $stylevar[] array. +It is similar to how a CSS element would be done. + +Each line has: +variablename: value; + +Only letters and numbers are valid in variable names; +everything else is converted to an undescore. + +Values only are allowed to have numbers, letters, dashes, +periods/decimals, the number/pound sign, and the percent sign. + +Comments are only valid in C++ style (the type of comment this is). +*/ + +/* table elements */ + +border: 0; +spacing: 1; +padding: 3; +normal-width: 100%; + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ \ No newline at end of file -- 2.22.5