Project

General

Profile

1
<?php
2

    
3
// $Id: frontend.functions.php 246 2005-11-25 15:16:13Z 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
			$page_id=$wb->page_id;
146
			// First get all sections for this page
147
			$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
148
			// If none were found, check if default content is supposed to be shown
149
			if($query_sections->numRows() == 0) {
150
				if ($wb->default_block_content=='none') {
151
					return;
152
				}
153
				if (is_numeric($wb->default_block_content)) {
154
					$page_id=$wb->default_block_content;
155
				} else {
156
					$page_id=$wb->default_page_id;
157
				}				
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
				// Still no cotent found? Give it up, there's just nothing to show!
160
				if($query_sections->numRows() == 0) {
161
					return;
162
				}
163
			}
164
			// Loop through them and include their module file
165
			while($section = $query_sections->fetchRow()) {
166
				$section_id = $section['section_id'];
167
				$module = $section['module'];
168
				require(WB_PATH.'/modules/'.$module.'/view.php');
169
			}
170
		} else {
171
			require(PAGE_CONTENT);
172
		}
173
	}
174
}
175

    
176
if (!function_exists('show_content')) {
177
	function show_content($block=1) {
178
		page_content($block);
179
	}
180
}
181

    
182
if (!function_exists('show_breadcrumbs')) {
183
	function show_breadcrumbs($sep=' > ',$tier=1,$links=true) {
184
		global $wb;
185
		$page_id=$wb->page_id;
186
		if ($page_id!=0)
187
		{
188
	 		global $database;
189
			$bca=$wb->page_trail;
190
			$counter=0;
191
			foreach ($bca as $temp)
192
			{
193
		        if ($counter>=($tier-1));
194
		        {
195
					if ($counter>=$tier) echo $sep;
196
					$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
197
					$page=$query_menu->fetchRow();
198
					if ($links==true AND $temp!=$page_id)
199
						echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
200
					else
201
					    echo $page['menu_title'];
202
		        }
203
	            $counter++;
204
			}
205
		}
206
	}
207
}
208

    
209
// Function for page title
210
if (!function_exists('page_title')) {
211
	function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
212
		$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
213
		$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
214
		echo str_replace($vars, $values, $template);
215
	}
216
}
217

    
218
// Function for page description
219
if (!function_exists('page_description')) {
220
	function page_description() {
221
		global $wb;
222
		if ($wb->page_description!='') {
223
			echo $wb->page_description;
224
		} else {
225
			echo PAGE_DESCRIPTION;
226
		}
227
	}
228
}
229

    
230
// Function for page keywords
231
if (!function_exists('page_keywords')) {
232
	function page_keywords() {
233
		global $wb;
234
		if ($wb->page_keywords!='') {
235
			echo $wb->page_keywords;
236
		} else {
237
			echo WEBSITE_KEYWORDS;
238
		}
239
	}
240
}
241
// Function for page header
242
if (!function_exists('page_header')) {
243
	function page_header($date_format = 'Y') {
244
		echo WEBSITE_HEADER;
245
	}
246
}
247

    
248
// Function for page footer
249
if (!function_exists('page_footer')) {
250
	function page_footer($date_format = 'Y') {
251
		global $starttime;
252
		$vars = array('[YEAR]', '[PROCESSTIME]');
253
		$processtime=array_sum(explode(" ",microtime()))-$starttime;
254
		$values = array(date($date_format),$processtime);
255
		echo str_replace($vars, $values, WEBSITE_FOOTER);
256
	}
257
}
258

    
259
// Begin WB < 2.4.x template compatibility code
260
	// Make extra_sql accessable through private_sql
261
	$private_sql = $extra_sql;
262
	$private_where_sql = $extra_where_sql;
263
	// Query pages for menu
264
	$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");
265
	// Check if current pages is a parent page and if we need its submenu
266
	if(PARENT == 0) {
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 = '".PAGE_ID."' AND $extra_where_sql ORDER BY position ASC");
269
	} else {
270
		// Get the pages submenu
271
		$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");
272
	}
273
// End WB < 2.4.x template compatibility code
274
// Include template file
275

    
276

    
277
?>
(8-8/11)