diff options
author | Chad Little <clittle@users.sourceforge.net> | 2004-01-26 06:34:09 +0000 |
---|---|---|
committer | Chad Little <clittle@users.sourceforge.net> | 2004-01-26 06:34:09 +0000 |
commit | 97490a16baeab752422569259366b309163cb6e5 (patch) | |
tree | 79aebf19073662d29f489274244a8ab81fa090b5 /functions | |
parent | d951bba0df4dfbf3b6e07e48a22fb8ef0b8a9027 (diff) | |
download | phpicalendar-97490a16baeab752422569259366b309163cb6e5.tar.gz phpicalendar-97490a16baeab752422569259366b309163cb6e5.tar.bz2 phpicalendar-97490a16baeab752422569259366b309163cb6e5.zip |
Template class checking, first round trying to get event templated.
Diffstat (limited to 'functions')
-rw-r--r-- | functions/init.inc.php | 2 | ||||
-rw-r--r-- | functions/template.php | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/functions/init.inc.php b/functions/init.inc.php index c6c623c..d2b2d90 100644 --- a/functions/init.inc.php +++ b/functions/init.inc.php @@ -6,7 +6,7 @@ //chmod(BASE.'calendars/School.ics',0666); // uncomment when developing, comment for shipping version -// error_reporting (E_ERROR | E_WARNING | E_PARSE); +error_reporting (E_ERROR | E_WARNING | E_PARSE); // Older versions of PHP do not define $_SERVER. Define it here instead. if (!isset($_SERVER) && isset($HTTP_SERVER_VARS)) { diff --git a/functions/template.php b/functions/template.php new file mode 100644 index 0000000..a1cf2bb --- /dev/null +++ b/functions/template.php @@ -0,0 +1,35 @@ +<?php + +class Page { + var $page; + function Page($template = 'std.tpl') { + if (file_exists($template)) + $this->page = join('', file($template)); + else + die("Template file $template not found."); + } + + function parse($file) { + ob_start(); + include($file); + $buffer = ob_get_contents(); + ob_end_clean(); + return $buffer; + } + + function replace_tags($tags = array()) { + if (sizeof($tags) > 0) + foreach ($tags as $tag => $data) { + $data = (file_exists($data)) ? $this->parse($data) : $data; + $this->page = eregi_replace('{' . $tag . '}', $data, + $this->page); + } + else + die('No tags designated for replacement.'); + } + + function output() { + print($this->page); + } +} +?>
\ No newline at end of file |