Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        frontend
5
 * @package         functions
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2010, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 4.3.4 and higher
13
 * @version         $Id: frontend.functions.php 1310 2010-04-01 00:43:23Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/framework/frontend.functions.php $
15
 * @lastmodified    $Date: 2010-04-01 02:43:23 +0200 (Thu, 01 Apr 2010) $
16
 *
17
*/
18

    
19
if(!defined('WB_URL')) {
20
	header('Location: ../index.php');
21
	exit(0);
22
}
23

    
24
// references to objects and variables that changed their names
25

    
26
$admin = &$wb;
27

    
28
$default_link=&$wb->default_link;
29

    
30
$page_trail=&$wb->page_trail;
31
$page_description=&$wb->page_description;
32
$page_keywords=&$wb->page_keywords;
33
$page_link=&$wb->link;
34

    
35
// extra_sql is not used anymore - this is basically a register_globals exploit prevention...
36
$extra_sql=&$wb->extra_sql;
37
$extra_where_sql=&$wb->extra_where_sql;
38

    
39
$include_head_link_css = '';
40
$include_body_links = '';
41
$include_head_links = '';
42
// workout to included frontend.css, fronten.js and frontend_body.js in snippets
43
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
44
$query_result=$database->query($query);
45
if ($query_result->numRows()>0) {
46
	while ($row = $query_result->fetchRow()) {
47
		$module_dir = $row['directory'];
48
		if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
49
			include(WB_PATH.'/modules/'.$module_dir.'/include.php');
50
			/* check if frontend.css file needs to be included into the <head></head> of index.php
51
			*/
52
			if( file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend.css')) {
53
				$include_head_link_css .= '<link href="'.WB_URL.'/modules/'.$module_dir.'/frontend.css"';
54
				$include_head_link_css .= ' rel="stylesheet" type="text/css" media="screen" />'."\n";
55
				$include_head_file = 'frontend.css';
56
			}
57
			// check if frontend.js file needs to be included into the <body></body> of index.php
58
			if(file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend.js')) {
59
				$include_head_links .= '<script src="'.WB_URL.'/modules/'.$module_dir.'/frontend.js" type="text/javascript"></script>'."\n";
60
				$include_head_file = 'frontend.js';
61
			}
62
			// check if frontend_body.js file needs to be included into the <body></body> of index.php
63
			if(file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend_body.js')) {
64
				$include_body_links .= '<script src="'.WB_URL.'/modules/'.$module_dir.'/frontend_body.js" type="text/javascript"></script>'."\n";
65
				$include_body_file = 'frontend_body.js';
66
			}
67
		}
68
	}
69
}
70

    
71
// Frontend functions
72
if (!function_exists('page_link'))
73
{
74
	function page_link($link) {
75
		global $wb;
76
		return $wb->page_link($link);
77
	}
78
}
79

    
80
if (!function_exists('get_page_link'))
81
{
82
    function get_page_link( $id )
83
    {
84
        global $database;
85
        // Get link
86
        $sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$id;
87
        $link = $database->get_one( $sql );
88
        return $link;
89
    }
90
}
91

    
92
//function to highlight search results
93
if(!function_exists('search_highlight')) {
94
function search_highlight($foo='', $arr_string=array()) {
95
	require_once(WB_PATH.'/framework/functions.php');
96
	static $string_ul_umlaut = FALSE;
97
	static $string_ul_regex = FALSE;
98
	if($string_ul_umlaut===FALSE || $string_ul_regex===FALSE)
99
		require(WB_PATH.'/search/search_convert.php');
100
	$foo = entities_to_umlauts($foo, 'UTF-8');
101
	array_walk($arr_string, create_function('&$v,$k','$v = preg_quote($v, \'~\');'));
102
	$search_string = implode("|", $arr_string);
103
	$string = str_replace($string_ul_umlaut, $string_ul_regex, $search_string);
104
	// the highlighting
105
	// match $string, but not inside <style>...</style>, <script>...</script>, <!--...--> or HTML-Tags
106
	// Also droplet tags are now excluded from highlighting.
107
	// split $string into pieces - "cut away" styles, scripts, comments, HTML-tags and eMail-addresses
108
	// we have to cut <pre> and <code> as well.
109
	// for HTML-Tags use <(?:[^<]|<.*>)*> which will match strings like <input ... value="<b>value</b>" >
110
	$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));
