Revision 452
Added by Matthias over 17 years ago
frontend.functions.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2007, 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 |
exit(0); |
|
33 |
} |
|
34 |
|
|
35 |
// references to objects and variables that changed their names |
|
36 |
|
|
37 |
$admin = &$wb; |
|
38 |
|
|
39 |
$default_link=&$wb->default_link; |
|
40 |
|
|
41 |
$page_trail=&$wb->page_trail; |
|
42 |
$page_description=&$wb->page_description; |
|
43 |
$page_keywords=&$wb->page_keywords; |
|
44 |
$page_link=&$wb->link; |
|
45 |
|
|
46 |
// extra_sql is not used anymore - this is basically a register_globals exploit prevention... |
|
47 |
$extra_sql=&$wb->extra_sql; |
|
48 |
$extra_where_sql=&$wb->extra_where_sql; |
|
49 |
|
|
50 |
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'"; |
|
51 |
$query_result=$database->query($query); |
|
52 |
if ($query_result->numRows()>0) { |
|
53 |
while ($row = $query_result->fetchRow()) { |
|
54 |
$module_dir = $row['directory']; |
|
55 |
if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) { |
|
56 |
include(WB_PATH.'/modules/'.$module_dir.'/include.php'); |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
// Frontend functions |
|
62 |
if (!function_exists('page_link')) { |
|
63 |
function page_link($link) { |
|
64 |
global $wb; |
|
65 |
return $wb->page_link($link); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
// Old menu call invokes new menu function |
|
70 |
if (!function_exists('page_menu')) { |
|
71 |
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) { |
|
72 |
global $wb; |
|
73 |
$wb->menu_number=$menu_number; |
|
74 |
$wb->menu_item_template=$item_template; |
|
75 |
$wb->menu_item_footer=''; |
|
76 |
$wb->menu_parent = $parent; |
|
77 |
$wb->menu_header = $menu_header; |
|
78 |
$wb->menu_footer = $menu_footer; |
|
79 |
$wb->menu_default_class = $default_class; |
|
80 |
$wb->menu_current_class = $current_class; |
|
81 |
$wb->menu_recurse = $recurse+2; |
|
82 |
$wb->menu(); |
|
83 |
unset($wb->menu_parent); |
|
84 |
unset($wb->menu_number); |
|
85 |
unset($wb->menu_item_template); |
|
86 |
unset($wb->menu_item_footer); |
|
87 |
unset($wb->menu_header); |
|
88 |
unset($wb->menu_footer); |
|
89 |
unset($wb->menu_default_class); |
|
90 |
unset($wb->menu_current_class); |
|
91 |
unset($wb->menu_start_level); |
|
92 |
unset($wb->menu_collapse); |
|
93 |
unset($wb->menu_recurse); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
if (!function_exists('show_menu')) { |
|
98 |
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) { |
|
99 |
global $wb; |
|
100 |
if (isset($menu_number)) |
|
101 |
$wb->menu_number=$menu_number; |
|
102 |
if (isset($start_level)) |
|
103 |
$wb->menu_start_level=$start_level; |
|
104 |
if (isset($recurse)) |
|
105 |
$wb->menu_recurse=$recurse; |
|
106 |
if (isset($collapse)) |
|
107 |
$wb->menu_collapse=$collapse; |
|
108 |
if (isset($item_template)) |
|
109 |
$wb->menu_item_template=$item_template; |
|
110 |
if (isset($item_footer)) |
|
111 |
$wb->menu_item_footer=$item_footer; |
|
112 |
if (isset($menu_header)) |
|
113 |
$wb->menu_header=$menu_header; |
|
114 |
if (isset($menu_footer)) |
|
115 |
$wb->menu_footer=$menu_footer; |
|
116 |
if (isset($default_class)) |
|
117 |
$wb->menu_default_class=$default_class; |
|
118 |
if (isset($current_class)) |
|
119 |
$wb->menu_current_class=$current_class; |
|
120 |
if (isset($parent)) |
|
121 |
$wb->menu_parent=$parent; |
|
122 |
$wb->menu(); |
|
123 |
unset($wb->menu_recurse); |
|
124 |
unset($wb->menu_parent); |
|
125 |
unset($wb->menu_start_level); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
if (!function_exists('page_content')) { |
|
130 |
function page_content($block = 1) { |
|
131 |
// Get outside objects |
|
132 |
global $TEXT,$MENU,$HEADING,$MESSAGE; |
|
133 |
global $globals; |
|
134 |
global $database; |
|
135 |
global $wb; |
|
136 |
$admin = & $wb; |
|
137 |
if ($wb->page_access_denied==true) { |
|
138 |
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS']; |
|
139 |
exit(); |
|
140 |
} |
|
141 |
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } } |
|
142 |
// Make sure block is numeric |
|
143 |
if(!is_numeric($block)) { $block = 1; } |
|
144 |
// Include page content |
|
145 |
if(!defined('PAGE_CONTENT') OR $block!=1) { |
|
146 |
$page_id=$wb->page_id; |
|
147 |
// First get all sections for this page |
|
148 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
149 |
// If none were found, check if default content is supposed to be shown |
|
150 |
if($query_sections->numRows() == 0) { |
|
151 |
if ($wb->default_block_content=='none') { |
|
152 |
return; |
|
153 |
} |
|
154 |
if (is_numeric($wb->default_block_content)) { |
|
155 |
$page_id=$wb->default_block_content; |
|
156 |
} else { |
|
157 |
$page_id=$wb->default_page_id; |
|
158 |
} |
|
159 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
160 |
// Still no cotent found? Give it up, there's just nothing to show! |
|
161 |
if($query_sections->numRows() == 0) { |
|
162 |
return; |
|
163 |
} |
|
164 |
} |
|
165 |
// Loop through them and include their module file |
|
166 |
while($section = $query_sections->fetchRow()) { |
|
167 |
$section_id = $section['section_id']; |
|
168 |
$module = $section['module']; |
|
169 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
170 |
} |
|
171 |
} else { |
|
172 |
require(PAGE_CONTENT); |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
if (!function_exists('show_content')) { |
|
178 |
function show_content($block=1) { |
|
179 |
page_content($block); |
|
180 |
} |
|
181 |
} |
|
182 |
|
|
183 |
if (!function_exists('show_breadcrumbs')) { |
|
184 |
function show_breadcrumbs($sep=' > ',$tier=1,$links=true,$depth=-1) { |
|
185 |
global $wb; |
|
186 |
$page_id=$wb->page_id; |
|
187 |
if ($page_id!=0) |
|
188 |
{ |
|
189 |
global $database; |
|
190 |
$bca=$wb->page_trail; |
|
191 |
$counter=0; |
|
192 |
foreach ($bca as $temp) |
|
193 |
{ |
|
194 |
if ($counter>=($tier-1) AND ($depth<0 OR $tier+$depth>$counter)) |
|
195 |
{ |
|
196 |
if ($counter>=$tier) echo $sep; |
|
197 |
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp"); |
|
198 |
$page=$query_menu->fetchRow(); |
|
199 |
if ($links==true AND $temp!=$page_id) |
|
200 |
echo '<a href="'.page_link($page['link']).'">'.htmlentities($page['menu_title']).'</a>'; |
|
201 |
else |
|
202 |
echo htmlentities($page['menu_title']); |
|
203 |
} |
|
204 |
$counter++; |
|
205 |
} |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
210 |
// Function for page title |
|
211 |
if (!function_exists('page_title')) { |
|
212 |
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') { |
|
213 |
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]'); |
|
214 |
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer); |
|
215 |
echo str_replace($vars, $values, $template); |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
// Function for page description |
|
220 |
if (!function_exists('page_description')) { |
|
221 |
function page_description() { |
|
222 |
global $wb; |
|
223 |
if ($wb->page_description!='') { |
|
224 |
echo $wb->page_description; |
|
225 |
} else { |
|
226 |
echo WEBSITE_DESCRIPTION; |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
|
|
231 |
// Function for page keywords |
|
232 |
if (!function_exists('page_keywords')) { |
|
233 |
function page_keywords() { |
|
234 |
global $wb; |
|
235 |
if ($wb->page_keywords!='') { |
|
236 |
echo $wb->page_keywords; |
|
237 |
} else { |
|
238 |
echo WEBSITE_KEYWORDS; |
|
239 |
} |
|
240 |
} |
|
241 |
} |
|
242 |
// Function for page header |
|
243 |
if (!function_exists('page_header')) { |
|
244 |
function page_header($date_format = 'Y') { |
|
245 |
echo WEBSITE_HEADER; |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
// Function for page footer |
|
250 |
if (!function_exists('page_footer')) { |
|
251 |
function page_footer($date_format = 'Y') { |
|
252 |
global $starttime; |
|
253 |
$vars = array('[YEAR]', '[PROCESS_TIME]'); |
|
254 |
$processtime=array_sum(explode(" ",microtime()))-$starttime; |
|
255 |
$values = array(date($date_format),$processtime); |
|
256 |
echo str_replace($vars, $values, WEBSITE_FOOTER); |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
260 |
// Begin WB < 2.4.x template compatibility code |
|
261 |
// Make extra_sql accessable through private_sql |
|
262 |
$private_sql = $extra_sql; |
|
263 |
$private_where_sql = $extra_where_sql; |
|
264 |
// Query pages for menu |
|
265 |
$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"); |
|
266 |
// Check if current pages is a parent page and if we need its submenu |
|
267 |
if(PARENT == 0) { |
|
268 |
// Get the pages submenu |
|
269 |
$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"); |
|
270 |
} else { |
|
271 |
// Get the pages submenu |
|
272 |
$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"); |
|
273 |
} |
|
274 |
// End WB < 2.4.x template compatibility code |
|
275 |
// Include template file |
|
276 |
|
|
277 |
|
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2007, 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 |
exit(0); |
|
33 |
} |
|
34 |
|
|
35 |
// references to objects and variables that changed their names |
|
36 |
|
|
37 |
$admin = &$wb; |
|
38 |
|
|
39 |
$default_link=&$wb->default_link; |
|
40 |
|
|
41 |
$page_trail=&$wb->page_trail; |
|
42 |
$page_description=&$wb->page_description; |
|
43 |
$page_keywords=&$wb->page_keywords; |
|
44 |
$page_link=&$wb->link; |
|
45 |
|
|
46 |
// extra_sql is not used anymore - this is basically a register_globals exploit prevention... |
|
47 |
$extra_sql=&$wb->extra_sql; |
|
48 |
$extra_where_sql=&$wb->extra_where_sql; |
|
49 |
|
|
50 |
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'"; |
|
51 |
$query_result=$database->query($query); |
|
52 |
if ($query_result->numRows()>0) { |
|
53 |
while ($row = $query_result->fetchRow()) { |
|
54 |
$module_dir = $row['directory']; |
|
55 |
if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) { |
|
56 |
include(WB_PATH.'/modules/'.$module_dir.'/include.php'); |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
// Frontend functions |
|
62 |
if (!function_exists('page_link')) { |
|
63 |
function page_link($link) { |
|
64 |
global $wb; |
|
65 |
return $wb->page_link($link); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
//function to highlight search results |
|
70 |
function search_highlight($foo='', $arr_string=array()) { |
|
71 |
require_once(WB_PATH.'/framework/functions.php'); |
|
72 |
require(WB_PATH.'/search/search_convert.php'); |
|
73 |
$foo = entities_to_umlauts($foo, 'UTF-8'); |
|
74 |
foreach($arr_string as $string) { |
|
75 |
$string = strtr($string, $string_htmlspecialchars_decode); |
|
76 |
$string = entities_to_umlauts($string, 'UTF-8'); |
|
77 |
$string = preg_quote($string, '/'); |
|
78 |
$string = strtr($string, $string_ul_umlauts); |
|
79 |
$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo); |
|
80 |
} |
|
81 |
$foo = umlauts_to_entities($foo, 'UTF-8', 0); |
|
82 |
return $foo; |
|
83 |
} |
|
84 |
|
|
85 |
// Old menu call invokes new menu function |
|
86 |
if (!function_exists('page_menu')) { |
|
87 |
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) { |
|
88 |
global $wb; |
|
89 |
$wb->menu_number=$menu_number; |
|
90 |
$wb->menu_item_template=$item_template; |
|
91 |
$wb->menu_item_footer=''; |
|
92 |
$wb->menu_parent = $parent; |
|
93 |
$wb->menu_header = $menu_header; |
|
94 |
$wb->menu_footer = $menu_footer; |
|
95 |
$wb->menu_default_class = $default_class; |
|
96 |
$wb->menu_current_class = $current_class; |
|
97 |
$wb->menu_recurse = $recurse+2; |
|
98 |
$wb->menu(); |
|
99 |
unset($wb->menu_parent); |
|
100 |
unset($wb->menu_number); |
|
101 |
unset($wb->menu_item_template); |
|
102 |
unset($wb->menu_item_footer); |
|
103 |
unset($wb->menu_header); |
|
104 |
unset($wb->menu_footer); |
|
105 |
unset($wb->menu_default_class); |
|
106 |
unset($wb->menu_current_class); |
|
107 |
unset($wb->menu_start_level); |
|
108 |
unset($wb->menu_collapse); |
|
109 |
unset($wb->menu_recurse); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
if (!function_exists('show_menu')) { |
|
114 |
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) { |
|
115 |
global $wb; |
|
116 |
if (isset($menu_number)) |
|
117 |
$wb->menu_number=$menu_number; |
|
118 |
if (isset($start_level)) |
|
119 |
$wb->menu_start_level=$start_level; |
|
120 |
if (isset($recurse)) |
|
121 |
$wb->menu_recurse=$recurse; |
|
122 |
if (isset($collapse)) |
|
123 |
$wb->menu_collapse=$collapse; |
|
124 |
if (isset($item_template)) |
|
125 |
$wb->menu_item_template=$item_template; |
|
126 |
if (isset($item_footer)) |
|
127 |
$wb->menu_item_footer=$item_footer; |
|
128 |
if (isset($menu_header)) |
|
129 |
$wb->menu_header=$menu_header; |
|
130 |
if (isset($menu_footer)) |
|
131 |
$wb->menu_footer=$menu_footer; |
|
132 |
if (isset($default_class)) |
|
133 |
$wb->menu_default_class=$default_class; |
|
134 |
if (isset($current_class)) |
|
135 |
$wb->menu_current_class=$current_class; |
|
136 |
if (isset($parent)) |
|
137 |
$wb->menu_parent=$parent; |
|
138 |
$wb->menu(); |
|
139 |
unset($wb->menu_recurse); |
|
140 |
unset($wb->menu_parent); |
|
141 |
unset($wb->menu_start_level); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
if (!function_exists('page_content')) { |
|
146 |
function page_content($block = 1) { |
|
147 |
// Get outside objects |
|
148 |
global $TEXT,$MENU,$HEADING,$MESSAGE; |
|
149 |
global $globals; |
|
150 |
global $database; |
|
151 |
global $wb; |
|
152 |
$admin = & $wb; |
|
153 |
if ($wb->page_access_denied==true) { |
|
154 |
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS']; |
|
155 |
exit(); |
|
156 |
} |
|
157 |
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } } |
|
158 |
// Make sure block is numeric |
|
159 |
if(!is_numeric($block)) { $block = 1; } |
|
160 |
// Include page content |
|
161 |
if(!defined('PAGE_CONTENT') OR $block!=1) { |
|
162 |
$page_id=$wb->page_id; |
|
163 |
// First get all sections for this page |
|
164 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
165 |
// If none were found, check if default content is supposed to be shown |
|
166 |
if($query_sections->numRows() == 0) { |
|
167 |
if ($wb->default_block_content=='none') { |
|
168 |
return; |
|
169 |
} |
|
170 |
if (is_numeric($wb->default_block_content)) { |
|
171 |
$page_id=$wb->default_block_content; |
|
172 |
} else { |
|
173 |
$page_id=$wb->default_page_id; |
|
174 |
} |
|
175 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
176 |
// Still no cotent found? Give it up, there's just nothing to show! |
|
177 |
if($query_sections->numRows() == 0) { |
|
178 |
return; |
|
179 |
} |
|
180 |
} |
|
181 |
// Loop through them and include their module file |
|
182 |
while($section = $query_sections->fetchRow()) { |
|
183 |
$section_id = $section['section_id']; |
|
184 |
$module = $section['module']; |
|
185 |
// highlights searchresults |
|
186 |
if (isset($_GET['searchresult']) AND is_numeric($_GET['searchresult']) ) { |
|
187 |
if (isset($_GET['sstring']) AND !empty($_GET['sstring']) ){ |
|
188 |
$arr_string = explode(" ", $_GET['sstring']); |
|
189 |
if($_GET['searchresult'] == 2) { |
|
190 |
// exact match |
|
191 |
$arr_string[0] = strtr($arr_string[0], "_"," "); |
|
192 |
} |
|
193 |
ob_start(); //start output buffer |
|
194 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
195 |
$foo = ob_get_contents(); // put outputbuffer in $foo |
|
196 |
ob_end_clean(); // clear outputbuffer |
|
197 |
echo search_highlight($foo, $arr_string); |
|
198 |
} |
|
199 |
} else { |
|
200 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
201 |
} |
|
202 |
} |
|
203 |
} else { |
|
204 |
require(PAGE_CONTENT); |
|
205 |
} |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
if (!function_exists('show_content')) { |
|
210 |
function show_content($block=1) { |
|
211 |
page_content($block); |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
if (!function_exists('show_breadcrumbs')) { |
|
216 |
function show_breadcrumbs($sep=' > ',$tier=1,$links=true,$depth=-1) { |
|
217 |
global $wb; |
|
218 |
$page_id=$wb->page_id; |
|
219 |
if ($page_id!=0) |
|
220 |
{ |
|
221 |
global $database; |
|
222 |
$bca=$wb->page_trail; |
|
223 |
$counter=0; |
|
224 |
foreach ($bca as $temp) |
|
225 |
{ |
|
226 |
if ($counter>=($tier-1) AND ($depth<0 OR $tier+$depth>$counter)) |
|
227 |
{ |
|
228 |
if ($counter>=$tier) echo $sep; |
|
229 |
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp"); |
|
230 |
$page=$query_menu->fetchRow(); |
|
231 |
if ($links==true AND $temp!=$page_id) |
|
232 |
echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>'; |
|
233 |
else |
|
234 |
echo $page['menu_title']; |
|
235 |
} |
|
236 |
$counter++; |
|
237 |
} |
|
238 |
} |
|
239 |
} |
|
240 |
} |
|
241 |
|
|
242 |
// Function for page title |
|
243 |
if (!function_exists('page_title')) { |
|
244 |
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') { |
|
245 |
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]'); |
|
246 |
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer); |
|
247 |
echo str_replace($vars, $values, $template); |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
// Function for page description |
|
252 |
if (!function_exists('page_description')) { |
|
253 |
function page_description() { |
|
254 |
global $wb; |
|
255 |
if ($wb->page_description!='') { |
|
256 |
echo $wb->page_description; |
|
257 |
} else { |
|
258 |
echo WEBSITE_DESCRIPTION; |
|
259 |
} |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
263 |
// Function for page keywords |
|
264 |
if (!function_exists('page_keywords')) { |
|
265 |
function page_keywords() { |
|
266 |
global $wb; |
|
267 |
if ($wb->page_keywords!='') { |
|
268 |
echo $wb->page_keywords; |
|
269 |
} else { |
|
270 |
echo WEBSITE_KEYWORDS; |
|
271 |
} |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
// Function for page header |
|
276 |
if (!function_exists('page_header')) { |
|
277 |
function page_header($date_format = 'Y') { |
|
278 |
echo WEBSITE_HEADER; |
|
279 |
} |
|
280 |
} |
|
281 |
|
|
282 |
// Function for page footer |
|
283 |
if (!function_exists('page_footer')) { |
|
284 |
function page_footer($date_format = 'Y') { |
|
285 |
global $starttime; |
|
286 |
$vars = array('[YEAR]', '[PROCESS_TIME]'); |
|
287 |
$processtime=array_sum(explode(" ",microtime()))-$starttime; |
|
288 |
$values = array(date($date_format),$processtime); |
|
289 |
echo str_replace($vars, $values, WEBSITE_FOOTER); |
|
290 |
} |
|
291 |
} |
|
292 |
|
|
293 |
// Function to include optional module CSS stylesheets (module.css) into the <head> section |
|
294 |
if (!function_exists('page_css')) { |
|
295 |
function page_css() { |
|
296 |
global $wb, $database; |
|
297 |
$css_head = ""; |
|
298 |
|
|
299 |
// obtain list of modules used for actual displayed page |
|
300 |
$page_id=$wb->page_id; |
|
301 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections WHERE page_id=$page_id AND module<>'wysiwyg'"); |
|
302 |
while($row = $query_modules->fetchRow()) { |
|
303 |
if(file_exists(WB_PATH .'/modules/' .$row['module'] .'/module.css')) { |
|
304 |
// build css link for current module.css |
|
305 |
$css_link = "<link href=\"" .WB_URL ."/modules/" .$row['module']; |
|
306 |
$css_link .= "/module.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />\n"; |
|
307 |
// ensure that module.css is not added twice (e.g. if 2 sections include the same module) |
|
308 |
$css_head = str_replace($css_link, "", $css_head); |
|
309 |
$css_head .= $css_link; |
|
310 |
} |
|
311 |
} |
|
312 |
// write out links to all external module stylesheets (module.css) |
|
313 |
if($css_head != "") { |
|
314 |
$css_head = "<!-- Include external module CSS stylesheets -->\n" .$css_head; |
|
315 |
echo $css_head; |
|
316 |
} |
|
317 |
} |
|
318 |
} |
|
319 |
|
|
320 |
// Function to include optional module javascript files (module.js) into the <head> section |
|
321 |
if (!function_exists('page_javascript')) { |
|
322 |
function page_javascript() { |
|
323 |
global $wb, $database; |
|
324 |
$js_head = ""; |
|
325 |
|
|
326 |
// obtain list of modules used for actual displayed page |
|
327 |
$page_id=$wb->page_id; |
|
328 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections WHERE page_id=$page_id AND module<>'wysiwyg'"); |
|
329 |
while($row = $query_modules->fetchRow()) { |
|
330 |
if(file_exists(WB_PATH .'/modules/' .$row['module'] .'/module.js')) { |
|
331 |
// build javascript link for current module.js |
|
332 |
$js_link = "<script type=\"text/javascript\" src=\"" .WB_URL ."/modules/" .$row['module']; |
|
333 |
$js_link .= "/module.js\"></script>\n"; |
|
334 |
// ensure that module.js is not added twice (e.g. if 2 sections include the same module) |
|
335 |
$js_head = str_replace($js_link, "", $js_head); |
|
336 |
$js_head .= $js_link; |
|
337 |
} |
|
338 |
} |
|
339 |
// write out links to all external module javascript files (module.js) |
|
340 |
if($js_head != "") { |
|
341 |
$js_head = "<!-- Include external module javascript files -->\n" .$js_head; |
|
342 |
echo $js_head; |
|
343 |
} |
|
344 |
} |
|
345 |
} |
|
346 |
|
|
347 |
// Begin WB < 2.4.x template compatibility code |
|
348 |
// Make extra_sql accessable through private_sql |
|
349 |
$private_sql = $extra_sql; |
|
350 |
$private_where_sql = $extra_where_sql; |
|
351 |
// Query pages for menu |
|
352 |
$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"); |
|
353 |
// Check if current pages is a parent page and if we need its submenu |
|
354 |
if(PARENT == 0) { |
|
355 |
// Get the pages submenu |
|
356 |
$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"); |
|
357 |
} else { |
|
358 |
// Get the pages submenu |
|
359 |
$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"); |
|
360 |
} |
|
361 |
// End WB < 2.4.x template compatibility code |
|
362 |
// Include template file |
|
363 |
|
|
364 |
|
|
278 | 365 |
?> |
Also available in: Unified diff
again copied all changes for WB 2.6.6 from trunk to branches