script >< link > tag is pulled out from the header of html contents.
function get_mod_header($contents)
{
global $xpress_config;
$pattern = "
]*?>(.*)<\/head>";
preg_match("/".$pattern."/s", $contents, $head_matches);
$head_str = $head_matches[1];
$pattern = ']*?>';
$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 = ']*?>(.*)<\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 = ']*?>(.*)<\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;
}
// get sidebar rendaring
function get_sidebar_rander($name = null)
{
$templates = array();
if ( isset($name) )
$templates[] = "sidebar-{$name}.php";
$templates[] = "sidebar.php";
$link= locate_template($templates, false);
if ('' == $link)
$link = get_theme_root() . '/default/sidebar.php';
ob_start();
require($link);
$sidebar = ob_get_contents();
ob_end_clean();
return $sidebar;
}
// < body > tag is pulled out from the header of html contents.
function get_body($contents)
{
$xpess_config = new XPressME_Class();
$pattern = "]*?>(.*)<\/body>";
preg_match("/".$pattern."/s", $contents, $body_matches);
$body = $body_matches[1];
if (!$xpess_config->is_theme_sidebar_disp){
$side_panel = get_sidebar_rander();
$body = str_replace($side_panel,'',$body);
}
return $body;
}
//Making of module header
function get_xpress_module_header($contents)
{
global $xoopsTpl;
if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
$preload_make_module_header = $xoopsTpl->get_template_vars('xoops_module_header');
} else {
$preload_make_module_header = '';
}
if (! empty($preload_make_module_header)){
$preload_make_module_header = '
' . $preload_make_module_header . '
';
}
$wp_module_header = '
' . get_mod_header($contents) . '
';
return $preload_make_module_header . $wp_module_header;
}
//rendering for the module header and the body
function xpress_render($contents){
global $xoops_config , $xoopsTpl,$xpress_config;
$mydirname = basename(dirname(dirname(__FILE__)));
include $xoops_config->xoops_root_path ."/header.php";
$xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
$page_title = $GLOBALS["xoopsModule"]->getVar("name"). ' »'. 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 :
}
$wp_robots = get_xpress_meta_name('robots',$contents);
switch ($xpress_config->meta_robot_type){
case 'xoops':
break;
case 'wordpress':
if (!empty($wp_robots))
$xoopsTpl->assign('xoops_meta_robots', $wp_robots);
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
$xpress_data['left_post_link'] = $GLOBALS['left_arrow_post_link'];
$xpress_data['right_post_link'] = $GLOBALS['right_arrow_post_link'];
$xpress_data['left_posts_link'] = str_replace('«','',xpress_left_arrow_posts_link(false));
$xpress_data['right_posts_link'] = str_replace('»','',xpress_right_arrow_posts_link(false));
$xpress_data['now_user_level'] = xpress_now_user_level(false);
$xoopsTpl->assign('xpress', $xpress_data);
$templates_file = 'db:'.$mydirname. '_index.html';
echo $xoopsTpl->fetch( $templates_file ) ;
require_once( ABSPATH .'/include/xpress_breadcrumbs.php' );
include $xoops_config->xoops_root_path . '/footer.php';
}
?>