[1] | 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);
|
---|
[96] | 12 | if (empty($style_matches[0]))
|
---|
| 13 | $style = '';
|
---|
| 14 | else
|
---|
| 15 | $style = $style_matches[0];
|
---|
[1] | 16 |
|
---|
| 17 | $pattern = "<link(.*)>";
|
---|
| 18 | preg_match_all("/".$pattern."/", $head_str, $link_match,PREG_PATTERN_ORDER);
|
---|
| 19 | $links = $link_match[0];
|
---|
| 20 | $link_str ='';
|
---|
| 21 | foreach ( $links as $link){
|
---|
| 22 | ob_start();
|
---|
| 23 | echo $link . "\n";
|
---|
| 24 |
|
---|
| 25 | $link_str .= ob_get_contents();
|
---|
| 26 | ob_end_clean();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | $pattern = "<script[^>]*?>(.*)<\/script>";
|
---|
| 30 | preg_match_all("/".$pattern."/s", $head_str, $script_match,PREG_PATTERN_ORDER);
|
---|
| 31 | $scripts = $script_match[0];
|
---|
| 32 | $script_str ='';
|
---|
| 33 | foreach ( $scripts as $script){
|
---|
| 34 | if (($GLOBALS["xoopsModuleConfig"]['use_d3forum'] != 1) || (strpos($script,'function wpopen') ===false))
|
---|
| 35 | $script_str .= $script;
|
---|
| 36 | }
|
---|
| 37 | return $link_str."\n".$style . "\n" . $script_str ."\n";
|
---|
| 38 | }
|
---|
| 39 |
|
---|
[26] | 40 | // get sidebar rendaring
|
---|
| 41 | function get_sidebar_rander($name = null)
|
---|
| 42 | {
|
---|
| 43 | $templates = array();
|
---|
| 44 | if ( isset($name) )
|
---|
| 45 | $templates[] = "sidebar-{$name}.php";
|
---|
| 46 |
|
---|
| 47 | $templates[] = "sidebar.php";
|
---|
| 48 |
|
---|
| 49 | $link= locate_template($templates, false);
|
---|
| 50 | if ('' == $link)
|
---|
| 51 | $link = get_theme_root() . '/default/sidebar.php';
|
---|
| 52 |
|
---|
| 53 | ob_start();
|
---|
| 54 | require($link);
|
---|
| 55 | $sidebar = ob_get_contents();
|
---|
| 56 | ob_end_clean();
|
---|
| 57 | return $sidebar;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[1] | 60 | // < body > tag is pulled out from the header of html contents.
|
---|
| 61 | function get_body($contents)
|
---|
| 62 | {
|
---|
[26] | 63 | $xpess_config = new XPressME_Class();
|
---|
[1] | 64 | $pattern = "<body[^>]*?>(.*)<\/body>";
|
---|
| 65 | preg_match("/".$pattern."/s", $contents, $body_matches);
|
---|
| 66 | $body = $body_matches[1];
|
---|
[26] | 67 |
|
---|
| 68 | if (!$xpess_config->is_theme_sidebar_disp){
|
---|
| 69 | $side_panel = get_sidebar_rander();
|
---|
| 70 | $body = str_replace($side_panel,'',$body);
|
---|
| 71 | }
|
---|
[1] | 72 | return $body;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | //Making of module header
|
---|
| 76 | function get_xpress_module_header($contents)
|
---|
| 77 | {
|
---|
| 78 | global $xoopsTpl;
|
---|
| 79 | if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
|
---|
| 80 | $preload_make_module_header = $xoopsTpl->get_template_vars('xoops_module_header');
|
---|
| 81 | } else {
|
---|
| 82 | $preload_make_module_header = '';
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | if (! empty($preload_make_module_header)){
|
---|
| 86 | $preload_make_module_header = '<!-- preload added module header -->
|
---|
| 87 | ' . $preload_make_module_header . '
|
---|
| 88 | ';
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | $wp_module_header = '<!-- wordpress added module header -->
|
---|
| 92 | ' . get_mod_header($contents) . '
|
---|
| 93 | <!-- end of wordpress added module header -->';
|
---|
| 94 |
|
---|
| 95 | return $preload_make_module_header . $wp_module_header;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | //rendering for the module header and the body
|
---|
| 99 | function xpress_render($contents){
|
---|
[96] | 100 | global $xoops_config , $xoopsTpl;
|
---|
[109] | 101 | $mydirname = basename(dirname(dirname(__FILE__)));
|
---|
[96] | 102 | include $xoops_config->xoops_root_path ."/header.php";
|
---|
| 103 | $page_title = $GLOBALS["xoopsModule"]->getVar("name")." ".wp_title('»', false);
|
---|
[1] | 104 | $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
|
---|
| 105 | $xoopsTpl->assign('xoops_pagetitle', $page_title);
|
---|
| 106 | $xoopsTpl->assign('xpress_body_contents', get_body($contents));
|
---|
[109] | 107 | $templates_file = 'db:'.$mydirname. '_index.html';
|
---|
| 108 | echo $xoopsTpl->fetch( $templates_file ) ;
|
---|
[96] | 109 | require_once( ABSPATH .'/include/xpress_breadcrumbs.php' );
|
---|
| 110 | include $xoops_config->xoops_root_path . '/footer.php';
|
---|
[1] | 111 | }
|
---|
| 112 |
|
---|
| 113 | ?> |
---|