Index: trunk/include/xpress_render.php
===================================================================
--- trunk/include/xpress_render.php	(revision 164)
+++ trunk/include/xpress_render.php	(revision 201)
@@ -4,36 +4,56 @@
 function get_mod_header($contents)
 {
+	global $xpress_config;
 	$pattern = "<head[^>]*?>(.*)<\/head>";
 	preg_match("/".$pattern."/s",  $contents, $head_matches);
 	$head_str = $head_matches[1];
 	
-	$pattern = "<style[^>]*?>(.*)<\/style>";
-	preg_match("/".$pattern."/s",  $head_str, $style_matches);
-	if (empty($style_matches[0]))
-		$style = '';
-	else
-		$style = $style_matches[0];
- 
-	$pattern = "<link(.*)>";
-	preg_match_all("/".$pattern."/",  $head_str, $link_match,PREG_PATTERN_ORDER);
-	$links = $link_match[0];
-	$link_str ='';
-	foreach ( $links as $link){
-		ob_start();
-			echo $link . "\n";
-			
-			$link_str .= ob_get_contents();
-		ob_end_clean();
-	}
-	
-	$pattern = "<script[^>]*?>(.*)<\/script>";
-	preg_match_all("/".$pattern."/s",  $head_str, $script_match,PREG_PATTERN_ORDER);
-	$scripts = $script_match[0];
-	$script_str ='';
-	foreach ( $scripts as $script){		
-		if (($GLOBALS["xoopsModuleConfig"]['use_d3forum'] != 1) || (strpos($script,'function wpopen') ===false))
-			$script_str .= $script;
-	}
-	return $link_str."\n".$style . "\n" . $script_str ."\n";
+	$pattern = '<head[^>]*?>';
+	$head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
+	$pattern = '<\/head>';
+	$head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
+	$pattern = '<\s*html\s+xmlns[^>]*?>';
+	$head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
+	$pattern = '<\s*head\s+profile[^>]*?>';
+	$head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
+	$pattern = '<\s*meta\s+http-equiv[^>]*?>';
+	$head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
+	$pattern = '<title[^>]*?>(.*)<\s*\/\s*title\s*>';
+	$head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
+
+	$head_str = meta_name_cut('robots',$head_str);
+	$head_str = meta_name_cut('keywords',$head_str);
+	$head_str = meta_name_cut('description',$head_str);
+	$head_str = meta_name_cut('rating',$head_str);
+	$head_str = meta_name_cut('author',$head_str);
+	$head_str = meta_name_cut('copyright',$head_str);
+	$head_str = meta_name_cut('generator',$head_str);
+
+	$head_str = preg_replace("/^(\s)*(\r|\n|\r\n)/m", "", $head_str);	
+	return $head_str;
+}
+
+function meta_name_cut($name = '', $head_str)
+{
+	$pattern = '<\s*meta\s+name\s*=\s*["\']' . $name . '["\'][^>]*?>';
+	$head_str = preg_replace("/".$pattern."/i" , '' , $head_str);
+	return $head_str;
+}
+
+// for title reprace plugin (all in one seo pack)
+function get_xpress_title($contents)
+{
+	$pattern = '<title[^>]*?>(.*)<\s*\/\s*title\s*>';
+	preg_match("/".$pattern."/i",  $contents, $head_matches);
+	$title_str = $head_matches[1];
+	return $title_str;
+}
+
+function get_xpress_meta_name($name = '',$contents)
+{
+	$pattern = '<\s*meta\s+name\s*=\s*["\']' . $name . '["\']\s*content\s*=\s*[\'"](.*)[\'"]\s*\/\s*>';
+	preg_match("/".$pattern."/i",  $contents, $head_matches);
+	$meta = $head_matches[1];
+	return $meta;
 }
 
@@ -98,10 +118,56 @@
 //rendering for the module header and the body
 function xpress_render($contents){
-	global $xoops_config , $xoopsTpl;
+	global $xoops_config , $xoopsTpl,$xpress_config;
 	$mydirname = basename(dirname(dirname(__FILE__)));
 	include $xoops_config->xoops_root_path ."/header.php";
-	$page_title = $GLOBALS["xoopsModule"]->getVar("name")." ".wp_title('&raquo;', false);
 	$xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
+	$page_title = $GLOBALS["xoopsModule"]->getVar("name"). ' &raquo;'. get_xpress_title($contents);
 	$xoopsTpl->assign('xoops_pagetitle', $page_title);
+	
+	$xoops_keywords = $xoopsTpl->get_template_vars('xoops_meta_keywords');
+	$wp_keyword = get_xpress_meta_name('keywords',$contents);
+	switch ($xpress_config->meta_keyword_type){
+		case 'xoops':
+			break;
+		case 'wordpress':
+			if (!empty($wp_keyword))
+				$xoopsTpl->assign('xoops_meta_keywords', $wp_keyword);
+			break;
+		case 'wordpress_xoops':
+			if (!empty($wp_keyword)){
+				if (!empty($xoops_keywords)){
+					$keywords = $wp_keyword . ', ' . $xoops_keywords;
+				} else {
+					$keywords = $wp_keyword;
+				}
+				$xoopsTpl->assign('xoops_meta_keywords', $keywords);
+			} 
+			break;
+		default :
+	}
+
+	$xoops_description = $xoopsTpl->get_template_vars('xoops_meta_description');
+	$wp_description = get_xpress_meta_name('description',$contents);
+	switch ($xpress_config->meta_description_type){
+		case 'xoops':
+			break;
+		case 'wordpress':
+			if (!empty($wp_description))
+				$xoopsTpl->assign('xoops_meta_description', $wp_description);
+			break;
+		case 'wordpress_xoops':
+			if (!empty($wp_description)){
+				if (!empty($xoops_description)){
+					$description = $wp_description . ' ' . $xoops_description;
+				} else {
+					$description = $wp_description;
+				}
+				$xoopsTpl->assign('xoops_meta_description', $description);
+			} 
+			break;
+		default :
+	}
+		
+	
 	$xpress_data['body_contents'] = get_body($contents);
 	// used $GLOBALS. becose xpress_left_arrow_post_link() and xpress_right_arrow_post_link() is other loop in this position
