Project

General

Profile

« Previous | Next » 

Revision 1464

Added by DarkViper over 13 years ago

fixed little bug in moveCssToHead()

View differences:

frontend.functions.php
595 595

  
596 596
	function moveCssToHead($content) {
597 597
		// move css definitions into head section
598
		$pattern1 = '/(?:.*?<body.*?)(<link[^>]*?\"text\/css\".*?\/>)(?:.*)/si';
599
		$pattern2 = '/(?:.*?<body.*?)(<style[^>]*?\"text\/css\"[^>]*?>.*?<\/style>)(?:.*)/si';
600
		$insert1 = array();
601
		$insert2 = array();
602
		if(preg_match_all($pattern1, $content, $matches)) {
603
			$insert1 = $matches[1];
604
			$content = str_replace($insert1, '', $content);
598
		$pattern1 = '/(?:<body.*?)(<link[^>]*?\"text\/css\".*?\/>)/si';
599
		$pattern2 = '/(?:<body.*?)(<style[^>]*?\"text\/css\"[^>]*?>.*?<\/style>)/si';
600
		while(preg_match($pattern1, $content, $matches)==1) {
601
		// loop through all linked CSS
602
			$insert = $matches[1];
603
			$content = str_replace($insert, '', $content);
604
			$insert = "\n".$insert."\n</head>\n<body";
605
			$content = preg_replace('/<\/head>.*?<body/si', $insert, $content);
605 606
		}
606
		if(preg_match_all($pattern2, $content, $matches)) {
607
			$insert2 = $matches[1];
608
			$content = str_replace($insert2, '', $content);
607
		while(preg_match($pattern2, $content, $matches)==1) {
608
		// loop through all inline CSS
609
			$insert = $matches[1];
610
			$content = str_replace($insert, '', $content);
611
			$insert = "\n".$insert."\n</head>\n<body";
612
			$content = preg_replace('/<\/head>.*?<body/si', $insert, $content);
609 613
		}
610
		$insert = array_merge($insert1, $insert2);
611
		$insert = "\n".implode("\n", $insert)."\n</head>\n<body";
612
		$content = preg_replace('/<\/head>.*?<body/si', $insert, $content);
613 614
		return $content;
614 615
	}
615 616

  
......
627 628
		// Get the pages submenu
628 629
		$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");
629 630
	}
630
// End WB < 2.4.x template compatibility code
631
// Include template file
632 631

  

Also available in: Unified diff