1
|
<?php
|
2
|
/*
|
3
|
*
|
4
|
* About WebsiteBaker
|
5
|
*
|
6
|
* Website Baker is a PHP-based Content Management System (CMS)
|
7
|
* designed with one goal in mind: to enable its users to produce websites
|
8
|
* with ease.
|
9
|
*
|
10
|
* LICENSE INFORMATION
|
11
|
*
|
12
|
* WebsiteBaker is free software; you can redistribute it and/or
|
13
|
* modify it under the terms of the GNU General Public License
|
14
|
* as published by the Free Software Foundation; either version 2
|
15
|
* of the License, or (at your option) any later version.
|
16
|
*
|
17
|
* WebsiteBaker is distributed in the hope that it will be useful,
|
18
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
20
|
* See the GNU General Public License for more details.
|
21
|
*
|
22
|
* You should have received a copy of the GNU General Public License
|
23
|
* along with this program; if not, write to the Free Software
|
24
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
25
|
*
|
26
|
* WebsiteBaker Extra Information
|
27
|
*
|
28
|
*
|
29
|
*/
|
30
|
/**
|
31
|
*
|
32
|
* @category frontend
|
33
|
* @package functions
|
34
|
* @author WebsiteBaker Project
|
35
|
* @copyright 2004-2009, Ryan Djurovich
|
36
|
* @copyright 2009-2010, Website Baker Org. e.V.
|
37
|
* @link http://www.websitebaker2.org/
|
38
|
* @license http://www.gnu.org/licenses/gpl.html
|
39
|
* @platform WebsiteBaker 2.8.x
|
40
|
* @requirements PHP 4.3.4 and higher
|
41
|
* @version $Id: frontend.functions.php 1269 2010-01-22 22:51:34Z Luisehahne $
|
42
|
* @filesource $HeadURL: $
|
43
|
* @lastmodified $Date: $
|
44
|
*
|
45
|
*/
|
46
|
|
47
|
if(!defined('WB_URL')) {
|
48
|
header('Location: ../index.php');
|
49
|
exit(0);
|
50
|
}
|
51
|
|
52
|
// references to objects and variables that changed their names
|
53
|
|
54
|
$admin = &$wb;
|
55
|
|
56
|
$default_link=&$wb->default_link;
|
57
|
|
58
|
$page_trail=&$wb->page_trail;
|
59
|
$page_description=&$wb->page_description;
|
60
|
$page_keywords=&$wb->page_keywords;
|
61
|
$page_link=&$wb->link;
|
62
|
|
63
|
// extra_sql is not used anymore - this is basically a register_globals exploit prevention...
|
64
|
$extra_sql=&$wb->extra_sql;
|
65
|
$extra_where_sql=&$wb->extra_where_sql;
|
66
|
|
67
|
$include_head_link_css = '';
|
68
|
$include_body_links = '';
|
69
|
$include_head_links = '';
|
70
|
// workout to included frontend.css, fronten.js and frontend_body.js in snippets
|
71
|
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
|
72
|
$query_result=$database->query($query);
|
73
|
if ($query_result->numRows()>0) {
|
74
|
while ($row = $query_result->fetchRow()) {
|
75
|
$module_dir = $row['directory'];
|
76
|
if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
|
77
|
include(WB_PATH.'/modules/'.$module_dir.'/include.php');
|
78
|
/* check if frontend.css file needs to be included into the <head></head> of index.php
|
79
|
*/
|
80
|
if( file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend.css')) {
|
81
|
$include_head_link_css .= '<link href="'.WB_URL.'/modules/'.$module_dir.'/frontend.css"';
|
82
|
$include_head_link_css .= ' rel="stylesheet" type="text/css" media="screen" />'."\n";
|
83
|
$include_head_file = 'frontend.css';
|
84
|
}
|
85
|
// check if frontend.js file needs to be included into the <body></body> of index.php
|
86
|
if(file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend.js')) {
|
87
|
$include_head_links .= '<script src="'.WB_URL.'/modules/'.$module_dir.'/frontend.js" type="text/javascript"></script>'."\n";
|
88
|
$include_head_file = 'frontend.js';
|
89
|
}
|
90
|
// check if frontend_body.js file needs to be included into the <body></body> of index.php
|
91
|
if(file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend_body.js')) {
|
92
|
$include_body_links .= '<script src="'.WB_URL.'/modules/'.$module_dir.'/frontend_body.js" type="text/javascript"></script>'."\n";
|
93
|
$include_body_file = 'frontend_body.js';
|
94
|
}
|
95
|
}
|
96
|
}
|
97
|
}
|
98
|
|
99
|
// Frontend functions
|
100
|
if (!function_exists('page_link')) {
|
101
|
function page_link($link) {
|
102
|
global $wb;
|
103
|
return $wb->page_link($link);
|
104
|
}
|
105
|
}
|
106
|
|
107
|
//function to highlight search results
|
108
|
if(!function_exists('search_highlight')) {
|
109
|
function search_highlight($foo='', $arr_string=array()) {
|
110
|
require_once(WB_PATH.'/framework/functions.php');
|
111
|
static $string_ul_umlaut = FALSE;
|
112
|
static $string_ul_regex = FALSE;
|
113
|
if($string_ul_umlaut===FALSE || $string_ul_regex===FALSE)
|
114
|
require(WB_PATH.'/search/search_convert.php');
|
115
|
$foo = entities_to_umlauts($foo, 'UTF-8');
|
116
|
array_walk($arr_string, create_function('&$v,$k','$v = preg_quote($v, \'~\');'));
|
117
|
$search_string = implode("|", $arr_string);
|
118
|
$string = str_replace($string_ul_umlaut, $string_ul_regex, $search_string);
|
119
|
// the highlighting
|
120
|
// match $string, but not inside <style>...</style>, <script>...</script>, <!--...--> or HTML-Tags
|
121
|
// Also droplet tags are now excluded from highlighting.
|
122
|
// split $string into pieces - "cut away" styles, scripts, comments, HTML-tags and eMail-addresses
|
123
|
// we have to cut <pre> and <code> as well.
|
124
|
// for HTML-Tags use <(?:[^<]|<.*>)*> which will match strings like <input ... value="<b>value</b>" >
|
125
|
$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));
|
126
|
if(is_array($matches) && $matches != array()) {
|
127
|
$foo = "";
|
128
|
foreach($matches as $match) {
|
129
|
if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}$/i', $match) && !preg_match('~\[\[.*\]\]~', $match)) {
|
130
|
$match = str_replace(array('<', '>', '&', '"', ''', ' '), array('<', '>', '&', '"', '\'', "\xC2\xA0"), $match);
|
131
|
$match = preg_replace('~('.$string.')~ui', '_span class=_highlight__$1_/span_',$match);
|
132
|
$match = str_replace(array('&', '<', '>', '"', '\'', "\xC2\xA0"), array('&', '<', '>', '"', ''', ' '), $match);
|
133
|
$match = str_replace(array('_span class=_highlight__', '_/span_'), array('<span class="highlight">', '</span>'), $match);
|
134
|
}
|
135
|
$foo .= $match;
|
136
|
}
|
137
|
}
|
138
|
|
139
|
if(DEFAULT_CHARSET != 'utf-8') {
|
140
|
$foo = umlauts_to_entities($foo, 'UTF-8');
|
141
|
}
|
142
|
return $foo;
|
143
|
}
|
144
|
}
|
145
|
|
146
|
// Old menu call invokes new menu function
|
147
|
if (!function_exists('page_menu')) {
|
148
|
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) {
|
149
|
global $wb;
|
150
|
$wb->menu_number=$menu_number;
|
151
|
$wb->menu_item_template=$item_template;
|
152
|
$wb->menu_item_footer='';
|
153
|
$wb->menu_parent = $parent;
|
154
|
$wb->menu_header = $menu_header;
|
155
|
$wb->menu_footer = $menu_footer;
|
156
|
$wb->menu_default_class = $default_class;
|
157
|
$wb->menu_current_class = $current_class;
|
158
|
$wb->menu_recurse = $recurse+2;
|
159
|
$wb->menu();
|
160
|
unset($wb->menu_parent);
|
161
|
unset($wb->menu_number);
|
162
|
unset($wb->menu_item_template);
|
163
|
unset($wb->menu_item_footer);
|
164
|
unset($wb->menu_header);
|
165
|
unset($wb->menu_footer);
|
166
|
unset($wb->menu_default_class);
|
167
|
unset($wb->menu_current_class);
|
168
|
unset($wb->menu_start_level);
|
169
|
unset($wb->menu_collapse);
|
170
|
unset($wb->menu_recurse);
|
171
|
}
|
172
|
}
|
173
|
|
174
|
if (!function_exists('show_menu')) {
|
175
|
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) {
|
176
|
global $wb;
|
177
|
if (isset($menu_number))
|
178
|
$wb->menu_number=$menu_number;
|
179
|
if (isset($start_level))
|
180
|
$wb->menu_start_level=$start_level;
|
181
|
if (isset($recurse))
|
182
|
$wb->menu_recurse=$recurse;
|
183
|
if (isset($collapse))
|
184
|
$wb->menu_collapse=$collapse;
|
185
|
if (isset($item_template))
|
186
|
$wb->menu_item_template=$item_template;
|
187
|
if (isset($item_footer))
|
188
|
$wb->menu_item_footer=$item_footer;
|
189
|
if (isset($menu_header))
|
190
|
$wb->menu_header=$menu_header;
|
191
|
if (isset($menu_footer))
|
192
|
$wb->menu_footer=$menu_footer;
|
193
|
if (isset($default_class))
|
194
|
$wb->menu_default_class=$default_class;
|
195
|
if (isset($current_class))
|
196
|
$wb->menu_current_class=$current_class;
|
197
|
if (isset($parent))
|
198
|
$wb->menu_parent=$parent;
|
199
|
$wb->menu();
|
200
|
unset($wb->menu_recurse);
|
201
|
unset($wb->menu_parent);
|
202
|
unset($wb->menu_start_level);
|
203
|
}
|
204
|
}
|
205
|
|
206
|
if (!function_exists('page_content')) {
|
207
|
function page_content($block = 1) {
|
208
|
// Get outside objects
|
209
|
global $TEXT,$MENU,$HEADING,$MESSAGE;
|
210
|
global $globals;
|
211
|
global $database;
|
212
|
global $wb;
|
213
|
$admin = & $wb;
|
214
|
if ($wb->page_access_denied==true)
|
215
|
{
|
216
|
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
|
217
|
return;
|
218
|
}
|
219
|
if ($wb->page_no_active_sections==true)
|
220
|
{
|
221
|
echo $MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'];
|
222
|
return;
|
223
|
}
|
224
|
if(isset($globals) AND is_array($globals))
|
225
|
{
|
226
|
foreach($globals AS $global_name)
|
227
|
{
|
228
|
global $$global_name;
|
229
|
}
|
230
|
}
|
231
|
// Make sure block is numeric
|
232
|
if(!is_numeric($block)) { $block = 1; }
|
233
|
// Include page content
|
234
|
if(!defined('PAGE_CONTENT') OR $block!=1)
|
235
|
{
|
236
|
$page_id=$wb->page_id;
|
237
|
// set session variable to save page_id only if PAGE_CONTENT is empty
|
238
|
$_SESSION['PAGE_ID'] = !isset($_SESSION['PAGE_ID']) ? $page_id : $_SESSION['PAGE_ID'];
|
239
|
// set to new value if page_id changed and not 0
|
240
|
if(($page_id != 0) AND ($_SESSION['PAGE_ID'] <> $page_id))
|
241
|
{
|
242
|
$_SESSION['PAGE_ID'] = $page_id;
|
243
|
}
|
244
|
|
245
|
// First get all sections for this page
|
246
|
$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");
|
247
|
// If none were found, check if default content is supposed to be shown
|
248
|
if($query_sections->numRows() == 0) {
|
249
|
if ($wb->default_block_content=='none') {
|
250
|
return;
|
251
|
}
|
252
|
if (is_numeric($wb->default_block_content)) {
|
253
|
$page_id=$wb->default_block_content;
|
254
|
} else {
|
255
|
$page_id=$wb->default_page_id;
|
256
|
}
|
257
|
$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");
|
258
|
// Still no cotent found? Give it up, there's just nothing to show!
|
259
|
if($query_sections->numRows() == 0) {
|
260
|
return;
|
261
|
}
|
262
|
}
|
263
|
// Loop through them and include their module file
|
264
|
while($section = $query_sections->fetchRow()) {
|
265
|
// skip this section if it is out of publication-date
|
266
|
$now = time();
|
267
|
if( !(($now<=$section['publ_end'] || $section['publ_end']==0) && ($now>=$section['publ_start'] || $section['publ_start']==0)) ) {
|
268
|
continue;
|
269
|
}
|
270
|
$section_id = $section['section_id'];
|
271
|
$module = $section['module'];
|
272
|
// make a anchor for every section.
|
273
|
if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
|
274
|
echo '<a class="section_anchor" id="'.SEC_ANCHOR.$section_id.'" name="'.SEC_ANCHOR.$section_id.'"></a>';
|
275
|
}
|
276
|
|
277
|
// fetch content -- this is where to place possible output-filters (before highlighting)
|
278
|
ob_start(); // fetch original content
|
279
|
require(WB_PATH.'/modules/'.$module.'/view.php');
|
280
|
$content = ob_get_contents();
|
281
|
ob_end_clean();
|
282
|
|
283
|
// highlights searchresults
|
284
|
if(isset($_GET['searchresult']) && is_numeric($_GET['searchresult']) && !isset($_GET['nohighlight']) && isset($_GET['sstring']) && !empty($_GET['sstring'])) {
|
285
|
$arr_string = explode(" ", $_GET['sstring']);
|
286
|
if($_GET['searchresult']==2) { // exact match
|
287
|
$arr_string[0] = str_replace("_", " ", $arr_string[0]);
|
288
|
}
|
289
|
echo search_highlight($content, $arr_string);
|
290
|
} else {
|
291
|
echo $content;
|
292
|
}
|
293
|
}
|
294
|
}
|
295
|
else
|
296
|
{
|
297
|
|
298
|
require(PAGE_CONTENT);
|
299
|
}
|
300
|
}
|
301
|
}
|
302
|
|
303
|
if (!function_exists('show_content')) {
|
304
|
function show_content($block=1) {
|
305
|
page_content($block);
|
306
|
}
|
307
|
}
|
308
|
|
309
|
if (!function_exists('show_breadcrumbs'))
|
310
|
{
|
311
|
function show_breadcrumbs($sep = ' » ',$level = 0, $links = true, $depth = -1, $title = 'You are here: ')
|
312
|
{
|
313
|
global $wb;
|
314
|
$page_id = $wb->page_id;
|
315
|
|
316
|
if ($page_id != 0)
|
317
|
{
|
318
|
global $database;
|
319
|
$counter = 0;
|
320
|
// get links as array
|
321
|
$bread_crumbs = $wb->page_trail;
|
322
|
$count = sizeof($bread_crumbs);
|
323
|
// level can't be greater than sum of links
|
324
|
$level = ($count <= $level ) ? $count-1 : $level;
|
325
|
// set level from which to show, delete indexes in array
|
326
|
$crumbs = array_slice($bread_crumbs, $level );
|
327
|
$depth = ($depth <= 0) ? sizeof($crumbs) : $depth;
|
328
|
// if empty array, set orginal links
|
329
|
$crumbs = (!empty($crumbs)) ? $crumbs : $wb->page_trail;
|
330
|
$total_crumbs = ( ($depth <= 0) OR ($depth > sizeof($crumbs)) ) ? sizeof($crumbs) : $depth;
|
331
|
print '<div class="breadcrumb"><span class="title">'.$title.'</span>';
|
332
|
// print_r($crumbs);
|
333
|
foreach ($crumbs as $temp)
|
334
|
{
|
335
|
if($counter == $depth) { break; }
|
336
|
// set links and separator
|
337
|
$query_menu = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = $temp");
|
338
|
$page = $query_menu->fetchRow();
|
339
|
|
340
|
$show_crumb = (($links == true) AND ($temp != $page_id))
|
341
|
? '<a href="'.page_link($page['link']).'" class="link">'.$page['menu_title'].'</a>'
|
342
|
: '<span class="crumb">'.MENU_TITLE.'</span>';
|
343
|
|
344
|
// Permission
|
345
|
switch ($page['visibility'])
|
346
|
{
|
347
|
case 'none' :
|
348
|
case 'hidden' :
|
349
|
// if show, you know there is an error in a hidden page
|
350
|
print $show_crumb.' ';
|
351
|
break;
|
352
|
default :
|
353
|
print $show_crumb;
|
354
|
break;
|
355
|
}
|
356
|
|
357
|
if ( ( $counter <> $total_crumbs-1 ) )
|
358
|
{
|
359
|
print '<span class="separator">'.$sep.'</span>';
|
360
|
}
|
361
|
$counter++;
|
362
|
}
|
363
|
print "</div>\n";
|
364
|
}
|
365
|
}
|
366
|
}
|
367
|
|
368
|
// Function for page title
|
369
|
if (!function_exists('page_title')) {
|
370
|
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
|
371
|
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
|
372
|
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
|
373
|
echo str_replace($vars, $values, $template);
|
374
|
}
|
375
|
}
|
376
|
|
377
|
// Function for page description
|
378
|
if (!function_exists('page_description')) {
|
379
|
function page_description() {
|
380
|
global $wb;
|
381
|
if ($wb->page_description!='') {
|
382
|
echo $wb->page_description;
|
383
|
} else {
|
384
|
echo WEBSITE_DESCRIPTION;
|
385
|
}
|
386
|
}
|
387
|
}
|
388
|
|
389
|
// Function for page keywords
|
390
|
if (!function_exists('page_keywords')) {
|
391
|
function page_keywords() {
|
392
|
global $wb;
|
393
|
if ($wb->page_keywords!='') {
|
394
|
echo $wb->page_keywords;
|
395
|
} else {
|
396
|
echo WEBSITE_KEYWORDS;
|
397
|
}
|
398
|
}
|
399
|
}
|
400
|
|
401
|
// Function for page header
|
402
|
if (!function_exists('page_header')) {
|
403
|
function page_header($date_format = 'Y') {
|
404
|
echo WEBSITE_HEADER;
|
405
|
}
|
406
|
}
|
407
|
|
408
|
// Function for page footer
|
409
|
if (!function_exists('page_footer')) {
|
410
|
function page_footer($date_format = 'Y') {
|
411
|
global $starttime;
|
412
|
$vars = array('[YEAR]', '[PROCESS_TIME]');
|
413
|
$processtime=array_sum(explode(" ",microtime()))-$starttime;
|
414
|
$values = array(gmdate($date_format),$processtime);
|
415
|
echo str_replace($vars, $values, WEBSITE_FOOTER);
|
416
|
}
|
417
|
}
|
418
|
|
419
|
function bind_jquery ($file_id='jquery')
|
420
|
{
|
421
|
$jquery_links = '';
|
422
|
/* include the Javascript jquery api */
|
423
|
if( $file_id == 'jquery' AND file_exists(WB_PATH .'/include/jquery/jquery-min.js'))
|
424
|
{
|
425
|
$wbpath = str_replace('\\','/',WB_PATH); // fixed localhost problem with ie
|
426
|
$jquery_links .= "<script type=\"text/javascript\">\n"
|
427
|
."var URL = '".WB_URL."';\n"
|
428
|
/* ."var WB_PATH = '".$wbpath."';\n" */
|
429
|
."var WB_URL = '".WB_URL."';\n"
|
430
|
."var TEMPLATE_DIR = '".TEMPLATE_DIR."';\n"
|
431
|
."</script>\n";
|
432
|
|
433
|
$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-min.js" type="text/javascript"></script>'."\n";
|
434
|
$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-ui-min.js" type="text/javascript"></script>'."\n";
|
435
|
$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-insert.js" type="text/javascript"></script>'."\n";
|
436
|
/* workout to insert ui.css and theme */
|
437
|
$jquery_theme = WB_PATH.'/modules/jquery/jquery_theme.js';
|
438
|
$jquery_links .= file_exists($jquery_theme)
|
439
|
? '<script src="'.WB_URL.'/modules/jquery/jquery_theme.js" type="text/javascript"></script>'."\n"
|
440
|
: '<script src="'.WB_URL.'/include/jquery/jquery_theme.js" type="text/javascript"></script>'."\n";
|
441
|
/* workout to insert plugins functions, set in templatedir */
|
442
|
$jquery_frontend_file = TEMPLATE_DIR.'/jquery_frontend.js';
|
443
|
$jquery_links .= file_exists(str_replace( WB_URL, WB_PATH, $jquery_frontend_file))
|
444
|
? '<script src="'.$jquery_frontend_file.'" type="text/javascript"></script>'."\n"
|
445
|
: '';
|
446
|
}
|
447
|
return $jquery_links;
|
448
|
}
|
449
|
|
450
|
|
451
|
// Function to add optional module Javascript into the <body> section of the frontend
|
452
|
if(!function_exists('register_frontend_modfiles_body'))
|
453
|
{
|
454
|
function register_frontend_modfiles_body($file_id="js")
|
455
|
{
|
456
|
// sanity check of parameter passed to the function
|
457
|
$file_id = strtolower($file_id);
|
458
|
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
|
459
|
{
|
460
|
return;
|
461
|
}
|
462
|
|
463
|
// define constant indicating that the register_frontent_files was invoked
|
464
|
if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);
|
465
|
global $wb, $database, $include_body_links;
|
466
|
// define default baselink and filename for optional module javascript files
|
467
|
$body_links = "";
|
468
|
|
469
|
/* include the Javascript jquery api */
|
470
|
$body_links .= bind_jquery($file_id);
|
471
|
|
472
|
if($file_id !== "css" && $file_id == "js" && $file_id !== "jquery")
|
473
|
{
|
474
|
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend_body.js" type="text/javascript"></script>';
|
475
|
$base_file = "frontend_body.js";
|
476
|
|
477
|
// ensure that frontend_body.js is only added once per module type
|
478
|
if(!empty($include_body_links))
|
479
|
{
|
480
|
if(strpos($body_links, $include_body_links) === false)
|
481
|
{
|
482
|
$body_links .= $include_body_links;
|
483
|
}
|
484
|
$include_body_links = '';
|
485
|
}
|
486
|
|
487
|
// gather information for all models embedded on actual page
|
488
|
$page_id = $wb->page_id;
|
489
|
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
490
|
WHERE page_id=$page_id AND module<>'wysiwyg'");
|
491
|
|
492
|
while($row = $query_modules->fetchRow())
|
493
|
{
|
494
|
// check if page module directory contains a frontend_body.js file
|
495
|
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
|
496
|
{
|
497
|
// create link with frontend_body.js source for the current module
|
498
|
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
499
|
|
500
|
// define constant indicating that the register_frontent_files_body was invoked
|
501
|
if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) { define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);}
|
502
|
|
503
|
// ensure that frontend_body.js is only added once per module type
|
504
|
if(strpos($body_links, $tmp_link) === false)
|
505
|
{
|
506
|
$body_links .= $tmp_link;
|
507
|
}
|
508
|
}
|
509
|
}
|
510
|
}
|
511
|
|
512
|
print $body_links."\n"; ;
|
513
|
}
|
514
|
}
|
515
|
|
516
|
|
517
|
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend
|
518
|
if(!function_exists('register_frontend_modfiles'))
|
519
|
{
|
520
|
function register_frontend_modfiles($file_id="css")
|
521
|
{
|
522
|
// sanity check of parameter passed to the function
|
523
|
$file_id = strtolower($file_id);
|
524
|
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
|
525
|
{
|
526
|
return;
|
527
|
}
|
528
|
|
529
|
global $wb, $database, $include_head_link_css, $include_head_links;
|
530
|
// define default baselink and filename for optional module javascript and stylesheet files
|
531
|
$head_links = "";
|
532
|
|
533
|
switch ($file_id)
|
534
|
{
|
535
|
case 'css':
|
536
|
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"';
|
537
|
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
|
538
|
$base_file = "frontend.css";
|
539
|
if(!empty($include_head_link_css))
|
540
|
{
|
541
|
$head_links .= !strpos($head_links, $include_head_link_css) ? $include_head_link_css : '';
|
542
|
$include_head_link_css = '';
|
543
|
}
|
544
|
break;
|
545
|
case 'jquery':
|
546
|
$head_links .= bind_jquery($file_id);
|
547
|
break;
|
548
|
case 'js':
|
549
|
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
|
550
|
$base_file = "frontend.js";
|
551
|
if(!empty($include_head_links))
|
552
|
{
|
553
|
$head_links .= !strpos($head_links, $include_head_links) ? $include_head_links : '';
|
554
|
$include_head_links = '';
|
555
|
}
|
556
|
break;
|
557
|
default:
|
558
|
break;
|
559
|
}
|
560
|
|
561
|
if( $file_id != 'jquery')
|
562
|
{
|
563
|
// gather information for all models embedded on actual page
|
564
|
$page_id = $wb->page_id;
|
565
|
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
566
|
WHERE page_id=$page_id AND module<>'wysiwyg'");
|
567
|
|
568
|
while($row = $query_modules->fetchRow())
|
569
|
{
|
570
|
// check if page module directory contains a frontend.js or frontend.css file
|
571
|
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
|
572
|
{
|
573
|
// create link with frontend.js or frontend.css source for the current module
|
574
|
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
575
|
|
576
|
// define constant indicating that the register_frontent_files was invoked
|
577
|
if($file_id == 'css')
|
578
|
{
|
579
|
if(!defined('MOD_FRONTEND_CSS_REGISTERED')) define('MOD_FRONTEND_CSS_REGISTERED', true);
|
580
|
} else
|
581
|
{
|
582
|
if(!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
|
583
|
}
|
584
|
// ensure that frontend.js or frontend.css is only added once per module type
|
585
|
if(strpos($head_links, $tmp_link) === false)
|
586
|
{
|
587
|
$head_links .= $tmp_link."\n";
|
588
|
}
|
589
|
};
|
590
|
}
|
591
|
// include the Javascript email protection function
|
592
|
if( $file_id != 'css' && file_exists(WB_PATH .'/modules/droplets/js/mdcr.js'))
|
593
|
{
|
594
|
$head_links .= '<script src="'.WB_URL.'/modules/droplets/js/mdcr.js" type="text/javascript"></script>'."\n";
|
595
|
}
|
596
|
elseif( $file_id != 'css' && file_exists(WB_PATH .'/modules/output_filter/js/mdcr.js'))
|
597
|
{
|
598
|
$head_links .= '<script src="'.WB_URL.'/modules/output_filter/js/mdcr.js" type="text/javascript"></script>'."\n";
|
599
|
}
|
600
|
}
|
601
|
print $head_links;
|
602
|
}
|
603
|
}
|
604
|
|
605
|
// Begin WB < 2.4.x template compatibility code
|
606
|
// Make extra_sql accessable through private_sql
|
607
|
$private_sql = $extra_sql;
|
608
|
$private_where_sql = $extra_where_sql;
|
609
|
// Query pages for menu
|
610
|
$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");
|
611
|
// Check if current pages is a parent page and if we need its submenu
|
612
|
if(PARENT == 0) {
|
613
|
// Get the pages submenu
|
614
|
$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");
|
615
|
} else {
|
616
|
// Get the pages submenu
|
617
|
$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");
|
618
|
}
|
619
|
// End WB < 2.4.x template compatibility code
|
620
|
// Include template file
|
621
|
|
622
|
|
623
|
?>
|