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 | // get sidebar rendaring
|
---|
38 | function get_sidebar_rander($name = null)
|
---|
39 | {
|
---|
40 | $templates = array();
|
---|
41 | if ( isset($name) )
|
---|
42 | $templates[] = "sidebar-{$name}.php";
|
---|
43 |
|
---|
44 | $templates[] = "sidebar.php";
|
---|
45 |
|
---|
46 | $link= locate_template($templates, false);
|
---|
47 | if ('' == $link)
|
---|
48 | $link = get_theme_root() . '/default/sidebar.php';
|
---|
49 |
|
---|
50 | ob_start();
|
---|
51 | require($link);
|
---|
52 | $sidebar = ob_get_contents();
|
---|
53 | ob_end_clean();
|
---|
54 | return $sidebar;
|
---|
55 | }
|
---|
56 |
|
---|
57 | // < body > tag is pulled out from the header of html contents.
|
---|
58 | function get_body($contents)
|
---|
59 | {
|
---|
60 | $xpess_config = new XPressME_Class();
|
---|
61 | $pattern = "<body[^>]*?>(.*)<\/body>";
|
---|
62 | preg_match("/".$pattern."/s", $contents, $body_matches);
|
---|
63 | $body = $body_matches[1];
|
---|
64 |
|
---|
65 | if (!$xpess_config->is_theme_sidebar_disp){
|
---|
66 | $side_panel = get_sidebar_rander();
|
---|
67 | $body = str_replace($side_panel,'',$body);
|
---|
68 | }
|
---|
69 | return $body;
|
---|
70 | }
|
---|
71 |
|
---|
72 | //Making of module header
|
---|
73 | function get_xpress_module_header($contents)
|
---|
74 | {
|
---|
75 | global $xoopsTpl;
|
---|
76 | if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
|
---|
77 | $preload_make_module_header = $xoopsTpl->get_template_vars('xoops_module_header');
|
---|
78 | } else {
|
---|
79 | $preload_make_module_header = '';
|
---|
80 | }
|
---|
81 |
|
---|
82 | if (! empty($preload_make_module_header)){
|
---|
83 | $preload_make_module_header = '<!-- preload added module header -->
|
---|
84 | ' . $preload_make_module_header . '
|
---|
85 | ';
|
---|
86 | }
|
---|
87 |
|
---|
88 | $wp_module_header = '<!-- wordpress added module header -->
|
---|
89 | ' . get_mod_header($contents) . '
|
---|
90 | <!-- end of wordpress added module header -->';
|
---|
91 |
|
---|
92 | return $preload_make_module_header . $wp_module_header;
|
---|
93 | }
|
---|
94 |
|
---|
95 | //rendering for the module header and the body
|
---|
96 | function xpress_render($contents){
|
---|
97 | global $xoopsTpl;
|
---|
98 | include XOOPS_ROOT_PATH."/header.php";
|
---|
99 | $page_title = $GLOBALS["xoopsModule"]->getVar("name")." ".wp_title('»', false);
|
---|
100 | $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
|
---|
101 | $xoopsTpl->assign('xoops_pagetitle', $page_title);
|
---|
102 | $xoopsTpl->assign('xpress_body_contents', get_body($contents));
|
---|
103 | echo get_body($contents);
|
---|
104 | }
|
---|
105 |
|
---|
106 | ?> |
---|