Project

General

Profile

« Previous | Next » 

Revision 1181

Added by Dietmar about 15 years ago

View differences:

frontend.functions.php
50 50
$include_head_link_css = '';
51 51
$include_body_links = '';
52 52
$include_head_links = '';
53

  
53
// workout to included frontend.css, fronten.js and frontend_body.js in snippets
54 54
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
55 55
$query_result=$database->query($query);
56 56
if ($query_result->numRows()>0) {
......
105 105
	// split $string into pieces - "cut away" styles, scripts, comments, HTML-tags and eMail-addresses
106 106
	// we have to cut <pre> and <code> as well.
107 107
	// for HTML-Tags use <(?:[^<]|<.*>)*> which will match strings like <input ... value="<b>value</b>" >
108
	$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));
108
	$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 109
	if(is_array($matches) && $matches != array()) {
110 110
		$foo = "";
111 111
		foreach($matches as $match) {
112
			if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}$/i', $match) && !preg_match('~\[\[.*\]\]~', $match)) {
112
			if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}$/i', $match) && !preg_match('~\[\[.*\]\]~', $match)) {

113 113
				$match = str_replace(array('&lt;', '&gt;', '&amp;', '&quot;', '&#039;', '&nbsp;'), array('<', '>', '&', '"', '\'', "\xC2\xA0"), $match);
114 114
				$match = preg_replace('~('.$string.')~ui', '_span class=_highlight__$1_/span_',$match);
115 115
				$match = str_replace(array('&', '<', '>', '"', '\'', "\xC2\xA0"), array('&amp;', '&lt;', '&gt;', '&quot;', '&#039;', '&nbsp;'), $match);
......
206 206
		// Make sure block is numeric
207 207
		if(!is_numeric($block)) { $block = 1; }
208 208
		// Include page content
209
		if(!defined('PAGE_CONTENT') OR $block!=1) {
209
		if(!defined('PAGE_CONTENT') OR $block!=1)
210
        {
210 211
			$page_id=$wb->page_id;
212
            // set session variable to save page_id only if PAGE_CONTENT is empty
213
            $_SESSION['PAGE_ID'] = !isset($_SESSION['PAGE_ID']) ? $page_id : $_SESSION['PAGE_ID'];
214
            // set to new value if page_id changed and not 0
215
            if(($page_id != 0) AND ($_SESSION['PAGE_ID'] <> $page_id))
216
            {
217
            $_SESSION['PAGE_ID'] = $page_id;
218
            }
219

  
211 220
			// First get all sections for this page
212 221
			$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 222
			// If none were found, check if default content is supposed to be shown
......
290 299
					$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
291 300
					$page=$query_menu->fetchRow();
292 301
					if ($links==true AND $temp!=$page_id)
293
                    {
294 302
						print '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
295
                    }
296 303
					else
297
                    {
298
					    print '<span>'.$page['menu_title'].'</span>';
299
                    }
304
					    print '<span class="crumb">'.$page['menu_title'].'</span>';
300 305
		        }
301 306
	            $counter++;
302 307
			}
......
356 361
	}
357 362
}
358 363

  
364
function bind_jquery ($file_id='jquery')
365
{
366
        $jquery_links = '';
367
		/* include the Javascript jquery api  */
368
		if( $file_id == 'jquery' AND file_exists(WB_PATH .'/include/jquery/jquery-min.js'))
369
        {
370
            $wbpath = str_replace('\\','/',WB_PATH);  // fixed localhost problem with ie
371
			$jquery_links .= "<script type=\"text/javascript\">\n"
372
                ."var URL = '".WB_URL."';\n"
373
                ."var WB_PATH = '".$wbpath."';\n"
374
                ."var WB_URL = '".WB_URL."';\n"
375
                ."var TEMPLATE_DIR = '".TEMPLATE_DIR."';\n"
376
                ."</script>\n";
377

  
378
			$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-min.js" type="text/javascript"></script>'."\n";
379
			$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-ui-min.js" type="text/javascript"></script>'."\n";
380
			$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-insert.js" type="text/javascript"></script>'."\n";
381
            /* workout to insert ui.css and theme */
382
            $jquery_theme =  WB_PATH.'/modules/jquery/jquery_theme.js';
383
			$jquery_links .=  file_exists($jquery_theme)
384
                ? '<script src="'.WB_URL.'/modules/jquery/jquery_theme.js" type="text/javascript"></script>'."\n"
385
                : '<script src="'.WB_URL.'/include/jquery/jquery_theme.js" type="text/javascript"></script>'."\n";
386
            /* workout to insert plugins functions, set in templatedir */
387
            $jquery_frontend_file = TEMPLATE_DIR.'/jquery_frontend.js';
388
			$jquery_links .= file_exists(str_replace( WB_URL, WB_PATH, $jquery_frontend_file))
389
                ? '<script src="'.$jquery_frontend_file.'" type="text/javascript"></script>'."\n"
390
                : '';
391
		}
392
    return $jquery_links;
393
}
394

  
395

  
359 396
// 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") {
397
if(!function_exists('register_frontend_modfiles_body'))
398
{
399
	function register_frontend_modfiles_body($file_id="js")
400
    {
362 401
		// sanity check of parameter passed to the function
363 402
		$file_id = strtolower($file_id);
364
		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") {
403
		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
404
        {
365 405
			return;
366 406
		}
367 407

  
408
       // define constant indicating that the register_frontent_files was invoked
409
       if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);
368 410
		global $wb, $database, $include_body_links;
369 411
		// define default baselink and filename for optional module javascript files
370 412
		$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 413

  
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
		}
