blob: ebecf7a4994565f2151787cb8c4e5a1219541dbf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?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) {
// This opens up another template and parses it as well.
$data = (file_exists($data)) ? $this->parse($data) : $data;
// This removes any unfilled tags
if ($data == '') {
$this->page = eregi_replace('<!-- switch ' . $tag . ' on -->(.*)<!-- switch ' . $tag . ' off -->', '', $this->page);
}
// This replaces any tags
$this->page = eregi_replace('{' . $tag . '}', $data, $this->page);
}
else
die('No tags designated for replacement.');
}
function output() {
print($this->page);
}
}
?>
|