111
	if(is_array($matches) && $matches != array()) {
112
		$foo = "";
113
		foreach($matches as $match) {
114
			if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}$/i', $match) && !preg_match('~\[\[.*\]\]~', $match)) {
115
				$match = str_replace(array('&lt;', '&gt;', '&amp;', '&quot;', '&#039;', '&nbsp;'), array('<', '>', '&', '"', '\'', "\xC2\xA0"), $match);
116
				$match = preg_replace('~('.$string.')~ui', '_span class=_highlight__$1_/span_',$match);
117
				$match = str_replace(array('&', '<', '>', '"', '\'', "\xC2\xA0"), array('&amp;', '&lt;', '&gt;', '&quot;', '&#039;', '&nbsp;'), $match);
118
				$match = str_replace(array('_span class=_highlight__', '_/span_'), array('<span class="highlight">', '</span>'), $match);
119
			}
120
			$foo .= $match;
121
		}
122
	}
123

    
124
	if(DEFAULT_CHARSET != 'utf-8') {
125
		$foo = umlauts_to_entities($foo, 'UTF-8');
126
	}
127
	return $foo;
128
}
129
}
130

    
131
// Old menu call invokes new menu function
132
if (!function_exists('page_menu')) {
133
	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) {
134
		global $wb;
135
		$wb->menu_number=$menu_number;
136
		$wb->menu_item_template=$item_template;
137
		$wb->menu_item_footer='';
138
		$wb->menu_parent = $parent;
139
		$wb->menu_header = $menu_header;
140
		$wb->menu_footer = $menu_footer;
141
		$wb->menu_default_class = $default_class;
142
		$wb->menu_current_class = $current_class;
143
		$wb->menu_recurse = $recurse+2;
144
		$wb->menu();
145
		unset($wb->menu_parent);
146
		unset($wb->menu_number);
147
		unset($wb->menu_item_template);
148
		unset($wb->menu_item_footer);
149
		unset($wb->menu_header);
150
		unset($wb->menu_footer);
151
		unset($wb->menu_default_class);
152
		unset($wb->menu_current_class);
153
		unset($wb->menu_start_level);
154
		unset($wb->menu_collapse);
155
		unset($wb->menu_recurse);
156
	}
157
}
158

    
159
if (!function_exists('show_menu')) {
160
	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) {
161
		global $wb;
162
		if (isset($menu_number))
163
			$wb->menu_number=$menu_number;
164
		if (isset($start_level))
165
			$wb->menu_start_level=$start_level;
166
		if (isset($recurse))
167
			$wb->menu_recurse=$recurse;
168
		if (isset($collapse))
169
			$wb->menu_collapse=$collapse;
170
		if (isset($item_template))
171
			$wb->menu_item_template=$item_template;
172
		if (isset($item_footer))
173
			$wb->menu_item_footer=$item_footer;
174
		if (isset($menu_header))
175
			$wb->menu_header=$menu_header;
176
		if (isset($menu_footer))
177
			$wb->menu_footer=$menu_footer;
178
		if (isset($default_class))
179
			$wb->menu_default_class=$default_class;
180
		if (isset($current_class))
181
			$wb->menu_current_class=$current_class;
182
		if (isset($parent))
183
			$wb->menu_parent=$parent;
184
		$wb->menu();
185
		unset($wb->menu_recurse);
186
		unset($wb->menu_parent);
187
		unset($wb->menu_start_level);
188
	}
