1
|
<?php
|
2
|
|
3
|
// $Id: frontend.functions.php 220 2005-11-18 14:51:07Z stefan $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2005, Ryan Djurovich
|
9
|
|
10
|
Website Baker is free software; you can redistribute it and/or modify
|
11
|
it under the terms of the GNU General Public License as published by
|
12
|
the Free Software Foundation; either version 2 of the License, or
|
13
|
(at your option) any later version.
|
14
|
|
15
|
Website Baker is distributed in the hope that it will be useful,
|
16
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
GNU General Public License for more details.
|
19
|
|
20
|
You should have received a copy of the GNU General Public License
|
21
|
along with Website Baker; if not, write to the Free Software
|
22
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
|
24
|
*/
|
25
|
|
26
|
/*
|
27
|
This file is purely for ensuring compatibility with 3rd party
|
28
|
contributions made for WB version 2.5.2 or below
|
29
|
*/
|
30
|
if(!defined('WB_URL')) {
|
31
|
header('Location: ../index.php');
|
32
|
}
|
33
|
|
34
|
// references to objects and variables that changed their names
|
35
|
|
36
|
$admin = &$wb;
|
37
|
|
38
|
$default_link=&$wb->default_link;
|
39
|
|
40
|
$page_trail=&$wb->page_trail;
|
41
|
$page_description=&$wb->page_description;
|
42
|
$page_keywords=&$wb->page_keywords;
|
43
|
$page_link=&$wb->link;
|
44
|
|
45
|
// extra_sql is not used anymore - this is basically a register_globals exploit prevention...
|
46
|
$extra_sql=&$wb->extra_sql;
|
47
|
$extra_where_sql=&$wb->extra_where_sql;
|
48
|
|
49
|
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
|
50
|
$query_result=$database->query($query);
|
51
|
if ($query_result->numRows()>0) {
|
52
|
while ($row = $query_result->fetchRow()) {
|
53
|
$module_dir = $row['directory'];
|
54
|
if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
|
55
|
include(WB_PATH.'/modules/'.$module_dir.'/include.php');
|
56
|
}
|
57
|
}
|
58
|
}
|
59
|
|
60
|
// Frontend functions
|
61
|
if (!function_exists('page_link')) {
|
62
|
function page_link($link) {
|
63
|
global $wb;
|
64
|
return $wb->page_link($link);
|
65
|
}
|
66
|
}
|
67
|
|
68
|
// Old menu call invokes new menu function
|
69
|
if (!function_exists('page_menu')) {
|
70
|
function page_menu($parent = 0, $menu_number = 1, $item_template = '<li[class]>[a][menu_title][/a]</li>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
|
71
|
global $wb;
|
72
|
$wb->menu_number=$menu_number;
|
73
|
$wb->menu_item_template=$item_template;
|
74
|
$wb->menu_item_footer='';
|
75
|
$wb->menu_parent = $parent;
|
76
|
$wb->menu_header = $menu_header;
|
77
|
$wb->menu_footer = $menu_footer;
|
78
|
$wb->menu_default_class = $default_class;
|
79
|
$wb->menu_current_class = $current_class;
|
80
|
$wb->menu_recurse = $recurse+2;
|
81
|
$wb->menu();
|
82
|
unset($wb->menu_parent);
|
83
|
unset($wb->menu_number);
|
84
|
unset($wb->menu_item_template);
|
85
|
unset($wb->menu_item_footer);
|
86
|
unset($wb->menu_header);
|
87
|
unset($wb->menu_footer);
|
88
|
unset($wb->menu_default_class);
|
89
|
unset($wb->menu_current_class);
|
90
|
unset($wb->menu_start_level);
|
91
|
unset($wb->menu_collapse);
|
92
|
unset($wb->menu_recurse);
|
93
|
}
|
94
|
}
|
95
|
|
96
|
if (!function_exists('show_menu')) {
|
97
|
function show_menu($menu_number = NULL, $start_level=NULL, $recurse = NULL, $collapse = NULL, $item_template = NULL, $item_footer = NULL, $menu_header = NULL, $menu_footer = NULL, $default_class = NULL, $current_class = NULL, $parent = NULL) {
|
98
|
global $wb;
|
99
|
if (isset($menu_number))
|
100
|
$wb->menu_number=$menu_number;
|
101
|
if (isset($start_level))
|
102
|
$wb->menu_start_level=$start_level;
|
103
|
if (isset($recurse))
|
104
|
$wb->menu_recurse=$recurse;
|
105
|
if (isset($collapse))
|
106
|
$wb->menu_collapse=$collapse;
|
107
|
if (isset($item_template))
|
108
|
$wb->menu_item_template=$item_template;
|
109
|
if (isset($item_footer))
|
110
|
$wb->menu_item_footer=$item_footer;
|
111
|
if (isset($menu_header))
|
112
|
$wb->menu_header=$menu_header;
|
113
|
if (isset($menu_footer))
|
114
|
$wb->menu_footer=$menu_footer;
|
115
|
if (isset($default_class))
|
116
|
$wb->menu_default_class=$default_class;
|
117
|
if (isset($current_class))
|
118
|
$wb->menu_current_class=$current_class;
|
119
|
if (isset($parent))
|
120
|
$wb->menu_parent=$parent;
|
121
|
$wb->menu();
|
122
|
unset($wb->menu_recurse);
|
123
|
unset($wb->menu_parent);
|
124
|
unset($wb->menu_start_level);
|
125
|
}
|
126
|
}
|
127
|
|
128
|
if (!function_exists('page_content')) {
|
129
|
function page_content($block = 1) {
|
130
|
// Get outside objects
|
131
|
global $TEXT,$MENU,$HEADING,$MESSAGE;
|
132
|
global $globals;
|
133
|
global $database;
|
134
|
global $wb;
|
135
|
$admin = & $wb;
|
136
|
if ($wb->page_access_denied==true) {
|
137
|
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
|
138
|
exit();
|
139
|
}
|
140
|
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
|
141
|
// Make sure block is numeric
|
142
|
if(!is_numeric($block)) { $block = 1; }
|
143
|
// Include page content
|
144
|
if(!defined('PAGE_CONTENT') OR $block!=1) {
|
145
|
if ($wb->page_id==0) {
|
146
|
if ($wb->default_block_content=='none') {
|
147
|
return;
|
148
|
}
|
149
|
if (is_numeric($wb->default_block_content)) {
|
150
|
$page_id=$wb->default_block_content;
|
151
|
} else {
|
152
|
$page_id=$wb->default_page-id;
|
153
|
}
|
154
|
} else {
|
155
|
$page_id=$wb->page_id;
|
156
|
}
|
157
|
// First get all sections for this page
|
158
|
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
|
159
|
if($query_sections->numRows() > 0) {
|
160
|
// Loop through them and include there modules file
|
161
|
while($section = $query_sections->fetchRow()) {
|
162
|
$section_id = $section['section_id'];
|
163
|
$module = $section['module'];
|
164
|
require(WB_PATH.'/modules/'.$module.'/view.php');
|
165
|
}
|
166
|
}
|
167
|
} else {
|
168
|
require(PAGE_CONTENT);
|
169
|
}
|
170
|
}
|
171
|
}
|
172
|
|
173
|
if (!function_exists('show_content')) {
|
174
|
function show_content($block=1) {
|
175
|
page_content($block);
|
176
|
}
|
177
|
}
|
178
|
|
179
|
if (!function_exists('show_breadcrumbs')) {
|
180
|
function show_breadcrumbs($sep=' > ',$tier=1,$links=true) {
|
181
|
global $wb;
|
182
|
$page_id=$wb->page_id;
|
183
|
if ($page_id!=0)
|
184
|
{
|
185
|
global $database;
|
186
|
$bca=$wb->page_trail;
|
187
|
$counter=0;
|
188
|
foreach ($bca as $temp)
|
189
|
{
|
190
|
if ($counter>=($tier-1));
|
191
|
{
|
192
|
if ($counter>=$tier) echo $sep;
|
193
|
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
|
194
|
$page=$query_menu->fetchRow();
|
195
|
if ($links==true AND $temp!=$page_id)
|
196
|
echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
|
197
|
else
|
198
|
echo $page['menu_title'];
|
199
|
}
|
200
|
$counter++;
|
201
|
}
|
202
|
}
|
203
|
}
|
204
|
}
|
205
|
|
206
|
// Function for page title
|
207
|
if (!function_exists('page_title')) {
|
208
|
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
|
209
|
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
|
210
|
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
|
211
|
echo str_replace($vars, $values, $template);
|
212
|
}
|
213
|
}
|
214
|
|
215
|
// Function for page description
|
216
|
if (!function_exists('page_description')) {
|
217
|
function page_description() {
|
218
|
global $wb;
|
219
|
if ($wb->page_description!='') {
|
220
|
echo $wb->page_description;
|
221
|
} else {
|
222
|
echo PAGE_DESCRIPTION;
|
223
|
}
|
224
|
}
|
225
|
}
|
226
|
|
227
|
// Function for page keywords
|
228
|
if (!function_exists('page_keywords')) {
|
229
|
function page_keywords() {
|
230
|
global $wb;
|
231
|
if ($wb->page_keywords!='') {
|
232
|
echo $wb->page_keywords;
|
233
|
} else {
|
234
|
echo WEBSITE_KEYWORDS;
|
235
|
}
|
236
|
}
|
237
|
}
|
238
|
// Function for page header
|
239
|
if (!function_exists('page_header')) {
|
240
|
function page_header($date_format = 'Y') {
|
241
|
echo WEBSITE_HEADER;
|
242
|
}
|
243
|
}
|
244
|
|
245
|
// Function for page footer
|
246
|
if (!function_exists('page_footer')) {
|
247
|
function page_footer($date_format = 'Y') {
|
248
|
global $starttime;
|
249
|
$vars = array('[YEAR]', '[PROCESSTIME]');
|
250
|
$processtime=array_sum(explode(" ",microtime()))-$starttime;
|
251
|
$values = array(date($date_format),$processtime);
|
252
|
echo str_replace($vars, $values, WEBSITE_FOOTER);
|
253
|
}
|
254
|
}
|
255
|
|
256
|
// Begin WB < 2.4.x template compatibility code
|
257
|
// Make extra_sql accessable through private_sql
|
258
|
$private_sql = $extra_sql;
|
259
|
$private_where_sql = $extra_where_sql;
|
260
|
// Query pages for menu
|
261
|
$menu1 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND $extra_where_sql ORDER BY position ASC");
|
262
|
// Check if current pages is a parent page and if we need its submenu
|
263
|
if(PARENT == 0) {
|
264
|
// Get the pages submenu
|
265
|
$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PAGE_ID."' AND $extra_where_sql ORDER BY position ASC");
|
266
|
} else {
|
267
|
// Get the pages submenu
|
268
|
$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PARENT."' AND $extra_where_sql ORDER BY position ASC");
|
269
|
}
|
270
|
// End WB < 2.4.x template compatibility code
|
271
|
// Include template file
|
272
|
|
273
|
|
274
|
?>
|