| [828] | 1 | <?php | 
|---|
|  | 2 |  | 
|---|
|  | 3 | //< style >< script >< link > tag is pulled out from the header of html contents. | 
|---|
|  | 4 | function get_mod_header($contents) | 
|---|
|  | 5 | { | 
|---|
|  | 6 | $pattern = "<head[^>]*?>(.*)<\/head>"; | 
|---|
|  | 7 | preg_match("/".$pattern."/s",  $contents, $head_matches); | 
|---|
|  | 8 | $head_str = $head_matches[1]; | 
|---|
|  | 9 |  | 
|---|
|  | 10 | $pattern = "<style[^>]*?>(.*)<\/style>"; | 
|---|
|  | 11 | preg_match("/".$pattern."/s",  $head_str, $style_matches); | 
|---|
|  | 12 | $style = $style_matches[0]; | 
|---|
|  | 13 |  | 
|---|
|  | 14 | $pattern = "<link(.*)>"; | 
|---|
|  | 15 | preg_match_all("/".$pattern."/",  $head_str, $link_match,PREG_PATTERN_ORDER); | 
|---|
|  | 16 | $links = $link_match[0]; | 
|---|
|  | 17 | $link_str =''; | 
|---|
|  | 18 | foreach ( $links as $link){ | 
|---|
|  | 19 | ob_start(); | 
|---|
|  | 20 | echo $link . "\n"; | 
|---|
|  | 21 |  | 
|---|
|  | 22 | $link_str .= ob_get_contents(); | 
|---|
|  | 23 | ob_end_clean(); | 
|---|
|  | 24 | } | 
|---|
|  | 25 |  | 
|---|
|  | 26 | $pattern = "<script[^>]*?>(.*)<\/script>"; | 
|---|
|  | 27 | preg_match_all("/".$pattern."/s",  $head_str, $script_match,PREG_PATTERN_ORDER); | 
|---|
|  | 28 | $scripts = $script_match[0]; | 
|---|
|  | 29 | $script_str =''; | 
|---|
|  | 30 | foreach ( $scripts as $script){ | 
|---|
|  | 31 | if (($GLOBALS["xoopsModuleConfig"]['use_d3forum'] != 1) || (strpos($script,'function wpopen') ===false)) | 
|---|
|  | 32 | $script_str .= $script; | 
|---|
|  | 33 | } | 
|---|
|  | 34 | return $link_str."\n".$style . "\n" . $script_str ."\n"; | 
|---|
|  | 35 | } | 
|---|
|  | 36 |  | 
|---|
|  | 37 | // < body > tag is pulled out from the header of html contents. | 
|---|
|  | 38 | function get_body($contents) | 
|---|
|  | 39 | { | 
|---|
|  | 40 | $pattern = "<body[^>]*?>(.*)<\/body>"; | 
|---|
|  | 41 | preg_match("/".$pattern."/s",  $contents, $body_matches); | 
|---|
|  | 42 | $body = $body_matches[1]; | 
|---|
|  | 43 | return $body; | 
|---|
|  | 44 | } | 
|---|
|  | 45 |  | 
|---|
|  | 46 | //Making of module header | 
|---|
|  | 47 | function get_xpress_module_header($contents) | 
|---|
|  | 48 | { | 
|---|
|  | 49 | global $xoopsTpl; | 
|---|
|  | 50 | if( defined( 'XOOPS_CUBE_LEGACY' ) ) { | 
|---|
|  | 51 | $preload_make_module_header = $xoopsTpl->get_template_vars('xoops_module_header'); | 
|---|
|  | 52 | } else { | 
|---|
|  | 53 | $preload_make_module_header = ''; | 
|---|
|  | 54 | } | 
|---|
|  | 55 |  | 
|---|
|  | 56 | if (! empty($preload_make_module_header)){ | 
|---|
|  | 57 | $preload_make_module_header = '<!-- preload added module header --> | 
|---|
|  | 58 | ' . $preload_make_module_header . ' | 
|---|
|  | 59 | '; | 
|---|
|  | 60 | } | 
|---|
|  | 61 |  | 
|---|
|  | 62 | $wp_module_header = '<!-- wordpress  added module header --> | 
|---|
|  | 63 | ' . get_mod_header($contents) . ' | 
|---|
|  | 64 | <!-- end of wordpress  added module header -->'; | 
|---|
|  | 65 |  | 
|---|
|  | 66 | return $preload_make_module_header . $wp_module_header; | 
|---|
|  | 67 | } | 
|---|
|  | 68 |  | 
|---|
|  | 69 | //rendering for the module header and the body | 
|---|
|  | 70 | function xpress_render($contents){ | 
|---|
|  | 71 | global $xoopsTpl; | 
|---|
|  | 72 | include XOOPS_ROOT_PATH."/header.php"; | 
|---|
|  | 73 | $page_title = $GLOBALS["xoopsModule"]->getVar("name")." ".wp_title('»', false); | 
|---|
|  | 74 | $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents)); | 
|---|
|  | 75 | $xoopsTpl->assign('xoops_pagetitle', $page_title); | 
|---|
|  | 76 | $xoopsTpl->assign('xpress_body_contents', get_body($contents)); | 
|---|
|  | 77 | echo get_body($contents); | 
|---|
|  | 78 | } | 
|---|
|  | 79 |  | 
|---|
|  | 80 | ?> | 
|---|