1 | <?php |
---|
2 | require_once('common/includes/class.navigation.php'); |
---|
3 | |
---|
4 | class Page |
---|
5 | { |
---|
6 | function Page($title = '', $cachable = true) |
---|
7 | { |
---|
8 | if (!config::get('public_stats')) |
---|
9 | { |
---|
10 | config::set('public_stats','do nothing'); |
---|
11 | } |
---|
12 | |
---|
13 | $this->title_ = $title; |
---|
14 | $this->admin_ = false; |
---|
15 | $this->headlines = $this->bodylines = array(); |
---|
16 | |
---|
17 | $this->igb_ = IS_IGB; |
---|
18 | |
---|
19 | $this->timestart_ = strtok(microtime(), ' ') + strtok(''); |
---|
20 | |
---|
21 | $this->killboard_ = new Killboard(KB_SITE); |
---|
22 | |
---|
23 | $this->cachable_ = $cachable; |
---|
24 | $this->cachetime_ = 5; |
---|
25 | |
---|
26 | // if you have probs with missing tables uncomment this and |
---|
27 | // require_once('common/includes/autoupgrade.php'); |
---|
28 | // check_navigationtable(); |
---|
29 | } |
---|
30 | |
---|
31 | function setContent($html) |
---|
32 | { |
---|
33 | $this->contenthtml_ = $html; |
---|
34 | } |
---|
35 | |
---|
36 | function addContext($html) |
---|
37 | { |
---|
38 | $this->contexthtml_ .= $html; |
---|
39 | } |
---|
40 | |
---|
41 | function error($message) |
---|
42 | { |
---|
43 | global $smarty; |
---|
44 | |
---|
45 | $smarty->assign('error', $message); |
---|
46 | $this->setContent($smarty->fetch(get_tpl('error'))); |
---|
47 | $this->generate(); |
---|
48 | } |
---|
49 | |
---|
50 | function addHeader($line) |
---|
51 | { |
---|
52 | $this->headlines[] = $line; |
---|
53 | } |
---|
54 | |
---|
55 | function addBody($line) |
---|
56 | { |
---|
57 | $this->bodylines[] = $line; |
---|
58 | } |
---|
59 | |
---|
60 | function generate() |
---|
61 | { |
---|
62 | global $smarty; |
---|
63 | |
---|
64 | $smarty->assign('kb_title', KB_TITLE.' Killboard - '.$this->title_); |
---|
65 | |
---|
66 | $style = config::get('style_name'); |
---|
67 | $smarty->assign('style', $style); |
---|
68 | |
---|
69 | $smarty->assign('common_url', COMMON_URL); |
---|
70 | if ($this->onload_) |
---|
71 | { |
---|
72 | $smarty->assign('on_load', ' onload="'.$this->onload_.'"'); |
---|
73 | } |
---|
74 | |
---|
75 | // header |
---|
76 | event::call('page_assembleheader', $this); |
---|
77 | $smarty->assign('page_headerlines', join("\n", $this->headlines)); |
---|
78 | |
---|
79 | event::call('page_assemblebody', $this); |
---|
80 | $smarty->assign('page_bodylines', join("\n", $this->bodylines)); |
---|
81 | |
---|
82 | if (!$this->igb_) |
---|
83 | { |
---|
84 | if (MAIN_SITE) |
---|
85 | { |
---|
86 | $smarty->assign('banner_link', MAIN_SITE); |
---|
87 | } |
---|
88 | $banner = config::get('style_banner'); |
---|
89 | if ($banner == 'custom') |
---|
90 | { |
---|
91 | $banner = 'kb-banner.jpg'; |
---|
92 | } |
---|
93 | $smarty->assign('banner', $banner); |
---|
94 | |
---|
95 | $nav = new Navigation(); |
---|
96 | $nav->setSite($_GET['a']); |
---|
97 | $menu = $nav->generateMenu(); |
---|
98 | $w = floor(100 / count($menu->get())); |
---|
99 | |
---|
100 | $smarty->assign('menu_w',$w.'%'); |
---|
101 | $smarty->assign('menu', $menu->get()); |
---|
102 | } |
---|
103 | $smarty->assign('page_title', $this->title_); |
---|
104 | |
---|
105 | $this->timeend_ = strtok(microtime(), ' ') + strtok(''); |
---|
106 | $this->processingtime_ = $this->timeend_ - $this->timestart_; |
---|
107 | |
---|
108 | $qry = new DBQuery(); |
---|
109 | if (method_exists($qry, 'queryCachedCount')) |
---|
110 | { |
---|
111 | $smarty->assign('profile_sql_cached', $qry->queryCachedCount()); |
---|
112 | } |
---|
113 | $smarty->assign('profile_sql', $qry->queryCount()); |
---|
114 | $smarty->assign('profile_time', $this->processingtime_); |
---|
115 | $smarty->assign('profile', KB_PROFILE); |
---|
116 | $smarty->assign('content_html', $this->contenthtml_); |
---|
117 | if (config::get('user_showmenu')) |
---|
118 | { |
---|
119 | $this->contexthtml_ = user::menu().$this->contexthtml_; |
---|
120 | } |
---|
121 | $smarty->assign('context_html', $this->contexthtml_); |
---|
122 | event::call('smarty_displayindex', $smarty); |
---|
123 | $smarty->display(get_tpl('index')); |
---|
124 | } |
---|
125 | |
---|
126 | function igb() |
---|
127 | { |
---|
128 | return $this->igb_; |
---|
129 | } |
---|
130 | |
---|
131 | function setOnLoad($onload) |
---|
132 | { |
---|
133 | $this->onload_ = $onload; |
---|
134 | } |
---|
135 | |
---|
136 | function setTitle($title) |
---|
137 | { |
---|
138 | $this->title_ = $title; |
---|
139 | } |
---|
140 | |
---|
141 | function setAdmin() |
---|
142 | { |
---|
143 | if (!Session::isAdmin()) |
---|
144 | { |
---|
145 | header("Location: ?a=login"); |
---|
146 | echo '<a href="?a=login">Login</a>'; |
---|
147 | exit; |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | function isAdmin() |
---|
152 | { |
---|
153 | return Session::isAdmin(); |
---|
154 | } |
---|
155 | |
---|
156 | function isSuperAdmin() |
---|
157 | { |
---|
158 | return Session::isSuperAdmin(); |
---|
159 | } |
---|
160 | |
---|
161 | function setSuperAdmin() |
---|
162 | { |
---|
163 | if (!Session::isSuperAdmin()) |
---|
164 | Header("Location: ?a=login"); |
---|
165 | } |
---|
166 | |
---|
167 | function setCachable($cachable) |
---|
168 | { |
---|
169 | $this->cachable_ = $cachable; |
---|
170 | } |
---|
171 | |
---|
172 | function setCacheTime($cachetime) |
---|
173 | { |
---|
174 | $this->cachetime_ = $cachetime; |
---|
175 | } |
---|
176 | |
---|
177 | } |
---|
178 | |
---|
179 | class Menu |
---|
180 | { |
---|
181 | function Menu() |
---|
182 | { |
---|
183 | $this->menu_ = array(); |
---|
184 | } |
---|
185 | |
---|
186 | function get() |
---|
187 | { |
---|
188 | return $this->menu_; |
---|
189 | } |
---|
190 | |
---|
191 | function add($link, $text) |
---|
192 | { |
---|
193 | $this->menu_[] = array('link' => $link, 'text' => $text); |
---|
194 | } |
---|
195 | } |
---|
196 | ?> |
---|