1 |
1165
|
Luisehahne
|
<?php
|
2 |
|
|
|
3 |
|
|
// $Id$
|
4 |
|
|
|
5 |
|
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
|
|
Copyright (C) 2004-2009, 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 |
|
|
$include_head_link_css = '';
|
51 |
|
|
$include_body_links = '';
|
52 |
|
|
$include_head_links = '';
|
53 |
|
|
|
54 |
|
|
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
|
55 |
|
|
$query_result=$database->query($query);
|
56 |
|
|
if ($query_result->numRows()>0) {
|
57 |
|
|
while ($row = $query_result->fetchRow()) {
|
58 |
|
|
$module_dir = $row['directory'];
|
59 |
|
|
if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
|
60 |
|
|
include(WB_PATH.'/modules/'.$module_dir.'/include.php');
|
61 |
|
|
/* check if frontend.css file needs to be included into the <head></head> of index.php
|
62 |
|
|
*/
|
63 |
|
|
if( file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend.css')) {
|
64 |
|
|
$include_head_link_css .= '<link href="'.WB_URL.'/modules/'.$module_dir.'/frontend.css"';
|
65 |
|
|
$include_head_link_css .= ' rel="stylesheet" type="text/css" media="screen" />'."\n";
|
66 |
|
|
$include_head_file = 'frontend.css';
|
67 |
|
|
}
|
68 |
|
|
// check if frontend.js file needs to be included into the <body></body> of index.php
|
69 |
|
|
if(file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend.js')) {
|
70 |
|
|
$include_head_links .= '<script src="'.WB_URL.'/modules/'.$module_dir.'/frontend.js" type="text/javascript"></script>'."\n";
|
71 |
|
|
$include_head_file = 'frontend.js';
|
72 |
|
|
}
|
73 |
|
|
// check if frontend_body.js file needs to be included into the <body></body> of index.php
|
74 |
|
|
if(file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend_body.js')) {
|
75 |
|
|
$include_body_links .= '<script src="'.WB_URL.'/modules/'.$module_dir.'/frontend_body.js" type="text/javascript"></script>'."\n";
|
76 |
|
|
$include_body_file = 'frontend_body.js';
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
// Frontend functions
|
83 |
|
|
if (!function_exists('page_link')) {
|
84 |
|
|
function page_link($link) {
|
85 |
|
|
global $wb;
|
86 |
|
|
return $wb->page_link($link);
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
//function to highlight search results
|
91 |
|
|
if(!function_exists('search_highlight')) {
|
92 |
|
|
function search_highlight($foo='', $arr_string=array()) {
|
93 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
94 |
|
|
static $string_ul_umlaut = FALSE;
|
95 |
|
|
static $string_ul_regex = FALSE;
|
96 |
|
|
if($string_ul_umlaut===FALSE || $string_ul_regex===FALSE)
|
97 |
|
|
require(WB_PATH.'/search/search_convert.php');
|
98 |
|
|
$foo = entities_to_umlauts($foo, 'UTF-8');
|
99 |
|
|
array_walk($arr_string, create_function('&$v,$k','$v = preg_quote($v, \'~\');'));
|
100 |
|
|
$search_string = implode("|", $arr_string);
|
101 |
|
|
$string = str_replace($string_ul_umlaut, $string_ul_regex, $search_string);
|
102 |
|
|
// the highlighting
|
103 |
|
|
// match $string, but not inside <style>...</style>, <script>...</script>, <!--...--> or HTML-Tags
|
104 |
1171
|
Ruud
|
// Also droplet tags are now excluded from highlighting.
|
105 |
1165
|
Luisehahne
|
// split $string into pieces - "cut away" styles, scripts, comments, HTML-tags and eMail-addresses
|
106 |
|
|
// we have to cut <pre> and <code> as well.
|
107 |
|
|
// for HTML-Tags use <(?:[^<]|<.*>)*> which will match strings like <input ... value="<b>value</b>" >
|
108 |
1171
|
Ruud
|
$matches = preg_split("~(\[\[.*\]\]|<style.*</style>|<script.*</script>|<pre.*</pre>|<code.*</code>|<!--.*-->|<(?:[^<]|<.*>)*>|\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}\b)~iUs",$foo,-1,(PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY));
|
109 |
1165
|
Luisehahne
|
if(is_array($matches) && $matches != array()) {
|
110 |
|
|
$foo = "";
|
111 |
|
|
foreach($matches as $match) {
|
112 |
1171
|
Ruud
|
if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}$/i', $match) && !preg_match('~\[\[.*\]\]~', $match)) {
|
113 |
1165
|
Luisehahne
|
$match = str_replace(array('<', '>', '&', '"', ''', ' '), array('<', '>', '&', '"', '\'', "\xC2\xA0"), $match);
|
114 |
|
|
$match = preg_replace('~('.$string.')~ui', '_span class=_highlight__$1_/span_',$match);
|
115 |
|
|
$match = str_replace(array('&', '<', '>', '"', '\'', "\xC2\xA0"), array('&', '<', '>', '"', ''', ' '), $match);
|
116 |
|
|
$match = str_replace(array('_span class=_highlight__', '_/span_'), array('<span class="highlight">', '</span>'), $match);
|
117 |
|
|
}
|
118 |
|
|
$foo .= $match;
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
if(DEFAULT_CHARSET != 'utf-8') {
|
123 |
|
|
$foo = umlauts_to_entities($foo, 'UTF-8');
|
124 |
|
|
}
|
125 |
|
|
return $foo;
|
126 |
|
|
}
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
// Old menu call invokes new menu function
|
130 |
|
|
if (!function_exists('page_menu')) {
|
131 |
|
|
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) {
|
132 |
|
|
global $wb;
|
133 |
|
|
$wb->menu_number=$menu_number;
|
134 |
|
|
$wb->menu_item_template=$item_template;
|
135 |
|
|
$wb->menu_item_footer='';
|
136 |
|
|
$wb->menu_parent = $parent;
|
137 |
|
|
$wb->menu_header = $menu_header;
|
138 |
|
|
$wb->menu_footer = $menu_footer;
|
139 |
|
|
$wb->menu_default_class = $default_class;
|
140 |
|
|
$wb->menu_current_class = $current_class;
|
141 |
|
|
$wb->menu_recurse = $recurse+2;
|
142 |
|
|
$wb->menu();
|
143 |
|
|
unset($wb->menu_parent);
|
144 |
|
|
unset($wb->menu_number);
|
145 |
|
|
unset($wb->menu_item_template);
|
146 |
|
|
unset($wb->menu_item_footer);
|
147 |
|
|
unset($wb->menu_header);
|
148 |
|
|
unset($wb->menu_footer);
|
149 |
|
|
unset($wb->menu_default_class);
|
150 |
|
|
unset($wb->menu_current_class);
|
151 |
|
|
unset($wb->menu_start_level);
|
152 |
|
|
unset($wb->menu_collapse);
|
153 |
|
|
unset($wb->menu_recurse);
|
154 |
|
|
}
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
if (!function_exists('show_menu')) {
|
158 |
|
|
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) {
|
159 |
|
|
global $wb;
|
160 |
|
|
if (isset($menu_number))
|
161 |
|
|
$wb->menu_number=$menu_number;
|
162 |
|
|
if (isset($start_level))
|
163 |
|
|
$wb->menu_start_level=$start_level;
|
164 |
|
|
if (isset($recurse))
|
165 |
|
|
$wb->menu_recurse=$recurse;
|
166 |
|
|
if (isset($collapse))
|
167 |
|
|
$wb->menu_collapse=$collapse;
|
168 |
|
|
if (isset($item_template))
|
169 |
|
|
$wb->menu_item_template=$item_template;
|
170 |
|
|
if (isset($item_footer))
|
171 |
|
|
$wb->menu_item_footer=$item_footer;
|
172 |
|
|
if (isset($menu_header))
|
173 |
|
|
$wb->menu_header=$menu_header;
|
174 |
|
|
if (isset($menu_footer))
|
175 |
|
|
$wb->menu_footer=$menu_footer;
|
176 |
|
|
if (isset($default_class))
|
177 |
|
|
$wb->menu_default_class=$default_class;
|
178 |
|
|
if (isset($current_class))
|
179 |
|
|
$wb->menu_current_class=$current_class;
|
180 |
|
|
if (isset($parent))
|
181 |
|
|
$wb->menu_parent=$parent;
|
182 |
|
|
$wb->menu();
|
183 |
|
|
unset($wb->menu_recurse);
|
184 |
|
|
unset($wb->menu_parent);
|
185 |
|
|
unset($wb->menu_start_level);
|
186 |
|
|
}
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
if (!function_exists('page_content')) {
|
190 |
|
|
function page_content($block = 1) {
|
191 |
|
|
// Get outside objects
|
192 |
|
|
global $TEXT,$MENU,$HEADING,$MESSAGE;
|
193 |
|
|
global $globals;
|
194 |
|
|
global $database;
|
195 |
|
|
global $wb;
|
196 |
|
|
$admin = & $wb;
|
197 |
|
|
if ($wb->page_access_denied==true) {
|
198 |
|
|
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
|
199 |
|
|
exit();
|
200 |
|
|
}
|
201 |
|
|
if ($wb->page_no_active_sections==true) {
|
202 |
|
|
echo $MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'];
|
203 |
|
|
exit();
|
204 |
|
|
}
|
205 |
|
|
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
|
206 |
|
|
// Make sure block is numeric
|
207 |
|
|
if(!is_numeric($block)) { $block = 1; }
|
208 |
|
|
// Include page content
|
209 |
|
|
if(!defined('PAGE_CONTENT') OR $block!=1) {
|
210 |
|
|
$page_id=$wb->page_id;
|
211 |
|
|
// First get all sections for this page
|
212 |
|
|
$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");
|
213 |
|
|
// If none were found, check if default content is supposed to be shown
|
214 |
|
|
if($query_sections->numRows() == 0) {
|
215 |
|
|
if ($wb->default_block_content=='none') {
|
216 |
|
|
return;
|
217 |
|
|
}
|
218 |
|
|
if (is_numeric($wb->default_block_content)) {
|
219 |
|
|
$page_id=$wb->default_block_content;
|
220 |
|
|
} else {
|
221 |
|
|
$page_id=$wb->default_page_id;
|
222 |
|
|
}
|
223 |
|
|
$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");
|
224 |
|
|
// Still no cotent found? Give it up, there's just nothing to show!
|
225 |
|
|
if($query_sections->numRows() == 0) {
|
226 |
|
|
return;
|
227 |
|
|
}
|
228 |
|
|
}
|
229 |
|
|
// Loop through them and include their module file
|
230 |
|
|
while($section = $query_sections->fetchRow()) {
|
231 |
|
|
// skip this section if it is out of publication-date
|
232 |
|
|
$now = time();
|
233 |
|
|
if( !(($now<=$section['publ_end'] || $section['publ_end']==0) && ($now>=$section['publ_start'] || $section['publ_start']==0)) ) {
|
234 |
|
|
continue;
|
235 |
|
|
}
|
236 |
|
|
$section_id = $section['section_id'];
|
237 |
|
|
$module = $section['module'];
|
238 |
|
|
// make a anchor for every section.
|
239 |
|
|
if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
|
240 |
|
|
echo '<a class="section_anchor" id="'.SEC_ANCHOR.$section_id.'" name="'.SEC_ANCHOR.$section_id.'"></a>';
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
// fetch content -- this is where to place possible output-filters (before highlighting)
|
244 |
|
|
ob_start(); // fetch original content
|
245 |
|
|
require(WB_PATH.'/modules/'.$module.'/view.php');
|
246 |
|
|
$content = ob_get_contents();
|
247 |
|
|
ob_end_clean();
|
248 |
|
|
|
249 |
|
|
// highlights searchresults
|
250 |
|
|
if(isset($_GET['searchresult']) && is_numeric($_GET['searchresult']) && !isset($_GET['nohighlight']) && isset($_GET['sstring']) && !empty($_GET['sstring'])) {
|
251 |
|
|
$arr_string = explode(" ", $_GET['sstring']);
|
252 |
|
|
if($_GET['searchresult']==2) { // exact match
|
253 |
|
|
$arr_string[0] = str_replace("_", " ", $arr_string[0]);
|
254 |
|
|
}
|
255 |
|
|
echo search_highlight($content, $arr_string);
|
256 |
|
|
} else {
|
257 |
|
|
echo $content;
|
258 |
|
|
}
|
259 |
|
|
}
|
260 |
|
|
} else {
|
261 |
|
|
require(PAGE_CONTENT);
|
262 |
|
|
}
|
263 |
|
|
}
|
264 |
|
|
}
|
265 |
|
|
|
266 |
|
|
if (!function_exists('show_content')) {
|
267 |
|
|
function show_content($block=1) {
|
268 |
|
|
page_content($block);
|
269 |
|
|
}
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
if (!function_exists('show_breadcrumbs'))
|
273 |
|
|
{
|
274 |
|
|
function show_breadcrumbs($sep=' » ',$tier=1,$links=true,$depth=-1, $title='You are here: ')
|
275 |
|
|
{
|
276 |
|
|
global $wb;
|
277 |
|
|
$page_id=$wb->page_id;
|
278 |
|
|
if ($page_id!=0)
|
279 |
|
|
{
|
280 |
|
|
global $database;
|
281 |
|
|
$bca=$wb->page_trail;
|
282 |
|
|
$counter=0;
|
283 |
|
|
print '<div class="breadcrumb">'.$title;
|
284 |
|
|
|
285 |
|
|
foreach ($bca as $temp)
|
286 |
|
|
{
|
287 |
|
|
if ($counter>=($tier-1) AND ($depth<0 OR $tier+$depth>$counter))
|
288 |
|
|
{
|
289 |
|
|
if ($counter>=$tier) print '<span class="separator">'.$sep.'</span>';
|
290 |
|
|
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
|
291 |
|
|
$page=$query_menu->fetchRow();
|
292 |
|
|
if ($links==true AND $temp!=$page_id)
|
293 |
|
|
{
|
294 |
|
|
print '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
|
295 |
|
|
}
|
296 |
|
|
else
|
297 |
|
|
{
|
298 |
|
|
print '<span>'.$page['menu_title'].'</span>';
|
299 |
|
|
}
|
300 |
|
|
}
|
301 |
|
|
$counter++;
|
302 |
|
|
}
|
303 |
|
|
print "</div>\n";
|
304 |
|
|
}
|
305 |
|
|
}
|
306 |
|
|
}
|
307 |
|
|
|
308 |
|
|
// Function for page title
|
309 |
|
|
if (!function_exists('page_title')) {
|
310 |
|
|
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
|
311 |
|
|
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
|
312 |
|
|
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
|
313 |
|
|
echo str_replace($vars, $values, $template);
|
314 |
|
|
}
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
// Function for page description
|
318 |
|
|
if (!function_exists('page_description')) {
|
319 |
|
|
function page_description() {
|
320 |
|
|
global $wb;
|
321 |
|
|
if ($wb->page_description!='') {
|
322 |
|
|
echo $wb->page_description;
|
323 |
|
|
} else {
|
324 |
|
|
echo WEBSITE_DESCRIPTION;
|
325 |
|
|
}
|
326 |
|
|
}
|
327 |
|
|
}
|
328 |
|
|
|
329 |
|
|
// Function for page keywords
|
330 |
|
|
if (!function_exists('page_keywords')) {
|
331 |
|
|
function page_keywords() {
|
332 |
|
|
global $wb;
|
333 |
|
|
if ($wb->page_keywords!='') {
|
334 |
|
|
echo $wb->page_keywords;
|
335 |
|
|
} else {
|
336 |
|
|
echo WEBSITE_KEYWORDS;
|
337 |
|
|
}
|
338 |
|
|
}
|
339 |
|
|
}
|
340 |
|
|
|
341 |
|
|
// Function for page header
|
342 |
|
|
if (!function_exists('page_header')) {
|
343 |
|
|
function page_header($date_format = 'Y') {
|
344 |
|
|
echo WEBSITE_HEADER;
|
345 |
|
|
}
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
// Function for page footer
|
349 |
|
|
if (!function_exists('page_footer')) {
|
350 |
|
|
function page_footer($date_format = 'Y') {
|
351 |
|
|
global $starttime;
|
352 |
|
|
$vars = array('[YEAR]', '[PROCESS_TIME]');
|
353 |
|
|
$processtime=array_sum(explode(" ",microtime()))-$starttime;
|
354 |
|
|
$values = array(gmdate($date_format),$processtime);
|
355 |
|
|
echo str_replace($vars, $values, WEBSITE_FOOTER);
|
356 |
|
|
}
|
357 |
|
|
}
|
358 |
|
|
|
359 |
|
|
// Function to add optional module Javascript into the <body> section of the frontend
|
360 |
|
|
if(!function_exists('register_frontend_modfiles_body')) {
|
361 |
|
|
function register_frontend_modfiles_body($file_id="js") {
|
362 |
|
|
// sanity check of parameter passed to the function
|
363 |
|
|
$file_id = strtolower($file_id);
|
364 |
|
|
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") {
|
365 |
|
|
return;
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
global $wb, $database, $include_body_links;
|
369 |
|
|
// define default baselink and filename for optional module javascript files
|
370 |
|
|
$body_links = "";
|
371 |
|
|
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend_body.js" type="text/javascript"></script>';
|
372 |
|
|
$base_file = "frontend_body.js";
|
373 |
|
|
|
374 |
|
|
if(!empty($include_body_links)) {
|
375 |
|
|
if(strpos($body_links, $include_body_links) === false) {
|
376 |
|
|
$body_links .= $include_body_links;
|
377 |
|
|
}
|
378 |
|
|
$include_body_links = '';
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
// gather information for all models embedded on actual page
|
382 |
|
|
$page_id = $wb->page_id;
|
383 |
|
|
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
384 |
|
|
WHERE page_id=$page_id AND module<>'wysiwyg'");
|
385 |
|
|
|
386 |
|
|
while($row = $query_modules->fetchRow()) {
|
387 |
|
|
// check if page module directory contains a frontend_body.js file
|
388 |
|
|
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
|
389 |
|
|
// create link with frontend_body.js source for the current module
|
390 |
|
|
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
391 |
|
|
|
392 |
|
|
// define constant indicating that the register_frontent_files was invoked
|
393 |
|
|
if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);
|
394 |
|
|
|
395 |
|
|
// ensure that frontend_body.js is only added once per module type
|
396 |
|
|
if(strpos($body_links, $tmp_link) === false) {
|
397 |
|
|
$body_links .= $tmp_link ."\n";
|
398 |
|
|
}
|
399 |
|
|
};
|
400 |
|
|
}
|
401 |
|
|
|
402 |
|
|
/* include the Javascript email protection function
|
403 |
|
|
if( $file_id != 'css' && file_exists(WB_PATH .'/modules/droplets/js/mdcr.js')) {
|
404 |
|
|
$body_links .= '<script type="text/javascript" src="'.WB_URL.'/modules/droplets/js/mdcr.js"></script>'."\n";
|
405 |
|
|
} elseif( $file_id != 'css' && file_exists(WB_PATH .'/modules/output_filter/js/mdcr.js')) {
|
406 |
|
|
$body_links .= '<script type="text/javascript" src="'.WB_URL.'/modules/output_filter/js/mdcr.js"></script>'."\n";
|
407 |
|
|
} */
|
408 |
|
|
echo $body_links;
|
409 |
|
|
}
|
410 |
|
|
}
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend
|
414 |
|
|
if(!function_exists('register_frontend_modfiles')) {
|
415 |
|
|
function register_frontend_modfiles($file_id="css") {
|
416 |
|
|
// sanity check of parameter passed to the function
|
417 |
|
|
$file_id = strtolower($file_id);
|
418 |
|
|
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") {
|
419 |
|
|
return;
|
420 |
|
|
}
|
421 |
|
|
|
422 |
|
|
global $wb, $database, $include_head_link_css, $include_head_links;
|
423 |
|
|
// define default baselink and filename for optional module javascript and stylesheet files
|
424 |
|
|
$head_links = "";
|
425 |
|
|
|
426 |
|
|
if($file_id == "css") {
|
427 |
|
|
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"';
|
428 |
|
|
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
|
429 |
|
|
$base_file = "frontend.css";
|
430 |
|
|
} else {
|
431 |
|
|
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
|
432 |
|
|
$base_file = "frontend.js";
|
433 |
|
|
}
|
434 |
|
|
|
435 |
|
|
if(!empty($include_head_link_css)) {
|
436 |
|
|
if(strpos($head_links, $include_head_link_css) === false) {
|
437 |
|
|
$head_links .= $include_head_link_css;
|
438 |
|
|
}
|
439 |
|
|
$include_head_link_css = '';
|
440 |
|
|
} else {
|
441 |
|
|
if(!empty($include_head_links)) {
|
442 |
|
|
if(strpos($head_links, $include_head_links) === false) {
|
443 |
|
|
$head_links .= $include_head_links;
|
444 |
|
|
}
|
445 |
|
|
$include_head_links = '';
|
446 |
|
|
}
|
447 |
|
|
}
|
448 |
|
|
|
449 |
|
|
// gather information for all models embedded on actual page
|
450 |
|
|
$page_id = $wb->page_id;
|
451 |
|
|
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
452 |
|
|
WHERE page_id=$page_id AND module<>'wysiwyg'");
|
453 |
|
|
|
454 |
|
|
while($row = $query_modules->fetchRow()) {
|
455 |
|
|
// check if page module directory contains a frontend.js or frontend.css file
|
456 |
|
|
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
|
457 |
|
|
// create link with frontend.js or frontend.css source for the current module
|
458 |
|
|
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
459 |
|
|
|
460 |
|
|
// define constant indicating that the register_frontent_files was invoked
|
461 |
|
|
if($file_id == 'css') {
|
462 |
|
|
if(!defined('MOD_FRONTEND_CSS_REGISTERED')) define('MOD_FRONTEND_CSS_REGISTERED', true);
|
463 |
|
|
} else {
|
464 |
|
|
if(!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
|
465 |
|
|
}
|
466 |
|
|
// ensure that frontend.js or frontend.css is only added once per module type
|
467 |
|
|
if(strpos($head_links, $tmp_link) === false) {
|
468 |
|
|
$head_links .= $tmp_link ."\n";
|
469 |
|
|
}
|
470 |
|
|
};
|
471 |
|
|
}
|
472 |
|
|
|
473 |
|
|
// include the Javascript email protection function
|
474 |
|
|
if( $file_id != 'css' && file_exists(WB_PATH .'/modules/droplets/js/mdcr.js')) {
|
475 |
|
|
$head_links .= '<script type="text/javascript" src="'.WB_URL.'/modules/droplets/js/mdcr.js"></script>'."\n";
|
476 |
|
|
} elseif( $file_id != 'css' && file_exists(WB_PATH .'/modules/output_filter/js/mdcr.js')) {
|
477 |
|
|
$head_links .= '<script type="text/javascript" src="'.WB_URL.'/modules/output_filter/js/mdcr.js"></script>'."\n";
|
478 |
|
|
}
|
479 |
|
|
echo $head_links;
|
480 |
|
|
}
|
481 |
|
|
}
|
482 |
|
|
|
483 |
|
|
// Begin WB < 2.4.x template compatibility code
|
484 |
|
|
// Make extra_sql accessable through private_sql
|
485 |
|
|
$private_sql = $extra_sql;
|
486 |
|
|
$private_where_sql = $extra_where_sql;
|
487 |
|
|
// Query pages for menu
|
488 |
|
|
$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");
|
489 |
|
|
// Check if current pages is a parent page and if we need its submenu
|
490 |
|
|
if(PARENT == 0) {
|
491 |
|
|
// Get the pages submenu
|
492 |
|
|
$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");
|
493 |
|
|
} else {
|
494 |
|
|
// Get the pages submenu
|
495 |
|
|
$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");
|
496 |
|
|
}
|
497 |
|
|
// End WB < 2.4.x template compatibility code
|
498 |
|
|
// Include template file
|
499 |
|
|
|
500 |
|
|
|
501 |
1166
|
Luisehahne
|
?>
|