-
Notifications
You must be signed in to change notification settings - Fork 1
/
base.inc
94 lines (79 loc) · 1.68 KB
/
base.inc
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
// Determine current file name
$THIS_FILE = &$_SERVER['PHP_SELF'];
if (preg_match("/[^\/]+$/", $THIS_FILE, $regs)) {
$CURRENTFILE = $regs[0];
}
// Default value for title
if (!isset($TITLE)) {
if (isset($HEADLINE)) {
$TITLE = "Exult: $HEADLINE";
} else {
$TITLE = "Exult";
}
}
// Default value for main template
if (!isset($MAIN_TEMPLATE)) {
$MAIN_TEMPLATE = "main";
}
// Default value for custom parse
if (!isset($CUSTOM_PARSE)) {
$CUSTOM_PARSE = false;
}
// Content is by default loaded from a data file
if (!isset($CONTENT) && isset($DATAFILE)) {
$CONTENT = join("", file("content/$DATAFILE"));
if (!isset($MOD_DATE)) {
$MOD_DATE = date("Y-m-d", filemtime("content/$DATAFILE"));
}
}
// Default value for modification time
if (!isset($MOD_DATE)) {
$MOD_DATE = date("Y-m-d", filemtime($CURRENTFILE));
}
if (isset($XHTML) && $XHTML) {
$MAIN_TEMPLATE .= "_xhtml";
}
// Template stuff follows
include_once "class.FastTemplate.php3";
$tpl = new FastTemplate("./templates");
$tpl->define(
array(
"main" => "$MAIN_TEMPLATE.tpl",
"topic" => "topic.tpl"
)
);
$tpl->assign(
array(
"URL" => $THIS_FILE,
"MOD_DATE" => $MOD_DATE,
"CURRENTFILE" => $CURRENTFILE,
"REFERRER" => rawurlencode($THIS_FILE),
"TITLE" => $TITLE
)
);
if (!$CUSTOM_PARSE) {
add_topic($HEADLINE, $CONTENT);
$tpl->parse("MAIN", "main");
$tpl->FastPrint();
exit;
}
function add_topic_headline($headline) {
global $tpl;
$tpl->assign(
array(
"HEADLINE" => $headline
)
);
$tpl->parse("TOPICS", ".topic");
}
function add_topic($headline, $content) {
global $tpl;
$tpl->assign(
array(
"HEADLINE" => $headline,
"CONTENT" => $content
)
);
$tpl->parse("TOPICS", ".topic");
}