Project

General

Profile

1
<?php
2

    
3
// $Id: frontend.functions.php 106 2005-09-15 19:15:43Z 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
// compatibility code
50
function page_link($link) {
51
	global $wb;
52
	return $wb->page_link($link);
53
}
54

    
55
// Old menu call invokes new menu function
56
function page_menu($parent = 0, $menu_number = 1, $item_template = '<li><span[class]>[a][menu_title][/a]</span>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
57
	global $wb;
58
	$wb->menu_number=$menu_number;
59
	$wb->menu_item_template=$item_template;
60
	$wb->menu_parent = $parent;
61
	$wb->menu_header = $menu_header; 
62
	$wb->menu_footer = $menu_footer;
63
	$wb->menu_default_class = $default_class;
64
	$wb->menu_current_class = $current_class;
65
	$wb->menu_recurse = $recurse+2; 	
66
	$wb->menu();
67
}
68

    
69
function page_content($block = 1) {
70
	// Get outside objects
71
	global $TEXT,$MENU,$HEADING,$MESSAGE;
72
	global $globals;
73
	global $database;
74
	$admin = & $this;
75
	global $wb;
76
	if ($wb->page_access_denied==true) {
77
        echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
78
		exit();
79
	}
80
	if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
81
	// Make sure block is numeric
82
	if(!is_numeric($block)) { $block = 1; }
83
	// Include page content
84
	if(!defined('PAGE_CONTENT') OR $block!=1) {
85
		if ($wb->page_id==0) {
86
			if ($wb->default_block_content=='none') {
87
				return;
88
			}
89
			if (is_numeric($wb->default_block_content)) {
90
				$page_id=$wb->default_block_content;
91
			} else {
92
				$page_id=$wb->default_page-id;
93
			}				
94
		} else {
95
			$page_id=$wb->page_id;
96
		}
97
		// First get all sections for this page
98
		$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
99
		if($query_sections->numRows() > 0) {
100
			// Loop through them and include there modules file
101
			while($section = $query_sections->fetchRow()) {
102
				$section_id = $section['section_id'];
103
				$module = $section['module'];
104
				require(WB_PATH.'/modules/'.$module.'/view.php');
105
			}
106
		}
107
	} else {
108
		require(PAGE_CONTENT);
109
	}
110
}
111

    
112
function show_content($block=1) {
113
	page_content($block);
114
}
115

    
116
function show_breadcrumbs($sep=' > ',$tier=1,$links=true) {
117
	$page_id=&$wb->page_id;
118
	if ($page_id!=0)
119
	{
120
 		global $database;
121
		$bca=&$wb->page_trail;
122
		if (sizeof($bca)==0)
123
		        create_breadcrumbs($page_id);
124
		$counter=0;
125
		foreach ($bca as $temp)
126
		{
127
	        if ($counter>=(tier-1));
128
	        {
129
				if ($counter>=$tier) echo $sep;
130
				$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
131
				$page=$query_menu->fetchRow();
132
				if ($links==true AND $temp!=$page_id)
133
					echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
134
				else
135
				        echo stripslashes($page['menu_title']);
136
	        }
137
            $counter++;
138
		}
139
	}
140
}
141

    
142
// Function for page title
143
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
144
	$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
145
	$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
146
	echo str_replace($vars, $values, $template);
147
}
148

    
149
// Function for page description
150
function page_description() {
151
	echo WEBSITE_DESCRIPTION;
152
}
153
// Function for page keywords
154
function page_keywords() {
155
	echo WEBSITE_KEYWORDS;
156
}
157
// Function for page header
158
function page_header($date_format = 'Y') {
159
	echo WEBSITE_HEADER;
160
}
161

    
162
// Function for page footer
163
function page_footer($date_format = 'Y') {
164
	global $starttime;
165
	$vars = array('[YEAR]', '[PROCESSTIME]');
166
	$processtime=(microtime()>$starttime)?microtime()-$starttime:microtime()-$starttime+1;
167
	$values = array(date($date_format),$processtime);
168
	echo str_replace($vars, $values, WEBSITE_FOOTER);
169
}
170

    
171
// Begin WB < 2.4.x template compatibility code
172
	// Make extra_sql accessable through private_sql
173
	$private_sql = $extra_sql;
174
	$private_where_sql = $extra_where_sql;
175
	// Query pages for menu
176
	$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");
177
	// Check if current pages is a parent page and if we need its submenu
178
	if(PARENT == 0) {
179
		// Get the pages submenu
180
		$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");
181
	} else {
182
		// Get the pages submenu
183
		$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");
184
	}
185
// End WB < 2.4.x template compatibility code
186
// Include template file
187

    
188

    
189
?>
(8-8/11)