Revision 552
Added by thorn almost 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-2008, 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 |
array_walk($arr_string, create_function('&$v,$k','$v = preg_quote($v, \'/\');')); |
|
75 |
$search_string = implode("|", $arr_string); |
|
76 |
$string = entities_to_umlauts($search_string, 'UTF-8'); |
|
77 |
$string = strtr($string, $string_ul_umlauts); |
|
78 |
// do some magic to prevent < > ... from being highlighted |
|
79 |
$foo = strtr($foo, array("<"=>"!,,!", ">"=>"!,,,!", "&"=>"!,,,,!", """=>"!,,,,,!", "'"=>"!,,,,,,!")); |
|
80 |
$string = strtr($string, array("<"=>"!,,!", ">"=>"!,,,!", "&"=>"!,,,,!", """=>"!,,,,,!", "'"=>"!,,,,,,!")); |
|
81 |
$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo); |
|
82 |
$pos = strpos($foo, '<'); |
|
83 |
if ($pos === false) { // "===" means identicaly |
|
84 |
$foo = preg_replace('/('.$string.')/i', '<span class="highlight">$1</span>',$foo); |
|
85 |
} |
|
86 |
$foo = strtr($foo, array("!,,!"=>"<", "!,,,!"=>">", "!,,,,!"=>"&", "!,,,,,!"=>""", "!,,,,,,!"=>"'")); |
|
87 |
//$foo = umlauts_to_defcharset($foo, 'UTF-8'); |
|
88 |
if(DEFAULT_CHARSET != 'utf-8') { |
|
89 |
$foo = umlauts_to_entities($foo, 'UTF-8'); |
|
90 |
} |
|
91 |
return $foo; |
|
92 |
} |
|
93 |
|
|
94 |
// Old menu call invokes new menu function |
|
95 |
if (!function_exists('page_menu')) { |
|
96 |
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) { |
|
97 |
global $wb; |
|
98 |
$wb->menu_number=$menu_number; |
|
99 |
$wb->menu_item_template=$item_template; |
|
100 |
$wb->menu_item_footer=''; |
|
101 |
$wb->menu_parent = $parent; |
|
102 |
$wb->menu_header = $menu_header; |
|
103 |
$wb->menu_footer = $menu_footer; |
|
104 |
$wb->menu_default_class = $default_class; |
|
105 |
$wb->menu_current_class = $current_class; |
|
106 |
$wb->menu_recurse = $recurse+2; |
|
107 |
$wb->menu(); |
|
108 |
unset($wb->menu_parent); |
|
109 |
unset($wb->menu_number); |
|
110 |
unset($wb->menu_item_template); |
|
111 |
unset($wb->menu_item_footer); |
|
112 |
unset($wb->menu_header); |
|
113 |
unset($wb->menu_footer); |
|
114 |
unset($wb->menu_default_class); |
|
115 |
unset($wb->menu_current_class); |
|
116 |
unset($wb->menu_start_level); |
|
117 |
unset($wb->menu_collapse); |
|
118 |
unset($wb->menu_recurse); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
if (!function_exists('show_menu')) { |
|
123 |
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) { |
|
124 |
global $wb; |
|
125 |
if (isset($menu_number)) |
|
126 |
$wb->menu_number=$menu_number; |
|
127 |
if (isset($start_level)) |
|
128 |
$wb->menu_start_level=$start_level; |
|
129 |
if (isset($recurse)) |
|
130 |
$wb->menu_recurse=$recurse; |
|
131 |
if (isset($collapse)) |
|
132 |
$wb->menu_collapse=$collapse; |
|
133 |
if (isset($item_template)) |
|
134 |
$wb->menu_item_template=$item_template; |
|
135 |
if (isset($item_footer)) |
|
136 |
$wb->menu_item_footer=$item_footer; |
|
137 |
if (isset($menu_header)) |
|
138 |
$wb->menu_header=$menu_header; |
|
139 |
if (isset($menu_footer)) |
|
140 |
$wb->menu_footer=$menu_footer; |
|
141 |
if (isset($default_class)) |
|
142 |
$wb->menu_default_class=$default_class; |
|
143 |
if (isset($current_class)) |
|
144 |
$wb->menu_current_class=$current_class; |
|
145 |
if (isset($parent)) |
|
146 |
$wb->menu_parent=$parent; |
|
147 |
$wb->menu(); |
|
148 |
unset($wb->menu_recurse); |
|
149 |
unset($wb->menu_parent); |
|
150 |
unset($wb->menu_start_level); |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
if (!function_exists('page_content')) { |
|
155 |
function page_content($block = 1) { |
|
156 |
// Get outside objects |
|
157 |
global $TEXT,$MENU,$HEADING,$MESSAGE; |
|
158 |
global $globals; |
|
159 |
global $database; |
|
160 |
global $wb; |
|
161 |
$admin = & $wb; |
|
162 |
if ($wb->page_access_denied==true) { |
|
163 |
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS']; |
|
164 |
exit(); |
|
165 |
} |
|
166 |
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } } |
|
167 |
// Make sure block is numeric |
|
168 |
if(!is_numeric($block)) { $block = 1; } |
|
169 |
// Include page content |
|
170 |
if(!defined('PAGE_CONTENT') OR $block!=1) { |
|
171 |
$page_id=$wb->page_id; |
|
172 |
// First get all sections for this page |
|
173 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
174 |
// If none were found, check if default content is supposed to be shown |
|
175 |
if($query_sections->numRows() == 0) { |
|
176 |
if ($wb->default_block_content=='none') { |
|
177 |
return; |
|
178 |
} |
|
179 |
if (is_numeric($wb->default_block_content)) { |
|
180 |
$page_id=$wb->default_block_content; |
|
181 |
} else { |
|
182 |
$page_id=$wb->default_page_id; |
|
183 |
} |
|
184 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
185 |
// Still no cotent found? Give it up, there's just nothing to show! |
|
186 |
if($query_sections->numRows() == 0) { |
|
187 |
return; |
|
188 |
} |
|
189 |
} |
|
190 |
// Loop through them and include their module file |
|
191 |
while($section = $query_sections->fetchRow()) { |
|
192 |
$section_id = $section['section_id']; |
|
193 |
$module = $section['module']; |
|
194 |
// highlights searchresults |
|
195 |
if (isset($_GET['searchresult']) AND is_numeric($_GET['searchresult']) ) { |
|
196 |
if (isset($_GET['sstring']) AND !empty($_GET['sstring']) ){ |
|
197 |
$arr_string = explode(" ", $_GET['sstring']); |
|
198 |
if($_GET['searchresult'] == 2) { |
|
199 |
// exact match |
|
200 |
$arr_string[0] = strtr($arr_string[0], "_"," "); |
|
201 |
} |
|
202 |
ob_start(); //start output buffer |
|
203 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
204 |
$foo = ob_get_contents(); // put outputbuffer in $foo |
|
205 |
ob_end_clean(); // clear outputbuffer |
|
206 |
echo search_highlight($foo, $arr_string); |
|
207 |
} |
|
208 |
} else { |
|
209 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
210 |
} |
|
211 |
} |
|
212 |
} else { |
|
213 |
require(PAGE_CONTENT); |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
if (!function_exists('show_content')) { |
|
219 |
function show_content($block=1) { |
|
220 |
page_content($block); |
|
221 |
} |
|
222 |
} |
|
223 |
|
|
224 |
if (!function_exists('show_breadcrumbs')) { |
|
225 |
function show_breadcrumbs($sep=' > ',$tier=1,$links=true,$depth=-1) { |
|
226 |
global $wb; |
|
227 |
$page_id=$wb->page_id; |
|
228 |
if ($page_id!=0) |
|
229 |
{ |
|
230 |
global $database; |
|
231 |
$bca=$wb->page_trail; |
|
232 |
$counter=0; |
|
233 |
foreach ($bca as $temp) |
|
234 |
{ |
|
235 |
if ($counter>=($tier-1) AND ($depth<0 OR $tier+$depth>$counter)) |
|
236 |
{ |
|
237 |
if ($counter>=$tier) echo $sep; |
|
238 |
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp"); |
|
239 |
$page=$query_menu->fetchRow(); |
|
240 |
if ($links==true AND $temp!=$page_id) |
|
241 |
echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>'; |
|
242 |
else |
|
243 |
echo $page['menu_title']; |
|
244 |
} |
|
245 |
$counter++; |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
// Function for page title |
|
252 |
if (!function_exists('page_title')) { |
|
253 |
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') { |
|
254 |
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]'); |
|
255 |
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer); |
|
256 |
echo str_replace($vars, $values, $template); |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
260 |
// Function for page description |
|
261 |
if (!function_exists('page_description')) { |
|
262 |
function page_description() { |
|
263 |
global $wb; |
|
264 |
if ($wb->page_description!='') { |
|
265 |
echo $wb->page_description; |
|
266 |
} else { |
|
267 |
echo WEBSITE_DESCRIPTION; |
|
268 |
} |
|
269 |
} |
|
270 |
} |
|
271 |
|
|
272 |
// Function for page keywords |
|
273 |
if (!function_exists('page_keywords')) { |
|
274 |
function page_keywords() { |
|
275 |
global $wb; |
|
276 |
if ($wb->page_keywords!='') { |
|
277 |
echo $wb->page_keywords; |
|
278 |
} else { |
|
279 |
echo WEBSITE_KEYWORDS; |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
// Function for page header |
|
285 |
if (!function_exists('page_header')) { |
|
286 |
function page_header($date_format = 'Y') { |
|
287 |
echo WEBSITE_HEADER; |
|
288 |
} |
|
289 |
} |
|
290 |
|
|
291 |
// Function for page footer |
|
292 |
if (!function_exists('page_footer')) { |
|
293 |
function page_footer($date_format = 'Y') { |
|
294 |
global $starttime; |
|
295 |
$vars = array('[YEAR]', '[PROCESS_TIME]'); |
|
296 |
$processtime=array_sum(explode(" ",microtime()))-$starttime; |
|
297 |
$values = array(date($date_format),$processtime); |
|
298 |
echo str_replace($vars, $values, WEBSITE_FOOTER); |
|
299 |
} |
|
300 |
} |
|
301 |
|
|
302 |
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend |
|
303 |
if(!function_exists('register_frontend_modfiles')) { |
|
304 |
function register_frontend_modfiles($file_id="css") { |
|
305 |
// sanity check of parameter passed to the function |
|
306 |
$file_id = strtolower($file_id); |
|
307 |
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") { |
|
308 |
return; |
|
309 |
} |
|
310 |
|
|
311 |
global $wb, $database; |
|
312 |
// define default baselink and filename for optional module javascript and stylesheet files |
|
313 |
$head_links = ""; |
|
314 |
if($file_id == "css") { |
|
315 |
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"'; |
|
316 |
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />'; |
|
317 |
$base_file = "frontend.css"; |
|
318 |
} else { |
|
319 |
$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js"></script>'; |
|
320 |
$base_file = "frontend.js"; |
|
321 |
} |
|
322 |
|
|
323 |
// gather information for all models embedded on actual page |
|
324 |
$page_id = $wb->page_id; |
|
325 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections |
|
326 |
WHERE page_id=$page_id AND module<>'wysiwyg'"); |
|
327 |
|
|
328 |
while($row = $query_modules->fetchRow()) { |
|
329 |
// check if page module directory contains a frontend.js or frontend.css file |
|
330 |
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) { |
|
331 |
// create link with frontend.js or frontend.css source for the current module |
|
332 |
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link); |
|
333 |
|
|
334 |
// define constant indicating that the register_frontent_files was invoked |
|
335 |
if($file_id == 'css') { |
|
336 |
define('MOD_FRONTEND_CSS_REGISTERED', true); |
|
337 |
} else { |
|
338 |
define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true); |
|
339 |
} |
|
340 |
|
|
341 |
// ensure that frontend.js or frontend.css is only added once per module type |
|
342 |
if(strpos($head_links, $tmp_link) === false) { |
|
343 |
$head_links .= $tmp_link ."\n"; |
|
344 |
} |
|
345 |
} |
|
346 |
} |
|
347 |
// write out links with all external module javascript/CSS files, remove last line feed |
|
348 |
echo $head_links; |
|
349 |
} |
|
350 |
} |
|
351 |
|
|
352 |
// Begin WB < 2.4.x template compatibility code |
|
353 |
// Make extra_sql accessable through private_sql |
|
354 |
$private_sql = $extra_sql; |
|
355 |
$private_where_sql = $extra_where_sql; |
|
356 |
// Query pages for menu |
|
357 |
$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"); |
|
358 |
// Check if current pages is a parent page and if we need its submenu |
|
359 |
if(PARENT == 0) { |
|
360 |
// Get the pages submenu |
|
361 |
$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"); |
|
362 |
} else { |
|
363 |
// Get the pages submenu |
|
364 |
$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"); |
|
365 |
} |
|
366 |
// End WB < 2.4.x template compatibility code |
|
367 |
// Include template file |
|
368 |
|
|
369 |
|
|
370 |
?> |
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2008, 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 |
if (!function_exists('search_highlight')) { |
|
71 |
function search_highlight($foo='', $arr_string=array()) { |
|
72 |
require_once(WB_PATH.'/framework/functions.php'); |
|
73 |
require_once(WB_PATH.'/search/search_convert.php'); |
|
74 |
|
|
75 |
$foo = entities_to_umlauts($foo, 'UTF-8'); |
|
76 |
array_walk($arr_string, create_function('&$v,$k','$v = preg_quote($v, \'/\');')); |
|
77 |
$search_string = implode("|", $arr_string); |
|
78 |
$string = entities_to_umlauts($search_string, 'UTF-8'); |
|
79 |
$string = strtr($string, $string_ul_umlauts); |
|
80 |
// special-feature: '|' means word-boundary (\b). Searching for 'the|' will find 'the', but not 'thema'. |
|
81 |
$string = strtr($string, array('\\|'=>'\b')); |
|
82 |
|
|
83 |
// the highlighting |
|
84 |
// match $string, but not inside <style>...</style>, <script>...</script>, <!--...--> or HTML-Tags |
|
85 |
// split $string into pieces - "cut away" styles, scripts, comments, and HTML-tags |
|
86 |
$matches = preg_split("/(<style.*<\/style>|<script.*<\/script>|<!--.*-->|<.*>)/iUs",$foo,-1,(PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY)); |
|
87 |
if(is_array($matches) && $matches != array()) { |
|
88 |
$foo = ""; |
|
89 |
$string = strtr($string, array('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"', '''=>'\'', ' '=>"\xC2\xA0")); |
|
90 |
foreach($matches as $match) { |
|
91 |
if($match{0}!="<") { |
|
92 |
$match = strtr($match, array('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"', '''=>'\'', ' '=>"\xC2\xA0")); |
|
93 |
$match = preg_replace('/('.$string.')/iS', '_span class=_highlight__$1_/span_',$match); |
|
94 |
$match = strtr($match, array('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"', '\''=>''', "\xC2\xA0"=>' ')); |
|
95 |
$match = str_replace(array('_span class=_highlight__', '_/span_'), array('<span class="highlight">', '</span>'), $match); |
|
96 |
} |
|
97 |
$foo .= $match; |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
if(DEFAULT_CHARSET != 'utf-8') { |
|
102 |
$foo = umlauts_to_entities($foo, 'UTF-8'); |
|
103 |
} |
|
104 |
return $foo; |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
// Old menu call invokes new menu function |
|
109 |
if (!function_exists('page_menu')) { |
|
110 |
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) { |
|
111 |
global $wb; |
|
112 |
$wb->menu_number=$menu_number; |
|
113 |
$wb->menu_item_template=$item_template; |
|
114 |
$wb->menu_item_footer=''; |
|
115 |
$wb->menu_parent = $parent; |
|
116 |
$wb->menu_header = $menu_header; |
|
117 |
$wb->menu_footer = $menu_footer; |
|
118 |
$wb->menu_default_class = $default_class; |
|
119 |
$wb->menu_current_class = $current_class; |
|
120 |
$wb->menu_recurse = $recurse+2; |
|
121 |
$wb->menu(); |
|
122 |
unset($wb->menu_parent); |
|
123 |
unset($wb->menu_number); |
|
124 |
unset($wb->menu_item_template); |
|
125 |
unset($wb->menu_item_footer); |
|
126 |
unset($wb->menu_header); |
|
127 |
unset($wb->menu_footer); |
|
128 |
unset($wb->menu_default_class); |
|
129 |
unset($wb->menu_current_class); |
|
130 |
unset($wb->menu_start_level); |
|
131 |
unset($wb->menu_collapse); |
|
132 |
unset($wb->menu_recurse); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
if (!function_exists('show_menu')) { |
|
137 |
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) { |
|
138 |
global $wb; |
|
139 |
if (isset($menu_number)) |
|
140 |
$wb->menu_number=$menu_number; |
|
141 |
if (isset($start_level)) |
|
142 |
$wb->menu_start_level=$start_level; |
|
143 |
if (isset($recurse)) |
|
144 |
$wb->menu_recurse=$recurse; |
|
145 |
if (isset($collapse)) |
|
146 |
$wb->menu_collapse=$collapse; |
|
147 |
if (isset($item_template)) |
|
148 |
$wb->menu_item_template=$item_template; |
|
149 |
if (isset($item_footer)) |
|
150 |
$wb->menu_item_footer=$item_footer; |
|
151 |
if (isset($menu_header)) |
|
152 |
$wb->menu_header=$menu_header; |
|
153 |
if (isset($menu_footer)) |
|
154 |
$wb->menu_footer=$menu_footer; |
|
155 |
if (isset($default_class)) |
|
156 |
$wb->menu_default_class=$default_class; |
|
157 |
if (isset($current_class)) |
|
158 |
$wb->menu_current_class=$current_class; |
|
159 |
if (isset($parent)) |
|
160 |
$wb->menu_parent=$parent; |
|
161 |
$wb->menu(); |
|
162 |
unset($wb->menu_recurse); |
|
163 |
unset($wb->menu_parent); |
|
164 |
unset($wb->menu_start_level); |
|
165 |
} |
|
166 |
} |
|
167 |
|
|
168 |
if (!function_exists('page_content')) { |
|
169 |
function page_content($block = 1) { |
|
170 |
// Get outside objects |
|
171 |
global $TEXT,$MENU,$HEADING,$MESSAGE; |
|
172 |
global $globals; |
|
173 |
global $database; |
|
174 |
global $wb; |
|
175 |
$admin = & $wb; |
|
176 |
if ($wb->page_access_denied==true) { |
|
177 |
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS']; |
|
178 |
exit(); |
|
179 |
} |
|
180 |
if ($wb->page_no_active_sections==true) { |
|
181 |
echo $MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS']; |
|
182 |
exit(); |
|
183 |
} |
|
184 |
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } } |
|
185 |
// Make sure block is numeric |
|
186 |
if(!is_numeric($block)) { $block = 1; } |
|
187 |
// Include page content |
|
188 |
if(!defined('PAGE_CONTENT') OR $block!=1) { |
|
189 |
$page_id=$wb->page_id; |
|
190 |
// First get all sections for this page |
|
191 |
$query_sections = $database->query("SELECT section_id,module,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
192 |
// If none were found, check if default content is supposed to be shown |
|
193 |
if($query_sections->numRows() == 0) { |
|
194 |
if ($wb->default_block_content=='none') { |
|
195 |
return; |
|
196 |
} |
|
197 |
if (is_numeric($wb->default_block_content)) { |
|
198 |
$page_id=$wb->default_block_content; |
|
199 |
} else { |
|
200 |
$page_id=$wb->default_page_id; |
|
201 |
} |
|
202 |
$query_sections = $database->query("SELECT section_id,module,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
203 |
// Still no cotent found? Give it up, there's just nothing to show! |
|
204 |
if($query_sections->numRows() == 0) { |
|
205 |
return; |
|
206 |
} |
|
207 |
} |
|
208 |
// Loop through them and include their module file |
|
209 |
while($section = $query_sections->fetchRow()) { |
|
210 |
// skip this section if it is out of publication-date |
|
211 |
$now = time(); |
|
212 |
if( !( $now<$section['publ_end'] && ($now>$section['publ_start'] || $section['publ_start']==0) || |
|
213 |
$now>$section['publ_start'] && $section['publ_end']==0) ) { |
|
214 |
continue; |
|
215 |
} |
|
216 |
$section_id = $section['section_id']; |
|
217 |
$module = $section['module']; |
|
218 |
// make a anchor for every section. This is for the search_extension |
|
219 |
echo "<a id=\"wb_section_$section_id\" name=\"wb_section_$section_id\"></a>"; |
|
220 |
// highlights searchresults |
|
221 |
if (isset($_GET['searchresult']) AND is_numeric($_GET['searchresult']) AND !isset($_GET['nohighlight'])) { |
|
222 |
if (isset($_GET['sstring']) AND !empty($_GET['sstring']) ){ |
|
223 |
$arr_string = explode(" ", $_GET['sstring']); |
|
224 |
if($_GET['searchresult'] == 2) { |
|
225 |
// exact match |
|
226 |
$arr_string[0] = strtr($arr_string[0], "_"," "); |
|
227 |
} |
|
228 |
ob_start(); //start output buffer |
|
229 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
230 |
$foo = ob_get_contents(); // put outputbuffer in $foo |
|
231 |
ob_end_clean(); // clear outputbuffer |
|
232 |
echo search_highlight($foo, $arr_string); |
|
233 |
} |
|
234 |
} else { |
|
235 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
236 |
} |
|
237 |
} |
|
238 |
} else { |
|
239 |
require(PAGE_CONTENT); |
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
if (!function_exists('show_content')) { |
|
245 |
function show_content($block=1) { |
|
246 |
page_content($block); |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
if (!function_exists('show_breadcrumbs')) { |
|
251 |
function show_breadcrumbs($sep=' > ',$tier=1,$links=true,$depth=-1) { |
|
252 |
global $wb; |
|
253 |
$page_id=$wb->page_id; |
|
254 |
if ($page_id!=0) |
|
255 |
{ |
|
256 |
global $database; |
|
257 |
$bca=$wb->page_trail; |
|
258 |
$counter=0; |
|
259 |
foreach ($bca as $temp) |
|
260 |
{ |
|
261 |
if ($counter>=($tier-1) AND ($depth<0 OR $tier+$depth>$counter)) |
|
262 |
{ |
|
263 |
if ($counter>=$tier) echo $sep; |
|
264 |
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp"); |
|
265 |
$page=$query_menu->fetchRow(); |
|
266 |
if ($links==true AND $temp!=$page_id) |
|
267 |
echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>'; |
|
268 |
else |
|
269 |
echo $page['menu_title']; |
|
270 |
} |
|
271 |
$counter++; |
|
272 |
} |
|
273 |
} |
|
274 |
} |
|
275 |
} |
|
276 |
|
|
277 |
// Function for page title |
|
278 |
if (!function_exists('page_title')) { |
|
279 |
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') { |
|
280 |
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]'); |
|
281 |
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer); |
|
282 |
echo str_replace($vars, $values, $template); |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
// Function for page description |
|
287 |
if (!function_exists('page_description')) { |
|
288 |
function page_description() { |
|
289 |
global $wb; |
|
290 |
if ($wb->page_description!='') { |
|
291 |
echo $wb->page_description; |
|
292 |
} else { |
|
293 |
echo WEBSITE_DESCRIPTION; |
|
294 |
} |
|
295 |
} |
|
296 |
} |
|
297 |
|
|
298 |
// Function for page keywords |
|
299 |
if (!function_exists('page_keywords')) { |
|
300 |
function page_keywords() { |
|
301 |
global $wb; |
|
302 |
if ($wb->page_keywords!='') { |
|
303 |
echo $wb->page_keywords; |
|
304 |
} else { |
|
305 |
echo WEBSITE_KEYWORDS; |
|
306 |
} |
|
307 |
} |
|
308 |
} |
|
309 |
|
|
310 |
// Function for page header |
|
311 |
if (!function_exists('page_header')) { |
|
312 |
function page_header($date_format = 'Y') { |
|
313 |
echo WEBSITE_HEADER; |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
// Function for page footer |
|
318 |
if (!function_exists('page_footer')) { |
|
319 |
function page_footer($date_format = 'Y') { |
|
320 |
global $starttime; |
|
321 |
$vars = array('[YEAR]', '[PROCESS_TIME]'); |
|
322 |
$processtime=array_sum(explode(" ",microtime()))-$starttime; |
|
323 |
$values = array(date($date_format),$processtime); |
|
324 |
echo str_replace($vars, $values, WEBSITE_FOOTER); |
|
325 |
} |
|
326 |
} |
|
327 |
|
|
328 |
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend |
|
329 |
if(!function_exists('register_frontend_modfiles')) { |
|
330 |
function register_frontend_modfiles($file_id="css") { |
|
331 |
// sanity check of parameter passed to the function |
|
332 |
$file_id = strtolower($file_id); |
|
333 |
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") { |
|
334 |
return; |
|
335 |
} |
|
336 |
|
|
337 |
global $wb, $database; |
|
338 |
// define default baselink and filename for optional module javascript and stylesheet files |
|
339 |
$head_links = ""; |
|
340 |
if($file_id == "css") { |
|
341 |
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"'; |
|
342 |
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />'; |
|
343 |
$base_file = "frontend.css"; |
|
344 |
} else { |
|
345 |
$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js"></script>'; |
|
346 |
$base_file = "frontend.js"; |
|
347 |
} |
|
348 |
|
|
349 |
// gather information for all models embedded on actual page |
|
350 |
$page_id = $wb->page_id; |
|
351 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections |
|
352 |
WHERE page_id=$page_id AND module<>'wysiwyg'"); |
|
353 |
|
|
354 |
while($row = $query_modules->fetchRow()) { |
|
355 |
// check if page module directory contains a frontend.js or frontend.css file |
|
356 |
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) { |
|
357 |
// create link with frontend.js or frontend.css source for the current module |
|
358 |
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link); |
|
359 |
|
|
360 |
// define constant indicating that the register_frontent_files was invoked |
|
361 |
if($file_id == 'css') { |
|
362 |
define('MOD_FRONTEND_CSS_REGISTERED', true); |
|
363 |
} else { |
|
364 |
define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true); |
|
365 |
} |
|
366 |
|
|
367 |
// ensure that frontend.js or frontend.css is only added once per module type |
|
368 |
if(strpos($head_links, $tmp_link) === false) { |
|
369 |
$head_links .= $tmp_link ."\n"; |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
// write out links with all external module javascript/CSS files, remove last line feed |
|
374 |
echo $head_links; |
|
375 |
} |
|
376 |
} |
|
377 |
|
|
378 |
// Begin WB < 2.4.x template compatibility code |
|
379 |
// Make extra_sql accessable through private_sql |
|
380 |
$private_sql = $extra_sql; |
|
381 |
$private_where_sql = $extra_where_sql; |
|
382 |
// Query pages for menu |
|
383 |
$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"); |
|
384 |
// Check if current pages is a parent page and if we need its submenu |
|
385 |
if(PARENT == 0) { |
|
386 |
// Get the pages submenu |
|
387 |
$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"); |
|
388 |
} else { |
|
389 |
// Get the pages submenu |
|
390 |
$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"); |
|
391 |
} |
|
392 |
// End WB < 2.4.x template compatibility code |
|
393 |
// Include template file |
|
394 |
|
|
395 |
|
|
396 |
?> |
Also available in: Unified diff
added new module-based search-function and publish-by-date code