Project

General

Profile

« Previous | Next » 

Revision 1107

Added by Matthias over 15 years ago

Fixed bug that frontend.js, frontend.css and frontend_body.js are not used from snippets (ticket #764) (Thanks to Luisehahne)

View differences:

frontend.functions.php
47 47
$extra_sql=&$wb->extra_sql;
48 48
$extra_where_sql=&$wb->extra_where_sql;
49 49

  
50
$include_head_link_css = '';
51
$include_body_links = '';
52
$include_head_links = '';
53

  
50 54
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
51 55
$query_result=$database->query($query);
52 56
if ($query_result->numRows()>0) {
......
54 58
		$module_dir = $row['directory'];
55 59
		if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
56 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
			}
57 78
		}
58 79
	}
59 80
}
......
334 355
			return;
335 356
		}
336 357

  
337
		global $wb, $database;
358
		global $wb, $database, $include_body_links;
338 359
		// define default baselink and filename for optional module javascript files
339 360
		$body_links = "";
340
        $base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend_body.js" type="text/javascript"></script>';
341
        $base_file = "frontend_body.js";
361
		$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend_body.js" type="text/javascript"></script>';
362
		$base_file = "frontend_body.js";
342 363

  
364
		if(!empty($include_body_links)) {
365
			if(strpos($body_links, $include_body_links) === false) {
366
				$body_links .= $include_body_links;
367
			}
368
			$include_body_links = '';
369
		}
370

  
343 371
		// gather information for all models embedded on actual page
344 372
		$page_id = $wb->page_id;
345 373
		$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
......
371 399
	}
372 400
}
373 401

  
402

  
374 403
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend
375 404
if(!function_exists('register_frontend_modfiles')) {
376 405
	function register_frontend_modfiles($file_id="css") {
......
380 409
			return;
381 410
		}
382 411

  
383
		global $wb, $database;
412
		global $wb, $database, $include_head_link_css, $include_head_links;
384 413
		// define default baselink and filename for optional module javascript and stylesheet files
385 414
		$head_links = "";
415

  
386 416
		if($file_id == "css") {
387 417
			$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"';
388 418
			$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
......
392 422
			$base_file = "frontend.js";
393 423
		}
394 424

  
425
		if(!empty($include_head_link_css)) {
426
			if(strpos($head_links, $include_head_link_css) === false) {
427
				$head_links .= $include_head_link_css;
428
			}
429
			$include_head_link_css = '';
430
		} else {
431
			if(!empty($include_head_links)) {
432
				if(strpos($head_links, $include_head_links) === false) {
433
					$head_links .= $include_head_links;
434
				}
435
				$include_head_links = '';
436
			}
437
		}
438

  
395 439
		// gather information for all models embedded on actual page
396 440
		$page_id = $wb->page_id;
397 441
		$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections 

Also available in: Unified diff