414
		/* include the Javascript jquery api  */
415
        $body_links .= bind_jquery($file_id);
380 416

  
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'");
417
		if($file_id !== "css" && $file_id == "js" && $file_id !== "jquery")
418
        {
419
    		$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend_body.js" type="text/javascript"></script>';
420
    		$base_file = "frontend_body.js";
385 421

  
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);
422
			// ensure that frontend_body.js is only added once per module type
423
    		if(!empty($include_body_links))
424
            {
425
    			if(strpos($body_links, $include_body_links) === false)
426
                {
427
    				$body_links .= $include_body_links;
428
    			}
429
    			$include_body_links = '';
430
    		}
391 431

  
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);
432
    		// gather information for all models embedded on actual page
433
    		$page_id = $wb->page_id;
434
    		$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
435
    				WHERE page_id=$page_id AND module<>'wysiwyg'");
394 436

  
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
		}
437
    		while($row = $query_modules->fetchRow())
438
            {
439
    			// check if page module directory contains a frontend_body.js file
440
    			if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
441
    			// create link with frontend_body.js source for the current module
442
    				$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
401 443

  
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;
444
    				// define constant indicating that the register_frontent_files_body was invoked
445
    					if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);
446

  
447
    				// ensure that frontend_body.js is only added once per module type
448
    				if(strpos($body_links, $tmp_link) === false) {
449
    					$body_links .= $tmp_link;
450
    				}
451
    			}
452
    		}
453
        }
454

  
455
		print $body_links."\n"; ;
409 456
	}
410 457
}
411 458

  
412 459

  
413 460
// 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") {
461
if(!function_exists('register_frontend_modfiles'))
462
{
463
	function register_frontend_modfiles($file_id="css")
464
    {
416 465
		// sanity check of parameter passed to the function
417 466
		$file_id = strtolower($file_id);
418
		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") {
467
		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
468
        {
419 469
			return;
420 470
		}
421 471

  
......
423 473
		// define default baselink and filename for optional module javascript and stylesheet files
424 474
		$head_links = "";
425 475

  
426
		if($file_id == "css") {
476
        switch ($file_id)
477
        {
478
            case 'css':
427 479
			$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"';
428 480
			$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
429 481
			$base_file = "frontend.css";
430
		} else {
482
    		if(!empty($include_head_link_css))
483
            {
484
              $head_links .=  !strpos($head_links, $include_head_link_css) ? $include_head_link_css : '';
485
              $include_head_link_css = '';
486
            }
487
            break;
488
            case 'jquery':
489
            $head_links .= bind_jquery($file_id);
490
            break;
491
            case 'js':
431 492
			$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
432 493
			$base_file = "frontend.js";
494
    		if(!empty($include_head_links))
495
            {
496
              $head_links .= !strpos($head_links, $include_head_links) ? $include_head_links : '';
497
              $include_head_links = '';
498
            }
499
            break;
500
            default:
501
            break;
433 502
		}
434 503

  
435 504
		if(!empty($include_head_link_css)) {
......
446 515
			}
447 516
		}
448 517

  
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'");
518
        if( $file_id != 'jquery')
519
        {
453 520

  
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);
521
    		// gather information for all models embedded on actual page
522
    		$page_id = $wb->page_id;
523
    		$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
524
    				WHERE page_id=$page_id AND module<>'wysiwyg'");
459 525

  
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
		}
526
    		while($row = $query_modules->fetchRow())
527
            {
528
    			// check if page module directory contains a frontend.js or frontend.css file
529
    			if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
530
                {
531
    			// create link with frontend.js or frontend.css source for the current module
532
    				$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
472 533

  
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
	}
534
    				// define constant indicating that the register_frontent_files was invoked
535
    				if($file_id == 'css')
536
                    {
537
    					if(!defined('MOD_FRONTEND_CSS_REGISTERED')) define('MOD_FRONTEND_CSS_REGISTERED', true);
538
    				} else
539
                    {
540
    					if(!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
541
    				}
542
    				// ensure that frontend.js or frontend.css is only added once per module type
543
    				if(strpos($head_links, $tmp_link) === false)
544
                    {
545
    					$head_links .= $tmp_link."\n";
546
    				}
547
    			};
548
    		}
549
        		// include the Javascript email protection function
550
        		if( $file_id != 'css' && file_exists(WB_PATH .'/modules/droplets/js/mdcr.js'))
551
                {
552
        			$head_links .= '<script src="'.WB_URL.'/modules/droplets/js/mdcr.js" type="text/javascript"></script>'."\n";
553
        		}
554
                elseif( $file_id != 'css' && file_exists(WB_PATH .'/modules/output_filter/js/mdcr.js'))
555
                {
556
        			$head_links .= '<script src="'.WB_URL.'/modules/output_filter/js/mdcr.js" type="text/javascript"></script>'."\n";
557
        		}
558
        }
559
        print $head_links;
560
    }
481 561
}
482 562

  
483 563
// Begin WB < 2.4.x template compatibility code

Also available in: Unified diff