189
}
190

    
191
if (!function_exists('page_content')) {
192
	function page_content($block = 1) {
193
		// Get outside objects
194
		global $TEXT,$MENU,$HEADING,$MESSAGE;
195
		global $globals;
196
		global $database;
197
		global $wb;
198
		$admin = & $wb;
199
		if ($wb->page_access_denied==true)
200
        {
201
	        echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
202
			return;
203
		}
204
		if ($wb->page_no_active_sections==true)
205
        {
206
	        echo $MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'];
207
			return;
208
		}
209
		if(isset($globals) AND is_array($globals))
210
        {
211
            foreach($globals AS $global_name)
212
            {
213
                global $$global_name;
214
                }
215
        }
216
		// Make sure block is numeric
217
		if(!is_numeric($block)) { $block = 1; }
218
		// Include page content
219
		if(!defined('PAGE_CONTENT') OR $block!=1)
220
        {
221
			$page_id = intval($wb->page_id);
222
            // set session variable to save page_id only if PAGE_CONTENT is empty
223
            $_SESSION['PAGE_ID'] = !isset($_SESSION['PAGE_ID']) ? $page_id : $_SESSION['PAGE_ID'];
224
            // set to new value if page_id changed and not 0
225
            if(($page_id != 0) && ($_SESSION['PAGE_ID'] <> $page_id))
226
            {
227
            $_SESSION['PAGE_ID'] = $page_id;
228
            }
229

    
230
			// First get all sections for this page
231
			$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");
232
			// If none were found, check if default content is supposed to be shown
233
			if($query_sections->numRows() == 0) {
234
				if ($wb->default_block_content=='none') {
235
					return;
236
				}
237
				if (is_numeric($wb->default_block_content)) {
238
					$page_id=$wb->default_block_content;
239
				} else {
240
					$page_id=$wb->default_page_id;
241
				}				
242
				$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");
243
				// Still no cotent found? Give it up, there's just nothing to show!
244
				if($query_sections->numRows() == 0) {
245
					return;
246
				}
247
			}
248
			// Loop through them and include their module file
249
			while($section = $query_sections->fetchRow()) {
250
				// skip this section if it is out of publication-date
251
				$now = time();
252
				if( !(($now<=$section['publ_end'] || $section['publ_end']==0) && ($now>=$section['publ_start'] || $section['publ_start']==0)) ) {
253
					continue;
254
				}
255
				$section_id = $section['section_id'];
256
				$module = $section['module'];
257
				// make a anchor for every section.
258
				if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
259
					echo '<a class="section_anchor" id="'.SEC_ANCHOR.$section_id.'" name="'.SEC_ANCHOR.$section_id.'"></a>';
260
				}
261

    
262
				// fetch content -- this is where to place possible output-filters (before highlighting)
263
				ob_start(); // fetch original content
264
				require(WB_PATH.'/modules/'.$module.'/view.php');
265
				$content = ob_get_contents();
266
				ob_end_clean();
267

    
268
				// highlights searchresults
269
				if(isset($_GET['searchresult']) && is_numeric($_GET['searchresult']) && !isset($_GET['nohighlight']) && isset($_GET['sstring']) && !empty($_GET['sstring'])) {
270
					$arr_string = explode(" ", $_GET['sstring']);
271
					if($_GET['searchresult']==2) { // exact match
272
						$arr_string[0] = str_replace("_", " ", $arr_string[0]);
273
					}
274
					echo search_highlight($content, $arr_string);
275
				} else {
276
					echo $content;
277
				}
278
			}
279
		}
280
        else
281
        {
282

    
283
			require(PAGE_CONTENT);
284
		}
285
	}
286
}
287

    
288
if (!function_exists('show_content')) {
289
	function show_content($block=1) {
290
		page_content($block);
291
	}
292
}
293

    
294
if (!function_exists('show_breadcrumbs'))
295
{
296
	function show_breadcrumbs($sep = ' &raquo; ',$level = 0, $links = true, $depth = -1, $title = 'You are here: ')
297
    {
298
		global $wb;
299
		$page_id = $wb->page_id;
300

    
301
		if ($page_id != 0)
302
		{
303
	 		global $database;
304
			$counter = 0;
305
            // get links as array
306
            $bread_crumbs = $wb->page_trail;
307
            $count = sizeof($bread_crumbs);
308
            // level can't be greater than sum of links
309
            $level = ($count <= $level ) ? $count-1 : $level;
310
            // set level from which to show, delete indexes in array
311
			$crumbs = array_slice($bread_crumbs, $level );
312
            $depth = ($depth <= 0) ? sizeof($crumbs) : $depth;
313
            // if empty array, set orginal links
314
            $crumbs = (!empty($crumbs)) ?  $crumbs : $wb->page_trail;
315
            $total_crumbs = ( ($depth <= 0) OR ($depth > sizeof($crumbs)) ) ? sizeof($crumbs) : $depth;
316
            print '<div class="breadcrumb"><span class="title">'.$title.'</span>';
317
          //  print_r($crumbs);
318
			foreach ($crumbs as $temp)
319
            {
320
                if($counter == $depth) { break; }
321
                    // set links and separator
322
					$query_menu = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = $temp");
323
					$page = $query_menu->fetchRow();
324

    
325
                    $show_crumb = (($links == true) AND ($temp != $page_id))
326
                            ? '<a href="'.page_link($page['link']).'" class="link">'.$page['menu_title'].'</a>'
327
                            : '<span class="crumb">'.MENU_TITLE.'</span>';
328

    
329
                    // Permission
330
                    switch ($page['visibility'])
331
                    {
332
                        case 'none' :
333
                        case 'hidden' :
334
                        // if show, you know there is an error in a hidden page
335
                            print $show_crumb.'&nbsp;';
336
                        break;
337
                        default :
338
                            print $show_crumb;
339
                        break;
340
                    }
341

    
342
                    if ( ( $counter <> $total_crumbs-1 ) )
343
                    {
344
                        print '<span class="separator">'.$sep.'</span>';
345
                    }
346
	            $counter++;
347
            }
348
            print "</div>\n";
349
		}
350
	}
351
}
352

    
353
// Function for page title
354
if (!function_exists('page_title')) {
355
	function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
356
		$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
357
		$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
358
		echo str_replace($vars, $values, $template);
359
	}
360
}
361

    
362
// Function for page description
363
if (!function_exists('page_description')) {
364
	function page_description() {
365
		global $wb;
366
		if ($wb->page_description!='') {
367
			echo $wb->page_description;
368
		} else {
369
			echo WEBSITE_DESCRIPTION;
370
		}
371
	}
372
}
373

    
374
// Function for page keywords
375
if (!function_exists('page_keywords')) {
376
	function page_keywords() {
377
		global $wb;
378
		if ($wb->page_keywords!='') {
379
			echo $wb->page_keywords;
380
		} else {
381
			echo WEBSITE_KEYWORDS;
382
		}
383
	}
384
}
385

    
386
// Function for page header
387
if (!function_exists('page_header')) {
388
	function page_header($date_format = 'Y') {
389
		echo WEBSITE_HEADER;
390
	}
391
}
392

    
393
// Function for page footer
394
if (!function_exists('page_footer')) {
395
	function page_footer($date_format = 'Y') {
396
		global $starttime;
397
		$vars = array('[YEAR]', '[PROCESS_TIME]');
398
		$processtime=array_sum(explode(" ",microtime()))-$starttime;
399
		$values = array(gmdate($date_format),$processtime);
400
		echo str_replace($vars, $values, WEBSITE_FOOTER);
401
	}
402
}
403

    
404
function bind_jquery ($file_id='jquery')
405
{
406

    
407
        $jquery_links = '';
408
		/* include the Javascript jquery api  */
409
		if( $file_id == 'jquery' AND file_exists(WB_PATH .'/include/jquery/jquery-min.js'))
410
        {
411
            $wbpath = str_replace('\\','/',WB_PATH);  // fixed localhost problem with ie
412
			$jquery_links .= "<script type=\"text/javascript\">\n"
413
                ."var URL = '".WB_URL."';\n"
414
               /* ."var WB_PATH = '".$wbpath."';\n" */
415
                ."var WB_URL = '".WB_URL."';\n"
416
                ."var TEMPLATE_DIR = '".TEMPLATE_DIR."';\n"
417
                ."</script>\n";
418

    
419
			$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-min.js" type="text/javascript"></script>'."\n";
420
			$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-insert.js" type="text/javascript"></script>'."\n";
421
            /* workout to insert ui.css and theme */
422
            $jquery_theme =  WB_PATH.'/modules/jquery/jquery_theme.js';
423
			$jquery_links .=  file_exists($jquery_theme)
424
                ? '<script src="'.WB_URL.'/modules/jquery/jquery_theme.js" type="text/javascript"></script>'."\n"
425
                : '<script src="'.WB_URL.'/include/jquery/jquery_theme.js" type="text/javascript"></script>'."\n";
426
            /* workout to insert plugins functions, set in templatedir */
427
            $jquery_frontend_file = TEMPLATE_DIR.'/jquery_frontend.js';
428
			$jquery_links .= file_exists(str_replace( WB_URL, WB_PATH, $jquery_frontend_file))
429
                ? '<script src="'.$jquery_frontend_file.'" type="text/javascript"></script>'."\n"
430
                : '';
431
		}
432
    return $jquery_links;
433
}
434

    
435

    
436
// Function to add optional module Javascript into the <body> section of the frontend
437
if(!function_exists('register_frontend_modfiles_body'))
438
{
439
	function register_frontend_modfiles_body($file_id="js")
440
    {
441
		// sanity check of parameter passed to the function
442
		$file_id = strtolower($file_id);
443
		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
444
        {
445
			return;
446
		}
447

    
448
       // define constant indicating that the register_frontent_files was invoked
449
       if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);
450
		global $wb, $database, $include_body_links;
451
		// define default baselink and filename for optional module javascript files
452
		$body_links = "";
453

    
454
		/* include the Javascript jquery api  */
455
        $body_links .= bind_jquery($file_id);
456

    
457
		if($file_id !== "css" && $file_id == "js" && $file_id !== "jquery")
458
        {
459
    		$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend_body.js" type="text/javascript"></script>';
460
    		$base_file = "frontend_body.js";
461

    
462
			// ensure that frontend_body.js is only added once per module type
463
    		if(!empty($include_body_links))
464
            {
465
    			if(strpos($body_links, $include_body_links) === false)
466
                {
467
    				$body_links .= $include_body_links;
468
    			}
469
    			$include_body_links = '';
470
    		}
471

    
472
    		// gather information for all models embedded on actual page
473
    		$page_id = $wb->page_id;
474
    		$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
475
    				WHERE page_id=$page_id AND module<>'wysiwyg'");
476

    
477
    		while($row = $query_modules->fetchRow())
478
            {
479
    			// check if page module directory contains a frontend_body.js file
480
    			if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
481
                {
482
    			// create link with frontend_body.js source for the current module
483
    				$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
484

    
485
    				// define constant indicating that the register_frontent_files_body was invoked
486
    					if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) { define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);}
487

    
488
    				// ensure that frontend_body.js is only added once per module type
489
    				if(strpos($body_links, $tmp_link) === false)
490
                    {
491
    					$body_links .= $tmp_link;
492
    				}
493
    			}
494
    		}
495
        }
496

    
497
		print $body_links."\n"; ;
498
	}
499
}
500

    
501

    
502
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend
503
if(!function_exists('register_frontend_modfiles'))
504
{
505
	function register_frontend_modfiles($file_id="css")
506
    {
507
		// sanity check of parameter passed to the function
508
		$file_id = strtolower($file_id);
509
		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
510
        {
511
			return;
512
		}
513

    
514
		global $wb, $database, $include_head_link_css, $include_head_links;
515
		// define default baselink and filename for optional module javascript and stylesheet files
516
		$head_links = "";
517

    
518
        switch ($file_id)
519
        {
520
            case 'css':
521
			$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"';
522
			$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
523
			$base_file = "frontend.css";
524
    		if(!empty($include_head_link_css))
525
            {
526
              $head_links .=  !strpos($head_links, $include_head_link_css) ? $include_head_link_css : '';
527
              $include_head_link_css = '';
528
            }
529
            break;
530
            case 'jquery':
531
            $head_links .= bind_jquery($file_id);
532
            break;
533
            case 'js':
534
			$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
535
			$base_file = "frontend.js";
536
    		if(!empty($include_head_links))
537
            {
538
              $head_links .= !strpos($head_links, $include_head_links) ? $include_head_links : '';
539
              $include_head_links = '';
540
            }
541
            break;
542
            default:
543
            break;
544
		}
545

    
546
        if( $file_id != 'jquery')
547
        {
548
    		// gather information for all models embedded on actual page
549
    		$page_id = $wb->page_id;
550
    		$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
551
    				WHERE page_id=$page_id AND module<>'wysiwyg'");
552

    
553
    		while($row = $query_modules->fetchRow())
554
            {
555
    			// check if page module directory contains a frontend.js or frontend.css file
556
    			if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
557
                {
558
    			// create link with frontend.js or frontend.css source for the current module
559
    				$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
560

    
561
    				// define constant indicating that the register_frontent_files was invoked
562
    				if($file_id == 'css')
563
                    {
564
    					if(!defined('MOD_FRONTEND_CSS_REGISTERED')) define('MOD_FRONTEND_CSS_REGISTERED', true);
565
    				} else
566
                    {
567
    					if(!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
568
    				}
569
    				// ensure that frontend.js or frontend.css is only added once per module type
570
    				if(strpos($head_links, $tmp_link) === false)
571
                    {
572
    					$head_links .= $tmp_link."\n";
573
    				}
574
    			};
575
    		}
576
        		// include the Javascript email protection function
577
        		if( $file_id != 'css' && file_exists(WB_PATH .'/modules/droplets/js/mdcr.js'))
578
                {
579
        			$head_links .= '<script src="'.WB_URL.'/modules/droplets/js/mdcr.js" type="text/javascript"></script>'."\n";
580
        		}
581
                elseif( $file_id != 'css' && file_exists(WB_PATH .'/modules/output_filter/js/mdcr.js'))
582
                {
583
        			$head_links .= '<script src="'.WB_URL.'/modules/output_filter/js/mdcr.js" type="text/javascript"></script>'."\n";
584
        		}
585
        }
586
        print $head_links;
587
    }
588
}
589

    
590
// Begin WB < 2.4.x template compatibility code
591
	// Make extra_sql accessable through private_sql
592
	$private_sql = $extra_sql;
593
	$private_where_sql = $extra_where_sql;
594
	// Query pages for menu
595
	$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");
596
	// Check if current pages is a parent page and if we need its submenu
597
	if(PARENT == 0) {
598
		// Get the pages submenu
599
		$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");
600
	} else {
601
		// Get the pages submenu
602
		$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");
603
	}
604
// End WB < 2.4.x template compatibility code
605
// Include template file
606

    
607

    
608
?>
(10-10/15)